23 #include <vpp/app/version.h>
26 #define vl_msg_id(n,h) n,
29 #include <nsh/nsh.api.h>
37 #include <nsh/nsh.api.h>
42 #include <nsh/nsh.api.h>
46 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
48 #include <nsh/nsh.api.h>
52 #define vl_api_version(n,v) static u32 api_version=(v);
53 #include <nsh/nsh.api.h>
56 #define vl_msg_name_crc_list
57 #include <nsh/nsh.api.h>
58 #undef vl_msg_name_crc_list
60 #define REPLY_MSG_ID_BASE nm->msg_id_base
65 #define foreach_nsh_plugin_api_msg \
66 _(NSH_ADD_DEL_ENTRY, nsh_add_del_entry) \
67 _(NSH_ENTRY_DUMP, nsh_entry_dump) \
68 _(NSH_ADD_DEL_MAP, nsh_add_del_map) \
69 _(NSH_MAP_DUMP, nsh_map_dump)
105 u32 dev_instance = va_arg (*args,
u32);
106 return format (s,
"nsh_tunnel%d", dev_instance);
199 if (map_index >=
vec_len (
nm->nsh_mappings))
203 t = &
nm->nsh_mappings[map_index];
219 a->map.nsp_nsi = ntohl (mp->
nsp_nsi);
228 if ((
a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN4)
229 | (
a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN6))
247 nsh_base_header_t *nsh_base;
248 nsh_md1_data_t *nsh_md1;
254 u8 old_option_size = 0;
255 u8 new_option_size = 0;
258 if (nsh_entry->
nsh_base.md_type == 1)
260 len =
sizeof (nsh_base_header_t) +
sizeof (nsh_md1_data_t);
262 else if (nsh_entry->
nsh_base.md_type == 2)
270 nsh_base = (nsh_base_header_t *) rw;
271 nsh_base->ver_o_c = nsh_entry->
nsh_base.ver_o_c;
272 nsh_base->length = nsh_entry->
nsh_base.length;
273 nsh_base->md_type = nsh_entry->
nsh_base.md_type;
274 nsh_base->next_protocol = nsh_entry->
nsh_base.next_protocol;
275 nsh_base->nsp_nsi = clib_host_to_net_u32 (nsh_entry->
nsh_base.nsp_nsi);
277 if (nsh_base->md_type == 1)
279 nsh_md1 = (nsh_md1_data_t *) (rw +
sizeof (nsh_base_header_t));
280 nsh_md1->c1 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c1);
281 nsh_md1->c2 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c2);
282 nsh_md1->c3 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c3);
283 nsh_md1->c4 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c4);
286 else if (nsh_base->md_type == 2)
294 while (opt0 < limit0)
298 old_option_size = ((old_option_size + 3) >> 2) << 2;
301 if (nsh_option == NULL)
306 if (
nm->add_options[nsh_option->
option_id] != NULL)
308 if (0 !=
nm->add_options[nsh_option->
option_id] ((
u8 *) nsh_md2,
315 new_option_size = ((new_option_size + 3) >> 2) << 2;
359 key = clib_host_to_net_u32 (
a->map.nsp_nsi);
373 map->nsp_nsi =
a->map.nsp_nsi;
374 map->mapped_nsp_nsi =
a->map.mapped_nsp_nsi;
375 map->nsh_action =
a->map.nsh_action;
376 map->sw_if_index =
a->map.sw_if_index;
377 map->rx_sw_if_index =
a->map.rx_sw_if_index;
378 map->next_node =
a->map.next_node;
379 map->adj_index =
a->map.adj_index;
386 map_index =
map -
nm->nsh_mappings;
388 if (
vec_len (
nm->free_nsh_tunnel_hw_if_indices) > 0)
390 nsh_hw_if =
nm->free_nsh_tunnel_hw_if_indices
391 [
vec_len (
nm->free_nsh_tunnel_hw_if_indices) - 1];
392 _vec_len (
nm->free_nsh_tunnel_hw_if_indices) -= 1;
395 hi->dev_instance = map_index;
396 hi->hw_instance =
hi->dev_instance;
401 (vnm, nsh_device_class.index, map_index,
nsh_hw_class.index,
407 map->nsh_hw_if = nsh_hw_if;
408 map->nsh_sw_if = nsh_sw_if =
hi->sw_if_index;
411 nm->tunnel_index_by_sw_if_index[nsh_sw_if] =
key;
425 vec_add1 (
nm->free_nsh_tunnel_hw_if_indices,
map->nsh_sw_if);
426 nm->tunnel_index_by_sw_if_index[
map->nsh_sw_if] = ~0;
429 key_copy = (
void *) (hp->
key);
437 *map_indexp = map_index;
454 u32 nsp = 0, nsi = 0;
457 key.transport_type =
a->map.next_node;
458 key.transport_index =
a->map.sw_if_index;
485 proxy -
nm->nsh_proxy_sessions);
494 key_copy = (
void *) (hp->
key);
516 u32 entry_index = ~0;
521 key =
a->nsh_entry.nsh_base.nsp_nsi;
535 #define _(x) nsh_entry->nsh_base.x = a->nsh_entry.nsh_base.x;
539 if (
a->nsh_entry.nsh_base.md_type == 1)
541 nsh_entry->
md.
md1_data.c1 =
a->nsh_entry.md.md1_data.c1;
542 nsh_entry->
md.
md1_data.c2 =
a->nsh_entry.md.md1_data.c2;
543 nsh_entry->
md.
md1_data.c3 =
a->nsh_entry.md.md1_data.c3;
544 nsh_entry->
md.
md1_data.c4 =
a->nsh_entry.md.md1_data.c4;
546 else if (
a->nsh_entry.nsh_base.md_type == 2)
549 tlvs_len =
a->nsh_entry.tlvs_len;
564 nsh_entry -
nm->nsh_entries);
565 entry_index = nsh_entry -
nm->nsh_entries;
574 key_copy = (
void *) (hp->
key);
584 *entry_indexp = entry_index;
598 u32 entry_index = ~0;
603 a->nsh_entry.nsh_base.ver_o_c =
605 a->nsh_entry.nsh_base.length =
607 a->nsh_entry.nsh_base.md_type = mp->
md_type;
609 a->nsh_entry.nsh_base.nsp_nsi = ntohl (mp->
nsp_nsi);
612 a->nsh_entry.md.md1_data.c1 = ntohl (mp->
c1);
613 a->nsh_entry.md.md1_data.c2 = ntohl (mp->
c2);
614 a->nsh_entry.md.md1_data.c3 = ntohl (mp->
c3);
615 a->nsh_entry.md.md1_data.c4 = ntohl (mp->
c4);
623 a->nsh_entry.tlvs_data =
data;
624 a->nsh_entry.tlvs_len = tlvs_len;
651 if (~0 == entry_index)
660 if (entry_index >=
vec_len (
nm->nsh_entries))
664 t = &
nm->nsh_entries[entry_index];
672 #define _(id,n,crc) \
673 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + nm->msg_id_base);
674 foreach_vl_msg_name_crc_nsh;
684 vl_msg_api_set_handlers((VL_API_##N + nm->msg_id_base), \
686 vl_api_##n##_t_handler, \
688 vl_api_##n##_t_endian, \
689 vl_api_##n##_t_print, \
690 sizeof(vl_api_##n##_t), 1);
703 name =
format (0,
"nsh_%08x%c", api_version, 0);