[][src]Struct capsule::packets::ip::v4::Ipv4

pub struct Ipv4 { /* fields omitted */ }

Internet Protocol v4 based on IETF RFC 791.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |    DSCP   |ECN|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  • Version: (4 bits) The Version field indicates the format of the internet header. This document describes version 4.

  • IHL: (4 bits) Internet Header Length is the length of the internet header in 32 bit words, and thus points to the beginning of the data. Note that the minimum value for a correct header is 5.

  • DSCP: (6 bits) Differentiated services codepoint defined in IETF RFC 2474. Used to select the per hop behavior a packet experiences at each node.

  • ECN: (2 bits) Explicit congestion notification codepoint defined in IETF RFC 3168.

  • Total Length: (16 bits) Total Length is the length of the datagram, measured in octets, including internet header and data.

  • Identification: (16 bits) An identifying value assigned by the sender to aid in assembling the fragments of a datagram.

  • Flags: (3 bits) Various Control Flags.

    • Bit 0: reserved, must be zero

    • Bit 1: (DF) 0 = May Fragment, 1 = Don't Fragment.

    • Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments.

        0   1   2
      +---+---+---+
      |   | D | M |
      | 0 | F | F |
      +---+---+---+
  • Fragment Offset: (13 bits) This field indicates where in the datagram this fragment belongs. The fragment offset is measured in units of 8 octets (64 bits). The first fragment has offset zero.

  • Time to Live: (8 bits) This field indicates the maximum time the datagram is allowed to remain in the internet system. If this field contains the value zero, then the datagram must be destroyed. This field is modified in internet header processing. The time is measured in units of seconds, but since every module that processes a datagram must decrease the TTL by at least one even if it process the datagram in less than a second, the TTL must be thought of only as an upper bound on the time a datagram may exist. The intention is to cause undeliverable datagrams to be discarded, and to bound the maximum datagram lifetime.

  • Protocol: (8 bits) This field indicates the next level protocol used in the data portion of the internet datagram. The values for various protocols are specified in "Assigned Numbers."

  • Header Checksum: (16 bits) A checksum on the header only. Since some header fields change (e.g., time to live), this is recomputed and verified at each point that the internet header is processed.

  • Source Address: (32 bits) The source address.

  • Destination Address: (32 bits) The destination address.

  • Options: (variable) The options may appear or not in datagrams. They must be implemented by all IP modules (host and gateways). What is optional is their transmission in any particular datagram, not their implementation.

Implementations

impl Ipv4[src]

pub fn version(&self) -> u8[src]

Returns the protocol version. Should always be 4.

pub fn ihl(&self) -> u8[src]

Returns the length of the internet header measured in number of 32-bit words. This indicates where the data begins.

pub fn dscp(&self) -> u8[src]

Returns the differentiated services codepoint.

pub fn set_dscp(&mut self, dscp: u8)[src]

Sets the differentiated services codepoint.

pub fn ecn(&self) -> u8[src]

Returns the explicit congestion notification codepoint.

pub fn set_ecn(&mut self, ecn: u8)[src]

Sets the explicit congestion notification codepoint.

pub fn total_length(&self) -> u16[src]

Returns the length of the packet, measured in octets, including the header and data.

pub fn identification(&self) -> u16[src]

Returns the identifying value assigned by the sender to aid in assembling the fragments of a packet.

pub fn set_identification(&mut self, identification: u16)[src]

Sets the identifying value.

pub fn dont_fragment(&self) -> bool[src]

Returns a flag indicating whether the packet can be fragmented.

pub fn set_dont_fragment(&mut self)[src]

Sets the don't fragment flag to indicate that the packet must not be fragmented.

pub fn unset_dont_fragment(&mut self)[src]

Unsets the don't fragment flag to indicate that the packet may be fragmented.

pub fn more_fragments(&self) -> bool[src]

Returns a flag indicating whether there are more fragments.

pub fn set_more_fragments(&mut self)[src]

Sets the more fragment flag indicating there are more fragments.

pub fn unset_more_fragments(&mut self)[src]

Unsets the more fragment flag indicating this is the last fragment.

pub fn fragment_offset(&self) -> u16[src]

Returns an offset indicating where in the datagram this fragment belongs. It is measured in units of 8 octets or 64 bits. The first fragment has offset zero.

pub fn set_fragment_offset(&mut self, offset: u16)[src]

Sets the fragment offset.

pub fn ttl(&self) -> u8[src]

Returns the packet's time to live.

pub fn set_ttl(&mut self, ttl: u8)[src]

Sets the time to live.

pub fn protocol(&self) -> ProtocolNumber[src]

Returns the next level protocol in the packet payload.

pub fn set_protocol(&mut self, protocol: ProtocolNumber)[src]

Sets the next level protocol.

pub fn checksum(&self) -> u16[src]

Returns the checksum.

pub fn src(&self) -> Ipv4Addr[src]

Returns the source address.

pub fn set_src(&mut self, src: Ipv4Addr)[src]

Sets the source address.

pub fn dst(&self) -> Ipv4Addr[src]

Returns the destination address.

pub fn set_dst(&mut self, dst: Ipv4Addr)[src]

Sets the destination address.

Trait Implementations

impl Debug for Ipv4[src]

impl IpPacket for Ipv4[src]

impl Packet for Ipv4[src]

type Envelope = Ethernet

The preceding type for an IPv4 packet must be Ethernet.

fn try_parse(envelope: Self::Envelope, _internal: Internal) -> Fallible<Self>[src]

Parses the Ethernet's payload as an IPv4 packet.

ether_type must be set to EtherTypes::Ipv4. Otherwise a parsing error is returned.

fn try_push(envelope: Self::Envelope, _internal: Internal) -> Fallible<Self>[src]

Prepends an IPv4 packet to the beginning of the Ethernet's payload.

ether_type is set to EtherTypes::Ipv4.

fn reconcile(&mut self)[src]

Reconciles the derivable header fields against the changes made to the packet.

  • total_length is set to the total length of the header and the payload.
  • checksum is computed based on the IPv4 header.

Auto Trait Implementations

impl RefUnwindSafe for Ipv4

impl !Send for Ipv4

impl !Sync for Ipv4

impl Unpin for Ipv4

impl UnwindSafe for Ipv4

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,