1// Copyright 2018 The Fuchsia Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5library fuchsia.net;
6
7// IPv4Address is expressed in network byte order, so the most significant byte
8// ("127" in the address "127.0.0.1") will be at index 0.
9struct IPv4Address {
10    array<uint8>:4 addr;
11};
12
13// IPv6Address is expressed in network byte order, so the most significant byte
14// ("ff" in the address "ff02::1") will be at index 0.
15struct IPv6Address {
16    array<uint8>:16 addr;
17};
18
19union IpAddress {
20    IPv4Address ipv4;
21    IPv6Address ipv6;
22};
23
24struct Subnet {
25    // The IPv4 or IPv6 address. Only the |prefix_len| most significant bits may be set in |addr|;
26    // all bits in the host portion of the address must be zero.
27    IpAddress addr;
28
29    // The prefix length of the netmask. E.g. for 192.168.1.0/24, the prefix
30    // length is 24, corresponding to a netmask of 255.255.255.0.
31    // For IPv4, prefix_len must be in the range [0, 32].
32    // For IPv6, prefix_len must be in the range [0, 128].
33    uint8 prefix_len;
34};
35
36struct MacAddress {
37    array<uint8>:6 addr;
38};
39