35 instance = sw_if_index = ~0;
43 if (
unformat (line_input,
"instance %d", &instance))
45 else if (
unformat (line_input,
"private-key %s", &private_key_64))
54 else if (
unformat (line_input,
"listen-port %d", &port))
56 else if (
unformat (line_input,
"port %d", &port))
58 else if (
unformat (line_input,
"generate-key"))
80 rv =
wg_if_create (instance, private_key, port, &src_ip, &sw_if_index);
95 .path =
"wireguard create",
96 .short_help =
"wireguard create listen-port <port> " 97 "private-key <key> src <IP> [generate-key]",
122 if (~0 != sw_if_index)
141 .path =
"wireguard delete",
142 .short_help =
"wireguard delete <interface>",
156 u8 *public_key_64 = 0;
163 u32 tun_sw_if_index = ~0;
172 if (
unformat (line_input,
"public-key %s", &public_key_64))
185 else if (
unformat (line_input,
"port %d", &portDst))
187 else if (
unformat (line_input,
"persistent-keepalive %d",
188 &persistent_keepalive))
190 else if (
unformat (line_input,
"allowed-ip %U",
196 else if (
unformat (line_input,
"%U",
208 rv = VNET_API_ERROR_INVALID_PROTOCOL;
215 portDst, persistent_keepalive, &peer_index);
219 case VNET_API_ERROR_KEY_LENGTH:
222 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
225 case VNET_API_ERROR_INVALID_SW_IF_INDEX:
228 case VNET_API_ERROR_LIMIT_EXCEEDED:
231 case VNET_API_ERROR_INIT_FAILED:
234 case VNET_API_ERROR_INVALID_PROTOCOL:
249 .path =
"wireguard peer add",
250 .short_help =
"wireguard peer add <wg_int> public-key <pub_key_other>" 251 "endpoint <ip4_dst> allowed-ip <prefix>" 252 "dst-port [port_dst] persistent-keepalive [keepalive_interval]",
269 if (
unformat (line_input,
"%d", &peer_index))
281 case VNET_API_ERROR_KEY_LENGTH:
294 .path =
"wireguard peer remove",
295 .short_help =
"wireguard peer remove <index>",
320 .path =
"show wireguard peer",
321 .short_help =
"show wireguard peer",
346 .path =
"show wireguard interface",
347 .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]
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