pub struct DhcpFixedPayload { /* private fields */ }Expand description
The fixed-length part of the DHCP payload. The options section can vary in length, and is handled separately. For “Inform” message kind, this is the entire message.
Implementations§
Source§impl DhcpFixedPayload
impl DhcpFixedPayload
Sourcepub fn new(
end_of_message: bool,
op: DhcpOperation,
kind: DhcpMessageKind,
transaction_id: u32,
broadcast: bool,
ciaddr: IpV4Addr,
yiaddr: IpV4Addr,
siaddr: IpV4Addr,
chaddr: MacAddr,
) -> Self
pub fn new( end_of_message: bool, op: DhcpOperation, kind: DhcpMessageKind, transaction_id: u32, broadcast: bool, ciaddr: IpV4Addr, yiaddr: IpV4Addr, siaddr: IpV4Addr, chaddr: MacAddr, ) -> Self
Convenience function to remove boilerplate for predetermined fields.
Sourcepub fn new_inform(
ipaddr: IpV4Addr,
macaddr: MacAddr,
transaction_id: u32,
) -> Self
pub fn new_inform( ipaddr: IpV4Addr, macaddr: MacAddr, transaction_id: u32, ) -> Self
Build a DHCP INFORM message to broadcast to the network indicating that we are taking a pre-assigned IP address which may have already be assigned statically in the configuration of the router. This message should also be accompanied by an ARP “announce” message to broadcast the presence of the machine to others on the network that may or may not receive a forwarded copy of the DHCP INFORM.
Examples found in repository?
2fn main() -> () {
3 use catnip::*;
4
5 let dhcp_inform = DhcpFixedPayload::new_inform(
6 IpV4Addr::new([1, 2, 3, 4]),
7 MacAddr::new([5, 6, 7, 8, 9, 10]),
8 12345
9 );
10
11 // Serialize
12 let bytes = dhcp_inform.to_be_bytes();
13 // Deserialize
14 let msg_parsed = DhcpFixedPayload::read_bytes(&bytes);
15
16 assert_eq!(msg_parsed, dhcp_inform);
17}Sourcepub fn to_be_bytes(&self) -> [u8; 244]
pub fn to_be_bytes(&self) -> [u8; 244]
Pack into big-endian (network) byte array
Examples found in repository?
2fn main() -> () {
3 use catnip::*;
4
5 let dhcp_inform = DhcpFixedPayload::new_inform(
6 IpV4Addr::new([1, 2, 3, 4]),
7 MacAddr::new([5, 6, 7, 8, 9, 10]),
8 12345
9 );
10
11 // Serialize
12 let bytes = dhcp_inform.to_be_bytes();
13 // Deserialize
14 let msg_parsed = DhcpFixedPayload::read_bytes(&bytes);
15
16 assert_eq!(msg_parsed, dhcp_inform);
17}Trait Implementations§
Source§impl ByteStruct for DhcpFixedPayload
impl ByteStruct for DhcpFixedPayload
Source§fn write_bytes(&self, bytes: &mut [u8])
fn write_bytes(&self, bytes: &mut [u8])
Source§fn read_bytes(bytes: &[u8]) -> Self
fn read_bytes(bytes: &[u8]) -> Self
Source§impl ByteStructLen for DhcpFixedPayload
impl ByteStructLen for DhcpFixedPayload
Source§impl Clone for DhcpFixedPayload
impl Clone for DhcpFixedPayload
Source§fn clone(&self) -> DhcpFixedPayload
fn clone(&self) -> DhcpFixedPayload
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DhcpFixedPayload
impl Debug for DhcpFixedPayload
Source§impl PartialEq for DhcpFixedPayload
impl PartialEq for DhcpFixedPayload
Source§impl uDebug for DhcpFixedPayload
impl uDebug for DhcpFixedPayload
impl Copy for DhcpFixedPayload
impl Eq for DhcpFixedPayload
impl StructuralPartialEq for DhcpFixedPayload
Auto Trait Implementations§
impl Freeze for DhcpFixedPayload
impl RefUnwindSafe for DhcpFixedPayload
impl Send for DhcpFixedPayload
impl Sync for DhcpFixedPayload
impl Unpin for DhcpFixedPayload
impl UnwindSafe for DhcpFixedPayload
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
Source§impl<T> ByteStructUnspecifiedByteOrder for Twhere
T: ByteStruct,
impl<T> ByteStructUnspecifiedByteOrder for Twhere
T: ByteStruct,
Source§fn write_bytes_default_le(&self, bytes: &mut [u8])
fn write_bytes_default_le(&self, bytes: &mut [u8])
A wrapper of ByteStruct::write_bytes
Source§fn read_bytes_default_le(bytes: &[u8]) -> T
fn read_bytes_default_le(bytes: &[u8]) -> T
A wrapper of ByteStruct::read_bytes
Source§fn write_bytes_default_be(&self, bytes: &mut [u8])
fn write_bytes_default_be(&self, bytes: &mut [u8])
A wrapper of ByteStruct::write_bytes
Source§fn read_bytes_default_be(bytes: &[u8]) -> T
fn read_bytes_default_be(bytes: &[u8]) -> T
A wrapper of ByteStruct::read_bytes