pub struct DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut,
{ /* private fields */ }
Expand description

Wraps the data buffer and contains metadata about the parsed protocols.

Implementations§

source§

impl<B, PHM> DataBuffer<B, Arp<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy,

source

pub fn parse_arp_alone( buf: B, headroom: usize ) -> Result<DataBuffer<B, Arp<NoPreviousHeader>>, ParseArpError>

Parses buf and creates a new DataBuffer for an ARP layer with no previous layers.

headroom indicates the amount of headroom in the provided buf.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the provided ARP packet’s hardware type is not Ethernet or IPv4.
source

pub fn parse_arp_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM> ) -> Result<DataBuffer<B, Arp<PHM>>, ParseArpError>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional ARP layer.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the provided ARP packet’s hardware type is not Ethernet or IPv4.
source§

impl<B> DataBuffer<B, Eth>
where B: AsRef<[u8]>,

source

pub fn parse_ethernet_layer( buf: B, headroom: usize ) -> Result<DataBuffer<B, Eth>, UnexpectedBufferEndError>

Parses data and creates a new DataBuffer for an Ethernet layer.

The provided headroom indicates the amount of headroom in the provided buf.

§Errors

Returns an error if the provided data buffer is shorter than expected.

source§

impl<B, PHM> DataBuffer<B, Ieee802_1QVlan<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy,

source

pub fn parse_ieee802_1q_alone( buf: B, headroom: usize, expected_vlan_tags: Vlan ) -> Result<DataBuffer<B, Ieee802_1QVlan<NoPreviousHeader>>, ParseIeee802_1QError>

Parses buf and creates a new DataBuffer for an IEEE 802.1Q layer with no previous layers.

headroom indicates the amount of headroom in the provided buf.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • no customer tag is found if expected_vlan_tag indicates double tagging.
source

pub fn parse_ieee802_1q_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM>, expected_vlan_tag: Vlan ) -> Result<DataBuffer<B, Ieee802_1QVlan<PHM>>, ParseIeee802_1QError>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional IEEE 802.1Q layer.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • no customer tag is found if expected_vlan_tag indicates double tagging.
source§

impl<B, PHM> DataBuffer<B, Ipv4<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy,

source

pub fn parse_ipv4_alone( buf: B, headroom: usize, check_ipv4_checksum: bool ) -> Result<DataBuffer<B, Ipv4<NoPreviousHeader>>, ParseIpv4Error>

Parses buf and creates a new DataBuffer for an IPv4 layer with no previous layers.

headroom indicates the amount of headroom in the provided buf.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the version field is not four.
  • the IHL field or total length field values are invalid.
  • if check_ipv4_checksum is true and the checksum is invalid.
source

pub fn parse_ipv4_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM>, check_ipv4_checksum: bool ) -> Result<DataBuffer<B, Ipv4<PHM>>, ParseIpv4Error>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional IPv4 layer.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the version field is not four.
  • the IHL field or total length field values are invalid.
  • if check_ipv4_checksum is true and the checksum is invalid.
source§

impl<B, PHM> DataBuffer<B, Ipv6<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy,

source

pub fn parse_ipv6_alone( buf: B, headroom: usize ) -> Result<DataBuffer<B, Ipv6<NoPreviousHeader>>, ParseIpv6Error>

Parses buf and creates a new DataBuffer for an IPv6 layer with no previous layers.

headroom indicates the amount of headroom in the provided buf.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the version field is not six.
source

pub fn parse_ipv6_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM> ) -> Result<DataBuffer<B, Ipv6<PHM>>, ParseIpv6Error>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional IPv6 layer.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the version field is not six.
source§

impl<B, PHM, const MAX_EXTENSIONS: usize> DataBuffer<B, Ipv6Extensions<PHM, MAX_EXTENSIONS>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy,

source

pub fn parse_ipv6_extensions_alone( buf: B, headroom: usize, next_header_byte: Ipv6ExtensionType ) -> Result<(DataBuffer<B, Ipv6Extensions<NoPreviousHeader, MAX_EXTENSIONS>>, bool), ParseIpv6ExtensionsError>

Parses buf and creates a new DataBuffer for an IPv6 extensions layer with no previous layers.

headroom indicates the amount of headroom in the provided buf.

The returned boolean indicates whether the payload is fragmented.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • more extensions than MAX_EXTENSIONS are present.
  • an unrecognized extension type is passed to the constructor of Ipv6Extensions (this constitutes a bug).
source

