blob: 3c071f43a2c030adf5f263e81335f5165257ba4a [file] [log] [blame]
// 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.
using fuchsia.hardware.ethernet;
using fuchsia.logger;
using fuchsia.posix.socket;
/// A list of IP addresses for an interface.
using interface_address_list = vector<>:MAX;
/// A path to a device node.
using device_path = string:255;
/// A list of interface descriptors.
using interface_list = vector<InterfaceInfo>:255;
enum PresenceStatus {
/// The interface is added.
ADDED = 1;
/// The interface is removed.
enum PhysicalStatus {
/// The link is not attached to the medium.
DOWN = 1;
/// The link is attached to the medium.
UP = 2;
enum AdministrativeStatus {
/// The interface is administratively disabled.
/// The interface is administratively enabled.
union InterfaceStatus {
1: PresenceStatus presence;
2: PhysicalStatus physical;
3: AdministrativeStatus administrative;
struct InterfaceInfo {
/// An opaque identifier for the interface, assigned by the stack.
/// This identifier will never be 0, and will not be reused even if the device is removed and
/// subsequently re-added. It is not stable across netstack instances. id;
/// All info of an interface except the interface name.
InterfaceProperties properties;
struct InterfaceProperties {
/// Human-readable name of the interface. eg. eth001, wlanx35.
fuchsia.posix.socket.interface_name name;
/// The topological path to the device, representing a stable identifier for the interface
/// hardware.
device_path topopath;
/// 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.
device_path filepath;
/// The MAC address of the interface, if available.
fuchsia.hardware.ethernet.MacAddress? mac;
/// The maximum transmission unit for the interface in bytes.
uint32 mtu;
/// The features present on the interface.
fuchsia.hardware.ethernet.Features features;
/// The administrative status of the interface.
AdministrativeStatus administrative_status;
/// The physical link status of the interface.
PhysicalStatus physical_status;
/// The list of addresses currently assigned to the interface.
interface_address_list addresses;
/// A ForwardingDestination represents either the device that should transmit a packet or the address
/// of the next hop in the route.
union ForwardingDestination {
/// The opaque identifier of the device to which packets should be forwarded.
1: device_id;
/// The IP address of the next hop, used to look up the next forwarding entry.
2: next_hop;
/// An entry in the forwarding table for the network stack.
struct ForwardingEntry {
/// The subnet is the key for the entry in the table. subnet;
/// The destination that will receive the forwarded packet.
ForwardingDestination destination;
struct InterfaceStatusChange {
/// The opaque identifier of the device that had its status change. id;
/// The new status.
InterfaceStatus status;
enum Error {
IO = 8;
/// An Ethernet device.
/// The provided `network_device` is expected to support `Ethernet` frames.
/// Its MAC address and MAC filtering is controlled by the provided `mac` channel.
resource struct EthernetDeviceDefinition {
/// The connection to the device's data plane. network_device;
/// The connection to the device's addressing control plane. mac;
/// Devices that can be used to back a `Stack` interface.
resource union DeviceDefinition {
/// A `` that exchanges only IP frames. It either doesn't have a
/// layer 2 or its layer 2 is irrelevant to the `Stack`.
1: ip;
/// An Ethernet device.
2: EthernetDeviceDefinition ethernet;
/// Base configuration for `Stack` interfaces.
table InterfaceConfig {
/// Human-readable name of the interface. eg. eth001, wlanx35.
/// Will be set to a default generic name if not provided.
1: fuchsia.posix.socket.interface_name name;
/// The topological path to the device, representing a stable identifier for the interface
/// hardware.
2: device_path topopath;
/// The default metric value used for routes to this interface.
3: uint32 metric;
protocol Stack {
/// Add an Ethernet interface to the network stack. On success, returns the identifier assigned
/// by the stack for use in subsequent calls.
AddEthernetInterface(device_path topological_path, fuchsia.hardware.ethernet.Device device) -> ( id) error Error;
/// Add a new interface to the network stack backed by the provided `DeviceDefinition`. On
/// success, returns the identifier assigned by the stack for use in subsequent calls.
AddInterface(InterfaceConfig config, DeviceDefinition device) -> ( id) error Error;
/// Remove an Ethernet interface from the network stack.
DelEthernetInterface( id) -> () error Error;
/// List all the interfaces available in the network stack.
ListInterfaces() -> (interface_list ifs);
/// Retrieve info about a specific interface.
GetInterfaceInfo( id) -> (InterfaceInfo info) error Error;
/// Enable the interface. Packets may be processed by the stack after this call is processed.
EnableInterface( id) -> () error Error;
/// Disable the interface. The stack will no longer process packets after this call.
DisableInterface( id) -> () error Error;
/// Add an address to the interface. If the interface already has an address of a given type that
/// does not allow duplicates, this method will return an error.
AddInterfaceAddress( id, addr) -> () error Error;
/// Remove the address from the interface. If the address is not assigned to the interface, an
/// error is returned.
DelInterfaceAddress( id, addr) -> () error Error;
/// List all the entries in the forwarding table for the network stack.
// TODO( This is unbounded for now, until we change the API to allow for
// pagination.
GetForwardingTable() -> (vector<ForwardingEntry>:MAX table);
/// Add a new entry to the forwarding table. If the table already contains an entry with the same
/// subnet, an error is returned. The entry may be deleted using DelForwardingEntry first.
AddForwardingEntry(ForwardingEntry entry) -> () error Error;
/// Removes the forwarding entry with the given subnet. This will not affect any overlapping
/// subnets (superset or subset) so the subnet must exactly match an entry in the forwarding
/// table. If no entry for the subnet exists, an error is returned.
DelForwardingEntry( subnet) -> () error Error;
/// Enable the packet filter on a specific interface.
EnablePacketFilter( id) -> () error Error;
/// Disable the packet filter on a specific interface.
DisablePacketFilter( id) -> () error Error;
/// Enable IP Forwarding.
EnableIpForwarding() -> ();
/// Disable IP Forwarding.
DisableIpForwarding() -> ();
/// Get a [``].
GetDnsServerWatcher(request<> watcher);
// Events
/// A status change event is triggered whenever an interface's status changes.
-> OnInterfaceStatusChange(InterfaceStatusChange info);
protocol Log {
/// Dynamically set a syslog level.
// TODO( replace by responding to the system wide
// fuchsia.logger.LogSink.OnInterestChanged event.
SetLogLevel(fuchsia.logger.LogLevelFilter level) -> () error Error;
/// Dynamically set packet logging.
// TODO( replace with optional packet captures in Inspect
// output.
SetLogPackets(bool enabled) -> ();