talos/api/network/network.proto
Andrey Smirnov 5b7bea2471 feat: use grpc-proxy in apid
This replaces codegen version of apid proxying with
talos-systems/grpc-proxy based version. Proxying is transparent, it
doesn't require exact information about methods and response types. It
requires some common layout response to enhance it properly with node
metadata or errors.

There should be no signifcant changes to the API with the previous
version, but it's worth mentioning a few changes:

1. grpc.ClientConn is established just once per upstream (either local
service or remote apid instance).

2. When called without `-t` (`targets`), apid proxies immediately down
to local service skipping proxying to itself (as before), which results
in empty node metadata in response (before it had local node IP). Might
revert this later to proxy to itself (?).

3. Streaming APIs are now fully supported with multiple targets, but
message definition doesn't contain `ResponseMetadata`, so streaming APIs
are broken now with targets (needs a fix).

4. Errors are now returned as responses with `Error` field set in
`ResponseMetadata`, this requires client library update and `osctl` to
handle it properly.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2019-11-29 22:57:25 +03:00

106 lines
3.1 KiB
Protocol Buffer

syntax = "proto3";
package network;
option go_package = "github.com/talos-systems/talos/api/network";
option java_multiple_files = true;
option java_outer_classname = "NetworkApi";
option java_package = "com.network.api";
import "google/protobuf/empty.proto";
import "common/common.proto";
// The network service definition.
service Network {
rpc Routes(google.protobuf.Empty) returns (RoutesReply);
rpc Interfaces(google.protobuf.Empty) returns (InterfacesReply);
}
enum AddressFamily {
option allow_alias = true;
AF_UNSPEC = 0;
AF_INET = 2;
IPV4 = 2;
AF_INET6 = 10;
IPV6 = 10;
}
enum RouteProtocol {
RTPROT_UNSPEC = 0;
RTPROT_REDIRECT = 1; // Route installed by ICMP redirects
RTPROT_KERNEL = 2; // Route installed by kernel
RTPROT_BOOT = 3; // Route installed during boot
RTPROT_STATIC = 4; // Route installed by administrator
RTPROT_GATED = 8; // Route installed by gated
RTPROT_RA = 9; // Route installed by router advertisement
RTPROT_MRT = 10; // Route installed by Merit MRT
RTPROT_ZEBRA = 11; // Route installed by Zebra/Quagga
RTPROT_BIRD = 12; // Route installed by Bird
RTPROT_DNROUTED = 13; // Route installed by DECnet routing daemon
RTPROT_XORP = 14; // Route installed by XORP
RTPROT_NTK = 15; // Route installed by Netsukuku
RTPROT_DHCP = 16; // Route installed by DHCP
RTPROT_MROUTED = 17; // Route installed by Multicast daemon
RTPROT_BABEL = 42; // Route installed by Babel daemon
}
enum InterfaceFlags {
FLAG_UNKNOWN = 0;
FLAG_UP = 1;
FLAG_BROADCAST = 2;
FLAG_LOOPBACK = 3;
FLAG_POINT_TO_POINT = 4;
FLAG_MULTICAST = 5;
}
// The response message containing the routes.
message RoutesReply {
repeated RoutesResponse response = 1;
}
message RoutesResponse {
common.ResponseMetadata metadata = 1;
repeated Route routes = 2;
}
// The response message containing a route.
message Route {
// Interface is the interface over which traffic to this destination should be sent
string interface = 1;
// Destination is the network prefix CIDR which this route provides
string destination = 2;
// Gateway is the gateway address to which traffic to this destination should be sent
string gateway = 3;
// Metric is the priority of the route, where lower metrics have higher priorities
uint32 metric = 4;
// Scope desribes the scope of this route
uint32 scope = 5;
// Source is the source prefix CIDR for the route, if one is defined
string source = 6;
// Family is the address family of the route. Currently, the only options are AF_INET (IPV4) and AF_INET6 (IPV6).
AddressFamily family = 7;
// Protocol is the protocol by which this route came to be in place
RouteProtocol protocol = 8;
// Flags indicate any special flags on the route
uint32 flags = 9;
}
message InterfacesReply {
repeated InterfacesResponse response = 1;
}
message InterfacesResponse {
common.ResponseMetadata metadata = 1;
repeated Interface interfaces = 2;
}
// Interface represents a net.Interface
message Interface {
uint32 index = 1;
uint32 mtu = 2;
string name = 3;
string hardwareaddr = 4;
InterfaceFlags flags = 5;
repeated string ipaddress = 6;
}