pub fn parse_ipv6_extensions_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM>, first_extension: Ipv6ExtensionType ) -> Result<(DataBuffer<B, Ipv6Extensions<PHM, MAX_EXTENSIONS>>, bool), ParseIpv6ExtensionsError>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional IPv6 extensions layer.

The returned boolean indicates whether the payload is fragmented.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • more extensions than MAX_EXTENSIONS are present.
  • an unrecognized extension type is passed to the constructor of Ipv6Extensions (this constitutes a bug).
source§

impl<B, PHM> DataBuffer<B, Tcp<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy, DataBuffer<B, Tcp<PHM>>: PseudoHeaderChecksum,

source

pub fn parse_tcp_alone( buf: B, headroom: usize ) -> Result<DataBuffer<B, Tcp<NoPreviousHeader>>, ParseTcpError>

Parses buf and creates a new DataBuffer for an TCP layer with no previous layers.

headroom indicates the amount of headroom in the provided buf. No checksum can be calculated without underlying header for the pseudo header.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the data offset field value is invalid.
source

pub fn parse_tcp_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM>, check_tcp_checksum: bool ) -> Result<DataBuffer<B, Tcp<PHM>>, ParseTcpError>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional TCP layer.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the data offset field value is invalid.
  • if check_tcp_checksum is true and the checksum is invalid.
source§

impl<B, PHM> DataBuffer<B, Udp<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut + Copy, DataBuffer<B, Udp<PHM>>: PseudoHeaderChecksum,

source

pub fn parse_udp_alone( buf: B, headroom: usize ) -> Result<DataBuffer<B, Udp<NoPreviousHeader>>, ParseUdpError>

Parses buf and creates a new DataBuffer for an UDP layer with no previous layers.

headroom indicates the amount of headroom in the provided buf. No checksum can be calculated without underlying header for the pseudo header.

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the length field value is invalid.
source

pub fn parse_udp_layer( lower_layer_data_buffer: impl HeaderMetadata + Payload + BufferIntoInner<B> + HeaderMetadataExtraction<PHM>, check_udp_checksum: bool ) -> Result<DataBuffer<B, Udp<PHM>>, ParseUdpError>

Consumes the lower_layer_data_buffer and creates a new DataBuffer with an additional UDP layer.

§Note

Inconsistencies between the IP payload length allocated for the UDP datagram and the UDP length are permissible as long as the indicated IP payload length is larger than the UDP length. https://datatracker.ietf.org/doc/html/rfc768 https://datatracker.ietf.org/doc/html/draft-ietf-tsvwg-udp-options-01#section-9

§Errors

Returns an error if:

  • the provided data buffer is shorter than expected.
  • the length field value is invalid.
  • if check_udp_checksum is true and the checksum is invalid.

Trait Implementations§

source§

impl<B, HM> ArpMethods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + ArpMarker,

source§

fn arp_hardware_type(&self) -> u16

Returns the ARP hardware type.
source§

fn arp_protocol_type(&self) -> u16

Returns the ARP protocol type.
source§

fn arp_typed_protocol_type( &self ) -> Result<EtherType, UnrecognizedEtherTypeError>

Returns the ARP protocol type as EtherType Read more
source§

fn arp_operation_code(&self) -> u16

Returns the ARP operation code.
source§

fn arp_typed_operation_code( &self ) -> Result<OperationCode, UnrecognizedOperationCodeError>

Returns the ARP operation code as OperationCode. Read more
source§

fn arp_hardware_address_length(&self) -> u8

Returns the ARP hardware address length.
source§

fn arp_protocol_address_length(&self) -> u8

Returns the ARP protocol address length.
source§

fn arp_sender_hardware_address(&self) -> MacAddress

Returns the ARP sender hardware address.
source§

fn arp_sender_protocol_address(&self) -> Ipv4Addr

Returns the ARP sender protocol address.
source§

fn arp_target_hardware_address(&self) -> MacAddress

Returns the ARP target hardware address.
source§

fn arp_target_protocol_address(&self) -> Ipv4Addr

Returns the ARP target protocol address.
source§

impl<B, HM> ArpMethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + ArpMarker,

source§

fn set_arp_operation_code(&mut self, operation_code: OperationCode)

Sets the ARP operation code.
source§

fn set_arp_sender_hardware_address(&mut self, sender_addr: &MacAddress)

Sets the ARP sender hardware address.
source§

fn set_arp_sender_protocol_address(&mut self, sender_addr: &Ipv4Addr)

