Expand description
Low-level packet access and construction.
The wire module deals with the packet representation. It provides functions to extract
fields from sequences of octets, and to insert fields into sequences of octets. This
happens through the Packet family of structures, e.g. EthernetFrame or Ipv4Packet.
The functions in the wire module are designed for use together with -Cpanic=abort.
The Packet family of data structures guarantees that, if the Packet::check_len() method
returned Ok(()), then no accessor or setter method will panic; however, the guarantee
provided by Packet::check_len() may no longer hold after changing certain fields,
which are listed in the documentation for the specific packet.
The Packet::new_checked method is a shorthand for a combination of Packet::new_unchecked
and Packet::check_len.
When parsing untrusted input, it is necessary to use Packet::new_checked();
so long as the buffer is not modified, no accessor will fail.
When emitting output, though, it is incorrect to use Packet::new_checked();
the length check is likely to succeed on a zeroed buffer, but fail on a buffer
filled with data from a previous packet, such as when reusing buffers, resulting
in nondeterministic panics with some network devices but not others.
The buffer length for emission is not calculated by the Packet layer.
Modules§
Structs§
- ArpHardware
- ARP hardware type.
- ArpOperation
- ARP operation type.
- ArpPacket
- A read/write wrapper around an Address Resolution Protocol packet buffer.
- Dhcp
Flags - The flags field of a DHCP packet.
- Dhcp
Message Type - The message type of a DHCP packet, from the message type option.
- Dhcp
OpCode - The opcode of a DHCP packet.
- Dhcp
Option - One DHCP option: a kind and its data.
- Dhcp
Option Writer - Writes DHCP options into the options field of a packet, one after the other.
- Dhcp
Packet - A read/write wrapper around a Dynamic Host Configuration Protocol packet buffer.
- DnsFlags
- DNS header flags.
- DnsOpcode
- DNS opcode.
- DnsPacket
- A read/write wrapper around a DNS packet buffer.
- DnsQuestion
- A question in a DNS packet.
- DnsRcode
- DNS response code.
- DnsRecord
- A resource record in a DNS packet.
- DnsType
- DNS record type.
- Error
- Parsing a packet failed.
- Ethernet
Address - A six-octet Ethernet II address.
- Ethernet
Frame - A read/write wrapper around an Ethernet II frame buffer.
- Ethernet
Protocol - Ethernet protocol type.
- Icmpv4
DstUnreachable - Internet protocol control message subtype for type “Destination Unreachable”.
- Icmpv4
Message - Internet protocol control message type.
- Icmpv4
Packet - A read/write wrapper around an Internet Control Message Protocol version 4 packet buffer.
- Icmpv4
Param Problem - Internet protocol control message subtype for type “Parameter Problem”.
- Icmpv4
Redirect - Internet protocol control message subtype for type “Redirect Message”.
- Icmpv4
Time Exceeded - Internet protocol control message subtype for type “Time Exceeded”.
- Icmpv6
DstUnreachable - Internet protocol control message subtype for type “Destination Unreachable”.
- Icmpv6
Message - Internet protocol control message type.
- Icmpv6
Packet - A read/write wrapper around an Internet Control Message Protocol version 6 packet buffer.
- Icmpv6
Param Problem - Internet protocol control message subtype for the type “Parameter Problem”.
- Icmpv6
Time Exceeded - Internet protocol control message subtype for the type “Time Exceeded”.
- Ieee802154
Frame Type - IEEE 802.15.4 frame type.
- Ieee802154
Frame Version - IEEE 802.15.4 frame version.
- Ieee802154
Pan - An IEEE 802.15.4 PAN identifier.
- Ieee802154
Repr - The fields of an IEEE 802.15.4 MAC header.
- Igmp
Message - Internet Group Management Protocol v1/v2 message version/type.
- Igmp
Packet - A read/write wrapper around an Internet Group Management Protocol v1/v2 packet buffer.
- IpEndpoint
- An internet endpoint address.
- IpListen
Endpoint - An internet endpoint address for listening.
- IpProtocol
- IP datagram encapsulated protocol.
- Ipv4
Address - An IPv4 address.
- Ipv4
Cidr - A specification of an IPv4 CIDR block, containing an address and a variable-length subnet masking prefix length.
- Ipv4
Packet - A read/write wrapper around an Internet Protocol version 4 packet buffer.
- Ipv6
Address - An IPv6 address.
- Ipv6
Cidr - A specification of an IPv6 CIDR block, containing an address and a variable-length subnet masking prefix length.
- Ipv6
ExtHeader - A read wrapper around an IPv6 extension header.
- Ipv6
Option Type - IPv6 option type, from the Hop-by-Hop or Destination Options TLVs.
- Ipv6
Options Iter - An iterator over TLV-encoded IPv6 options, yielding
(offset, option type, option data). The offset is of the option’s first byte, relative to the start of the options. - Ipv6
Packet - A read/write wrapper around an Internet Protocol version 6 packet buffer.
- Ipv6
Router Alert - The value of an IPv6 Router Alert Header Option.
- MldAddress
Record - A read/write wrapper around an MLDv2 Listener Report Message Address Record.
- MldRecord
Type - MLDv2 Multicast Listener Report Record Type. See RFC 3810 § 5.2.12 for more details.
- Ndisc
Neighbor Flags - Ndisc
Option - A read/write wrapper around an NDISC Option.
- Ndisc
Option Type - NDISC Option Type
- Ndisc
Prefix Info Flags - Ndisc
Router Flags - RawHardware
Address - Unparsed hardware address.
- Sixlowpan
Address Context - A 6LoWPAN address context: a 64-bit prefix that compressed addresses may refer to by index instead of carrying it inline.
- Sixlowpan
ExtHeader Repr - The fields of a 6LoWPAN NHC extension header.
- Sixlowpan
Frag Key - Key used for identifying all the link fragments that belong to the same packet.
- Sixlowpan
Iphc Repr - The fields of a 6LoWPAN IPHC header.
- Sixlowpan
UdpNhc Repr - The fields of a 6LoWPAN NHC UDP header.
- TcpPacket
- A read/write wrapper around a Transmission Control Protocol packet buffer.
- TcpSeq
Number - A TCP sequence number.
- UdpPacket
- A read/write wrapper around an User Datagram Protocol packet buffer.
Enums§
- DnsRecord
Data - The data of a resource record.
- Hardware
Address - A hardware (link-layer) address.
- Ieee802154
Address - An IEEE 802.15.4 address.
- Igmp
Version - Type of IGMP membership report version
- IpAddress
- An internetworking address.
- IpCidr
- A specification of a CIDR block, containing an address and a variable-length subnet masking prefix length.
- IpVersion
- Internet protocol version.
- Ipv6
Option Failure Action - The action required of a node that does not recognize an option, from the two highest-order bits of the option type (RFC 8200 §4.2).
- Sixlowpan
ExtHeader Id - The IPv6 extension header a compressed extension header stands for.
- Sixlowpan
Frag Repr - The fields of a 6LoWPAN fragment header.
- Sixlowpan
Next Header - The next header field of a compressed header.
- Sixlowpan
NhcPacket - The kind of compressed next header a buffer starts with.
- Sixlowpan
Packet - The kind of 6LoWPAN header a frame’s payload starts with.
- TcpControl
- The possible control flags of a Transmission Control Protocol packet.
- TcpOption
- A representation of a single TCP option.
Constants§
- ARP_
BUFFER_ LEN - The length of an Ethernet+IPv4 Address Resolution Protocol packet.
- DHCP_
CLIENT_ PORT - The UDP port DHCP clients listen on.
- DHCP_
HEADER_ LEN - Length of the fixed part of a DHCP packet, everything before the options.
- DHCP_
MAGIC_ NUMBER - The magic cookie that starts the options field of every DHCP packet.
- DHCP_
SERVER_ PORT - The UDP port DHCP servers listen on.
- DNS_
HEADER_ LEN - Length of the DNS header.
- ETHERNET_
HEADER_ LEN - The Ethernet header length
- IEEE802154_
MAX_ HEADER_ LEN - The largest MAC header this crate emits: frame control, sequence number, destination PAN, and two extended addresses.
- IGMP_
BUFFER_ LEN - The length of an IGMPv1/v2 packet. Always 8 bytes.
- IPV4_
FRAGMENT_ PAYLOAD_ ALIGNMENT - The payload of every fragment but the last is a multiple of this, in octets. Fragment offsets are counted in units of it. See RFC 791 § 3.1.
- IPV4_
HEADER_ LEN - IPV4_
MIN_ MTU - Minimum MTU required of all links supporting IPv4. See RFC 791 § 3.1.
- IPV4_
MULTICAST_ ALL_ ROUTERS - All multicast-capable routers
- IPV4_
MULTICAST_ ALL_ SYSTEMS - All multicast-capable nodes
- IPV6_
HEADER_ LEN - Length of an IPv6 header.
- IPV6_
LINK_ LOCAL_ ALL_ MLDV2_ ROUTERS - The link-local all MLVDv2-capable routers multicast address.
- IPV6_
LINK_ LOCAL_ ALL_ NODES - The link-local all nodes multicast address.
- IPV6_
LINK_ LOCAL_ ALL_ ROUTERS - The link-local all routers multicast address.
- IPV6_
MIN_ MTU - Minimum MTU required of all links supporting IPv6. See RFC 8200 § 5.
- LINK_
HEADER_ LEN - The headroom every egress packet reserves for the link-layer header below IP.
- MAX_
HARDWARE_ ADDRESS_ LEN - The longest hardware address of any enabled medium: 8 with
medium-ieee802154, 6 otherwise. - MLD_
ADDRESS_ RECORD_ LEN - The length of a Multicast Address Record with no sources and no auxiliary data.
- SIXLOWPAN_
FIRST_ FRAGMENT_ HEADER_ SIZE - The length of a first fragment header.
- SIXLOWPAN_
IPHC_ MAX_ HEADER_ LEN - The largest IPHC header: the base, a context identifier, an inline traffic class and flow label, next header, hop limit, and two full addresses.
- SIXLOWPAN_
NEXT_ FRAGMENT_ HEADER_ SIZE - The length of a subsequent fragment header.
- TCP_
HEADER_ LEN - UDP_
HEADER_ LEN