[−][src]Struct jnet::ipv6::Packet
IPv6 packet
Methods
impl<B> Packet<B> where
B: AsSlice<Element = u8>,
[src]
B: AsSlice<Element = u8>,
pub fn parse(bytes: B) -> Result<Self, ()>
[src]
Parses bytes into an IPv6 packet
pub fn get_version(&self) -> u8
[src]
Reads the 'Version' field
This always returns 6
pub fn get_traffic_class(&self) -> u8
[src]
Reads the 'Traffic Class' field
pub fn get_flow_label(&self) -> u32
[src]
Reads the 'Flow Label' field (20 bits)
pub fn get_length(&self) -> u16
[src]
Reads the 'Payload length' field
pub fn get_next_header(&self) -> NextHeader
[src]
Reads the 'Next Header' field
pub fn get_hop_limit(&self) -> u8
[src]
Reads the 'Hop Limit' field
pub fn get_source(&self) -> Addr
[src]
Reads the 'Source Address' field
pub fn get_destination(&self) -> Addr
[src]
Reads the 'Destination Address' field
pub fn payload(&self) -> &[u8]
[src]
Immutable view into the payload
pub fn as_bytes(&self) -> &[u8]
[src]
Returns the byte representation of this packet
impl<B> Packet<B> where
B: AsMutSlice<Element = u8>,
[src]
B: AsMutSlice<Element = u8>,
pub fn new(buffer: B) -> Self
[src]
Transforms the given buffer into an IPv4 packet
Most of the header will be filled with sensible defaults:
- Version = 6
- Traffic class = 0
- Flow label = 0
- Length = buffer.len() - HEADER_SIZE
- Hop limit = 255
The fields that are left unpopulated are:
- Next header
- Source address
- Destination address
Panics
This constructor panics if
- the given
buffer
is smaller thanHEADER_SIZE
- the packet would result in a payload length larger than
u16::MAX
.
pub fn set_traffic_class(&mut self, tc: u8)
[src]
Sets the 'Traffic class' field
pub fn set_flow_label(&mut self, fl: u32)
[src]
Sets the 'Flow label' field
pub fn set_next_header(&mut self, nh: NextHeader)
[src]
Sets the 'Next Header' field
Panics
This function panics if nh
is an extension header (currently not supported)
pub fn set_hop_limit(&mut self, hl: u8)
[src]
Sets the 'Hop limit' field
pub fn set_source(&mut self, addr: Addr)
[src]
Sets the 'Source address' field
pub fn set_destination(&mut self, addr: Addr)
[src]
Sets the 'Destination address' field
pub fn payload_mut(&mut self) -> &mut [u8]
[src]
Immutable view into the payload
impl<B> Packet<B> where
B: AsMutSlice<Element = u8> + Truncate<u16>,
[src]
B: AsMutSlice<Element = u8> + Truncate<u16>,
pub fn neighbor_advertisement(
&mut self,
target_ll_addr: Option<Addr>,
f: impl FnOnce(&mut Message<&mut [u8], NeighborAdvertisement>)
)
[src]
&mut self,
target_ll_addr: Option<Addr>,
f: impl FnOnce(&mut Message<&mut [u8], NeighborAdvertisement>)
)
Fills the payload with a Neighbor Advertisement ICMPv6 message
pub fn udp(&mut self, f: impl FnOnce(&mut Packet<&mut [u8]>))
[src]
Fills the payload with a UDP packet
pub fn truncate(&mut self, len: u16)
[src]
Truncates the payload to the specified length
Trait Implementations
Auto Trait Implementations
impl<BUFFER> Unpin for Packet<BUFFER> where
BUFFER: Unpin,
BUFFER: Unpin,
impl<BUFFER> Send for Packet<BUFFER> where
BUFFER: Send,
BUFFER: Send,
impl<BUFFER> Sync for Packet<BUFFER> where
BUFFER: Sync,
BUFFER: 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