pub struct DhcpLayer {
pub index: LayerIndex,
}Expand description
DHCP layer — a zero-copy view into a parsed DHCP packet.
Fields§
§index: LayerIndexImplementations§
Source§impl DhcpLayer
impl DhcpLayer
pub fn new(index: LayerIndex) -> Self
Sourcepub fn chaddr(&self, buf: &[u8]) -> Result<[u8; 6], FieldError>
pub fn chaddr(&self, buf: &[u8]) -> Result<[u8; 6], FieldError>
Client hardware address (first 6 bytes for Ethernet).
Sourcepub fn options(&self, buf: &[u8]) -> Vec<DhcpOption>
pub fn options(&self, buf: &[u8]) -> Vec<DhcpOption>
Parse all DHCP options.
Sourcepub fn get_option(&self, buf: &[u8], opt_code: u8) -> Option<DhcpOption>
pub fn get_option(&self, buf: &[u8], opt_code: u8) -> Option<DhcpOption>
Get a specific option by code.
Sourcepub fn requested_ip(&self, buf: &[u8]) -> Option<Ipv4Addr>
pub fn requested_ip(&self, buf: &[u8]) -> Option<Ipv4Addr>
Get the requested IP address.
Sourcepub fn lease_time(&self, buf: &[u8]) -> Option<u32>
pub fn lease_time(&self, buf: &[u8]) -> Option<u32>
Get the lease time option value.
Sourcepub fn subnet_mask(&self, buf: &[u8]) -> Option<Ipv4Addr>
pub fn subnet_mask(&self, buf: &[u8]) -> Option<Ipv4Addr>
Get the subnet mask option.
Sourcepub fn is_request(&self, buf: &[u8]) -> bool
pub fn is_request(&self, buf: &[u8]) -> bool
Check if this is a DHCP request (BOOTP op=1).
Sourcepub fn set_flags(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
pub fn set_flags(&self, buf: &mut [u8], val: u16) -> Result<(), FieldError>
Set the flags field.
Sourcepub fn get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
pub fn get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get field value by name.
Sourcepub fn set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
pub fn set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set field value by name.
Sourcepub fn field_names(&self) -> &'static [&'static str]
pub fn field_names(&self) -> &'static [&'static str]
Field names for this layer.
Trait Implementations§
Source§impl Layer for DhcpLayer
impl Layer for DhcpLayer
Source§fn header_len(&self, buf: &[u8]) -> usize
fn header_len(&self, buf: &[u8]) -> usize
Get the header length for this layer
Source§fn field_names(&self) -> &'static [&'static str]
fn field_names(&self) -> &'static [&'static str]
Get the list of field names for this layer
Source§impl LayerDispatch for DhcpLayer
impl LayerDispatch for DhcpLayer
Source§fn dispatch_kind(&self) -> LayerKind
fn dispatch_kind(&self) -> LayerKind
Get the kind of this layer.
Source§fn dispatch_index(&self) -> &LayerIndex
fn dispatch_index(&self) -> &LayerIndex
Get the layer index (start/end offsets).
Source§fn dispatch_summary(&self, buf: &[u8]) -> String
fn dispatch_summary(&self, buf: &[u8]) -> String
Get a human-readable summary.
Source§fn dispatch_header_len(&self, buf: &[u8]) -> usize
fn dispatch_header_len(&self, buf: &[u8]) -> usize
Get the header length in bytes.
Source§fn dispatch_field_names(&self) -> &'static [&'static str]
fn dispatch_field_names(&self) -> &'static [&'static str]
Get field names for this layer type.
Source§fn dispatch_get_field(
&self,
buf: &[u8],
name: &str,
) -> Option<Result<FieldValue, FieldError>>
fn dispatch_get_field( &self, buf: &[u8], name: &str, ) -> Option<Result<FieldValue, FieldError>>
Get a field value by name.
Source§fn dispatch_set_field(
&self,
buf: &mut [u8],
name: &str,
value: FieldValue,
) -> Option<Result<(), FieldError>>
fn dispatch_set_field( &self, buf: &mut [u8], name: &str, value: FieldValue, ) -> Option<Result<(), FieldError>>
Set a field value by name.
Auto Trait Implementations§
impl Freeze for DhcpLayer
impl RefUnwindSafe for DhcpLayer
impl Send for DhcpLayer
impl Sync for DhcpLayer
impl Unpin for DhcpLayer
impl UnsafeUnpin for DhcpLayer
impl UnwindSafe for DhcpLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more