1// Copyright (C) 2015-2017 Nippon Telegraph and Telephone Corporation.
2//
3// Permission is hereby granted, free of charge, to any person
4// obtaining a copy of this software and associated documentation files
5// (the "Software"), to deal in the Software without restriction,
6// including without limitation the rights to use, copy, modify, merge,
7// publish, distribute, sublicense, and/or sell copies of the Software,
8// and to permit persons to whom the Software is furnished to do so,
9// subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be
12// included in all copies or substantial portions of the Software.
13
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22syntax = "proto3";
23
24package gobgpapi;
25
26// Interface exported by the server.
27
28service GobgpApi {
29  rpc GetGlobalConfig(Arguments) returns (Global) {}
30  rpc ModGlobalConfig(ModGlobalConfigArguments) returns (Error) {}
31  rpc GetNeighbors(Arguments) returns (stream Peer) {}
32  rpc GetNeighbor(Arguments) returns (Peer) {}
33  rpc ModNeighbor(ModNeighborArguments) returns(Error) {}
34  rpc GetRib(Table) returns (Table) {}
35  rpc Reset(Arguments) returns (Error) {}
36  rpc SoftReset(Arguments) returns (Error) {}
37  rpc SoftResetIn(Arguments) returns (Error) {}
38  rpc SoftResetOut(Arguments) returns (Error) {}
39  rpc Shutdown(Arguments) returns (Error) {}
40  rpc Enable(Arguments) returns (Error) {}
41  rpc Disable(Arguments) returns (Error) {}
42  rpc ModPath(ModPathArguments) returns (ModPathResponse) {}
43  rpc ModPaths(stream ModPathsArguments) returns (Error) {}
44  rpc MonitorRib(Table) returns (stream Destination) {}
45  rpc MonitorBestChanged(Arguments) returns (stream Destination) {}
46  rpc MonitorPeerState(Arguments) returns (stream Peer) {}
47  rpc MonitorROAValidation(Arguments) returns (stream ROAResult) {}
48  rpc GetMrt(MrtArguments) returns (stream MrtMessage) {}
49  rpc ModMrt(ModMrtArguments) returns (Error) {}
50  rpc ModBmp(ModBmpArguments) returns (Error) {}
51  rpc GetRPKI(Arguments) returns (stream RPKI) {}
52  rpc ModRPKI(ModRpkiArguments) returns (Error) {}
53  rpc GetROA(Arguments) returns (stream ROA) {}
54  rpc GetVrfs(Arguments) returns (stream Vrf) {}
55  rpc ModVrf(ModVrfArguments) returns (Error) {}
56  rpc GetDefinedSet(DefinedSet) returns (DefinedSet) {}
57  rpc GetDefinedSets(DefinedSet) returns (stream DefinedSet) {}
58  rpc ModDefinedSet(ModDefinedSetArguments) returns (Error) {}
59  rpc GetStatement(Statement) returns (Statement) {}
60  rpc GetStatements(Statement) returns (stream Statement) {}
61  rpc ModStatement(ModStatementArguments) returns (Error) {}
62  rpc GetPolicy(Policy) returns (Policy) {}
63  rpc GetPolicies(Policy) returns (stream Policy) {}
64  rpc ModPolicy(ModPolicyArguments) returns (Error) {}
65  rpc GetPolicyAssignment(PolicyAssignment) returns (PolicyAssignment) {}
66  rpc ModPolicyAssignment(ModPolicyAssignmentArguments) returns (Error) {}
67}
68
69message Error {
70    enum ErrorCode {
71        SUCCESS = 0;
72        FAIL = 1;
73    }
74    ErrorCode code = 1;
75    string msg = 2;
76}
77
78message Arguments {
79    Resource resource = 1;
80    uint32 family = 2;
81    string name = 3;
82}
83
84message ModPathArguments {
85    Operation operation = 1;
86    Resource resource = 2;
87    string name = 3;
88    Path path = 4;
89    // uuid field can be only used when operation is DEL
90    bytes uuid = 5;
91    // family field is only used when operation is DEL_ALL
92    uint32 family = 6;
93}
94
95message ModPathResponse {
96    bytes uuid = 1;
97}
98
99message ModPathsArguments {
100    Resource resource = 1;
101    string name = 2;
102    repeated Path paths = 3;
103}
104
105message ModNeighborArguments {
106    Operation operation = 1;
107    Peer peer = 2;
108}
109
110message MrtArguments {
111    Resource resource = 1;
112    uint32 family = 2;
113    uint64 interval = 3;
114    string neighbor_address = 4;
115}
116
117message ModMrtArguments {
118    Operation operation = 1;
119    int32 dump_type = 2;
120    string filename = 3;
121    uint64 interval = 4;
122}
123
124message ModBmpArguments {
125    Operation operation = 1;
126    string address = 2;
127    uint32 port = 3;
128    enum MonitoringPolicy {
129        PRE = 0;
130        POST = 1;
131        BOTH = 2;
132    }
133    MonitoringPolicy type = 4;
134}
135
136message ModRpkiArguments {
137    Operation operation = 1;
138    string address = 2;
139    uint32 port = 3;
140}
141
142message ModVrfArguments {
143    Operation operation = 1;
144    Vrf vrf = 2;
145}
146
147message ModDefinedSetArguments {
148    Operation operation = 1;
149    DefinedSet set = 2;
150}
151
152message ModStatementArguments {
153    Operation operation = 1;
154    Statement statement = 2;
155}
156
157message ModPolicyArguments {
158    Operation operation = 1;
159    Policy policy = 2;
160    // if this flag is set, gobgpd won't define new statements
161    // but refer existing statements using statement's names in this arguments.
162    // this flag only works with Operation_ADD
163    bool refer_existing_statements = 3;
164    // if this flag is set, gobgpd won't delete any statements
165    // even if some statements get not used by any policy by this operation.
166    // this flag means nothing if it is used with Operation_ADD
167    bool preserve_statements = 4;
168}
169
170message ModPolicyAssignmentArguments {
171    Operation operation = 1;
172    PolicyAssignment assignment = 2;
173}
174
175message ModGlobalConfigArguments {
176    Operation operation = 1;
177    Global global = 2;
178}
179
180enum Resource {
181    GLOBAL = 0;
182    LOCAL = 1;
183    ADJ_IN = 2;
184    ADJ_OUT = 3;
185    VRF = 4;
186}
187
188enum Operation {
189    ADD = 0;
190    DEL = 1;
191    DEL_ALL = 2;
192    REPLACE = 3;
193    ENABLE = 4;
194    DISABLE = 5;
195    RESET = 6;
196    SOFTRESET = 7;
197}
198
199message Path {
200    bytes nlri = 1;
201    repeated bytes pattrs = 2;
202    int64 age = 3;
203    bool best = 4;
204    bool is_withdraw = 5;
205    int32 validation = 6;
206    bool no_implicit_withdraw = 7;
207    uint32 family = 8;
208    uint32 source_asn = 9;
209    string source_id = 10;
210    bool filtered = 11;
211    bool stale = 12;
212    bool is_from_external = 13;
213    string neighbor_ip = 14;
214}
215
216message Destination {
217    string prefix = 1;
218    repeated Path paths = 2;
219    bool longer_prefixes = 3;
220}
221
222message Table {
223    Resource type = 1;
224    string name = 2;
225    uint32 family = 3;
226    repeated Destination destinations = 4;
227    bool post_policy = 5;
228}
229
230message Peer {
231  repeated uint32 families = 2;
232  ApplyPolicy apply_policy = 3;
233  PeerConf conf = 5;
234  EbgpMultihop ebgp_multihop = 6;
235  RouteReflector route_reflector = 10;
236  PeerState info = 11;
237  Timers timers = 12;
238  Transport transport = 13;
239  RouteServer route_server = 15;
240}
241
242message ApplyPolicy {
243  PolicyAssignment in_policy = 1;
244  PolicyAssignment export_policy = 2;
245  PolicyAssignment import_policy = 3;
246}
247
248message PeerConf {
249  string auth_password = 1;
250  string description = 2;
251  uint32 local_as = 3;
252  string neighbor_address = 4;
253  uint32 peer_as = 5;
254  string peer_group = 6;
255  uint32 peer_type = 7;
256  uint32 remove_private_as = 8;
257  bool route_flap_damping = 9;
258  uint32 send_community = 10;
259  repeated bytes remote_cap = 11;
260  repeated bytes local_cap = 12;
261  string id = 13;
262}
263
264message EbgpMultihop {
265  bool enabled = 1;
266  uint32 multihop_ttl = 2;
267}
268
269message RouteReflector {
270  bool route_reflector_client = 1;
271  uint32 route_reflector_cluster_id = 2;
272  }
273
274message PeerState {
275  string auth_password = 1;
276  string description = 2;
277  uint32 local_as = 3;
278  Messages messages = 4;
279  string neighbor_address = 5;
280  uint32 peer_as = 6;
281  string peer_group = 7;
282  uint32 peer_type = 8;
283  Queues queues = 9;
284  uint32 remove_private_as = 10;
285  bool route_flap_damping = 11;
286  uint32 send_community = 12;
287  uint32 session_state = 13;
288  repeated string supported_capabilities = 14;
289  string bgp_state = 15;
290  string admin_state = 16;
291  uint32 received = 17;
292  uint32 accepted = 18;
293  uint32 advertised = 19;
294  uint32 out_q = 20;
295  uint32 flops = 21;
296}
297
298message Messages {
299  Message received = 1;
300  Message sent = 2;
301}
302
303message Message {
304  uint64 NOTIFICATION = 1;
305  uint64 UPDATE = 2;
306  uint64 OPEN = 3;
307  uint64 KEEPALIVE = 4;
308  uint64 REFRESH = 5;
309  uint64 DISCARDED = 6;
310  uint64 TOTAL = 7;
311}
312
313message Queues {
314  uint32 input = 1;
315  uint32 output = 2;
316}
317
318message Timers {
319 TimersConfig config =1;
320 TimersState state = 2;
321}
322
323message TimersConfig{
324   uint64 connect_retry = 1;
325   uint64 hold_time = 2;
326   uint64 keepalive_interval = 3;
327   uint64 minimum_advertisement_interval = 4;
328}
329
330message TimersState{
331   uint64 connect_retry = 1;
332   uint64 hold_time = 2;
333   uint64 keepalive_interval = 3;
334   uint64 minimum_advertisement_interval = 4;
335   uint64 negotiated_hold_time = 5;
336   uint64 uptime = 6;
337   uint64 downtime = 7;
338}
339
340message Transport {
341  string local_address = 1;
342  uint32 local_port = 2;
343  bool mtu_discovery = 3;
344  bool passive_mode = 4;
345  string remote_address = 5;
346  uint32 remote_port = 6;
347  uint32 tcp_mss = 7;
348  }
349
350message RouteServer {
351  bool route_server_client = 1;
352}
353
354message Prefix {
355    string ip_prefix  = 1;
356    uint32 mask_length_min = 2;
357    uint32 mask_length_max = 3;
358}
359
360enum DefinedType {
361    PREFIX = 0;
362    NEIGHBOR = 1;
363    TAG = 2;
364    AS_PATH = 3;
365    COMMUNITY = 4;
366    EXT_COMMUNITY = 5;
367}
368
369message DefinedSet {
370    DefinedType type = 1;
371    string name = 2;
372    repeated string list = 3;
373    repeated Prefix prefixes = 4;
374}
375
376enum MatchType {
377    ANY = 0;
378    ALL = 1;
379    INVERT = 2;
380}
381
382message MatchSet {
383    MatchType type = 1;
384    string name = 2;
385}
386
387enum AsPathLengthType {
388    EQ = 0;
389    GE = 1;
390    LE = 2;
391}
392
393message AsPathLength {
394    AsPathLengthType type = 1;
395    uint32 length = 2;
396}
397
398message Conditions {
399    MatchSet prefix_set = 1;
400    MatchSet neighbor_set = 2;
401    AsPathLength as_path_length = 3;
402    MatchSet as_path_set = 4;
403    MatchSet community_set = 5;
404    MatchSet ext_community_set = 6;
405    int32 rpki_result = 7;
406}
407
408enum RouteAction {
409    NONE = 0;
410    ACCEPT = 1;
411    REJECT = 2;
412}
413
414enum CommunityActionType {
415    COMMUNITY_ADD = 0;
416    COMMUNITY_REMOVE = 1;
417    COMMUNITY_REPLACE = 2;
418}
419
420message CommunityAction {
421    CommunityActionType type = 1;
422    repeated string communities = 2;
423}
424
425enum MedActionType {
426    MED_MOD = 0;
427    MED_REPLACE = 1;
428}
429
430message MedAction {
431    MedActionType type = 1;
432    int64 value = 2;
433}
434
435message AsPrependAction {
436    uint32 asn = 1;
437    uint32 repeat = 2;
438    bool use_left_most = 3;
439}
440
441message Actions {
442    RouteAction route_action = 1;
443    CommunityAction community = 2;
444    MedAction med = 3;
445    AsPrependAction as_prepend = 4;
446    CommunityAction ext_community = 5;
447}
448
449message Statement {
450    string name = 1;
451    Conditions conditions = 2;
452    Actions actions = 3;
453}
454
455message Policy {
456    string name = 1;
457    repeated Statement statements = 2;
458}
459
460enum PolicyType {
461    IN = 0;
462    IMPORT = 1;
463    EXPORT = 2;
464}
465
466message PolicyAssignment {
467    PolicyType type = 1;
468    Resource resource = 2;
469    string name = 3;
470    repeated Policy policies = 4;
471    RouteAction default = 5;
472}
473
474message MrtMessage {
475    bytes data = 1;
476}
477
478message RPKIConf {
479    string address = 1;
480    string remote_port = 2;
481}
482
483message RPKIState {
484    int64 uptime = 1;
485    int64 downtime = 2;
486    bool  up = 3;
487    uint32 record_ipv4 = 4;
488    uint32 record_ipv6 = 5;
489    uint32 prefix_ipv4 = 6;
490    uint32 prefix_ipv6 = 7;
491    uint32 serial = 8;
492    int64 received_ipv4 = 9;
493    int64 received_ipv6 = 10;
494    int64 serial_notify = 11;
495    int64 cache_reset = 12;
496    int64 cache_response = 13;
497    int64 end_of_data = 14;
498    int64 error = 15;
499    int64 serial_query = 16;
500    int64 reset_query = 17;
501}
502
503message RPKI {
504    RPKIConf conf = 1;
505    RPKIState state = 2;
506}
507
508message ROA {
509    uint32 as = 1;
510    uint32 prefixlen = 2;
511    uint32 maxlen = 3;
512    string prefix = 4;
513    RPKIConf conf = 5;
514}
515
516message ROAResult {
517    enum ValidationReason {
518        UPDATE = 0;
519        WITHDRAW = 1;
520        PEER_DOWN = 2;
521	REVALIDATE = 3;
522    }
523    ValidationReason reason = 1;
524    string address = 2;
525    int64 timestamp = 3;
526    bytes aspath_attr = 4;
527    uint32 origin_as = 5;
528    string prefix = 6;
529    enum ValidationResult {
530        NONE = 0;
531        NOT_FOUND = 1;
532        VALID = 2;
533        INVALID = 3;
534    }
535    ValidationResult old_result = 7;
536    ValidationResult new_result = 8;
537    repeated ROA roas = 9;
538}
539
540message Vrf {
541    string name = 1;
542    bytes rd = 2;
543    repeated bytes import_rt = 3;
544    repeated bytes export_rt = 4;
545}
546
547message Global {
548    uint32 as = 1;
549    string router_id = 2;
550    int32 listen_port = 3;
551    repeated string listen_addresses = 4;
552    repeated uint32 families = 5;
553    uint32 mpls_label_min = 6;
554    uint32 mpls_label_max = 7;
555    bool collector = 8;
556}
557