From: Nathan Skrzypczak Date: Thu, 26 Nov 2020 08:27:01 +0000 (+0100) Subject: wireguard: return public key in api X-Git-Tag: v21.06-rc0~90 X-Git-Url: https://gerrit.fd.io/r/gitweb?p=vpp.git;a=commitdiff_plain;h=de22111b5;hp=2df2f75ec52003e3b6addbde5f2e8254a9aee800 wireguard: return public key in api Type: feature Change-Id: Iacb0da8bc738ed400678f9bb40e70e0031c6588e Signed-off-by: Nathan Skrzypczak --- diff --git a/src/plugins/wireguard/wireguard.api b/src/plugins/wireguard/wireguard.api index 195755e5c43..e290fc41ffc 100755 --- a/src/plugins/wireguard/wireguard.api +++ b/src/plugins/wireguard/wireguard.api @@ -23,6 +23,7 @@ import "vnet/ip/ip_types.api"; @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param private_key - private key in binary format of this device + @param public_key - public key in binary format of this device @param port - port of this device @param src_ip - packet sent through this interface us this address as the IP source. @@ -32,6 +33,7 @@ typedef wireguard_interface u32 user_instance [default=0xffffffff]; vl_api_interface_index_t sw_if_index; u8 private_key[32]; + u8 public_key[32]; u16 port; vl_api_address_t src_ip; }; diff --git a/src/plugins/wireguard/wireguard_api.c b/src/plugins/wireguard/wireguard_api.c index c9fe1e1a2d2..36cc2509463 100755 --- a/src/plugins/wireguard/wireguard_api.c +++ b/src/plugins/wireguard/wireguard_api.c @@ -94,6 +94,7 @@ typedef struct wg_deatils_walk_t_ { vl_api_registration_t *reg; u32 context; + u8 show_private_key; } wg_deatils_walk_t; static walk_rc_t @@ -111,8 +112,11 @@ wireguard_if_send_details (index_t wgii, void *data) rmp->_vl_msg_id = htons (VL_API_WIREGUARD_INTERFACE_DETAILS + wg_main.msg_id_base); - clib_memcpy (rmp->interface.private_key, - local->l_private, NOISE_PUBLIC_KEY_LEN); + if (ctx->show_private_key) + clib_memcpy (rmp->interface.private_key, + local->l_private, NOISE_PUBLIC_KEY_LEN); + clib_memcpy (rmp->interface.public_key, + local->l_public, NOISE_PUBLIC_KEY_LEN); rmp->interface.sw_if_index = htonl (wgi->sw_if_index); rmp->interface.port = htons (wgi->port); ip_address_encode2 (&wgi->src_ip, &rmp->interface.src_ip); @@ -140,6 +144,7 @@ vl_api_wireguard_interface_dump_t_handler (vl_api_wireguard_interface_dump_t * wg_deatils_walk_t ctx = { .reg = reg, .context = mp->context, + .show_private_key = mp->show_private_key, }; wg_if_walk (wireguard_if_send_details, &ctx);