38 #include <arpa/inet.h> 59 if (my_nfv9_logging_info->
i_vrf_id == i_vrf_id) {
60 logging_index = my_nfv9_logging_info -
61 cnat_nfv9_logging_info_pool;
66 return (logging_index);
81 if (my_syslog_info->
i_vrf_id == i_vrf_id) {
82 logging_index = my_syslog_info -
83 cnat_syslog_logging_info_pool;
88 return (logging_index);
97 my_vrfmap->
i_vrf = i_vrf;
103 #ifndef NO_BULK_LOGGING 126 printf(
"Initializing params in cnat_set_vrf_params_with_default\n" 127 "my_vrfmap->status = %u\n" 128 "my_vrfmap->tcp_mss = %u\n" 129 "my_vrfmap->i_vrf = %u\n" 130 "my_vrfmap->i_vrf_id = %u\n" 131 "my_vrfmap->o_vrf = %u\n" 132 "my_vrfmap->o_vrf_id = %u\n" 133 "my_vrfmap->bulk_size = %u\n" 134 "my_vrfmap->nfv9_logging_index = %u\n" 135 "my_vrfmap->syslog_logging_index = %u\n" 136 "my_vrfmap->frag_tout = %u\n" 137 "my_vrfmap->port_limit = %u\n" 138 "my_vrfmap->nf_logging_policy = %u\n" 139 "my_vrfmap->syslog_logging_policy = %u\n",
162 u32 start_addr, end_addr;
163 u32 pm_len __attribute__((unused));
167 u32 ivrf_id, ovrf_id;
171 start_addr = mp->start_addr[0];
172 end_addr = mp->end_addr[0];
175 ovrf_id = mp->o_vrf_id;
176 ivrf_id = mp->i_vrf_id;
178 #if DEBUG_NOT_COMMENTED 179 vlib_cli_output(vm,
"%s: saddr[0x%x], eaddr[0x%x], i_vrf[0x%x], o_vrf[0x%x], " 180 "ovrf_id[0x%x], ivrf_id[0x%x]\n", __func__, start_addr, end_addr,
181 i_vrf, o_vrf, ovrf_id, ivrf_id);
183 if (start_addr > end_addr) {
184 vlib_cli_output(vm,
"Add VRF Map failed start addr 0x%x > end addr 0x%x\n",
185 start_addr, end_addr);
190 "0x%x range > 65536\n", start_addr, end_addr);
199 my_vrfmap->
o_vrf = o_vrf;
207 memset(my_vrfmap, 0,
sizeof(*my_vrfmap));
210 my_vrfmap->
i_vrf = i_vrf;
211 my_vrfmap->
o_vrf = o_vrf;
214 #ifndef NO_BULK_LOGGING 226 for(i=0; i < 1 ; i++) {
227 start_addr = mp->start_addr[
i];
228 end_addr = mp->end_addr[
i];
229 if((start_addr == 0) || (end_addr == 0))
243 if (!strncmp((
char *) proto,
"tcp", 3)) {
247 }
else if (!strncmp((
char *) proto,
"udp", 3)) {
251 }
else if (!strncmp((
char *) proto,
"icmp", 4)) {
295 vlib_cli_output(vm,
"\t-------------------------------------------------\n");
297 vlib_cli_output(vm,
"\t-------------------------------------------------\n");
303 for (i = 0; i < pm_len; i++) {
309 ip.s_addr = ntohl(my_pm->ipv4_address);
324 struct in_addr ip_addr;
327 *global_nfv9_logging_info = 0;
346 memset(status_str, 0x00,
sizeof(status_str));
347 switch(my_vrfmap->
status) {
353 default:
clib_memcpy(status_str,
"Invalid state", 13);
357 "\tAddress pool map table status : %s\n", status_str);
362 ip_addr.s_addr = clib_net_to_host_u32(my_pm->
ipv4_address);
364 "\tStart Address : %s\n", inet_ntoa(ip_addr));
365 my_pm = pm + (pm_len - 1);
366 ip_addr.s_addr = clib_net_to_host_u32(my_pm->
ipv4_address);
368 "\tEnd Address : %s\n", inet_ntoa(ip_addr));
394 if (my_nfv9_logging_info != global_nfv9_logging_info) {
418 u8 display_entry = 0;
423 if (!entry_flag_ptr) {
424 return (display_entry);
454 (*entry_flag_ptr & CNAT_TRANSLATION_ENTRY_STATIC)) {
459 (*entry_flag_ptr & CNAT_TRANSLATION_ENTRY_ALG)) {
464 (*entry_flag_ptr & CNAT_TRANSLATION_ENTRY_PCPI_DYNAMIC)) {
469 (*entry_flag_ptr & CNAT_TRANSLATION_ENTRY_PCPE_DYNAMIC)) {
477 (*entry_flag_ptr & CNAT_TRANSLATION_ENTRY_DYNAMIC)) {
483 PLATFORM_DEBUG_PRINT(
"Entry (0x%x, %d) -> (0x%x, %d) request_flag 0x%x, entry_flag 0x%x, display_entry %d\n", db->
in2out_key.
k.
ipv4, db->
in2out_key.
k.
port, db->
out2in_key.
k.
ipv4, db->
out2in_key.
k.
port, request_flag, *entry_flag_ptr, display_entry);
486 return (display_entry);
496 u16 start_port, end_port, port;
497 u16 request_flag = 0;
509 ki.
k.
k.
ipv4 = mp->ipv4_addr;
510 ki.
k.
k.
vrf = mp->vrf_id;
511 start_port = mp->start_port;
512 end_port = mp->end_port;
515 "end_port %u, vrf 0x%x, flag 0x%x\n",
524 proto = mp->protocol;
527 all = mp->all_entries;
528 request_flag = mp->flags;
546 "start_port %d, end_port %d",
548 ki.
k.
k.
vrf, start_port, end_port);
581 spp_api_cnat_v4_show_verify_display_entry(request_flag, db,
606 spp_host_to_net_byte_order_16(entry_flag);
609 entry_list = entry_list + 1;
626 start_port, end_port);
637 if (port >= end_port) {
656 }
while (index !=
EMPTY);
658 if (index ==
EMPTY) {
691 clib_net_to_host_u32(entry_list->
ipv4_addr),
692 clib_net_to_host_u16(entry_list->
cnat_port),
696 entry_list = entry_list + 1;
715 memset(proto_str, 0x00, 10);
716 memset(transl_str, 0x00, 10);
718 if (proto == 1) strncpy((
char *)proto_str,
"udp", 3);
719 else if (proto == 2) strncpy((
char *)proto_str,
"tcp", 3);
720 else if (proto == 3) strncpy((
char *)proto_str,
"icmp", 4);
721 else strncpy((
char *)proto_str,
"unknown", 7);
723 if (request_flag == 0x04) strncpy((
char *)transl_str,
"Dynamic", 7);
724 else strncpy((
char *)transl_str,
"Unknown", 7);
726 ip.s_addr = clib_net_to_host_u32(u_ki.
k.
k.
ipv4);
737 vlib_cli_output (vm,
"--------------------------------------------------------------------------------------" 738 "-----------------------\n");
740 " I2O O2I Flag Num\n");
742 " Pkts Pkts Sessions\n");
743 vlib_cli_output (vm,
"--------------------------------------------------------------------------------------" 744 "-----------------------\n");
746 while ((num_entries) && (entry_list) && (i < 50)) {
749 memset(flag_str,0x00,11);
750 if((proto == 1) || (proto == 2)) {
751 if(entry_list->
flags == 1) {
752 strncpy((
char *)flag_str,
"Active",6);
755 strncpy((
char *) flag_str,
"Non Active",10);
758 strncpy((
char *) flag_str,
"NA", 2);
761 inet_ntoa(ip), proto_str,
762 clib_net_to_host_u16(entry_list->
src_port),
763 clib_net_to_host_u16(entry_list->
cnat_port),
783 u16 start_port, end_port, port;
784 u16 request_flag = 0;
796 ko.
k.
k.
ipv4 = mp->ipv4_addr;
797 ko.
k.
k.
vrf = mp->vrf_id;
798 start_port = mp->start_port;
799 end_port = mp->end_port;
801 proto = mp->protocol;
802 request_flag = mp->flags;
826 if (port >= end_port) {
847 }
while (index !=
EMPTY);
849 if (index ==
EMPTY) {
878 clib_host_to_net_u16(entry_flag);
880 entry_list = entry_list + 1;
886 if (num_entries == 0) {
903 memset(proto_str, 0x00, 10);
904 memset(transl_str, 0x00, 10);
906 if (proto == 1) strncpy((
char *) proto_str,
"udp", 3);
907 else if (proto == 2) strncpy((
char *) proto_str,
"tcp", 3);
908 else if (proto == 3) strncpy((
char *) proto_str,
"icmp", 4);
909 else strncpy((
char *) proto_str,
"unknown", 7);
911 if (request_flag == 0x04) strncpy((
char *) transl_str,
"Dynamic", 7);
912 else strncpy((
char *)transl_str,
"Unknown", 7);
914 ip.s_addr = clib_net_to_host_u32(ko.
k.
k.
ipv4);
925 vlib_cli_output (vm,
"--------------------------------------------------------------------------------------" 926 "-----------------------\n");
928 " I2O O2I Flag Num\n");
930 " Pkts Pkts Sessions\n");
931 vlib_cli_output (vm,
"--------------------------------------------------------------------------------------" 932 "-----------------------\n");
934 while ((num_entries) && (entry_list) && (i < 50)) {
936 memset(flag_str,0x00,11);
937 if((proto == 1) || (proto == 2)) {
938 if(entry_list->
flags == 1) {
939 strncpy((
char *) flag_str,
"Active",6);
942 strncpy((
char *) flag_str,
"Non Active",10);
945 strncpy((
char *) flag_str,
"NA", 2);
948 inet_ntoa(ip), proto_str,
949 clib_net_to_host_u16(entry_list->
cnat_port),
950 clib_net_to_host_u16(entry_list->
src_port),
cnat_nfv9_global_info_t cnat_nfv9_global_info
cnat_main_db_entry_t * cnat_main_db
sll srl srl sll sra u16x4 i
u32 total_address_pool_allocated
cnat_syslog_global_info_t cnat_syslog_global_info
#define CNAT_DB_FLAG_PCPE
u16 cnat_static_port_range
#define CNAT_TRANSLATION_ENTRY_ALG
index_slist_t in2out_hash
#define V4_DEF_VRF_MAX_PORTS
#define CNAT_DB_FLAG_STATIC_PORT
u16 udp_init_session_timeout
#define CNAT_TRANSLATION_ENTRY_STATIC
u32 cnat_nfv9_global_collector_index
u32 cnat_get_vrfmap_nfv9_logging_index(u32 i_vrf_id)
cnat_portmap_v2_t * portmap_list
static u8 cnat_v4_show_verify_display_entry(u16 request_flag, cnat_main_db_entry_t *db, u16 *entry_flag_ptr)
void cnat_nat44_add_vrf_map_t_handler(spp_api_cnat_v4_add_vrf_map_t *mp, vlib_main_t *vm)
u16 cnat_main_db_max_ports_per_user
index_slist_t out2in_hash
void cnat_v4_show_inside_entry_req_t_handler(spp_api_cnat_v4_show_inside_entry_req_t *mp, vlib_main_t *vm)
index_slist_t * cnat_in2out_hash
#define CNAT_DB_FLAG_PPTP_GRE_ENTRY
#define pool_foreach(VAR, POOL, BODY)
u64 in2out_drops_system_limit_reached
#define CNAT_TRANSLATION_ENTRY_PCPE_DYNAMIC
void cnat_nat44_set_protocol_timeout_value(u16 active, u16 init, u8 *proto, u8 reset, vlib_main_t *vm)
u64 in2out_drops_port_limit_exceeded
#define CNAT_DB_FLAG_ALG_ENTRY
u16 vrf_map_array[CNAT_MAX_VRFMAP_ENTRIES]
void cnat_nfv9_show_collector(vlib_main_t *vm, cnat_nfv9_logging_info_t *my_nfv9_logging_info)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define CNAT_IPV4_FRAG_TIMEOUT_DEF
u32 translation_list_head_index
#define CNAT_DB_FLAG_PCPI
#define V4_TCP_MSS_NOT_CONFIGURED_VALUE
#define clib_memcpy(a, b, c)
struct _spp_api_cnat_v4_show_outside_entry_req spp_api_cnat_v4_show_outside_entry_req_t
u32 cnat_get_vrfmap_syslog_logging_index(u32 i_vrf_id)
struct _spp_api_cnat_v4_add_vrf_map spp_api_cnat_v4_add_vrf_map_t
bulk_alloc_size_t bulk_size
always_inline vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
void cnat_nat44_handle_show_config(vlib_main_t *vm)
#define BULKSIZE_FROM_VRFMAP(vrfmap)
#define CNAT_TRANSLATION_ENTRY_PCPI_DYNAMIC
#define CNAT_DB_FLAG_TCP_ACTIVE
u16 tcp_initial_setup_timeout
void cnat_nat44_handle_show_stats(vlib_main_t *vm)
index_slist_t * cnat_out2in_hash
struct _spp_api_cnat_v4_show_inside_entry_req spp_api_cnat_v4_show_inside_entry_req_t
void cnat_v4_show_outside_entry_req_t_handler(spp_api_cnat_v4_show_outside_entry_req_t *mp, vlib_main_t *vm)
cnat_nfv9_logging_info_t * cnat_nfv9_logging_info_pool
#define VRF_MAP_ENTRY_EMPTY
always_inline pool_header_t * pool_header(void *v)
cnat_syslog_logging_info_t * cnat_syslog_logging_info_pool
#define NAT44_COMMON_STATS
cnat_vrfmap_t * cnat_map_by_vrf
cnat_user_db_entry_t * cnat_user_db_lookup_entry(cnat_db_key_bucket_t *uki)
#define CNAT_MAIN_HASH_MASK
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
void cnat_table_entry_fill_map(u32 start_addr, u32 end_addr, cnat_portmap_v2_t **port_map_holder)
u16 udp_act_session_timeout
u64 in2out_drops_resource_depletion
#define CNAT_TRANSLATION_ENTRY_ALL
#define CNAT_DB_FLAG_UDP_ACTIVE
#define CNAT_V4_GET_HASH(key64, hash, mask)
void cnat_set_vrf_params_with_default(cnat_vrfmap_t *my_vrfmap, u32 i_vrf, u32 i_vrf_id)
#define CNAT_TRANSLATION_ENTRY_DYNAMIC
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".
#define CNAT_MAX_ADDR_POOL_SIZE