Sets the ARP sender protocol address.
source§

fn set_arp_target_hardware_address(&mut self, target_addr: &MacAddress)

Sets the ARP target hardware address.
source§

fn set_arp_target_protocol_address(&mut self, target_addr: &Ipv4Addr)

Sets the ARP target protocol address.
source§

impl<B, HM> BufferIntoInner<B> for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut,

source§

fn data_length(&self) -> usize

Returns the data length. Read more
source§

fn headroom(&self) -> usize

Returns the amount of headroom the buffer currently has.
source§

fn buffer_into_inner(self) -> B

Returns the underlying buffer.
source§

fn buffer_get_ref(&self) -> &[u8]

Returns a reference to the underlying buffer.
source§

impl<B, HM> Clone for DataBuffer<B, HM>
where B: AsRef<[u8]> + Clone, HM: HeaderMetadata + HeaderMetadataMut + Copy,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<B, HM> Debug for DataBuffer<B, HM>
where B: AsRef<[u8]> + Debug, HM: HeaderMetadata + HeaderMetadataMut + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<B, HM> EthernetMethods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + EthernetMarker,

source§

fn ethernet_destination(&self) -> MacAddress

Returns the ethernet II destination.
source§

fn ethernet_source(&self) -> MacAddress

Returns the ethernet II source.
source§

fn ethernet_ether_type(&self) -> u16

Returns the ethernet II ether type.
source§

fn ethernet_typed_ether_type( &self ) -> Result<EtherType, UnrecognizedEtherTypeError>

Returns the ethernet II ether type as EtherType. Read more
source§

impl<B, HM> EthernetMethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + EthernetMarker + Sized,

source§

fn set_ethernet_destination(&mut self, mac_addr: &MacAddress)

Sets the ethernet II destination.
source§

fn set_ethernet_source(&mut self, mac_addr: &MacAddress)

Sets the ethernet II source.
source§

fn set_ethernet_ether_type(&mut self, ether_type: EtherType)

Sets the ethernet II ether type.
source§

impl<B, HM> Hash for DataBuffer<B, HM>
where B: AsRef<[u8]> + Hash, HM: HeaderMetadata + HeaderMetadataMut + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<B, HM> Ieee802_1QMethods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ieee802_1QVlanMarker,

source§

fn ieee802_1q_c_tag_control_information(&self) -> [u8; 2]

Returns the IEEE802.1Q customer tag control information.
source§

fn ieee802_1q_c_tag_priority_code_point(&self) -> u8

Returns the IEEE802.1Q customer tag priority code point.
source§

fn ieee802_1q_c_tag_drop_eligible_indicator(&self) -> bool

Returns the IEEE802.1Q customer tag drop eligible indicator.
source§

fn ieee802_1q_c_tag_vlan_identifier(&self) -> u16

Returns the IEEE802.1Q customer tag VLAN identifier.
source§

fn ieee802_1q_s_tag_control_information(&self) -> Option<[u8; 2]>

Returns the IEEE802.1Q service tag control information.
source§

fn ieee802_1q_s_tag_priority_code_point(&self) -> Option<u8>

Returns the IEEE802.1Q service tag priority code point.
source§

fn ieee802_1q_s_tag_drop_eligible_indicator(&self) -> Option<bool>

Returns the IEEE802.1Q service tag drop eligible indicator.
source§

fn ieee802_1q_s_tag_vlan_identifier(&self) -> Option<u16>

Returns the IEEE802.1Q service tag VLAN identifier.
source§

fn ieee802_1q_typed_vlan(&self) -> Vlan

Returns Vlan indicating whether the IEEE802.1Q header is single or double tagged.
source§

fn ieee802_1q_ether_type(&self) -> u16

Returns the IEEE802.1Q ether type.
source§

fn ieee802_1q_typed_ether_type( &self ) -> Result<EtherType, UnrecognizedEtherTypeError>

Returns the IEEE802.1Q ether type as EtherType. Read more
source§

impl<B, HM> Ieee802_1QMethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ieee802_1QVlanMarker, DataBuffer<B, HM>: UpdateEtherTypeBelowIeee802_1q,

source§

fn set_ieee802_1q_c_tag_control_information( &mut self, tag_control_information: &[u8; 2] )

Sets the IEEE802.1Q customer tag control information.
source§

fn set_ieee802_1q_c_tag_priority_code_point(&mut self, priority_code_point: u8)

Sets the IEEE802.1Q customer tag priority code point. Read more
source§

