37 instance = sw_if_index = ~0;
47 if (
unformat (line_input,
"instance %d", &instance))
49 else if (
unformat (line_input,
"private-key %s", &private_key_64))
58 else if (
unformat (line_input,
"listen-port %d", &port))
60 else if (
unformat (line_input,
"port %d", &port))
62 else if (
unformat (line_input,
"generate-key"))
84 rv =
wg_if_create (instance, private_key, port, &src_ip, &sw_if_index);
99 .path =
"wireguard create",
100 .short_help =
"wireguard create listen-port <port> " 101 "private-key <key> src <IP> [generate-key]",
129 if (~0 != sw_if_index)
148 .path =
"wireguard delete",
149 .short_help =
"wireguard delete <interface>",
164 u8 *public_key_64 = 0;
171 u32 tun_sw_if_index = ~0;
182 if (
unformat (line_input,
"public-key %s", &public_key_64))
195 else if (
unformat (line_input,
"port %d", &portDst))
197 else if (
unformat (line_input,
"persistent-keepalive %d",
198 &persistent_keepalive))
200 else if (
unformat (line_input,
"allowed-ip %U",
206 else if (
unformat (line_input,
"%U",
218 rv = VNET_API_ERROR_INVALID_PROTOCOL;
225 portDst, persistent_keepalive, &peer_index);
229 case VNET_API_ERROR_KEY_LENGTH:
232 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
235 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
238 case VNET_API_ERROR_LIMIT_EXCEEDED:
241 case VNET_API_ERROR_INIT_FAILED:
244 case VNET_API_ERROR_INVALID_PROTOCOL:
259 .path =
"wireguard peer add",
260 .short_help =
"wireguard peer add <wg_int> public-key <pub_key_other>" 261 "endpoint <ip4_dst> allowed-ip <prefix>" 262 "dst-port [port_dst] persistent-keepalive [keepalive_interval]",
282 if (
unformat (line_input,
"%d", &peer_index))
294 case VNET_API_ERROR_KEY_LENGTH:
307 .path =
"wireguard peer remove",
308 .short_help =
"wireguard peer remove <index>",
333 .path =
"show wireguard peer",
334 .short_help =
"show wireguard peer",
363 .path =
"show wireguard interface",
364 .short_help =
"show wireguard",
fib_protocol_t fp_proto
protocol type
#define NOISE_KEY_LEN_BASE64
void ip_prefix_to_fib_prefix(const ip_prefix_t *ip_prefix, fib_prefix_t *fib_prefix)
convert from a LISP to a FIB prefix
vnet_main_t * vnet_get_main(void)
index_t wg_peer_walk(wg_peer_walk_cb_t fn, void *data)
u32 index_t
A Data-Path Object is an object that represents actions that are applied to packets are they are swit...
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static walk_rc_t wg_peer_show_one(index_t peeri, void *arg)
unformat_function_t unformat_vnet_sw_interface
int wg_peer_add(u32 tun_sw_if_index, const u8 public_key[NOISE_PUBLIC_KEY_LEN], u32 table_id, const ip46_address_t *endpoint, const fib_prefix_t *allowed_ips, u16 port, u16 persistent_keepalive, u32 *peer_index)
#define ip_addr_version(_a)
static clib_error_t * wg_show_peer_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_vnet_sw_if_index_name
static walk_rc_t wg_if_show_one(index_t itfi, void *arg)
static clib_error_t * wg_show_if_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
enum walk_rc_t_ walk_rc_t
Walk return code.
static clib_error_t * wg_if_create_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vl_api_prefix_t allowed_ips[n_allowed_ips]
void wg_feature_init(wg_main_t *wmp)
Aggregate type for a prefix.
#define clib_error_return(e, args...)
int wg_if_delete(u32 sw_if_index)
static clib_error_t * wg_peer_add_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define NOISE_PUBLIC_KEY_LEN
u8 * format_wg_if(u8 *s, va_list *args)
static clib_error_t * wg_peer_remove_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
uword unformat_ip_address(unformat_input_t *input, va_list *args)
bool key_from_base64(const u8 *src, size_t src_len, u8 *out)
#define vec_free(V)
Free vector's memory (no header).
#define VLIB_CLI_COMMAND(x,...)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
bool curve25519_gen_secret(u8 secret_key[CURVE25519_KEY_SIZE])
void wg_if_walk(wg_if_walk_cb_t fn, void *data)
static clib_error_t * wg_if_delete_cli(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u8 * format_wg_peer(u8 *s, va_list *va)
int wg_peer_remove(index_t peeri)
int wg_if_create(u32 user_instance, const u8 private_key[NOISE_PUBLIC_KEY_LEN], u16 port, const ip_address_t *src_ip, u32 *sw_if_indexp)
uword unformat_ip_prefix(unformat_input_t *input, va_list *args)
vl_api_interface_index_t sw_if_index