[−][src]Struct jnet::arp::Packet
ARP packet
Methods
impl<B> Packet<B, Ethernet, Ipv4> where
B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u8>,
[src]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8> + Truncate<u8>,
pub fn new(buffer: B) -> Self
[src]
Transforms the given buffer into an ARP packet
This function populates the following header fields:
- HTYPE = Ethernet
- PTYPE = IPv4
- HLEN = 6
- PLEN = 4
- OPER = Request
impl<B> Packet<B, Ethernet, Ipv4> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
pub fn get_sha(&self) -> Addr
[src]
Returns the SHA (Sender Hardware Address) field of the payload
pub fn get_spa(&self) -> Addr
[src]
Returns the SPA (Sender Protocol Address) field of the payload
pub fn get_tha(&self) -> Addr
[src]
Returns the THA (Target Hardware Address) field of the payload
pub fn get_tpa(&self) -> Addr
[src]
Returns the TPA (Target Protocol Address) field of the payload
pub fn is_a_probe(&self) -> bool
[src]
Is this an ARP probe?
impl<B> Packet<B, Ethernet, Ipv4> where
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
[src]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
pub fn set_sha(&mut self, sha: Addr)
[src]
Sets the SHA (Sender Hardware Address) field of the payload
pub fn set_spa(&mut self, spa: Addr)
[src]
Sets the SPA (Sender Protocol Address) field of the payload
pub fn set_tha(&mut self, tha: Addr)
[src]
Sets the THA (Target Hardware Address) field of the payload
pub fn set_tpa(&mut self, tpa: Addr)
[src]
Sets the TPA (Target Protocol Address) field of the payload
pub fn announce(&mut self, addr: Addr)
[src]
ARP announcement
Shortcut for setting these fields
- OPER = Request
- SPA = TPA = addr
- THA = 00:00:00:00:00:00
pub fn probe(&mut self, addr: Addr)
[src]
ARP probe
Shortcut for setting these fields
- OPER = Request
- SPA = 0.0.0.0
- THA = 00:00:00:00:00:00
- TPA = addr
impl<B> Packet<B, Unknown, Unknown> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
pub fn get_sha(&self) -> &[u8]
[src]
Returns the SHA (Sender Hardware Address) field of the payload
pub fn get_spa(&self) -> &[u8]
[src]
Returns the SPA (Sender Protocol Address) field of the payload
pub fn get_tha(&self) -> &[u8]
[src]
Returns the THA (Target Hardware Address) field of the payload
pub fn get_tpa(&self) -> &[u8]
[src]
Returns the TPA (Target Protocol Address) field of the payload
pub fn downcast(self) -> Result<Packet<B>, Self>
[src]
Interprets this packet as Packet<Ethernet, Ipv4>
impl<B> Packet<B, Unknown, Unknown> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
impl<B> Packet<B, Unknown, Unknown> where
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
[src]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
pub fn set_htype(&mut self, htype: HardwareType)
[src]
Sets the HTYPE (Hardware TYPE) field of the header
pub fn set_ptype(&mut self, ptype: Type)
[src]
Sets the PTYPE (Protocol TYPE) field of the header
impl<B, H, P> Packet<B, H, P> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
pub fn get_htype(&self) -> HardwareType
[src]
Returns the HTYPE (Hardware TYPE) field of the header
pub fn get_ptype(&self) -> Type
[src]
Returns the PTYPE (Protocol TYPE) field of the header
pub fn get_hlen(&self) -> u8
[src]
Returns the HLEN (Hardware LENgth) field of the header
pub fn get_plen(&self) -> u8
[src]
Returns the PLEN (Protocol LENgth) field of the header
pub fn get_oper(&self) -> Operation
[src]
Returns the OPER (OPERation) field of the header
pub fn payload(&self) -> &[u8]
[src]
View into the payload
NOTE this may contain padding bytes at the end
pub fn len(&self) -> u8
[src]
Returns the canonical length of this packet
This ignores padding bytes, if any
pub fn free(self) -> B
[src]
Frees the underlying buffer
impl<B, H, P> Packet<B, H, P> where
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
[src]
B: AsSlice<Element = u8> + AsMutSlice<Element = u8>,
pub fn set_oper(&mut self, oper: Operation)
[src]
Sets the OPER (OPERation) field of the header
pub fn payload_mut(&mut self) -> &mut [u8]
[src]
Mutable view into the payload
NOTE this may contain padding bytes at the end
Trait Implementations
impl<B> Debug for Packet<B, Ethernet, Ipv4> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
impl<B> Debug for Packet<B, Unknown, Unknown> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
impl<B, H, P> Copy for Packet<B, H, P> where
B: Copy + AsSlice<Element = u8>,
[src]
B: Copy + AsSlice<Element = u8>,
impl<B, H, P> Clone for Packet<B, H, P> where
B: Clone + AsSlice<Element = u8>,
[src]
B: Clone + AsSlice<Element = u8>,
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Auto Trait Implementations
impl<BUFFER, HTYPE, PTYPE> Unpin for Packet<BUFFER, HTYPE, PTYPE> where
BUFFER: Unpin,
HTYPE: Unpin,
PTYPE: Unpin,
BUFFER: Unpin,
HTYPE: Unpin,
PTYPE: Unpin,
impl<BUFFER, HTYPE, PTYPE> Send for Packet<BUFFER, HTYPE, PTYPE> where
BUFFER: Send,
HTYPE: Send,
PTYPE: Send,
BUFFER: Send,
HTYPE: Send,
PTYPE: Send,
impl<BUFFER, HTYPE, PTYPE> Sync for Packet<BUFFER, HTYPE, PTYPE> where
BUFFER: Sync,
HTYPE: Sync,
PTYPE: Sync,
BUFFER: Sync,
HTYPE: Sync,
PTYPE: Sync,
Blanket Implementations
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Same<T> for T
[src]
type Output = T
Should always be Self