blob: 61ba76511dc1d23c2e0215ba08eaed548ca1dc6d [file] [log] [blame]
// Copyright 2019 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.routing;
using fuchsia.net;
const uint32 ROUTING_TABLE_ENTRIES_LIMIT = 256;
const uint32 DEFAULT_METRIC = 100; // TODO(7889): Support default vales on tables.
/// A mapping between a destination subnet and an egress.
/// This serves as a key to a routing table entry.
/// A routing table may have multiple entries for the same destination subnet
/// with a different egress.
table Route {
/// Destination subnet
/// subnet.prefix_len = 0 is interpreted as "default" route. See IETF RFC 4632.
1: fuchsia.net.Subnet subnet;
/// Where the packet for the destination subnet goes to: egress points.
/// At least one of nicid and next_hop MUST be present.
2: uint32 nicid;
/// At least one of nicid and next_hop MUST be present.
/// Address of the next hop router to reach destination subnet.
3: fuchsia.net.IpAddress next_hop;
};
/// The information source from which the routing entry metric is drawn.
enum MetricSource : uint8 {
/// Assigned manually.
MANUAL = 0;
/// Follows the value of the egress interface.
INTERFACE = 1;
};
/// Properties that management plane utilizes for each route.
/// If exists, may be updated dynamically.
table RouteProperties {
/// A value to indicate the preference.
/// Lower values take precedence. Breaking ties is up to the implementation of the protocol.
1: uint32 metric; // TODO(7889): Add default 100.
};
/// An element of a route table.
/// A route table is represented as a vector of RouteTableEntry.
table RouteTableEntry {
/// Route is the identifier of an RouteTableEntry.
1: Route route;
/// Any associated properties for the route.
2: RouteProperties properties;
};
/// A choice of route change action.
flexible union RouteChange {
/// Add a new Route to the table. If the Route already exists, an error is returned.
1: RouteTableEntry add;
/// Delete a Route from the table. If the Route does not exist, an error is returned.
2: Route delete;
/// Update the properties of a given Route. If the Route does not exist, an error is returned.
3: RouteTableEntry update;
};
enum Error {
OK = 0;
/// Generic error for argument.
INVALID_ARGS = 1;
INTERFACE_NOT_FOUND = 2;
ROUTE_NOT_FOUND = 3;
/// Generic error for ChangeRouteTable method, when no specific error is applicable.
ROUTE_CHANGE_FAILURE = 4;
};
[Discoverable]
protocol Routing {
/// Returns the routing metric associated with the interface specified by the NICID.
GetInterfaceMetric(uint32 nicid) -> (uint32 metric) error Error;
/// Update the routing metric associated with the interface specified by the NICID.
SetInterfaceMetric(uint32 nicid, uint32 metric) -> () error Error;
/// Returns routing table under operation.
GetRouteTable() -> (vector<RouteTableEntry>:ROUTING_TABLE_ENTRIES_LIMIT entries) error Error;
/// A set of changes to commit together: all-or-nothing.
/// The changes MUST be sequentially coherent.
/// eg. add x - update x is coherent
/// eg. update x - add x is not.
/// If any of RouteChange is incoherent, none of the RouteChanges in
/// a single ChangeRouteTable shall be committed.
ChangeRouteTable(vector<RouteChange>:ROUTING_TABLE_ENTRIES_LIMIT changes) -> () error Error;
};