24 #include <wireguard/wireguard.api_enum.h> 25 #include <wireguard/wireguard.api_types.h> 32 #define REPLY_MSG_ID_BASE wmp->msg_id_base 51 rv = VNET_API_ERROR_INVALID_PROTOCOL;
76 vl_api_wireguard_interface_delete_reply_t *rmp;
89 REPLY_MACRO(VL_API_WIREGUARD_INTERFACE_DELETE_REPLY);
112 rmp->_vl_msg_id = htons (VL_API_WIREGUARD_INTERFACE_DETAILS +
166 if (0 == mp->
peer.n_allowed_ips)
168 rv = VNET_API_ERROR_INVALID_VALUE;
177 for (ii = 0; ii < mp->
peer.n_allowed_ips; ii++)
184 rv = VNET_API_ERROR_INVALID_PROTOCOL;
188 ntohl (mp->
peer.table_id),
192 ntohs (mp->
peer.persistent_keepalive), &peeri);
208 vl_api_wireguard_peer_remove_reply_t *rmp;
233 ss = (
sizeof (*rmp) + (n_allowed_ips *
sizeof (rmp->
peer.allowed_ips[0])));
237 rmp->_vl_msg_id = htons (VL_API_WIREGUARD_PEERS_DETAILS +
253 &rmp->
peer.allowed_ips[ii]);
283 #include <wireguard/wireguard.api.c> #define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
Add Wireguard interface interface response.
wg_peer_allowed_ip_t * allowed_ips
VLIB_API_INIT_FUNCTION(wg_api_hookup)
void ip_address_encode2(const ip_address_t *in, vl_api_address_t *out)
void ip_prefix_decode(const vl_api_prefix_t *in, fib_prefix_t *out)
static_always_inline wg_if_t * wg_if_get(index_t wgii)
Create an Wireguard interface.
#define REPLY_MACRO2(t, body)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
vl_api_interface_index_t sw_if_index
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...
vl_api_wireguard_interface_t 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)
void * vl_msg_api_alloc_zero(int nbytes)
uint8_t r_public[NOISE_PUBLIC_KEY_LEN]
static walk_rc_t wireguard_if_send_details(index_t wgii, void *data)
#define clib_memcpy(d, s, n)
enum walk_rc_t_ walk_rc_t
Walk return code.
vl_api_interface_index_t sw_if_index
vl_api_registration_t * reg
vl_api_prefix_t allowed_ips[n_allowed_ips]
void wg_feature_init(wg_main_t *wmp)
Aggregate type for a prefix.
int wg_if_delete(u32 sw_if_index)
#define NOISE_PUBLIC_KEY_LEN
static void vl_api_wireguard_peers_dump_t_handler(vl_api_wireguard_peers_dump_t *mp)
uint8_t l_public[NOISE_PUBLIC_KEY_LEN]
void ip_address_decode2(const vl_api_address_t *in, ip_address_t *out)
An API client registration, only in vpp/vlib.
static void setup_message_id_table(api_main_t *am)
#define BAD_SW_IF_INDEX_LABEL
vl_api_address_t endpoint
#define vec_free(V)
Free vector's memory (no header).
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
struct wg_deatils_walk_t_ wg_deatils_walk_t
Remove peer by public_key.
static void vl_api_wireguard_interface_delete_t_handler(vl_api_wireguard_interface_delete_t *mp)
static void vl_api_wireguard_peer_add_t_handler(vl_api_wireguard_peer_add_t *mp)
static void vl_api_wireguard_interface_create_t_handler(vl_api_wireguard_interface_create_t *mp)
bool curve25519_gen_secret(u8 secret_key[CURVE25519_KEY_SIZE])
vl_api_wireguard_peer_t peer
vl_api_wireguard_interface_t interface
void wg_if_walk(wg_if_walk_cb_t fn, void *data)
static void vl_api_wireguard_peer_remove_t_handler(vl_api_wireguard_peer_remove_t *mp)
void ip_prefix_encode(const fib_prefix_t *in, vl_api_prefix_t *out)
uint8_t l_private[NOISE_PUBLIC_KEY_LEN]
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define INDEX_INVALID
Invalid index - used when no index is known blazoned capitals INVALID speak volumes where ~0 does not...
void ip_address_encode(const ip46_address_t *in, ip46_type_t type, vl_api_address_t *out)
static_always_inline noise_local_t * noise_local_get(uint32_t locali)
int wg_peer_remove(index_t peeri)
static clib_error_t * wg_api_hookup(vlib_main_t *vm)
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)
static void vl_api_wireguard_interface_dump_t_handler(vl_api_wireguard_interface_dump_t *mp)
vl_api_wireguard_peer_t peer
static wg_peer_t * wg_peer_get(index_t peeri)
vl_api_interface_index_t sw_if_index
#define VALIDATE_SW_IF_INDEX(mp)
static walk_rc_t send_wg_peers_details(index_t peeri, void *data)