wireguard: stabilize the API
[vpp.git] / src / plugins / wireguard / wireguard.api
1 /* Hey Emacs use -*- mode: C -*- */
2 /*
3  * Copyright (c) 2020 Doc.ai and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 option version = "1.3.0";
18
19 import "vnet/interface_types.api";
20 import "vnet/ip/ip_types.api";
21
22 /** \brief Create wireguard interface
23     @param client_index - opaque cookie to identify the sender
24     @param context - sender context, to match reply w/ request
25     @param private_key - private key in binary format of this device
26     @param public_key - public key in binary format of this device
27     @param port - port of this device
28     @param src_ip - packet sent through this interface us this
29                     address as the IP source.
30 */
31 typedef wireguard_interface
32 {
33   u32 user_instance [default=0xffffffff];
34   vl_api_interface_index_t sw_if_index;
35   u8 private_key[32];
36   u8 public_key[32];
37   u16 port;
38   vl_api_address_t src_ip;
39 };
40
41 /** \brief Create an Wireguard interface
42  */
43 define wireguard_interface_create {
44   u32 client_index;
45   u32 context;
46   vl_api_wireguard_interface_t interface;
47   bool generate_key;
48 };
49
50 /** \brief Add Wireguard interface interface response
51     @param context - sender context, to match reply w/ request
52     @param retval - return status
53     @param sw_if_index - sw_if_index of new interface (for successful add)
54 */
55 define wireguard_interface_create_reply
56 {
57   u32 context;
58   i32 retval;
59   vl_api_interface_index_t sw_if_index;
60 };
61
62 autoreply define wireguard_interface_delete
63 {
64   u32 client_index;
65   u32 context;
66   vl_api_interface_index_t sw_if_index;
67 };
68
69 define wireguard_interface_dump
70 {
71   u32 client_index;
72   u32 context;
73   bool show_private_key;
74   vl_api_interface_index_t sw_if_index;
75 };
76
77 define wireguard_interface_details
78 {
79   u32 context;
80   vl_api_wireguard_interface_t interface;
81 };
82
83 enum wireguard_peer_flags : u8
84 {
85   WIREGUARD_PEER_STATUS_DEAD = 0x1,
86   WIREGUARD_PEER_ESTABLISHED = 0x2,
87 };
88
89 /** \brief Peer structure
90     @param peer_index - peer pool index
91     @param public_key - public key (in binary format) of destination peer
92     @param port - destination port
93     @param persistent_keepalive - keepalive packet timeout
94     @param table_id - The IP table in which 'endpoint' is reachable
95     @param endpoint - destination ip
96     @param sw_if_index - tunnel SW interface
97     @param flags - peer status flags
98     @param n_allowed_ips - number of prefixes in allowed_ips
99     @param allowed_ips - allowed incoming tunnel prefixes
100 */
101 typedef wireguard_peer
102 {
103   u32 peer_index;
104   u8 public_key[32];
105   u16 port;
106   u16 persistent_keepalive;
107   u32 table_id;
108   vl_api_address_t endpoint;
109   vl_api_interface_index_t sw_if_index;
110   vl_api_wireguard_peer_flags_t flags;
111   u8 n_allowed_ips;
112   vl_api_prefix_t allowed_ips[n_allowed_ips];
113 };
114
115 service {
116   rpc want_wireguard_peer_events returns want_wireguard_peer_events_reply
117     events wireguard_peer_event;
118 };
119 /** \brief Register for wireguard peer events
120     @param client_index - opaque cookie to identify the sender
121     @param context - sender context, to match reply w/ request
122     @param sw_if_index - index of the interface to dump peer info on, ~0 if on all
123     @param peer_index - index of the peer to dump info on, ~0 if on all
124     @param enable_disable - 1 => register for events, 0 => cancel registration
125     @param pid - sender's pid
126 */
127 autoreply define want_wireguard_peer_events
128 {
129   u32 client_index;
130   u32 context;
131   vl_api_interface_index_t sw_if_index [default=0xFFFFFFFF];
132   u32 peer_index [default=0xFFFFFFFF];
133   u32 enable_disable;
134   u32 pid;
135 };
136 /** \brief Interface Event generated by want_wireguard_peer_events
137     @param client_index - opaque cookie to identify the sender
138     @param pid - client pid registered to receive notification
139     @param peer_index - index of the peer for this event
140     @param deleted - interface was deleted
141 */
142 define wireguard_peer_event
143 {
144   u32 client_index;
145   u32 pid;
146   u32 peer_index;
147   vl_api_wireguard_peer_flags_t flags;
148 };
149
150 /** \brief Create new peer
151     @param client_index - opaque cookie to identify the sender
152     @param context - sender context, to match reply w/ request
153     @param peer - peer to create
154 */
155 define wireguard_peer_add
156 {
157   u32 client_index;
158   u32 context;
159   vl_api_wireguard_peer_t peer;
160 };
161
162 /** \brief Create new peer
163     @param context - sender context, to match reply w/ request
164     @param retval - return status
165     @param peer_index - Created or existing peer pool index
166 */
167 define wireguard_peer_add_reply
168 {
169   u32 context;
170   i32 retval;
171   u32 peer_index;
172 };
173
174 /** \brief Remove peer
175     @param client_index - opaque cookie to identify the sender
176     @param context - sender context, to match reply w/ request
177     @param peer_index - peer to be removed
178 */
179 autoreply define wireguard_peer_remove
180 {
181   u32 client_index;
182   u32 context;
183   u32 peer_index;
184 };
185
186 /** \brief Dump all peers
187     @param client_index - opaque cookie to identify the sender
188     @param context - sender context, to match reply w/ request
189     @param peer_index - peer index to be dumped.  If 0xFFFFFFFF dumps all peers
190 */
191 define wireguard_peers_dump {
192   u32 client_index;
193   u32 context;
194   u32 peer_index [default=0xFFFFFFFF];
195 };
196
197 /** \brief Dump peer details
198     @param context - sender context, to match reply w/ request
199     @param peer - peer details
200 */
201 define wireguard_peers_details {
202   u32 context;
203   vl_api_wireguard_peer_t peer;
204 };
205
206 /** \brief Wireguard Set Async mode
207     @param client_index - opaque cookie to identify the sender
208     @param context - sender context, to match reply w/ request
209     @param async_enable - wireguard async mode on or off, default off
210 */
211 autoreply define wg_set_async_mode {
212   u32 client_index;
213   u32 context;
214   bool async_enable [default=false];
215 };
216
217 /*
218  * Local Variables:
219  * eval: (c-set-style "gnu")
220  * End:
221  */