X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fipsec%2Fipsec_api.c;h=ced2c9ce6cd6c0625c1de159fb6af5d9730a21b4;hb=refs%2Fchanges%2F74%2F15674%2F5;hp=8ea47b7ebe135e07fe5e361e5cdc0ad1aca1a012;hpb=a8d476468d6dad10f0d55423eded2a2a065f8478;p=vpp.git diff --git a/src/vnet/ipsec/ipsec_api.c b/src/vnet/ipsec/ipsec_api.c index 8ea47b7ebe1..ced2c9ce6cd 100644 --- a/src/vnet/ipsec/ipsec_api.c +++ b/src/vnet/ipsec/ipsec_api.c @@ -54,7 +54,9 @@ _(IPSEC_SPD_ADD_DEL_ENTRY, ipsec_spd_add_del_entry) \ _(IPSEC_SAD_ADD_DEL_ENTRY, ipsec_sad_add_del_entry) \ _(IPSEC_SA_SET_KEY, ipsec_sa_set_key) \ _(IPSEC_SA_DUMP, ipsec_sa_dump) \ +_(IPSEC_SPDS_DUMP, ipsec_spds_dump) \ _(IPSEC_SPD_DUMP, ipsec_spd_dump) \ +_(IPSEC_SPD_INTERFACE_DUMP, ipsec_spd_interface_dump) \ _(IPSEC_TUNNEL_IF_ADD_DEL, ipsec_tunnel_if_add_del) \ _(IPSEC_TUNNEL_IF_SET_KEY, ipsec_tunnel_if_set_key) \ _(IPSEC_TUNNEL_IF_SET_SA, ipsec_tunnel_if_set_sa) \ @@ -124,7 +126,7 @@ static void vl_api_ipsec_spd_add_del_entry_t_handler #if WITH_LIBSSL > 0 ipsec_policy_t p; - memset (&p, 0, sizeof (p)); + clib_memset (&p, 0, sizeof (p)); p.id = ntohl (mp->spd_id); p.priority = ntohl (mp->priority); @@ -188,7 +190,7 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler ipsec_main_t *im = &ipsec_main; ipsec_sa_t sa; - memset (&sa, 0, sizeof (sa)); + clib_memset (&sa, 0, sizeof (sa)); sa.id = ntohl (mp->sad_id); sa.spi = ntohl (mp->spi); @@ -219,6 +221,7 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler sa.use_esn = mp->use_extended_sequence_number; sa.is_tunnel = mp->is_tunnel; sa.is_tunnel_ip6 = mp->is_tunnel_ipv6; + sa.udp_encap = mp->udp_encap; if (sa.is_tunnel_ip6) { clib_memcpy (&sa.tunnel_src_addr, mp->tunnel_src_address, 16); @@ -240,7 +243,7 @@ static void vl_api_ipsec_sad_add_del_entry_t_handler goto out; } - rv = ipsec_add_del_sa (vm, &sa, mp->is_add, mp->udp_encap); + rv = ipsec_add_del_sa (vm, &sa, mp->is_add); #else rv = VNET_API_ERROR_UNIMPLEMENTED; goto out; @@ -250,6 +253,44 @@ out: REPLY_MACRO (VL_API_IPSEC_SAD_ADD_DEL_ENTRY_REPLY); } +static void +send_ipsec_spds_details (ipsec_spd_t * spd, vl_api_registration_t * reg, + u32 context) +{ + vl_api_ipsec_spds_details_t *mp; + + mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); + mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPDS_DETAILS); + mp->context = context; + + mp->spd_id = htonl (spd->id); + mp->npolicies = htonl (pool_len (spd->policies)); + + vl_api_send_msg (reg, (u8 *) mp); +} + +static void +vl_api_ipsec_spds_dump_t_handler (vl_api_ipsec_spds_dump_t * mp) +{ + vl_api_registration_t *reg; + ipsec_main_t *im = &ipsec_main; + ipsec_spd_t *spd; +#if WITH_LIBSSL > 0 + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + /* *INDENT-OFF* */ + pool_foreach (spd, im->spds, ({ + send_ipsec_spds_details (spd, reg, mp->context); + })); + /* *INDENT-ON* */ +#else + clib_warning ("unimplemented"); +#endif +} + static void send_ipsec_spd_details (ipsec_policy_t * p, vl_api_registration_t * reg, u32 context) @@ -257,7 +298,7 @@ send_ipsec_spd_details (ipsec_policy_t * p, vl_api_registration_t * reg, vl_api_ipsec_spd_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_DETAILS); mp->context = context; @@ -326,6 +367,60 @@ vl_api_ipsec_spd_dump_t_handler (vl_api_ipsec_spd_dump_t * mp) #endif } +static void +send_ipsec_spd_interface_details (vl_api_registration_t * reg, u32 spd_index, + u32 sw_if_index, u32 context) +{ + vl_api_ipsec_spd_interface_details_t *mp; + + mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); + mp->_vl_msg_id = ntohs (VL_API_IPSEC_SPD_INTERFACE_DETAILS); + mp->context = context; + + mp->spd_index = htonl (spd_index); + mp->sw_if_index = htonl (sw_if_index); + + vl_api_send_msg (reg, (u8 *) mp); +} + +static void +vl_api_ipsec_spd_interface_dump_t_handler (vl_api_ipsec_spd_interface_dump_t * + mp) +{ + ipsec_main_t *im = &ipsec_main; + vl_api_registration_t *reg; + u32 k, v, spd_index; + +#if WITH_LIBSSL > 0 + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) + return; + + if (mp->spd_index_valid) + { + spd_index = ntohl (mp->spd_index); + /* *INDENT-OFF* */ + hash_foreach(k, v, im->spd_index_by_sw_if_index, ({ + if (v == spd_index) + send_ipsec_spd_interface_details(reg, v, k, mp->context); + })); + /* *INDENT-ON* */ + } + else + { + /* *INDENT-OFF* */ + hash_foreach(k, v, im->spd_index_by_sw_if_index, ({ + send_ipsec_spd_interface_details(reg, v, k, mp->context); + })); + /* *INDENT-ON* */ + } + +#else + clib_warning ("unimplemented"); +#endif +} + static void vl_api_ipsec_sa_set_key_t_handler (vl_api_ipsec_sa_set_key_t * mp) { @@ -361,7 +456,7 @@ vl_api_ipsec_tunnel_if_add_del_t_handler (vl_api_ipsec_tunnel_if_add_del_t * #if WITH_LIBSSL > 0 ipsec_add_del_tunnel_args_t tun; - memset (&tun, 0, sizeof (ipsec_add_del_tunnel_args_t)); + clib_memset (&tun, 0, sizeof (ipsec_add_del_tunnel_args_t)); tun.is_add = mp->is_add; tun.esn = mp->esn; @@ -407,7 +502,7 @@ send_ipsec_sa_details (ipsec_sa_t * sa, vl_api_registration_t * reg, vl_api_ipsec_sa_details_t *mp; mp = vl_msg_api_alloc (sizeof (*mp)); - memset (mp, 0, sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_IPSEC_SA_DETAILS); mp->context = context; @@ -888,7 +983,7 @@ static void /* * ipsec_api_hookup * Add vpe's API message handlers to the table. - * vlib has alread mapped shared memory and + * vlib has already mapped shared memory and * added the client registration handlers. * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() */