fn set_ieee802_1q_c_tag_drop_eligible_indicator( &mut self, drop_eligible_indicator: bool )

Sets the IEEE802.1Q customer tag drop eligible indicator.
source§

fn set_ieee802_1q_c_tag_vlan_identifier(&mut self, vlan_identifier: u16)

Sets the IEEE802.1Q customer tag VLAN identifier. Read more
source§

fn add_or_update_ieee802_1q_s_tag( &mut self, s_tag_control_information: &[u8; 2] ) -> Result<(), NotEnoughHeadroomError>

Adds or updates the IEEE802.1Q service tag. Read more
source§

fn set_ieee802_1q_s_tag_priority_code_point( &mut self, priority_code_point: u8 ) -> Result<(), NotDoubleTaggedError>

Sets the IEEE802.1Q service tag priority code point. Read more
source§

fn set_ieee802_1q_s_tag_drop_eligible_indicator( &mut self, drop_eligible_indicator: bool ) -> Result<(), NotDoubleTaggedError>

Sets the IEEE802.1Q service tag drop eligible indicator. Read more
source§

fn set_ieee802_1q_s_tag_vlan_identifier( &mut self, vlan_identifier: u16 ) -> Result<(), NotDoubleTaggedError>

Sets the IEEE802.1Q service tag VLAN identifier. Read more
source§

fn cut_ieee802_1q_s_tag(&mut self)

Removes the IEEE802.1Q service tag. Read more
source§

fn set_ieee802_1q_ether_type(&mut self, ether_type: u16)

Sets the IEEE802.1Q ether type.
source§

impl<B, HM> Ipv4Methods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: Ipv4Marker + HeaderMetadata + HeaderMetadataMut,

source§

fn ipv4_version(&self) -> u8

Returns the IPv4 version.
source§

fn ipv4_ihl(&self) -> u8

Returns the IPv4 IHL.
source§

fn ipv4_dscp(&self) -> u8

Returns the IPv4 DSCP.
source§

fn ipv4_typed_dscp(&self) -> Result<Dscp, UnrecognizedDscpError>

Returns the IPv4 DSCP as Dscp Read more
source§

fn ipv4_ecn(&self) -> u8

Returns the IPv4 ECN.
source§

fn ipv4_typed_ecn(&self) -> Result<Ecn, UnrecognizedEcnError>

Returns the IPv4 ECN as Ecn Read more
source§

fn ipv4_total_length(&self) -> u16

Returns the IPv4 total length.
source§

fn ipv4_identification(&self) -> u16

Returns the IPv4 identification.
source§

fn ipv4_flags(&self) -> u8

Returns the IPv4 flags.
source§

fn ipv4_evil_flag(&self) -> bool

Returns the IPv4 evil flag. Read more
source§

fn ipv4_dont_fragment_flag(&self) -> bool

Returns the IPv4 don’t fragment flag.
source§

fn ipv4_more_fragments_flag(&self) -> bool

Returns the IPv4 more fragments flag.
source§

fn ipv4_fragment_offset(&self) -> u16

Returns the IPv4 fragment offset.
source§

fn ipv4_time_to_live(&self) -> u8

Returns the IPv4 time to live.
source§

fn ipv4_protocol(&self) -> u8

Returns the IPv4 protocol.
source§

fn ipv4_typed_protocol( &self ) -> Result<InternetProtocolNumber, UnrecognizedInternetProtocolNumberError>

Returns the IPv4 protocol as InternetProtocolNumber Read more
source§

fn ipv4_header_checksum(&self) -> u16

Returns the IPv4 header checksum.
source§

fn ipv4_calculate_checksum(&self) -> u16

Calculates and returns the IPv4 header checksum. Read more
source§

fn ipv4_source(&self) -> Ipv4Addr

Returns the IPv4 source.
source§

fn ipv4_destination(&self) -> Ipv4Addr

Returns the IPv4 destination.
source§

fn ipv4_options(&self) -> &[u8]

Returns a slice containing the IPv4 options. Read more
source§

fn ipv4_payload_length(&self) -> u16

Returns the IPv4 payload length.
source§

impl<B, HM> Ipv4MethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ipv4Marker + Sized,

source§

fn set_ipv4_ihl(&mut self, ihl: u8) -> Result<(), SetIhlError>

Sets the IPv4 IHL. Read more
source§

fn set_ipv4_dscp(&mut self, dscp: Dscp)

Sets the IPv4 DSCP.
source§

