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) 97 clib_warning (
"you shouldn't be here, leaking buffers...");
113 u32 dev_instance = va_arg (*args,
u32);
114 return format (s,
"nsh_tunnel%d", dev_instance);
135 rmp->_vl_msg_id = ntohs ((VL_API_NSH_ENTRY_DETAILS) + nm->
msg_id_base);
172 rmp->_vl_msg_id = ntohs ((VL_API_NSH_MAP_DETAILS) + nm->
msg_id_base);
203 send_nsh_map_details (t, rp,
258 nsh_base_header_t *nsh_base;
259 nsh_md1_data_t *nsh_md1;
265 u8 old_option_size = 0;
266 u8 new_option_size = 0;
269 if (nsh_entry->
nsh_base.md_type == 1)
271 len =
sizeof (nsh_base_header_t) +
sizeof (nsh_md1_data_t);
273 else if (nsh_entry->
nsh_base.md_type == 2)
281 nsh_base = (nsh_base_header_t *) rw;
282 nsh_base->ver_o_c = nsh_entry->
nsh_base.ver_o_c;
283 nsh_base->length = nsh_entry->
nsh_base.length;
284 nsh_base->md_type = nsh_entry->
nsh_base.md_type;
285 nsh_base->next_protocol = nsh_entry->
nsh_base.next_protocol;
286 nsh_base->nsp_nsi = clib_host_to_net_u32 (nsh_entry->
nsh_base.nsp_nsi);
288 if (nsh_base->md_type == 1)
290 nsh_md1 = (nsh_md1_data_t *) (rw +
sizeof (nsh_base_header_t));
291 nsh_md1->c1 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c1);
292 nsh_md1->c2 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c2);
293 nsh_md1->c3 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c3);
294 nsh_md1->c4 = clib_host_to_net_u32 (nsh_entry->
md.
md1_data.c4);
297 else if (nsh_base->md_type == 2)
305 while (opt0 < limit0)
309 old_option_size = ((old_option_size + 3) >> 2) << 2;
312 if (nsh_option ==
NULL)
326 new_option_size = ((new_option_size + 3) >> 2) << 2;
412 (vnm, nsh_device_class.index, map_index, nsh_hw_class.index,
440 key_copy = (
void *) (hp->
key);
448 *map_indexp = map_index;
465 u32 nsp = 0, nsi = 0;
505 key_copy = (
void *) (hp->
key);
527 u32 entry_index = ~0;
546 #define _(x) nsh_entry->nsh_base.x = a->nsh_entry.nsh_base.x; 585 key_copy = (
void *) (hp->
key);
595 *entry_indexp = entry_index;
609 u32 entry_index = ~0;
662 if (~0 == entry_index)
666 send_nsh_entry_details (t, rp,
685 #define _(id,n,crc) \ 686 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + nm->msg_id_base); 687 foreach_vl_msg_name_crc_nsh;
697 vl_msg_api_set_handlers((VL_API_##N + nm->msg_id_base), \ 699 vl_api_##n##_t_handler, \ 701 vl_api_##n##_t_endian, \ 702 vl_api_##n##_t_print, \ 703 sizeof(vl_api_##n##_t), 1); 716 name =
format (0,
"nsh_%08x%c", api_version, 0);
VNET_DEVICE_CLASS(nsh_device_class, static)
#define VNET_SW_INTERFACE_FLAG_ADMIN_DOWN
static uword dummy_interface_tx(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Reply from adding NSH entry (nsh_add_del_entry)
u32 * tunnel_index_by_sw_if_index
Mapping from sw_if_index to tunnel 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::@555 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)
#define vec_free(V)
Free vector's memory (no header).
#define MAX_NSH_HEADER_LEN
#define clib_warning(format, args...)
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)
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)