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);
194 send_nsh_map_details (t, rp,
249 nsh_base_header_t *nsh_base;
250 nsh_md1_data_t *nsh_md1;
256 u8 old_option_size = 0;
257 u8 new_option_size = 0;
260 if (nsh_entry->
nsh_base.md_type == 1)
262 len =
sizeof (nsh_base_header_t) +
sizeof (nsh_md1_data_t);
264 else if (nsh_entry->
nsh_base.md_type == 2)
272 nsh_base = (nsh_base_header_t *) rw;
273 nsh_base->ver_o_c = nsh_entry->
nsh_base.ver_o_c;
274 nsh_base->length = nsh_entry->
nsh_base.length;
275 nsh_base->md_type = nsh_entry->
nsh_base.md_type;
276 nsh_base->next_protocol = nsh_entry->
nsh_base.next_protocol;
277 nsh_base->nsp_nsi = clib_host_to_net_u32 (nsh_entry->
nsh_base.nsp_nsi);
279 if (nsh_base->md_type == 1)
281 nsh_md1 = (nsh_md1_data_t *) (rw +
sizeof (nsh_base_header_t));
282 nsh_md1->c1 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c1);
283 nsh_md1->c2 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c2);
284 nsh_md1->c3 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c3);
285 nsh_md1->c4 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c4);
288 else if (nsh_base->md_type == 2)
296 while (opt0 < limit0)
300 old_option_size = ((old_option_size + 3) >> 2) << 2;
303 if (nsh_option == NULL)
317 new_option_size = ((new_option_size + 3) >> 2) << 2;
403 (vnm, nsh_device_class.index, map_index, nsh_hw_class.index,
431 key_copy = (
void *) (hp->
key);
439 *map_indexp = map_index;
456 u32 nsp = 0, nsi = 0;
496 key_copy = (
void *) (hp->
key);
518 u32 entry_index = ~0;
537 #define _(x) nsh_entry->nsh_base.x = a->nsh_entry.nsh_base.x; 576 key_copy = (
void *) (hp->
key);
586 *entry_indexp = entry_index;
600 u32 entry_index = ~0;
653 if (~0 == entry_index)
657 send_nsh_entry_details (t, rp,
676 #define _(id,n,crc) \ 677 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + nm->msg_id_base); 678 foreach_vl_msg_name_crc_nsh;
688 vl_msg_api_set_handlers((VL_API_##N + nm->msg_id_base), \ 690 vl_api_##n##_t_handler, \ 692 vl_api_##n##_t_endian, \ 693 vl_api_##n##_t_print, \ 694 sizeof(vl_api_##n##_t), 1); 707 name =
format (0,
"nsh_%08x%c", api_version, 0);
VNET_DEVICE_CLASS(nsh_device_class, static)
vl_api_interface_index_t sw_if_index
#define VNET_SW_INTERFACE_FLAG_ADMIN_DOWN
Reply from adding NSH entry (nsh_add_del_entry)
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel index.
vl_api_wireguard_peer_flags_t flags
vl_api_interface_index_t rx_sw_if_index
vl_api_interface_index_t sw_if_index
#define REPLY_MACRO2(t, body)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
union nsh_entry_t::@675 md
#define hash_set_mem(h, key, value)
static void send_nsh_map_details(nsh_map_t *t, vl_api_registration_t *rp, u32 context)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
int nsh_add_del_proxy_session(nsh_add_del_map_args_t *a)
Action function to add or del an nsh-proxy-session.
vlib_node_registration_t nsh_aware_vnf_proxy_node
(constructor) VLIB_REGISTER_NODE (nsh_aware_vnf_proxy_node)
void * vl_msg_api_alloc(int nbytes)
nsh_base_header_t nsh_base
nsh_proxy_session_t * nsh_proxy_sessions
#define clib_memcpy(d, s, n)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
int(* add_options[MAX_MD2_OPTIONS])(u8 *opt, u8 *opt_size)
#define foreach_copy_nsh_base_hdr_field
nsh_entry_t * nsh_entries
#define hash_get_pair(h, key)
u32 * free_nsh_tunnel_hw_if_indices
Free vlib hw_if_indices.
u32 vnet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u32 hw_class_index, u32 hw_instance)
nsh_option_map_t * nsh_md2_lookup_option(u16 class, u8 type)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
#define hash_unset_mem(h, key)
static void vl_api_nsh_add_del_entry_t_handler(vl_api_nsh_add_del_entry_t *mp)
API message handler.
u8 * rewrite
Rewrite string.
#define pool_put(P, E)
Free an object E in pool P.
int nsh_add_del_map(nsh_add_del_map_args_t *a, u32 *map_indexp)
Action function to add or del an nsh map.
static u8 * format_nsh_name(u8 *s, va_list *args)
Naming for NSH tunnel.
API main structure, used by both vpp and binary API clients.
#define pool_get_aligned(P, E, A)
Allocate an object E from a pool P with alignment A.
An API client registration, only in vpp/vlib.
static void setup_message_id_table(nsh_main_t *nm, api_main_t *am)
static void vl_api_nsh_map_dump_t_handler(vl_api_nsh_map_dump_t *mp)
vl_api_interface_index_t rx_sw_if_index
#define vec_free(V)
Free vector's memory (no header).
#define MAX_NSH_HEADER_LEN
uword * nsh_proxy_session_by_key
u32 nsp_nsi
Key for nsh_header_t entry: 24bit NSP 8bit NSI.
u32 nsh_hw_if
vnet intfc hw_if_index
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
static clib_error_t * nsh_plugin_api_hookup(vlib_main_t *vm)
nsh_tlv_header_t nsh_md2_data_t
u32 mapped_nsp_nsi
Key for nsh_header_t entry to map to.
vnet_hw_interface_class_t nsh_hw_class
int nsh_add_del_entry(nsh_add_del_entry_args_t *a, u32 *entry_indexp)
Action function for adding an NSH entry nsh_add_del_entry_args_t *a: host order.
static void clib_mem_free(void *p)
Set or delete a mapping from one NSH header to another and its egress (decap to inner packet...
static clib_error_t * nsh_interface_admin_up_down(vnet_main_t *vnm, u32 nsh_hw_if, u32 flags)
CLI function for NSH admin up/down.
static void vl_api_nsh_entry_dump_t_handler(vl_api_nsh_entry_dump_t *mp)
static void send_nsh_entry_details(nsh_entry_t *t, vl_api_registration_t *rp, u32 context)
static void * clib_mem_alloc(uword size)
struct _vnet_hw_interface_class vnet_hw_interface_class_t
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
#define hash_get_mem(h, key)
static api_main_t * vlibapi_get_main(void)
Reply from adding NSH map (nsh_add_del_map)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
Note: rewrite and rewrite_size used to support varied nsh header.
clib_error_t * nsh_api_init(vlib_main_t *vm, nsh_main_t *nm)
#define vec_validate_init_empty(V, I, INIT)
Make sure vector is long enough for given index and initialize empty space (no header, unspecified alignment)
#define CLIB_CACHE_LINE_BYTES
static void vl_api_nsh_add_del_map_t_handler(vl_api_nsh_add_del_map_t *mp)
API message handler.
uword * nsh_mapping_by_key
int nsh_header_rewrite(nsh_entry_t *nsh_entry)
#define foreach_nsh_plugin_api_msg
u16 vl_msg_api_get_msg_ids(const char *name, int n)