-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
- Added missing tags: | ||
- `ApmTag` | ||
- `BootdevTag` | ||
- `NetworkTag` | ||
|
||
## v0.22.2 (2024-08-24) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! Module for [`NetworkTag`]. | ||
use crate::{TagHeader, TagType, TagTypeId}; | ||
#[cfg(feature = "builder")] | ||
use alloc::boxed::Box; | ||
use core::mem; | ||
use multiboot2_common::{new_boxed, MaybeDynSized, Tag}; | ||
use ptr_meta::Pointee; | ||
|
||
/// The end tag ends the information struct. | ||
#[derive(Debug, Pointee)] | ||
#[repr(C, align(8))] | ||
pub struct NetworkTag { | ||
typ: TagTypeId, | ||
size: u32, | ||
dhcpack: [u8], | ||
} | ||
|
||
impl NetworkTag { | ||
/// Create a new network tag from the given DHCP package. | ||
#[cfg(feature = "builder")] | ||
#[must_use] | ||
pub fn new(dhcp_pack: &[u8]) -> Box<Self> { | ||
let header = TagHeader::new(Self::ID, 0); | ||
new_boxed(header, &[dhcp_pack]) | ||
} | ||
} | ||
|
||
impl MaybeDynSized for NetworkTag { | ||
type Header = TagHeader; | ||
|
||
const BASE_SIZE: usize = mem::size_of::<TagHeader>(); | ||
|
||
fn dst_len(header: &TagHeader) -> usize { | ||
header.size as usize - Self::BASE_SIZE | ||
} | ||
} | ||
|
||
impl Tag for NetworkTag { | ||
type IDType = TagType; | ||
|
||
const ID: TagType = TagType::Network; | ||
} |