fn set_ipv4_ecn(&mut self, ecn: Ecn)

Sets the IPv4 ECN.
source§

fn set_ipv4_total_length( &mut self, total_length: u16 ) -> Result<(), SetTotalLengthError>

Sets the IPv4 total length. Read more
source§

fn set_ipv4_identification(&mut self, identification: u16)

Sets the IPv4 identification.
source§

fn set_ipv4_flags(&mut self, flags: u8)

Sets the IPv4 flags.
source§

fn set_ipv4_evil_flag(&mut self, evil: bool)

Sets the IPv4 evil flag. Read more
source§

fn set_ipv4_dont_fragment_flag(&mut self, dont_fragment: bool)

Sets the IPv4 don’t fragment flag.
source§

fn set_ipv4_more_fragments_flag(&mut self, more_fragments: bool)

Sets the IPv4 more fragments flag.
source§

fn set_ipv4_fragment_offset(&mut self, fragment_offset: u16)

Sets the IPv4 fragment offset.
source§

fn set_ipv4_time_to_live(&mut self, time_to_live: u8)

Sets the IPv4 time to live.
source§

fn set_ipv4_protocol(&mut self, protocol: u8)

Sets the IPv4 protocol.
source§

fn set_ipv4_header_checksum(&mut self, checksum: u16)

Sets the IPv4 header checksum.
source§

fn update_ipv4_header_checksum(&mut self)

Calculates and updates the IPv4 checksum.
source§

fn set_ipv4_source(&mut self, source: Ipv4Addr)

Sets the IPv4 source.
source§

fn set_ipv4_destination(&mut self, destination: Ipv4Addr)

Sets the IPv4 destination.
source§

fn ipv4_options_mut(&mut self) -> &mut [u8]

Returns a mutable slice containing the IPv4 options. Read more
source§

impl<B, HM, const MAX_EXTENSIONS: usize> Ipv6ExtMethods<MAX_EXTENSIONS> for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ipv6ExtMarker<MAX_EXTENSIONS>,

source§

fn ipv6_ext_amount(&self) -> usize

Returns the amount of IPv6 extensions.
source§

fn ipv6_extensions(&self) -> [Option<Ipv6ExtensionType>; MAX_EXTENSIONS]

Returns an array containing all IPv6 extensions. Read more
source§

fn ipv6_ext_next_header(&self) -> Result<u8, Ipv6ExtensionIndexOutOfBoundsError>

Returns the last extension’s next header. Read more
source§

fn ipv6_ext_typed_next_header( &self ) -> Result<InternetProtocolNumber, Ipv6ExtTypedHeaderError>

Returns the last extension’s next header as InternetProtocolNumber. Read more
source§

fn ipv6_ext_per_extension_next_header( &self, extension_index: usize ) -> Result<u8, Ipv6ExtensionIndexOutOfBoundsError>

Returns the next header of the extension at extension_index. Read more
source§

fn ipv6_ext_per_extension_typed_next_header( &self, extension_index: usize ) -> Result<InternetProtocolNumber, Ipv6ExtTypedHeaderError>

Returns the next header of the extension at extension_index as InternetProtocolNumber. Read more
source§

fn ipv6_ext_length( &self, extension_index: usize ) -> Result<u8, Ipv6ExtFieldError>

Returns the length field of the extension at extension_index. Read more
source§

fn ipv6_ext_length_in_bytes( &self, extension_index: usize ) -> Result<usize, Ipv6ExtensionIndexOutOfBoundsError>

Returns the length of the extension at extension_index in bytes. Read more
source§

fn ipv6_ext_data( &self, extension_index: usize ) -> Result<&[u8], Ipv6ExtFieldError>

Returns a slice containing the data of the extension at extension_index. Read more
source§

fn ipv6_ext_routing_type( &self, extension_index: usize ) -> Result<u8, Ipv6ExtFieldError>

Returns the routing type of the extension at extension_index. Read more
source§

fn ipv6_ext_segments_left( &self, extension_index: usize ) -> Result<u8, Ipv6ExtFieldError>

Returns the segments left of the extension at extension_index. Read more
source§

fn ipv6_ext_fragment_offset( &self, extension_index: usize ) -> Result<u16, Ipv6ExtFieldError>

Returns the fragment offset of the extension at extension_index. Read more
source§

fn ipv6_ext_more_fragments( &self, extension_index: usize ) -> Result<bool, Ipv6ExtFieldError>

Returns the more fragments flag of the extension at extension_index. Read more
source§

