| // Copyright 2018 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| library fuchsia.net; |
| |
| /// A unique non-zero interface identifier. |
| alias interface_id = uint64; |
| |
| /// IpVersion is an IP version. |
| type IpVersion = strict enum { |
| V4 = 1; |
| V6 = 2; |
| }; |
| |
| /// Ipv4Address is expressed in network byte order, so the most significant byte |
| /// ("127" in the address "127.0.0.1") will be at index 0. |
| type Ipv4Address = struct { |
| addr array<uint8, 4>; |
| }; |
| |
| /// Ipv6Address is expressed in network byte order, so the most significant byte |
| /// ("ff" in the address "ff02::1") will be at index 0. |
| type Ipv6Address = struct { |
| addr array<uint8, 16>; |
| }; |
| |
| /// Represents an IP address that may be either v4 or v6. |
| type IpAddress = strict union { |
| 1: ipv4 Ipv4Address; |
| 2: ipv6 Ipv6Address; |
| }; |
| |
| // TODO(https://fxbug.dev/54163): rename Subnet to AddressWithPrefix when |
| // binding support is ready, so we don't have to recursively fix all users. |
| /// An IP address with its subnet prefix length. |
| type Subnet = struct { |
| /// The Ipv4 or Ipv6 address. |
| addr IpAddress; |
| |
| /// The prefix length of the netmask. E.g. for 192.168.1.0/24, the prefix |
| /// length is 24, corresponding to a netmask of 255.255.255.0. |
| /// For Ipv4, prefix_len must be in the range [0, 32]. |
| /// For Ipv6, prefix_len must be in the range [0, 128]. |
| prefix_len uint8; |
| }; |
| |
| /// A MAC address used to identify a network interface on the data link layer within the network. |
| type MacAddress = struct { |
| octets array<uint8, 6>; |
| }; |