23 #include <vpp/app/version.h>
26 #include <plugins/nsh/nsh.api_enum.h>
27 #include <plugins/nsh/nsh.api_types.h>
63 u32 dev_instance = va_arg (*args,
u32);
64 return format (s,
"nsh_tunnel%d", dev_instance);
157 if (map_index >=
vec_len (
nm->nsh_mappings))
161 t = &
nm->nsh_mappings[map_index];
176 a->map.nsp_nsi = ntohl (mp->
nsp_nsi);
185 if ((
a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN4)
186 | (
a->map.next_node == NSH_NODE_NEXT_ENCAP_VXLAN6))
204 nsh_base_header_t *nsh_base;
205 nsh_md1_data_t *nsh_md1;
211 u8 old_option_size = 0;
212 u8 new_option_size = 0;
215 if (nsh_entry->
nsh_base.md_type == 1)
217 len =
sizeof (nsh_base_header_t) +
sizeof (nsh_md1_data_t);
219 else if (nsh_entry->
nsh_base.md_type == 2)
227 nsh_base = (nsh_base_header_t *) rw;
228 nsh_base->ver_o_c = nsh_entry->
nsh_base.ver_o_c;
229 nsh_base->length = nsh_entry->
nsh_base.length;
230 nsh_base->md_type = nsh_entry->
nsh_base.md_type;
231 nsh_base->next_protocol = nsh_entry->
nsh_base.next_protocol;
232 nsh_base->nsp_nsi = clib_host_to_net_u32 (nsh_entry->
nsh_base.nsp_nsi);
234 if (nsh_base->md_type == 1)
236 nsh_md1 = (nsh_md1_data_t *) (rw +
sizeof (nsh_base_header_t));
237 nsh_md1->c1 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c1);
238 nsh_md1->c2 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c2);
239 nsh_md1->c3 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c3);
240 nsh_md1->c4 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c4);
243 else if (nsh_base->md_type == 2)
251 while (opt0 < limit0)
255 old_option_size = ((old_option_size + 3) >> 2) << 2;
258 if (nsh_option == NULL)
263 if (
nm->add_options[nsh_option->
option_id] != NULL)
265 if (0 !=
nm->add_options[nsh_option->
option_id] ((
u8 *) nsh_md2,
272 new_option_size = ((new_option_size + 3) >> 2) << 2;
316 key = clib_host_to_net_u32 (
a->map.nsp_nsi);
330 map->nsp_nsi =
a->map.nsp_nsi;
331 map->mapped_nsp_nsi =
a->map.mapped_nsp_nsi;
332 map->nsh_action =
a->map.nsh_action;
333 map->sw_if_index =
a->map.sw_if_index;
334 map->rx_sw_if_index =
a->map.rx_sw_if_index;
335 map->next_node =
a->map.next_node;
336 map->adj_index =
a->map.adj_index;
343 map_index =
map -
nm->nsh_mappings;
345 if (
vec_len (
nm->free_nsh_tunnel_hw_if_indices) > 0)
347 nsh_hw_if =
nm->free_nsh_tunnel_hw_if_indices
348 [
vec_len (
nm->free_nsh_tunnel_hw_if_indices) - 1];
349 _vec_len (
nm->free_nsh_tunnel_hw_if_indices) -= 1;
352 hi->dev_instance = map_index;
353 hi->hw_instance =
hi->dev_instance;
358 (vnm, nsh_device_class.index, map_index,
nsh_hw_class.index,
364 map->nsh_hw_if = nsh_hw_if;
365 map->nsh_sw_if = nsh_sw_if =
hi->sw_if_index;
368 nm->tunnel_index_by_sw_if_index[nsh_sw_if] =
key;
382 vec_add1 (
nm->free_nsh_tunnel_hw_if_indices,
map->nsh_sw_if);
383 nm->tunnel_index_by_sw_if_index[
map->nsh_sw_if] = ~0;
386 key_copy = (
void *) (hp->
key);
394 *map_indexp = map_index;
411 u32 nsp = 0, nsi = 0;
414 key.transport_type =
a->map.next_node;
415 key.transport_index =
a->map.sw_if_index;
442 proxy -
nm->nsh_proxy_sessions);
451 key_copy = (
void *) (hp->
key);
473 u32 entry_index = ~0;
478 key =
a->nsh_entry.nsh_base.nsp_nsi;
492 #define _(x) nsh_entry->nsh_base.x = a->nsh_entry.nsh_base.x;
496 if (
a->nsh_entry.nsh_base.md_type == 1)
498 nsh_entry->
md.
md1_data.c1 =
a->nsh_entry.md.md1_data.c1;
499 nsh_entry->
md.
md1_data.c2 =
a->nsh_entry.md.md1_data.c2;
500 nsh_entry->
md.
md1_data.c3 =
a->nsh_entry.md.md1_data.c3;
501 nsh_entry->
md.
md1_data.c4 =
a->nsh_entry.md.md1_data.c4;
503 else if (
a->nsh_entry.nsh_base.md_type == 2)
506 tlvs_len =
a->nsh_entry.tlvs_len;
521 nsh_entry -
nm->nsh_entries);
522 entry_index = nsh_entry -
nm->nsh_entries;
531 key_copy = (
void *) (hp->
key);
541 *entry_indexp = entry_index;
554 u32 entry_index = ~0;
559 a->nsh_entry.nsh_base.ver_o_c =
561 a->nsh_entry.nsh_base.length =
563 a->nsh_entry.nsh_base.md_type = mp->
md_type;
565 a->nsh_entry.nsh_base.nsp_nsi = ntohl (mp->
nsp_nsi);
568 a->nsh_entry.md.md1_data.c1 = ntohl (mp->
c1);
569 a->nsh_entry.md.md1_data.c2 = ntohl (mp->
c2);
570 a->nsh_entry.md.md1_data.c3 = ntohl (mp->
c3);
571 a->nsh_entry.md.md1_data.c4 = ntohl (mp->
c4);
579 a->nsh_entry.tlvs_data =
data;
580 a->nsh_entry.tlvs_len = tlvs_len;
607 if (~0 == entry_index)
616 if (entry_index >=
vec_len (
nm->nsh_entries))
620 t = &
nm->nsh_entries[entry_index];
625 #include <nsh/nsh.api.c>