These tags can be applied to byte strings to represent a single address.
This form is called the "Address Format".
When applied to an array that starts with an unsigned integer, the tags represent a CIDR-style prefix of that length.
When the Address Format (i.e., without prefix) appears in a context where a prefix is expected, then it is to be assumed that all bits are relevant. That is, for IPv4, a /32 is implied, and for IPv6, a /128 is implied.
This form is called the "Prefix Format".
When applied to an array that starts with a byte string, which stands for an IP address, followed by an unsigned integer giving the bit length of a prefix built out of the first
length bits of the address, the tags represent information that is commonly used to specify both the network prefix and the IP address of an interface.
The length of the byte string is always 16 bytes (for IPv6) and 4 bytes (for IPv4).
This form is called the "Interface Format".
Interface Format definitions support an optional third element to the array, which is to be used as the IPv6 link-local zone identifier from
Section 6 of
RFC 4007; for symmetry, this is also provided for IPv4 as in [
RFC 4001] and [
RFC 6991]. The zone identifier may be an integer, in which case it is to be interpreted as the interface index. It may be a text string, in which case it is to be interpreted as an interface name.
As explained in [
RFC 4007], the zone identifiers are strictly local to the node. They are useful for communications within a node about connected addresses (for instance, where a link-local peer is discovered by one daemon and another daemon needs to be informed). They may also have utility in some management protocols.
In the cases where the Interface Format is being used to represent only an address with a zone identifier and no interface prefix information, the prefix length may be replaced with the CBOR "null" (0xF6).
IANA has allocated tag 54 for IPv6 uses. (This is the ASCII code for '6'.)
An IPv6 address is to be encoded as a sixteen-byte byte string (
Section 3.1 of
RFC 8949, major type 2), enclosed in tag number 54.
For example:
54(h'20010db81234deedbeefcafefacefeed')
An IPv6 prefix, such as 2001:db8:1234::/48, is to be encoded as a two-element array, with the length of the prefix first. See
Section 4 for the detailed construction of the second element.
For example:
54([48, h'20010db81234'])
An IPv6 address combined with a prefix length, such as one used for configuring an interface, is to be encoded as a two-element array, with the (full-length) IPv6 address first and the length of the associated network the prefix next; a third element can be added for the zone identifier.
For example:
54([h'20010db81234deedbeefcafefacefeed', 56])
The address-with-prefix form can be reliably distinguished from the prefix form only in the sequence of the array elements.
An example of a link-local IPv6 address with a 64-bit prefix:
54([h'fe8000000000020202fffffffe030303', 64, 'eth0'])
with a numeric zone identifier:
54([h'fe8000000000020202fffffffe030303', 64, 42])
An IPv6 link-local address without a prefix length:
54([h'fe8000000000020202fffffffe030303', null, 42])
Zone identifiers may be used with any kind of IP address, not just link-local addresses. In particular, they are valid for multicast addresses, and there may still be some significance for Globally Unique Addresses (GUAs).
IANA has allocated tag 52 for IPv4 uses. (This is the ASCII code for '4'.)
An IPv4 address is to be encoded as a four-byte byte string (
Section 3.1 of
RFC 8949, major type 2), enclosed in tag number 52.
For example:
An IPv4 prefix, such as 192.0.2.0/24, is to be encoded as a two-element array, with the length of the prefix first. See
Section 4 for the detailed construction of the second element.
For example:
An IPv4 address combined with a prefix length, such as being used for configuring an interface, is to be encoded as a two-element array, with the (full-length) IPv4 address first and the length of the associated network the prefix next; a third element can be added for the zone identifier.
For example, 192.0.2.1/24 is to be encoded as a two-element array, with the length of the prefix (implied 192.0.2.0/24) last.
The address-with-prefix form can be reliably distinguished from the prefix form only in the sequence of the array elements.