Expand description
Internet Protocol (IP) types.
This module provides support for various types and traits relating to IPv4 and IPv6, including a number of mechanisms for abstracting over details which are shared between IPv4 and IPv6.
§Ip and IpAddress
The most important traits are Ip and IpAddress.
Ip represents a version of the IP protocol - either IPv4 or IPv6 - and is
implemented by Ipv4 and Ipv6. These types exist only at the type
level - they cannot be constructed at runtime. They provide a place to put
constants and functionality which are not associated with a particular type,
and they allow code to be written which is generic over the version of the
IP protocol. For example:
struct Entry<A: IpAddress> {
subnet: Subnet<A>,
dest: Destination<A>,
}
enum Destination<A: IpAddress> {
Local { device_id: usize },
Remote { dst: A },
}
struct ForwardingTable<I: Ip> {
entries: Vec<Entry<I::Addr>>,
}See also IpVersionMarker.
The IpAddress trait is implemented by the concrete Ipv4Addr and
Ipv6Addr types.
§Runtime types
Sometimes, it is not known at compile time which version of a given type -
IPv4 or IPv6 - is present. For these cases, enums are provided with variants
for both IPv4 and IPv6. These are IpAddr, SubnetEither, and
AddrSubnetEither.
§Composite types
This modules also provides composite types such as Subnet and
AddrSubnet.
Structs§
- Addr
Subnet - An address and that address’s subnet.
- IpInvariant
- Wrapper type that implements
GenericOverIpwithType<I: Ip>=Self. - IpMarked
- A wrapper structure to add an IP version marker to an IP-invariant type.
- IpVersion
Marker - A zero-sized type that carries IP version information.
- Ipv4
Addr - An IPv4 address.
- Ipv6
Addr - An IPv6 address.
- Mtu
- The maximum transmit unit, i.e., the maximum size of an entire IP packet one link can transmit.
- NotSubnet
Mask Error - An IP address was provided which is not a valid subnet mask (the address has set bits after the first unset bit).
- Prefix
Length - An IP prefix length.
- Prefix
TooLong Error - A prefix was provided which is longer than the number of bits in the address (32 for IPv4/128 for IPv6).
- Subnet
- An IP subnet.
Enums§
- Addr
Subnet Either - An address and that address’s subnet, either IPv4 or IPv6.
- Addr
Subnet Error - The error returned from
AddrSubnet::newandAddrSubnetEither::new. - IpAddr
- An IP address.
- IpVersion
- An IP protocol version.
- Ipv4
- IPv4.
- Ipv6
- IPv6.
- Ipv4
Address Class - The class of an IPv4 address.
- Ipv4
Source Addr - The source address from an IPv4 packet.
- Ipv6
Reserved Scope - The list of IPv6 scopes which are reserved for future use by RFC 4291 Section 2.7.
- Ipv6
Scope - The list of IPv6 scopes.
- Ipv6
Source Addr - The source address from an IPv6 packet.
- Ipv6
Unassigned Scope - The list of IPv6 scopes which are available for local definition by administrators.
- Subnet
Either - An IPv4 subnet or an IPv6 subnet.
- Subnet
Error - The error returned from
Subnet::newandSubnetEither::new. - Unicast
OrMulticast Ipv6 Addr - An IPv6 address stored as a unicast or multicast witness type.
Traits§
- Generic
Over Ip - Marks types that are generic over IP version.
- Ip
- A trait for IP protocol versions.
- IpAddr
Witness - A type which is a witness to some property about an
IpAddress. - IpAddress
- An IPv4 or IPv6 address.
- IpAddress
Witness - A type which is witness to some property about an
IpAddress,A.
Derive Macros§
- Generic
Over Ip - Implements a derive macro for [
net_types::ip::GenericOverIp]. Requires that #[derive(GenericOverIp)] invocations explicitly specify which type parameter is the generic-over-ip one with the#[generic_over_ip]attribute, rather than inferring it from the bounds on the struct generics.