blob: d9d9e20434abc27b171b537acc95066fa0788b32 [file] [log] [blame]
// Copyright 2013 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.netstack;
using fuchsia.hardware.ethernet;
using fuchsia.net.dhcp;
using fuchsia.net;
using fuchsia.posix.socket;
using zx;
enum Status {
OK = 0;
UNKNOWN_ERROR = 1;
DNS_ERROR = 2;
PARSE_ERROR = 3;
IPV4_ONLY = 4;
UNKNOWN_INTERFACE = 5;
};
struct NetErr {
Status status;
string:MAX message;
};
struct InterfaceConfig {
fuchsia.posix.socket.interface_name name;
/// An unstable file path corresponding to the interface. Used in watching the creation
/// and destruction of the interface, or in accessing the interface using netdump.
string:MAX filepath;
uint32 metric;
};
/// Flags describe an interface's runtime configuration.
// TODO(https://fxbug.dev/75555): Migrate callers and remove this.
[Deprecated = "Use fuchsia.net.interfaces/Watcher"]
bits Flags : uint32 {
/// Set if the interface is up.
UP = 0x01;
// Set if DHCP is enabled on the interface.
DHCP = 0x02;
};
/// https://linux.die.net/man/7/netdevice
// TODO(https://fxbug.dev/75555): Migrate callers and remove this.
[Deprecated = "Use fuchsia.net.interfaces/Watcher"]
struct NetInterface {
uint32 id;
Flags flags;
fuchsia.hardware.ethernet.Features features;
uint32 configuration;
uint32 metric;
fuchsia.posix.socket.interface_name name;
/// addr is one of the interface's IPv4 addresses, even if the interface
/// holds multiple. No guarantees are made about which address is used when
/// an interface has multiple IPv4 addresses.
///
/// If the interface does not have an IPv4 address, addr is the unspecified
/// IPv4 address (0.0.0.0).
fuchsia.net.IpAddress addr;
/// netmask is addr's corresponding network mask.
///
/// If the interface does not have an IPv4 address, netmask is the 0 netmask
/// (0.0.0.0).
fuchsia.net.IpAddress netmask;
/// netmask is addr's corresponding network's broadcast address.
///
/// If the interface does not have an IPv4 address, broadaddr is the
/// unspecified IPv4 address (0.0.0.0).
fuchsia.net.IpAddress broadaddr;
vector<fuchsia.net.Subnet>:MAX ipv6addrs;
bytes hwaddr;
};
struct RouteTableEntry {
fuchsia.net.IpAddress destination;
fuchsia.net.IpAddress netmask;
fuchsia.net.IpAddress? gateway;
uint32 nicid;
uint32 metric;
};
struct SocketAddress {
fuchsia.net.IpAddress addr;
uint16 port;
};
[Discoverable]
protocol Netstack {
/// Returns the list of registered network interfaces.
// TODO(https://fxbug.dev/75555): Migrate callers and remove this.
[Deprecated = "Use fuchsia.net.interfaces/Watcher"]
GetInterfaces() -> (vector<NetInterface>:MAX interfaces);
/// Returns current route table.
GetRouteTable() -> (vector<RouteTableEntry>:MAX rt);
/// Sets the status (up or down) for the interface with the given nicid.
SetInterfaceStatus(uint32 nicid, bool enabled);
/// Sets the address for the interface with the given nicid.
/// Masks off addr.PrefixLen bits from addr.Addr to set the subnet.
SetInterfaceAddress(uint32 nicid, fuchsia.net.IpAddress addr, uint8 prefix_len) -> (NetErr result);
/// Removes the address for the interface with the given nicid.
/// Masks off addr.PrefixLen bits from addr.Addr to set the subnet.
RemoveInterfaceAddress(uint32 nicid, fuchsia.net.IpAddress addr, uint8 prefix_len) -> (NetErr result);
/// Sets the route metric for the interface with the given nicid.
SetInterfaceMetric(uint32 nicid, uint32 metric) -> (NetErr result);
/// Creates a bridge and returns the newly created nicid or an
/// error if the creation fails.
BridgeInterfaces(vector<uint32>:MAX nicids) -> (NetErr result, uint32 nicid);
/// Adds a new interface backed by the given ethernet device.
AddEthernetDevice(string:MAX topological_path, InterfaceConfig interface_config, fuchsia.hardware.ethernet.Device device) -> (uint32 nicid) error zx.status;
// TODO(stijlist): re-home this protocol. GetDhcpClient should be a member
// of the protocol that eventually owns network interface management
// in general.
GetDhcpClient(uint32 nicid, request<fuchsia.net.dhcp.Client> client) -> () error zx.status;
/// Begin a route transaction to synchronize updates to the route table.
///
/// Returns `ZX_OK` if a transaction can be started; `ZX_ERR_SHOULD_WAIT` if a transaction is
/// currently in progress.
StartRouteTableTransaction(request<RouteTableTransaction> route_table_transaction) -> (zx.status status);
};
[Discoverable]
protocol RouteTableTransaction {
AddRoute(RouteTableEntry r) -> (zx.status status);
DelRoute(RouteTableEntry r) -> (zx.status status);
};