fn ipv6_ext_fragment_identification( &self, extension_index: usize ) -> Result<u32, Ipv6ExtFieldError>

Returns the fragment identification of the extension at extension_index. Read more
source§

impl<B, HM, const MAX_EXTENSIONS: usize> Ipv6ExtMethodsMut<MAX_EXTENSIONS> for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ipv6ExtMarker<MAX_EXTENSIONS>, DataBuffer<B, HM>: UpdateIpv6Length,

source§

fn set_ipv6_ext_next_header( &mut self, next_header: InternetProtocolNumber ) -> Result<(), Ipv6ExtensionIndexOutOfBoundsError>

Sets the last extension’s next header. Read more
source§

fn set_ipv6_ext_length( &mut self, new_length: u8, extension_index: usize ) -> Result<(), Ipv6ExtSetFieldError>

Sets the extension’s length of the extension at extension_index. Read more
source§

fn ipv6_ext_data_mut( &mut self, extension_index: usize ) -> Result<&mut [u8], Ipv6ExtFieldError>

Returns a mutable slice containing the data of the extension at extension_index. Read more
source§

fn set_ipv6_ext_routing_type( &mut self, routing_type: RoutingType, extension_index: usize ) -> Result<(), Ipv6ExtFieldError>

Sets the routing type of the extension at extension_index. Read more
source§

fn set_ipv6_ext_segments_left( &mut self, segments_left: u8, extension_index: usize ) -> Result<(), Ipv6ExtFieldError>

Sets the segments left of the extension at extension_index. Read more
source§

fn set_ipv6_ext_fragment_offset( &mut self, fragment_offset: u16, extension_index: usize ) -> Result<(), Ipv6ExtFieldError>

Sets the fragment offset of the extension at extension_index. Read more
source§

fn set_ipv6_ext_more_fragments( &mut self, more_fragments: bool, extension_index: usize ) -> Result<(), Ipv6ExtFieldError>

Sets the more fragments flag of the extension at extension_index. Read more
source§

fn set_ipv6_ext_fragment_identification( &mut self, identification: u32, extension_index: usize ) -> Result<(), Ipv6ExtFieldError>

Sets the fragment identification of the extension at extension_index. Read more
source§

impl<B, HM> Ipv6Methods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ipv6Marker,

source§

fn ipv6_version(&self) -> u8

Returns the IPv6 version.
source§

fn ipv6_traffic_class(&self) -> u8

Returns the IPv6 traffic class.
source§

fn ipv6_flow_label(&self) -> u32

Returns the IPv6 flow label.
source§

fn ipv6_payload_length(&self) -> u16

Returns the IPv6 payload length.
source§

fn ipv6_next_header(&self) -> u8

Returns the IPv6 next header.
source§

fn ipv6_typed_next_header( &self ) -> Result<InternetProtocolNumber, UnrecognizedInternetProtocolNumberError>

Returns the IPv6 next header as InternetProtocolNumber. Read more
source§

fn ipv6_hop_limit(&self) -> u8

Returns the IPv6 hop limit.
source§

fn ipv6_source(&self) -> Ipv6Addr

Returns the IPv6 source.
source§

fn ipv6_destination(&self) -> Ipv6Addr

Returns the IPv6 destination.
source§

impl<B, HM> Ipv6MethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + Ipv6Marker + Sized,

source§

fn set_ipv6_traffic_class(&mut self, traffic_class: u8)

Sets the IPv6 traffic class.
source§

fn set_ipv6_flow_label(&mut self, flow_label: u32)

Sets the IPv6 flow label. Read more
source§

fn set_ipv6_payload_length( &mut self, payload_length: u16 ) -> Result<(), SetPayloadLengthError>

Sets the IPv6 payload length. Read more
source§

fn set_ipv6_next_header(&mut self, next_header: u8)

Sets the IPv6 next header.
source§

fn set_ipv6_hop_limit(&mut self, hop_limit: u8)

Sets the IPv6 hop limit.
source§

fn set_ipv6_source(&mut self, source: Ipv6Addr)

Sets the IPv6 source.
source§

fn set_ipv6_destination(&mut self, destination: Ipv6Addr)

Sets the IPv6 destination.
source§

impl<B, HM> PartialEq for DataBuffer<B, HM>
where B: AsRef<[u8]> + PartialEq, HM: HeaderMetadata + HeaderMetadataMut + PartialEq,

source§

