35 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__) 41 #define vl_api_version(n,v) static u32 api_version=(v); 45 #define REPLY_MSG_ID_BASE mm->msg_id_base 59 len = ntohl (mp->
tag.length);
82 rmp->
index = ntohl(index);
91 vl_api_map_del_domain_reply_t *rmp;
103 vl_api_map_del_domain_reply_t *rmp;
121 u32 map_domain_index;
135 map_domain_index = d - mm->domains;
136 de = vec_elt_at_index(mm->domain_extras, map_domain_index);
140 len = strlen(de->tag);
143 rmp = vl_msg_api_alloc (sizeof (*rmp) + sizeof(rmp->tag.length) + len);
145 rmp->_vl_msg_id = htons(VL_API_MAP_DOMAIN_DETAILS + mm->msg_id_base);
146 rmp->context = mp->context;
147 rmp->domain_index = htonl(map_domain_index);
148 clib_memcpy(&rmp->ip6_prefix.prefix, &d->ip6_prefix, sizeof(rmp->ip6_prefix.prefix));
149 clib_memcpy(&rmp->ip4_prefix.prefix, &d->ip4_prefix, sizeof(rmp->ip4_prefix.prefix));
150 clib_memcpy(&rmp->ip6_src.prefix, &d->ip6_src, sizeof(rmp->ip6_src.prefix));
151 rmp->ip6_prefix.len = d->ip6_prefix_len;
152 rmp->ip4_prefix.len = d->ip4_prefix_len;
153 rmp->ip6_src.len = d->ip6_src_len;
154 rmp->ea_bits_len = d->ea_bits_len;
155 rmp->psid_offset = d->psid_offset;
156 rmp->psid_length = d->psid_length;
157 rmp->flags = d->flags;
158 rmp->mtu = htons(d->mtu);
162 rmp->tag.length = htonl (len);
163 clib_memcpy ((char *)rmp->tag.buf, de->tag, len);
204 rmp->_vl_msg_id = ntohs (VL_API_MAP_RULE_DETAILS + mm->
msg_id_base);
205 rmp->
psid = htons (i);
229 rmp->_vl_msg_id = htons (VL_API_MAP_SUMMARY_STATS_REPLY + mm->
msg_id_base);
240 clib_memset (total_bytes, 0,
sizeof (total_bytes));
250 total_pkts[which] += v.
packets;
251 total_bytes[which] += v.
bytes;
261 clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_RX]);
265 clib_host_to_net_u64 (total_bytes[MAP_DOMAIN_COUNTER_TX]);
296 vl_api_map_param_set_fragmentation_reply_t *rmp;
301 REPLY_MACRO (VL_API_MAP_PARAM_SET_FRAGMENTATION_REPLY);
310 if (icmp_src_address == 0)
323 vl_api_map_param_set_icmp_reply_t *rmp;
346 vl_api_map_param_set_icmp6_reply_t *rmp;
360 vl_api_map_param_add_del_pre_resolve_reply_t *rmp;
366 REPLY_MACRO (VL_API_MAP_PARAM_ADD_DEL_PRE_RESOLVE_REPLY);
375 f64 ht_ratio,
u32 * reass,
u32 * packets)
377 u32 ps_reass = 0, ps_packets = 0;
378 u32 ht_reass = 0, ht_packets = 0;
382 if (pool_size != (
u16) ~ 0)
387 (pool_size, &ps_reass, &ps_packets))
399 if (lifetime_ms != (
u16) ~ 0)
424 if (pool_size != (
u16) ~ 0)
429 (pool_size, &ps_reass, &ps_packets))
441 if (lifetime_ms != (
u16) ~ 0)
466 *reass = ps_reass + ht_reass;
469 *packets = ps_packets + ht_packets;
480 vl_api_map_param_set_reassembly_reply_t *rmp;
481 u32 reass = 0, packets = 0;
485 ht_ratio = (
f64) clib_net_to_host_u64 (mp->
ht_ratio);
492 clib_net_to_host_u32 (mp->
buffers),
493 ht_ratio, &reass, &packets);
499 REPLY_MACRO (VL_API_MAP_PARAM_SET_REASSEMBLY_REPLY);
519 vl_api_map_param_set_security_check_reply_t *rmp;
524 REPLY_MACRO (VL_API_MAP_PARAM_SET_SECURITY_CHECK_REPLY);
544 vl_api_map_param_set_traffic_class_reply_t *rmp;
549 REPLY_MACRO (VL_API_MAP_PARAM_SET_TRAFFIC_CLASS_REPLY);
568 vl_api_map_param_set_tcp_reply_t *rmp;
588 rmp->_vl_msg_id = htons (VL_API_MAP_PARAM_GET_REPLY + mm->
msg_id_base);
638 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
640 is_enable = ! !is_enable;
655 if (is_translation ==
false)
658 is_enable ? 1 : 0, 0, 0);
660 is_enable ? 1 : 0, 0, 0);
668 is_enable ? 1 : 0, 0, 0);
670 is_enable ? 1 : 0, 0, 0);
684 vl_api_map_if_enable_disable_reply_t *rmp;
698 #define foreach_map_plugin_api_msg \ 699 _(MAP_ADD_DOMAIN, map_add_domain) \ 700 _(MAP_DEL_DOMAIN, map_del_domain) \ 701 _(MAP_ADD_DEL_RULE, map_add_del_rule) \ 702 _(MAP_DOMAIN_DUMP, map_domain_dump) \ 703 _(MAP_RULE_DUMP, map_rule_dump) \ 704 _(MAP_IF_ENABLE_DISABLE, map_if_enable_disable) \ 705 _(MAP_SUMMARY_STATS, map_summary_stats) \ 706 _(MAP_PARAM_SET_FRAGMENTATION, map_param_set_fragmentation) \ 707 _(MAP_PARAM_SET_ICMP, map_param_set_icmp) \ 708 _(MAP_PARAM_SET_ICMP6, map_param_set_icmp6) \ 709 _(MAP_PARAM_ADD_DEL_PRE_RESOLVE, map_param_add_del_pre_resolve) \ 710 _(MAP_PARAM_SET_REASSEMBLY, map_param_set_reassembly) \ 711 _(MAP_PARAM_SET_SECURITY_CHECK, map_param_set_security_check) \ 712 _(MAP_PARAM_SET_TRAFFIC_CLASS, map_param_set_traffic_class) \ 713 _(MAP_PARAM_SET_TCP, map_param_set_tcp) \ 714 _(MAP_PARAM_GET, map_param_get) 716 #define vl_msg_name_crc_list 718 #undef vl_msg_name_crc_list 723 #define _(id,n,crc) \ 724 vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id + mm->msg_id_base); 725 foreach_vl_msg_name_crc_map;
740 vl_msg_api_set_handlers((VL_API_##N + mm->msg_id_base), \ 742 vl_api_##n##_t_handler, \ 744 vl_api_##n##_t_endian, \ 745 vl_api_##n##_t_print, \ 746 sizeof(vl_api_##n##_t), 1);
static void vl_api_map_param_set_tcp_t_handler(vl_api_map_param_set_tcp_t *mp)
int map_create_domain(ip4_address_t *ip4_prefix, u8 ip4_prefix_len, ip6_address_t *ip6_prefix, u8 ip6_prefix_len, ip6_address_t *ip6_src, u8 ip6_src_len, u8 ea_bits_len, u8 psid_offset, u8 psid_length, u32 *map_domain_index, u16 mtu, u8 flags, char *tag)
int map_add_del_psid(u32 map_domain_index, u16 psid, ip6_address_t *tep, bool is_add)
static void vl_api_map_if_enable_disable_t_handler(vl_api_map_if_enable_disable_t *mp)
u32 ip4_reass_conf_buffers
static void vl_api_map_param_set_icmp_t_handler(vl_api_map_param_set_icmp_t *mp)
#define MAP_IP6_REASS_CONF_BUFFERS_MAX
Set MAP traffic class parameters.
Add or Delete MAP rule from a domain (Only used for shared IPv4 per subscriber)
int map_delete_domain(u32 map_domain_index)
static void vl_api_map_domain_dump_t_handler(vl_api_map_domain_dump_t *mp)
vnet_interface_main_t interface_main
vl_api_ip6_prefix_t ip6_src
#define REPLY_MACRO2(t, body)
Add/delete MAP pre-resolve IP addresses parameters.
u64 map_error_counter_get(u32 node_index, map_error_t map_error)
static void vl_api_send_msg(vl_api_registration_t *rp, u8 *elem)
static void vl_api_map_param_set_security_check_t_handler(vl_api_map_param_set_security_check_t *mp)
static void map_domain_counter_unlock(map_main_t *mm)
Combined counter to hold both packets and byte differences.
u64 total_security_check[2]
static uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
clib_memset(h->entries, 0, sizeof(h->entries[0])*entries)
static void vl_api_map_param_set_traffic_class_t_handler(vl_api_map_param_set_traffic_class_t *mp)
vlib_node_registration_t ip4_map_node
(constructor) VLIB_REGISTER_NODE (ip4_map_node)
int map_param_set_traffic_class(bool copy, u8 tc)
uword * bm_trans_enabled_by_sw_if
#define MAP_ERR_BAD_HT_RATIO
void map_pre_resolve(ip4_address_t *ip4, ip6_address_t *ip6, bool is_del)
void * vl_msg_api_alloc(int nbytes)
static void vl_api_map_param_set_icmp6_t_handler(vl_api_map_param_set_icmp6_t *mp)
int map_ip6_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
static void vl_api_map_add_del_rule_t_handler(vl_api_map_add_del_rule_t *mp)
#define MAP_IP6_REASS_CONF_LIFETIME_MAX
static void vl_api_map_summary_stats_t_handler(vl_api_map_summary_stats_t *mp)
vl_api_ip6_address_t ip6_dst
#define clib_memcpy(d, s, n)
int map_param_set_security_check(bool enable, bool fragments)
#define MAP_ERR_BAD_BUFFERS_TOO_LARGE
#define MAP_IP4_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
static void vl_api_map_add_domain_t_handler(vl_api_map_add_domain_t *mp)
vl_api_ip4_prefix_t ip4_prefix
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vlib_combined_counter_main_t * domain_counters
ip4_address_t icmp4_src_address
Reply for map_param_get request.
#define MAP_IP4_REASS_CONF_LIFETIME_MAX
static void vl_api_map_del_domain_t_handler(vl_api_map_del_domain_t *mp)
Set MAP fragmentation parameters.
static void vl_api_map_param_add_del_pre_resolve_t_handler(vl_api_map_param_add_del_pre_resolve_t *mp)
#define MAP_IP6_REASS_CONF_POOL_SIZE_MAX
int map_param_set_icmp6(u8 enable_unreachable)
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
int map_ip6_reass_conf_buffers(u32 buffers)
counter_t packets
packet counter
int map_if_enable_disable(bool is_enable, u32 sw_if_index, bool is_translation)
int map_ip4_reass_conf_lifetime(u16 lifetime_ms)
clib_error_t * map_plugin_api_hookup(vlib_main_t *vm)
bool icmp6_enable_unreachable
#define MAP_IP4_REASS_CONF_HT_RATIO_MAX
static void vl_api_map_rule_dump_t_handler(vl_api_map_rule_dump_t *mp)
u32 vlib_combined_counter_n_counters(const vlib_combined_counter_main_t *cm)
The number of counters (not the number of per-thread counters)
u16 ip4_reass_conf_pool_size
vl_api_ip4_address_t ip4_nh_address
static void vl_api_map_param_get_t_handler(vl_api_map_param_get_t *mp)
vl_api_ip4_address_t ip4_nh_address
int map_ip4_reass_conf_buffers(u32 buffers)
int map_ip6_reass_conf_lifetime(u16 lifetime_ms)
int map_ip4_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
#define MAP_ERR_BAD_BUFFERS
static void setup_message_id_table(map_main_t *mm, api_main_t *am)
int map_param_set_reassembly(bool is_ipv6, u16 lifetime_ms, u16 pool_size, u32 buffers, f64 ht_ratio, u32 *reass, u32 *packets)
API main structure, used by both vpp and binary API clients.
Request for a single block of MAP parameters.
int map_param_set_tcp(u16 tcp_mss)
Details about a single MAP domain.
An API client registration, only in vpp/vlib.
#define BAD_SW_IF_INDEX_LABEL
static void vl_api_map_param_set_fragmentation_t_handler(vl_api_map_param_set_fragmentation_t *mp)
u16 ip6_reass_conf_pool_size
Enable or disable a MAP interface.
static void vlib_get_combined_counter(const vlib_combined_counter_main_t *cm, u32 index, vlib_counter_t *result)
Get the value of a combined counter, never called in the speed path Scrapes the entire set of per-thr...
vl_api_ip6_address_t ip6_nh_address
uword * bm_encap_enabled_by_sw_if
#define vec_free(V)
Free vector's memory (no header).
Set MAP ICMP6 parameters.
Reply for map_summary_stats request.
#define pool_is_free_index(P, I)
Use free bitmap to query whether given index is free.
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
static vl_api_registration_t * vl_api_client_index_to_registration(u32 index)
vl_api_ip6_address_t ip6_dst
int map_ip4_reass_conf_ht_ratio(f32 ht_ratio, u32 *trashed_reass, u32 *dropped_packets)
static void map_domain_counter_lock(map_main_t *mm)
f32 ip4_reass_conf_ht_ratio
int map_param_set_icmp(ip4_address_t *icmp_src_address)
int map_ip6_reass_conf_pool_size(u16 pool_size, u32 *trashed_reass, u32 *dropped_packets)
vl_api_ip6_address_t ip6_nh_address
static void clib_mem_free(void *p)
Request for a single block of summary stats.
Reply for MAP domain add.
static void * clib_mem_alloc(uword size)
#define MAP_ERR_BAD_POOL_SIZE
#define foreach_map_plugin_api_msg
f32 ip6_reass_conf_ht_ratio
counter_t bytes
byte counter
Set MAP security-check parameters.
vl_api_ip4_address_t ip4_err_relay_src
u16 ip6_reass_conf_lifetime_ms
#define MAP_IP6_REASS_CONF_HT_RATIO_MAX
vnet_sw_interface_t * sw_interfaces
A collection of combined counters.
#define MAP_IP4_REASS_CONF_POOL_SIZE_MAX
vl_api_ip4_address_t icmp_ip4_err_relay_src
vl_api_ip6_prefix_t ip6_prefix
static void vl_api_map_param_set_reassembly_t_handler(vl_api_map_param_set_reassembly_t *mp)
#define MAP_IP6_REASS_MAX_FRAGMENTS_PER_REASSEMBLY
u16 ip4_reass_conf_lifetime_ms
#define vec_foreach(var, vec)
Vector iterator.
#define MAP_IP4_REASS_CONF_BUFFERS_MAX
#define MAP_ERR_BAD_LIFETIME
Set MAP reassembly parameters.
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
#define VALIDATE_SW_IF_INDEX(mp)
int map_param_set_fragmentation(bool inner, bool ignore_df)
u16 vl_msg_api_get_msg_ids(const char *name, int n)
u32 ip6_reass_conf_buffers
static uword pool_elts(void *v)
Number of active elements in a pool.