Struct etherparse::Ipv6Header
source · [−]pub struct Ipv6Header {
pub traffic_class: u8,
pub flow_label: u32,
pub payload_length: u16,
pub next_header: u8,
pub hop_limit: u8,
pub source: [u8; 16],
pub destination: [u8; 16],
}
Expand description
IPv6 header according to rfc8200.
Fields
traffic_class: u8
flow_label: u32
If non 0 serves as a hint to router and switches with multiple outbound paths that these packets should stay on the same path, so that they will not be reordered.
payload_length: u16
The length of the payload and extension headers in bytes (0 in case of jumbo payloads).
next_header: u8
IP protocol number specifying the next header or transport layer protocol.
hop_limit: u8
The number of hops the packet can take before it is discarded.
source: [u8; 16]
IPv6 source address
destination: [u8; 16]
IPv6 destination address
Implementations
sourceimpl Ipv6Header
impl Ipv6Header
sourcepub fn read_from_slice(slice: &[u8]) -> Result<(Ipv6Header, &[u8]), ReadError>
👎 Deprecated since 0.10.1: Renamed to Ipv6Header::from_slice
pub fn read_from_slice(slice: &[u8]) -> Result<(Ipv6Header, &[u8]), ReadError>
Renamed to Ipv6Header::from_slice
Renamed to Ipv6Header::from_slice
sourcepub fn from_slice(slice: &[u8]) -> Result<(Ipv6Header, &[u8]), ReadError>
pub fn from_slice(slice: &[u8]) -> Result<(Ipv6Header, &[u8]), ReadError>
Read an Ipv6Header from a slice and return the header & unused parts of the slice.
sourcepub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv6Header, ReadError>
pub fn read<T: Read + Seek + Sized>(
reader: &mut T
) -> Result<Ipv6Header, ReadError>
Reads an IPv6 header from the current position.
sourcepub fn read_without_version<T: Read + Seek + Sized>(
reader: &mut T,
version_rest: u8
) -> Result<Ipv6Header, Error>
pub fn read_without_version<T: Read + Seek + Sized>(
reader: &mut T,
version_rest: u8
) -> Result<Ipv6Header, Error>
Reads an IPv6 header assuming the version & flow_label field have already been read.
sourcepub fn skip_header_extension_in_slice(
slice: &[u8],
next_header: u8
) -> Result<(u8, &[u8]), ReadError>
pub fn skip_header_extension_in_slice(
slice: &[u8],
next_header: u8
) -> Result<(u8, &[u8]), ReadError>
Takes a slice and skips an ipv6 header extensions and returns the next_header ip number & the slice past the header.
sourcepub fn is_skippable_header_extension(ip_protocol_number: u8) -> bool
pub fn is_skippable_header_extension(ip_protocol_number: u8) -> bool
Returns true if the given ip protocol number is a skippable header extension.
A skippable header extension is an extension header for which it is known how to determine the protocol number of the following header as well as how many octets have to be skipped to reach the start of the following header.
sourcepub fn skip_all_header_extensions_in_slice(
slice: &[u8],
next_header: u8
) -> Result<(u8, &[u8]), ReadError>
pub fn skip_all_header_extensions_in_slice(
slice: &[u8],
next_header: u8
) -> Result<(u8, &[u8]), ReadError>
Takes a slice & ip protocol number (identifying the first header type) and returns next_header id & the slice past after all ipv6 header extensions.
sourcepub fn skip_header_extension<T: Read + Seek + Sized>(
reader: &mut T,
next_header: u8
) -> Result<u8, Error>
pub fn skip_header_extension<T: Read + Seek + Sized>(
reader: &mut T,
next_header: u8
) -> Result<u8, Error>
Skips the ipv6 header extension and returns the next ip protocol number
sourcepub fn skip_all_header_extensions<T: Read + Seek + Sized>(
reader: &mut T,
next_header: u8
) -> Result<u8, ReadError>
pub fn skip_all_header_extensions<T: Read + Seek + Sized>(
reader: &mut T,
next_header: u8
) -> Result<u8, ReadError>
Skips all ipv6 header extensions and returns the next ip protocol number
sourcepub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
pub fn write<T: Write + Sized>(&self, writer: &mut T) -> Result<(), WriteError>
Writes a given IPv6 header to the current position.
sourcepub fn header_len(&self) -> usize
pub fn header_len(&self) -> usize
Length of the serialized header in bytes.
The function always returns the constant Ipv6Header::SERIALIZED_SIZE and exists to keep the methods consistent with other headers.
sourcepub fn set_payload_length(&mut self, size: usize) -> Result<(), ValueError>
pub fn set_payload_length(&mut self, size: usize) -> Result<(), ValueError>
Sets the field total_length based on the size of the payload and the options. Returns an error if the payload is too big to fit.
Trait Implementations
sourceimpl Clone for Ipv6Header
impl Clone for Ipv6Header
sourcefn clone(&self) -> Ipv6Header
fn clone(&self) -> Ipv6Header
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for Ipv6Header
impl Debug for Ipv6Header
sourceimpl Default for Ipv6Header
impl Default for Ipv6Header
sourcefn default() -> Ipv6Header
fn default() -> Ipv6Header
Returns the “default value” for a type. Read more
sourceimpl PartialEq<Ipv6Header> for Ipv6Header
impl PartialEq<Ipv6Header> for Ipv6Header
sourcefn eq(&self, other: &Ipv6Header) -> bool
fn eq(&self, other: &Ipv6Header) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &Ipv6Header) -> bool
fn ne(&self, other: &Ipv6Header) -> bool
This method tests for !=
.
sourceimpl SerializedSize for Ipv6Header
impl SerializedSize for Ipv6Header
sourceconst SERIALIZED_SIZE: usize = 40usize
const SERIALIZED_SIZE: usize = 40usize
Size of the header itself in bytes.
impl Eq for Ipv6Header
impl StructuralEq for Ipv6Header
impl StructuralPartialEq for Ipv6Header
Auto Trait Implementations
impl RefUnwindSafe for Ipv6Header
impl Send for Ipv6Header
impl Sync for Ipv6Header
impl Unpin for Ipv6Header
impl UnwindSafe for Ipv6Header
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more