xarxa

Crates

git

Versions

default

Flavors

Skip to main content

Module wire

Module wire 

Source
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§

checksum

Structs§

ArpHardware
ARP hardware type.
ArpOperation
ARP operation type.
ArpPacket
A read/write wrapper around an Address Resolution Protocol packet buffer.
DhcpFlags
The flags field of a DHCP packet.
DhcpMessageType
The message type of a DHCP packet, from the message type option.
DhcpOpCode
The opcode of a DHCP packet.
DhcpOption
One DHCP option: a kind and its data.
DhcpOptionWriter
Writes DHCP options into the options field of a packet, one after the other.
DhcpPacket
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.
EthernetAddress
A six-octet Ethernet II address.
EthernetFrame
A read/write wrapper around an Ethernet II frame buffer.
EthernetProtocol
Ethernet protocol type.
Icmpv4DstUnreachable
Internet protocol control message subtype for type “Destination Unreachable”.
Icmpv4Message
Internet protocol control message type.
Icmpv4Packet
A read/write wrapper around an Internet Control Message Protocol version 4 packet buffer.
Icmpv4ParamProblem
Internet protocol control message subtype for type “Parameter Problem”.
Icmpv4Redirect
Internet protocol control message subtype for type “Redirect Message”.
Icmpv4TimeExceeded
Internet protocol control message subtype for type “Time Exceeded”.
Icmpv6DstUnreachable
Internet protocol control message subtype for type “Destination Unreachable”.
Icmpv6Message
Internet protocol control message type.
Icmpv6Packet
A read/write wrapper around an Internet Control Message Protocol version 6 packet buffer.
Icmpv6ParamProblem
Internet protocol control message subtype for the type “Parameter Problem”.
Icmpv6TimeExceeded
Internet protocol control message subtype for the type “Time Exceeded”.
Ieee802154FrameType
IEEE 802.15.4 frame type.
Ieee802154FrameVersion
IEEE 802.15.4 frame version.
Ieee802154Pan
An IEEE 802.15.4 PAN identifier.
Ieee802154Repr
The fields of an IEEE 802.15.4 MAC header.
IgmpMessage
Internet Group Management Protocol v1/v2 message version/type.
IgmpPacket
A read/write wrapper around an Internet Group Management Protocol v1/v2 packet buffer.
IpEndpoint
An internet endpoint address.
IpListenEndpoint
An internet endpoint address for listening.
IpProtocol
IP datagram encapsulated protocol.
Ipv4Address
An IPv4 address.
Ipv4Cidr
A specification of an IPv4 CIDR block, containing an address and a variable-length subnet masking prefix length.
Ipv4Packet
A read/write wrapper around an Internet Protocol version 4 packet buffer.
Ipv6Address
An IPv6 address.
Ipv6Cidr
A specification of an IPv6 CIDR block, containing an address and a variable-length subnet masking prefix length.
Ipv6ExtHeader
A read wrapper around an IPv6 extension header.
Ipv6OptionType
IPv6 option type, from the Hop-by-Hop or Destination Options TLVs.
Ipv6OptionsIter
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.
Ipv6Packet
A read/write wrapper around an Internet Protocol version 6 packet buffer.
Ipv6RouterAlert
The value of an IPv6 Router Alert Header Option.
MldAddressRecord
A read/write wrapper around an MLDv2 Listener Report Message Address Record.
MldRecordType
MLDv2 Multicast Listener Report Record Type. See RFC 3810 § 5.2.12 for more details.
NdiscNeighborFlags
NdiscOption
A read/write wrapper around an NDISC Option.
NdiscOptionType
NDISC Option Type
NdiscPrefixInfoFlags
NdiscRouterFlags
RawHardwareAddress
Unparsed hardware address.
SixlowpanAddressContext
A 6LoWPAN address context: a 64-bit prefix that compressed addresses may refer to by index instead of carrying it inline.
SixlowpanExtHeaderRepr
The fields of a 6LoWPAN NHC extension header.
SixlowpanFragKey
Key used for identifying all the link fragments that belong to the same packet.
SixlowpanIphcRepr
The fields of a 6LoWPAN IPHC header.
SixlowpanUdpNhcRepr
The fields of a 6LoWPAN NHC UDP header.
TcpPacket
A read/write wrapper around a Transmission Control Protocol packet buffer.
TcpSeqNumber
A TCP sequence number.
UdpPacket
A read/write wrapper around an User Datagram Protocol packet buffer.

Enums§

DnsRecordData
The data of a resource record.
HardwareAddress
A hardware (link-layer) address.
Ieee802154Address
An IEEE 802.15.4 address.
IgmpVersion
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.
Ipv6OptionFailureAction
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).
SixlowpanExtHeaderId
The IPv6 extension header a compressed extension header stands for.
SixlowpanFragRepr
The fields of a 6LoWPAN fragment header.
SixlowpanNextHeader
The next header field of a compressed header.
SixlowpanNhcPacket
The kind of compressed next header a buffer starts with.
SixlowpanPacket
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

Type Aliases§

Result