X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fl2tp%2Fl2tp_api.c;h=3a31372253f2c04f3c72dccddafdeb6565aaf81c;hb=eda1b8c32f9857bb749835b0189af002b224927d;hp=aaba2b04e197aa631207874569d77001f5559520;hpb=e86a8edd3c14fb41ace2a12efd17bc7772bf623f;p=vpp.git diff --git a/src/vnet/l2tp/l2tp_api.c b/src/vnet/l2tp/l2tp_api.c index aaba2b04e19..3a31372253f 100644 --- a/src/vnet/l2tp/l2tp_api.c +++ b/src/vnet/l2tp/l2tp_api.c @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -51,7 +52,7 @@ _(SW_IF_L2TPV3_TUNNEL_DUMP, sw_if_l2tpv3_tunnel_dump) static void send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am, - svm_queue_t * q, + vl_api_registration_t * reg, l2t_session_t * s, l2t_main_t * lm, u32 context) { @@ -65,7 +66,7 @@ send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am, format_vnet_sw_interface_name, lm->vnet_main, si); 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_SW_IF_L2TPV3_TUNNEL_DETAILS); strncpy ((char *) mp->interface_name, (char *) if_name, ARRAY_LEN (mp->interface_name) - 1); @@ -75,13 +76,14 @@ send_sw_if_l2tpv3_tunnel_details (vpe_api_main_t * am, mp->local_cookie[0] = s->local_cookie[0]; mp->local_cookie[1] = s->local_cookie[1]; mp->remote_cookie = s->remote_cookie; - clib_memcpy (mp->client_address, &s->client_address, - sizeof (s->client_address)); - clib_memcpy (mp->our_address, &s->our_address, sizeof (s->our_address)); + ip_address_encode ((ip46_address_t *) & s->client_address, IP46_TYPE_IP6, + &mp->client_address); + ip_address_encode ((ip46_address_t *) & s->our_address, IP46_TYPE_IP6, + &mp->our_address); mp->l2_sublayer_present = s->l2_sublayer_present; mp->context = context; - vl_msg_api_send_shmem (q, (u8 *) & mp); + vl_api_send_msg (reg, (u8 *) mp); } @@ -91,17 +93,17 @@ vl_api_sw_if_l2tpv3_tunnel_dump_t_handler (vl_api_sw_if_l2tpv3_tunnel_dump_t * { vpe_api_main_t *am = &vpe_api_main; l2t_main_t *lm = &l2t_main; - svm_queue_t *q; + vl_api_registration_t *reg; l2t_session_t *session; - q = vl_api_client_index_to_input_queue (mp->client_index); - if (q == 0) + reg = vl_api_client_index_to_registration (mp->client_index); + if (!reg) return; /* *INDENT-OFF* */ pool_foreach (session, lm->sessions, ({ - send_sw_if_l2tpv3_tunnel_details (am, q, session, lm, mp->context); + send_sw_if_l2tpv3_tunnel_details (am, reg, session, lm, mp->context); })); /* *INDENT-ON* */ } @@ -113,8 +115,9 @@ static void vl_api_l2tpv3_create_tunnel_t_handler l2t_main_t *lm = &l2t_main; u32 sw_if_index = (u32) ~ 0; int rv; + ip46_address_t client, our; - if (mp->is_ipv6 != 1) + if (mp->our_address.af == ADDRESS_IP4) { rv = VNET_API_ERROR_UNIMPLEMENTED; goto out; @@ -140,9 +143,12 @@ static void vl_api_l2tpv3_create_tunnel_t_handler encap_fib_index = ~0; } + ip_address_decode (&mp->client_address, &client); + ip_address_decode (&mp->our_address, &our); + rv = create_l2tpv3_ipv6_tunnel (lm, - (ip6_address_t *) mp->client_address, - (ip6_address_t *) mp->our_address, + &client.ip6, + &our.ip6, ntohl (mp->local_session_id), ntohl (mp->remote_session_id), clib_net_to_host_u64 (mp->local_cookie), @@ -202,13 +208,13 @@ static void vl_api_l2tpv3_set_lookup_key_t_handler l2t_main_t *lm = &l2t_main; vl_api_l2tpv3_set_lookup_key_reply_t *rmp; - if (mp->key > L2T_LOOKUP_SESSION_ID) + if (mp->key > L2T_LOOKUP_KEY_API_SESSION_ID) { rv = VNET_API_ERROR_INVALID_VALUE; goto out; } - lm->lookup_type = mp->key; + lm->lookup_type = (ip6_to_l2_lookup_t) mp->key; out: REPLY_MACRO (VL_API_L2TPV3_SET_LOOKUP_KEY_REPLY); @@ -217,7 +223,7 @@ out: /* * l2tp_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() */ @@ -236,7 +242,7 @@ setup_message_id_table (api_main_t * am) static clib_error_t * l2tp_api_hookup (vlib_main_t * vm) { - api_main_t *am = &api_main; + api_main_t *am = vlibapi_get_main (); #define _(N,n) \ vl_msg_api_set_handlers(VL_API_##N, #n, \