fn eq(&self, other: &DataBuffer<B, HM>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<B> Payload for DataBuffer<B, Eth>
where B: AsRef<[u8]>,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM> Payload for DataBuffer<B, Ieee802_1QVlan<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM> Payload for DataBuffer<B, Ipv4<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM> Payload for DataBuffer<B, Ipv6<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM, const MAX_EXTENSIONS: usize> Payload for DataBuffer<B, Ipv6Extensions<PHM, MAX_EXTENSIONS>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B> Payload for DataBuffer<B, NoPreviousHeader>
where B: AsRef<[u8]>,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM> Payload for DataBuffer<B, Tcp<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B, PHM> Payload for DataBuffer<B, Udp<PHM>>
where B: AsRef<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut, DataBuffer<B, Udp<PHM>>: PseudoHeaderChecksum,

source§

fn payload(&self) -> &[u8]

Returns a reference to the highest parsed layer’s payload.
source§

fn payload_length(&self) -> usize

Returns the length of the highest parsed layer’s payload.
source§

impl<B> PayloadMut for DataBuffer<B, Eth>
where B: AsRef<[u8]> + AsMut<[u8]>,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM> PayloadMut for DataBuffer<B, Ieee802_1QVlan<PHM>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM> PayloadMut for DataBuffer<B, Ipv4<PHM>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM> PayloadMut for DataBuffer<B, Ipv6<PHM>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM, const MAX_EXTENSIONS: usize> PayloadMut for DataBuffer<B, Ipv6Extensions<PHM, MAX_EXTENSIONS>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM> PayloadMut for DataBuffer<B, Tcp<PHM>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, PHM> PayloadMut for DataBuffer<B, Udp<PHM>>
where B: AsRef<[u8]> + AsMut<[u8]>, PHM: HeaderMetadata + HeaderMetadataMut, DataBuffer<B, Udp<PHM>>: PseudoHeaderChecksum,

source§

fn payload_mut(&mut self) -> &mut [u8]

Returns a mutable reference to the highest parsed layer’s payload.
source§

impl<B, HM> TcpMethods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + TcpMarker, DataBuffer<B, HM>: PseudoHeaderChecksum,

source§

fn tcp_source_port(&self) -> u16

Returns the TCP source port.
source§

fn tcp_destination_port(&self) -> u16

Returns the TCP destination port.
source§

fn tcp_sequence_number(&self) -> u32

Returns the TCP sequence number.
source§

fn tcp_acknowledgment_number(&self) -> u32

Returns the TCP acknowledgment number.
source§

fn tcp_data_offset(&self) -> u8

Returns the TCP data offset.
source§

fn tcp_reserved_bits(&self) -> u8

Returns the TCP reserved bits.
source§

fn tcp_flags(&self) -> u8

Returns the TCP flags.
source§

fn tcp_congestion_window_reduced_flag(&self) -> bool

Returns the TCP congestion window reduced flag.
source§

fn tcp_ecn_echo_flag(&self) -> bool

Returns the TCP ECN echo flag.
source§

fn tcp_urgent_pointer_flag(&self) -> bool

Returns the TCP urgent pointer flag.
source§

fn tcp_acknowledgement_flag(&self) -> bool

Returns the TCP acknowledgement flag.
source§

fn tcp_push_flag(&self) -> bool

Returns the TCP push flag.
source§

fn tcp_reset_flag(&self) -> bool

Returns the TCP reset flag.
source§

fn tcp_synchronize_flag(&self) -> bool

Returns the TCP synchronize flag.
source§

fn tcp_fin_flag(&self) -> bool

Returns the TCP FIN flag.
source§

fn tcp_window_size(&self) -> u16

Returns the TCP window size.
source§

fn tcp_checksum(&self) -> u16

Returns the TCP checksum.
source§

fn tcp_urgent_pointer(&self) -> u16

Returns the TCP urgent pointer.
source§

fn tcp_options(&self) -> Option<&[u8]>

Returns the TCP options if present.
source§

fn tcp_calculate_checksum(&self) -> u16

Calculates and returns the TCP checksum. Read more
source§

impl<B, HM> TcpMethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + TcpMarker, DataBuffer<B, HM>: PseudoHeaderChecksum + UpdateIpLength,

source§

fn set_tcp_source_port(&mut self, port: u16)

Set the TCP source port.
source§

fn set_tcp_destination_port(&mut self, port: u16)

Set the TCP destination port.
source§

fn set_tcp_sequence_number(&mut self, sequence_number: u32)

Set the TCP sequence number.
source§

fn set_tcp_acknowledgement_number(&mut self, acknowledgement_number: u32)

Set the TCP acknowledgement number.
source§

fn set_tcp_data_offset( &mut self, data_offset: u8 ) -> Result<(), SetDataOffsetError>

Set the TCP data offset. Read more
source§

fn set_tcp_reserved_bits(&mut self, reserved_bits: u8)

Set the TCP reserved bits.
source§

fn set_tcp_flags(&mut self, flags: u8)

Set the TCP flags.
source§

fn set_tcp_congestion_window_reduced_flag( &mut self, congestion_window_reduced: bool )

Set the TCP congestion window reduced flag.
source§

fn set_tcp_ecn_echo_flag(&mut self, ecn_echo: bool)

Set the TCP ECN echo flag.
source§

fn set_tcp_urgent_pointer_flag(&mut self, urgent_pointer: bool)

Set the TCP urgent pointer flag.
source§

fn set_tcp_acknowledgement_flag(&mut self, acknowledgement: bool)

Set the TCP acknowledgement flag.
source§

fn set_tcp_push_flag(&mut self, push: bool)

Set the TCP push flag.
source§

fn set_tcp_reset_flag(&mut self, reset: bool)

Set the TCP reset flag.
source§

fn set_tcp_synchronize_flag(&mut self, synchronize: bool)

Set the TCP synchronize flag.
source§

fn set_tcp_fin_flag(&mut self, fin: bool)

Set the TCP FIN flag.
source§

fn set_tcp_window_size(&mut self, window_size: u16)

Set the TCP window size.
source§

fn set_tcp_checksum(&mut self, checksum: u16)

Set the TCP checksum.
source§

fn set_tcp_urgent_pointer(&mut self, urgent_pointer: u16)

Set the TCP urgent pointer.
source§

fn tcp_options_mut(&mut self) -> Option<&mut [u8]>

Returns a mutable slice containing the TCP options or None if no options are present.
source§

fn update_tcp_checksum(&mut self)

Calculates and replaces the TCP checksum. Read more
source§

impl<B, HM> UdpMethods for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + UdpMarker, DataBuffer<B, HM>: PseudoHeaderChecksum,

source§

fn udp_source_port(&self) -> u16

Returns the UDP source port.
source§

fn udp_destination_port(&self) -> u16

Returns the UDP destination port.
source§

fn udp_length(&self) -> u16

Returns the UDP length.
source§

fn udp_checksum(&self) -> u16

Returns the UDP checksum.
source§

fn udp_calculate_checksum(&self) -> u16

Calculates and returns the UDP checksum. Read more
source§

impl<B, HM> UdpMethodsMut for DataBuffer<B, HM>
where B: AsRef<[u8]> + AsMut<[u8]>, HM: HeaderMetadata + HeaderMetadataMut + UdpMarker, DataBuffer<B, HM>: PseudoHeaderChecksum + UpdateIpLength,

source§

fn set_udp_source_port(&mut self, port: u16)

Sets the UDP source port.
source§

fn set_udp_destination_port(&mut self, port: u16)

Sets the UDP destination port.
source§

fn set_udp_length(&mut self, length: u16) -> Result<(), SetLengthError>

Sets the UDP length. Read more
source§

fn set_udp_checksum(&mut self, checksum: u16)

Sets the UDP checksum.
source§

fn update_udp_checksum(&mut self)

Calculates and updates the UDP checksum. Read more
source§

impl<B, HM> Eq for DataBuffer<B, HM>
where B: AsRef<[u8]> + Eq, HM: HeaderMetadata + HeaderMetadataMut + Eq,

source§

impl<B, HM> StructuralPartialEq for DataBuffer<B, HM>
where B: AsRef<[u8]>, HM: HeaderMetadata + HeaderMetadataMut,

Auto Trait Implementations§

§

impl<B, HM> Freeze for DataBuffer<B, HM>
where B: Freeze, HM: Freeze,

§

impl<B, HM> RefUnwindSafe for DataBuffer<B, HM>

§

impl<B, HM> Send for DataBuffer<B, HM>
where B: Send, HM: Send,

§

impl<B, HM> Sync for DataBuffer<B, HM>
where B: Sync, HM: Sync,

§

impl<B, HM> Unpin for DataBuffer<B, HM>
where B: Unpin, HM: Unpin,

§

impl<B, HM> UnwindSafe for DataBuffer<B, HM>
where B: UnwindSafe, HM: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.