32 void spp_api_cnat_v4_config_dummy_t_handler
33 (spp_api_cnat_v4_config_dummy_t *mp);
35 void spp_api_cnat_v4_config_dummy_max_t_handler
36 (spp_api_cnat_v4_config_dummy_max_t *mp);
38 void spp_api_cnat_v4_config_icmp_timeout_t_handler
39 (spp_api_cnat_v4_config_icmp_timeout_t *mp);
41 void spp_api_cnat_clear_db_request_t_handler
42 (spp_api_cnat_clear_db_request_t *mp);
44 void spp_api_cnat_v4_debug_global_t_handler
45 (spp_api_cnat_v4_debug_global_t *mp);
47 void spp_api_cnat_v4_show_outside_entry_req_t_handler
50 void spp_api_cnat_v4_show_inside_entry_req_t_handler
53 void spp_api_cnat_show_statistics_summary_req_t_handler
54 (spp_api_cnat_show_statistics_summary_req_t *mp);
56 void cnat_db_create_db_entries_cmd (
int argc,
unsigned long *argv)
66 memset(&dest_info_dummy, 0,
sizeof(
cnat_key_t));
67 printf (
"Create %d users, 100 translations each...\n", nusers);
69 for (i = 0; i < nusers; i++) {
70 for (j = 0; j < 100; j++) {
73 key_info.
k.
k.
ipv4 = 0x0c000001+
i;
74 key_info.
k.
k.
port = 1024+j;
80 printf (
"OOPS: cnat_main_db_create failed users %d trans %d\n", i, j);
90 void db_test_clear (
int argc,
unsigned long *argv)
92 spp_api_cnat_clear_db_request_t mp;
94 mp.wildcard = argv[0];
95 mp.protocol = argv[1];
96 mp.port_num = argv[2];
97 mp.inside_vrf = argv[3];
99 spp_api_cnat_clear_db_request_t_handler(&mp);
103 void cnat_db_test_show (
int argc,
unsigned long *argv)
111 printf(
"Usage: db test show dec((which)) dec((vrf)) dec((proto)) dec((ip)) dec((start_port)) dec((end_port)) dec((flags))\n");
115 mp1[0].vrf_id = argv[1];
116 mp1[0].protocol = argv[2];;
117 mp1[0].ipv4_addr = argv[3];
118 mp1[0].start_port = argv[4];
119 mp1[0].end_port = argv[5];
120 mp1[0].flags = argv[6];
121 mp1[0].all_entries = 0;
124 spp_api_cnat_v4_show_inside_entry_req_t_handler (&(mp1[0]));
126 spp_api_cnat_v4_show_outside_entry_req_t_handler (&(mp2[0]));
131 printf(
"inside entries \n");
132 mp1[0].ipv4_addr = 0x016994CA;
134 mp1[0].all_entries = 0;
135 mp1[0].start_port = 32765;
136 mp1[0].end_port = 65535;
140 spp_api_cnat_v4_show_inside_entry_req_t_handler (&(mp1[0]));
142 mp2[0].ipv4_addr = 0x640200c1;
144 mp2[0].start_port = 1025;
145 mp2[0].end_port = 62235;
149 spp_api_cnat_v4_show_outside_entry_req_t_handler (&(mp2[0]));
154 spp_api_cnat_stats_node_mapping_t mp3[20000];
155 spp_api_cnat_stats_counter_mapping_t mp4[20000];
156 spp_api_cnat_stats_counter_values_t mp5[23000];
159 spp_api_cnat_stats_node_mapping_t_handler (&mp3);
161 spp_api_cnat_stats_counter_mapping_t_handler (&mp4);
164 spp_api_cnat_stats_counter_values_t_handler(&mp5);
169 mp1.ipv4_addr = 0x0A010102;
174 spp_api_cnat_v4_show_inside_entry_req_t_handler (&mp1);
177 mp1.ipv4_addr = 0x0A010103;
182 spp_api_cnat_v4_show_inside_entry_req_t_handler (&mp1);
184 mp6[0].inside_vrf_id = 1;
185 mp6[0].start_ipv4_address = 0x64020001;
186 mp6[0].end_ipv4_address = 0x64020101;
187 mp6[0].free_addr = 0;
190 spp_api_cnat_v4_show_freeUsed_entry_req_t_handler(&mp6);
193 printf(
"returned here");
200 void cnat_db_clear_all_entries (
int argc,
unsigned long *argv)
220 void spp_log_cmd (
int argc,
unsigned long *argv)
228 num_traces = argv[0];
230 for (i = 0; i < num_traces; i++) {
231 error_code = argv[1 + 4*
i];
232 num_args = argv[2 + 4*
i];
233 arg[0] = argv[3 + 4*
i];
234 arg[1] = argv[4 + 4*
i];
241 void cnat_db_create_random_entries (
int argc,
unsigned long *argv)
244 platform_cnat_db_create_random_entries();
249 void show_user_db_hash_chain_len() {
251 u32 max_len, len, n,
i, max_idx, index, used;
253 u32 hash_depth[MAX_DEPTH];
255 memset(hash_depth, 0,
sizeof(
u32)*MAX_DEPTH);
266 if (index !=
EMPTY) used++;
268 while (index !=
EMPTY) {
274 if(len < (MAX_DEPTH-1) ) {
277 hash_depth[MAX_DEPTH-1]++;
286 printf(
"Max user db hash length %u, total buckets %u used %u\n",
289 for( i=1; i<(MAX_DEPTH - 1); i++) {
290 printf(
"Hash chain len %02d, entries count %d\n", i, hash_depth[i]);
293 printf(
"Hash chain len >%02d, entries count %d\n",
294 MAX_DEPTH-1, hash_depth[MAX_DEPTH-1]);
298 void show_main_db_hash_chain_len() {
300 u32 max_len, len, n,
i, max_idx, index, used;
302 u32 hash_depth[MAX_DEPTH];
304 memset(hash_depth, 0,
sizeof(
u32)*MAX_DEPTH);
315 if (index !=
EMPTY) used++;
317 while (index !=
EMPTY) {
323 if(len < (MAX_DEPTH-1) ) {
326 hash_depth[MAX_DEPTH-1]++;
335 printf(
"Max main db I2O hash length %u, total buckets %u used %u\n",
338 for( i=1; i<(MAX_DEPTH - 1); i++) {
339 printf(
"Hash chain len %02d, entries count %d\n", i, hash_depth[i]);
342 printf(
"Hash chain len >%02d, entries count %d\n",
343 MAX_DEPTH-1, hash_depth[MAX_DEPTH-1]);
346 memset(hash_depth, 0,
sizeof(
u32)*MAX_DEPTH);
357 if (index !=
EMPTY) used++;
359 while (index !=
EMPTY) {
365 if(len < (MAX_DEPTH-1) ) {
368 hash_depth[MAX_DEPTH-1]++;
377 printf(
"Max main db O2I hash length %u, total buckets %u used %u\n",
380 for( i=1; i<(MAX_DEPTH - 1); i++) {
381 printf(
"Hash chain len %02d, entries count %d\n", i, hash_depth[i]);
384 printf(
"Hash chain len >%02d, entries count %d\n",
385 MAX_DEPTH-1, hash_depth[MAX_DEPTH-1]);
402 void cnat_db_summary (
int argc,
unsigned long *argv) {
407 u32 count1, count2,
i;
409 extern void nat64_session_db_summary();
415 PLATFORM_DEBUG_PRINT(
"main db entries: total %u, active %u, free %u\n", count1, count1 - count2, count2);
421 PLATFORM_DEBUG_PRINT(
"user db entries: total %u, active %u, free %u\n", count1, count1 - count2, count2);
426 nat64_session_db_summary();
441 CNAT_MAIN_HASH_SIZE, count1,
442 (100.0*count1)/CNAT_MAIN_HASH_SIZE);
445 CNAT_MAIN_HASH_SIZE, count2,
446 (100.0 * count1)/CNAT_MAIN_HASH_SIZE);
457 CNAT_USER_HASH_SIZE, count1,
458 (100.0*count1)/CNAT_USER_HASH_SIZE);
469 #ifndef CGN_PERF_SCALE_DEBUG 481 void cnat_db_hash_summary (
int argc,
unsigned long *argv) {
483 show_main_db_hash_chain_len();
485 show_user_db_hash_chain_len();
497 int *index,
u32 *ipv4_address,
u16 *base_port)
501 int *index,
u32 *ipv4_address,
u16 *base_port)
523 void spp_api_cnat_port_allocate_t_handler(spp_api_cnat_port_allocate_t *mp)
530 char *out1, *out2, *out_f;
541 char out_r[12] =
"allocated-r";
542 char out_o[12] =
"allocated-o";
543 char out_e[12] =
"allocated-e";
560 printf(
"need to run db create portmaps first 0x%d\n",
565 nr_ports = mp->nr_ports;
566 nodd_ports = mp->nodd_ports;
567 neven_ports = mp->neven_ports;
570 printf(
"invalid port# nr_ports %d + odd %d + even %d " 571 "should be less than 200 \n", nr_ports, nodd_ports, neven_ports);
578 firstp = nr_ports ? (&nr_ports) : (nodd_ports ? (&nodd_ports) : (&neven_ports));
580 printf(
"invalid port# nr_ports %d odd %d even %d ",
581 nr_ports, nodd_ports, neven_ports);
583 out_f = nr_ports ? out_r : (nodd_ports ? out_o : out_e);
586 rv = cnat_port_alloc (pm, pm_inuse, my_instance,
588 &pm_index, &ipv4_address, &aport);
590 rv = cnat_port_alloc (pm, pm_inuse,
592 &pm_index, &ipv4_address, &aport);
596 printf(
"failed-o\n");
599 printf(
"%s %8d %10x %8d\n", out_f,
600 pm_index, ipv4_address, aport);
604 for (i=0; i < nr_ports; i++) {
606 rv = cnat_port_alloc (pm, pm_inuse, my_instance,
608 &pm_index, &ipv4_address, &aport);
610 rv = cnat_port_alloc (pm, pm_inuse,
612 &pm_index, &ipv4_address, &aport);
615 printf(
"%s %8d %10x %8d\n", out_r,
616 pm_index, ipv4_address, aport);
618 printf(
"%s failed\n", out_r);
623 if (nodd_ports > neven_ports) {
640 for (i=0; i < k1; i++) {
642 rv = cnat_port_alloc (pm, pm_inuse, my_instance,
644 &pm_index, &ipv4_address, &aport);
646 rv = cnat_port_alloc (pm, pm_inuse,
648 &pm_index, &ipv4_address, &aport);
651 printf(
"%s %8d %10x %8d\n", out1,
652 pm_index, ipv4_address, aport);
654 printf(
"%s failed\n", out1);
660 rv = cnat_port_alloc (pm, pm_inuse, my_instance,
662 &pm_index, &ipv4_address, &aport);
664 rv = cnat_port_alloc (pm, pm_inuse,
666 &pm_index, &ipv4_address, &aport);
670 printf(
"%s %8d %10x %8d\n", out2,
671 pm_index, ipv4_address, aport);
674 printf(
"%s failed\n", __FUNCTION__);
681 void cnat_db_summary_stats (
int argc,
unsigned long *argv)
683 spp_api_cnat_show_statistics_summary_req_t mp[50000];
685 spp_api_cnat_show_statistics_summary_req_t_handler(&(mp[0]));
688 void cnat_debug_global_test (
int argc,
unsigned long *argv)
690 spp_api_cnat_v4_debug_global_t *mp;
691 spp_api_cnat_v4_config_dummy_t mp1;
692 spp_api_cnat_v4_config_icmp_timeout_t mp2[10];
694 mp = spp_msg_api_alloc (
sizeof (*mp));
695 memset(mp, 0,
sizeof (*mp));
698 mp->_spp_msg_id = SPP_API_CNAT_V4_DEBUG_GLOBAL;
699 mp->debug_flag = argv[0];
701 platform_send_msg(mp);
703 mp2[0].default_value = 3;
705 spp_api_cnat_v4_config_dummy_t_handler(&mp1);
706 spp_api_cnat_v4_config_icmp_timeout_t_handler(&(mp2[0]));
709 void cnat_debug_inside_test (
int argc,
unsigned long *argv)
712 spp_api_cnat_v4_debug_in2out_private_addr_t *mp;
714 mp = spp_msg_api_alloc (
sizeof (*mp));
715 memset(mp, 0,
sizeof (*mp));
718 mp->_spp_msg_id = SPP_API_CNAT_V4_DEBUG_IN2OUT_PRIVATE_ADDR;
720 mp->start_addr = spp_host_to_net_byte_order_32(argv[0]);
721 mp->end_addr = spp_host_to_net_byte_order_32(argv[1]);
722 mp->i_vrf = spp_host_to_net_byte_order_16(argv[2]);
723 mp->debug_flag = spp_host_to_net_byte_order_32(argv[3]);
725 platform_send_msg(mp);
728 void cnat_config_ports_user (
int argc,
unsigned long *argv)
730 spp_api_cnat_v4_config_port_limit_t *mp;
732 mp = spp_msg_api_alloc (
sizeof (*mp));
733 memset(mp, 0,
sizeof (*mp));
736 mp->_spp_msg_id = SPP_API_CNAT_V4_CONFIG_PORT_LIMIT;
738 mp->port_limit = spp_host_to_net_byte_order_16(argv[0]);
740 platform_send_msg(mp);
744 void cnat_debug_outside_test (
int argc,
unsigned long *argv)
747 spp_api_cnat_v4_debug_out2in_public_addr_t *mp;
749 mp = spp_msg_api_alloc (
sizeof (*mp));
750 memset(mp, 0,
sizeof (*mp));
753 mp->_spp_msg_id = SPP_API_CNAT_V4_DEBUG_OUT2IN_PUBLIC_ADDR;
755 mp->start_addr = spp_host_to_net_byte_order_32(argv[0]);
756 mp->end_addr = spp_host_to_net_byte_order_32(argv[1]);
757 mp->o_vrf = spp_host_to_net_byte_order_16(argv[2]);
758 mp->debug_flag = spp_host_to_net_byte_order_32(argv[3]);
760 platform_send_msg(mp);
763 void cnat_debug_udp_dump (
int argc,
unsigned long *argv)
766 spp_api_cnat_p2mp_debug_request_t *mp;
768 mp = spp_msg_api_alloc (
sizeof (*mp));
769 memset(mp, 0,
sizeof (*mp));
772 mp->_spp_msg_id = SPP_API_CNAT_P2MP_DEBUG_REQUEST;
776 if (spp_host_to_net_byte_order_32(argv[0]) == 1) {
777 mp->param[0] = spp_host_to_net_byte_order_32(
780 mp->param[0] = spp_host_to_net_byte_order_32(
783 mp->param[1] = spp_host_to_net_byte_order_32(argv[1]);
785 platform_send_msg(mp);
791 void cnat_debug_udp_crc (
int argc,
unsigned long *argv)
793 spp_api_cnat_p2mp_debug_request_t *mp;
795 mp = spp_msg_api_alloc (
sizeof (*mp));
796 memset(mp, 0,
sizeof (*mp));
799 mp->_spp_msg_id = SPP_API_CNAT_P2MP_DEBUG_REQUEST;
803 if (spp_host_to_net_byte_order_32(argv[0]) == 1) {
804 mp->param[0] = spp_host_to_net_byte_order_32(
807 mp->param[0] = spp_host_to_net_byte_order_32(
810 mp->param[1] = spp_host_to_net_byte_order_32(argv[1]);
812 platform_send_msg(mp);
816 void cnat_db_allocate_port_cmd (
int argc,
unsigned long *argv)
818 spp_api_cnat_port_allocate_t *mp;
822 printf(
"no port# defined\n");
827 printf(
"no port# defined\n");
831 if ((argc == 3) && (argv[0] == 0) && (argv[1] == 0) && (argv[2] == 0)) {
832 printf(
"no port# defined\n");
836 mp = spp_msg_api_alloc (
sizeof (*mp));
837 memset(mp, 0,
sizeof (*mp));
840 mp->_spp_msg_id = SPP_API_CNAT_PORT_ALLOCATE;
841 mp->nr_ports = argv[0];
842 mp->nodd_ports = argv[1];
843 mp->neven_ports = argv[2];
846 platform_send_msg(mp);
850 void spp_api_cnat_port_clear_t_handler(spp_api_cnat_port_clear_t *mp)
874 printf(
"portmap is not created 0x%d\n",
879 if (mp->pm_index >=
vec_len(pm)) {
880 printf(
"invalid port_index 0x%d >= 0x%d\n",
886 cnat_port_free(pm, pm_inuse, my_instance,
889 cnat_port_free(pm, pm_inuse,
892 printf(
"\n pm_index %d port %d is deleted\n", mp->pm_index, mp->port);
897 void cnat_db_clear_port_cmd (
int argc,
unsigned long *argv)
899 spp_api_cnat_port_clear_t *mp;
902 printf(
"no port# defined\n");
907 printf(
"no port# defined\n");
912 printf(
"too many port# defined\n");
916 mp = spp_msg_api_alloc (
sizeof (*mp));
917 memset(mp, 0,
sizeof (*mp));
920 mp->_spp_msg_id = SPP_API_CNAT_PORT_CLEAR;
921 mp->pm_index = argv[0];
925 platform_send_msg(mp);
929 void spp_api_cnat_v4_add_vrf_map_t_handler
932 void spp_api_cnat_v4_del_vrf_map_t_handler
933 (spp_api_cnat_v4_del_vrf_map_t *mp);
935 void spp_api_cnat_v4_add_static_port_t_handler
936 (spp_api_cnat_v4_add_static_port_t *mp);
938 void spp_api_cnat_v4_del_static_port_t_handler
939 (spp_api_cnat_v4_del_static_port_t *mp);
942 void cnat_db_create_vrfmap_cmd (
int argc,
unsigned long *argv)
947 printf(
"need right input\n");
951 mp = spp_msg_api_alloc (
sizeof (*mp));
952 memset(mp, 0,
sizeof (*mp));
953 mp->_spp_msg_id = SPP_API_CNAT_V4_ADD_VRF_MAP;
954 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
955 mp->o_vrf = spp_host_to_net_byte_order_16(argv[1]);
956 mp->start_addr[0] = spp_host_to_net_byte_order_32(argv[2]);
957 mp->end_addr[0] = spp_host_to_net_byte_order_32(argv[3]);
962 mp->i_vrf_id = spp_host_to_net_byte_order_32(0x00000100 | mp->i_vrf);
963 mp->o_vrf_id = spp_host_to_net_byte_order_32(0x00000200 | mp->o_vrf);
965 platform_send_msg(mp);
969 void cnat_db_delete_vrfmap_cmd (
int argc,
unsigned long *argv)
971 spp_api_cnat_v4_del_vrf_map_t *mp;
974 printf(
"need right input\n");
978 mp = spp_msg_api_alloc (
sizeof (*mp));
979 memset(mp, 0,
sizeof (*mp));
980 mp->_spp_msg_id = SPP_API_CNAT_V4_DEL_VRF_MAP;
981 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
982 mp->start_addr[0] = spp_host_to_net_byte_order_32(argv[2]);
983 mp->end_addr[0] = spp_host_to_net_byte_order_32(argv[3]);
985 platform_send_msg(mp);
988 void cnat_db_add_svi_cmd (
int argc,
unsigned long *argv)
990 spp_api_cnat_config_svi_params_t *mp;
993 printf(
"need right input\n");
998 mp = spp_msg_api_alloc (
sizeof (*mp));
999 memset(mp, 0,
sizeof (*mp));
1000 mp->_spp_msg_id = SPP_API_CNAT_CONFIG_SVI_PARAMS;
1001 mp->uidb_index = spp_host_to_net_byte_order_16(argv[1]);
1002 mp->svi_ipv4_addr = spp_host_to_net_byte_order_32(argv[2]);
1003 platform_send_msg(mp);
1009 void spp_api_cnat_port_create_t_handler(spp_api_cnat_port_create_t *mp)
1018 char *out1, *out2, *out_f;
1025 u32 neven_ports = 0;
1027 u32 my_instance = 1;
1029 char out_r[12] =
"allocated-r";
1030 char out_o[12] =
"allocated-o";
1031 char out_e[12] =
"allocated-e";
1032 #ifndef NO_BULK_LOGGING 1036 nr_ports = mp->nr_ports;
1037 nodd_ports = mp->nodd_ports;
1038 neven_ports = mp->neven_ports;
1048 (my_vrfmap->
i_vrf == i_vrf)) {
1049 pm = my_vrfmap->portmap_list;
1050 pm_len = vec_len(pm);
1052 goto found_portmaps;
1057 printf(
"need to run db create vrfmaps first for this vrf0x%d\n", pm_len);
1063 printf(
"invalid port# nr_ports %d + odd %d + even %d " 1064 "should be less than 200 \n", nr_ports, nodd_ports, neven_ports);
1071 firstp = nr_ports ? (&nr_ports) : (nodd_ports ? (&nodd_ports) : (&neven_ports));
1073 printf(
"invalid port# nr_ports %d odd %d even %d ",
1074 nr_ports, nodd_ports, neven_ports);
1076 out_f = nr_ports ? out_r : (nodd_ports ? out_o : out_e);
1079 &my_index, &ipv4_address, &aport,
1081 #ifndef NO_BULK_LOGGING
1090 printf(
"failed-o\n");
1093 printf(
"%s %8d %10x %8d\n", out_f,
1094 my_index, ipv4_address, aport);
1098 for (i=0; i < nr_ports; i++) {
1100 &my_index, &ipv4_address, &aport,
1102 #ifndef NO_BULK_LOGGING
1111 printf(
"%s %8d %10x %8d\n", out_r,
1112 my_index, ipv4_address, aport);
1114 printf(
"%s failed\n", __FUNCTION__);
1119 if (nodd_ports > neven_ports) {
1136 for (i=0; i < k1; i++) {
1138 &my_index, &ipv4_address, &aport,
1140 #ifndef NO_BULK_LOGGING
1149 printf(
"%s %8d %10x %8d\n", out1,
1150 my_index, ipv4_address, aport);
1152 printf(
"%s failed\n", __FUNCTION__);
1158 &my_index, &ipv4_address, &aport,
1160 #ifndef NO_BULK_LOGGING
1169 printf(
"%s %8d %10x %8d\n", out2,
1170 my_index, ipv4_address, aport);
1173 printf(
"%s failed\n", __FUNCTION__);
1182 void cnat_db_create_port_cmd (
int argc,
unsigned long *argv)
1184 spp_api_cnat_port_create_t *mp;
1187 printf(
"no proper input defined\n");
1191 if ((argv[0] == 0) && (argv[1] == 0) && (argv[2] == 0)) {
1192 printf(
"no port# defined\n");
1196 mp = spp_msg_api_alloc (
sizeof (*mp));
1197 memset(mp, 0,
sizeof (*mp));
1200 mp->_spp_msg_id = SPP_API_CNAT_PORT_CREATE;
1201 mp->nr_ports = argv[0];
1202 mp->nodd_ports = argv[1];
1203 mp->neven_ports = argv[2];
1206 platform_send_msg(mp);
1209 void spp_api_cnat_port_delete_t_handler(spp_api_cnat_port_delete_t *mp)
1215 u32 my_index, my_port;
1218 u32 my_instance = 1;
1221 my_index = mp->pm_index;
1229 if (my_vrfmap->
i_vrf == i_vrf) {
1230 pm = my_vrfmap->portmap_list;
1231 pm_len = vec_len(pm);
1233 goto found_portmaps;
1238 printf(
"portmap is not created 0x%d\n",
1243 if (my_index >= pm_len) {
1244 printf(
"invalid port_index 0x%d >= 0x%d\n",
1255 printf(
"\n pm_index %d port %d is deleted\n", mp->pm_index, mp->port);
1258 void cnat_db_delete_port_cmd (
int argc,
unsigned long *argv)
1260 spp_api_cnat_port_clear_t *mp;
1263 printf(
"no proper input defined\n");
1267 mp = spp_msg_api_alloc (
sizeof (*mp));
1268 memset(mp, 0,
sizeof (*mp));
1271 mp->_spp_msg_id = SPP_API_CNAT_PORT_DELETE;
1272 mp->pm_index = argv[0];
1275 platform_send_msg(mp);
1278 void cnat_db_create_static_fwd_cmd (
int argc,
unsigned long *argv)
1280 spp_api_cnat_v4_add_static_port_t *mp;
1283 printf(
"need right input\n");
1287 mp = spp_msg_api_alloc (
sizeof (*mp));
1288 memset(mp, 0,
sizeof (*mp));
1289 mp->_spp_msg_id = SPP_API_CNAT_V4_ADD_STATIC_PORT;
1290 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
1291 mp->i_ip = spp_host_to_net_byte_order_32(argv[1]);
1292 mp->i_port = spp_host_to_net_byte_order_16(argv[2]);
1293 mp->proto = argv[3];
1295 platform_send_msg(mp);
1299 void cnat_db_create_static_fwd_stby_cmd (
int argc,
unsigned long *argv)
1301 spp_api_cnat_v4_add_static_port_t *mp;
1304 printf(
"need right input\n");
1308 mp = spp_msg_api_alloc (
sizeof (*mp));
1309 memset(mp, 0,
sizeof (*mp));
1310 mp->_spp_msg_id = SPP_API_CNAT_V4_ADD_STATIC_PORT;
1311 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
1312 mp->i_ip = spp_host_to_net_byte_order_32(argv[1]);
1313 mp->i_port = spp_host_to_net_byte_order_16(argv[2]);
1314 mp->proto = argv[3];
1315 mp->o_vrf_id = spp_host_to_net_byte_order_32(argv[4]);
1316 mp->o_ip = spp_host_to_net_byte_order_32(argv[5]);
1317 mp->o_port = spp_host_to_net_byte_order_16(argv[6]);
1319 printf(
"\ni_vrf %d, ip 0x%x, port %d, o_ip, port %d", mp->i_vrf, mp->i_ip, mp->i_port, mp->o_ip, mp->o_port);
1321 platform_send_msg(mp);
1325 void cnat_db_delete_static_fwd_cmd (
int argc,
unsigned long *argv)
1327 spp_api_cnat_v4_del_static_port_t *mp;
1330 printf(
"need right input\n");
1334 mp = spp_msg_api_alloc (
sizeof (*mp));
1335 memset(mp, 0,
sizeof (*mp));
1336 mp->_spp_msg_id = SPP_API_CNAT_V4_DEL_STATIC_PORT;
1337 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
1338 mp->i_ip = spp_host_to_net_byte_order_32(argv[1]);
1339 mp->i_port = spp_host_to_net_byte_order_16(argv[2]);
1341 platform_send_msg(mp);
1345 void cnat_nfv9_create_cmd (
int argc,
unsigned long *argv)
1350 printf(
"nfv9 create i_vrf ip_addr port [refresh_rate] [timeout] [mtu]");
1354 mp = spp_msg_api_alloc (
sizeof (*mp));
1355 memset(mp, 0,
sizeof (*mp));
1356 mp->_spp_msg_id = SPP_API_CNAT_V4_CONFIG_NFV9_LOGGING;
1358 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
1360 mp->ipv4_address = spp_host_to_net_byte_order_32(argv[1]);
1361 mp->port = spp_host_to_net_byte_order_16(argv[2]);
1364 mp->refresh_rate = spp_host_to_net_byte_order_16(argv[3]);
1365 mp->timeout_rate = spp_host_to_net_byte_order_16(argv[4]);
1366 mp->path_mtu = spp_host_to_net_byte_order_16(argv[5]);
1368 mp->refresh_rate = spp_host_to_net_byte_order_16(1000);
1369 mp->timeout_rate = spp_host_to_net_byte_order_16(30);
1370 mp->path_mtu = spp_host_to_net_byte_order_16(1500);
1372 platform_send_msg(mp);
1375 void cnat_delete_cgn (
int argc,
unsigned long *argv)
1378 spp_api_cnat_del_cgn_t *mp;
1381 mp_size =
sizeof(spp_api_cnat_del_cgn_t);
1383 mp = spp_msg_api_alloc(mp_size);
1384 memset(mp, 0, mp_size);
1386 mp->_spp_msg_id = SPP_API_CNAT_DEL_CGN;
1390 platform_send_msg(mp);
1393 void cnat_debug_global_all (
int argc,
unsigned long *argv)
1395 spp_api_cnat_v4_debug_global_t *mp;
1397 mp = spp_msg_api_alloc (
sizeof (*mp));
1398 memset(mp, 0,
sizeof (*mp));
1400 mp->_spp_msg_id = SPP_API_CNAT_V4_DEBUG_GLOBAL;
1403 platform_send_msg(mp);
1406 void cnat_debug_global_none (
int argc,
unsigned long *argv)
1408 spp_api_cnat_v4_debug_global_t *mp;
1410 mp = spp_msg_api_alloc (
sizeof (*mp));
1411 memset(mp, 0,
sizeof (*mp));
1413 mp->_spp_msg_id = SPP_API_CNAT_V4_DEBUG_GLOBAL;
1416 platform_send_msg(mp);
1420 void cnat_bulk_cmd (
int argc,
unsigned long *argv)
1425 printf(
"\nargc = %d", argc);
1426 printf(
"\n1. bulk cmd [0=static-port, 1=bulk_vrf, 2=policy_knob]");
1434 spp_api_cnat_v4_bulk_add_delete_static_port_t *mp;
1435 spp_api_cnat_v4_add_static_port_t *mp_sp;
1437 sizeof(spp_api_cnat_v4_bulk_add_delete_static_port_t) +
1438 (
sizeof(spp_api_cnat_v4_add_static_port_t))*2;
1440 mp = spp_msg_api_alloc(mp_size);
1441 memset(mp, 0, mp_size);
1443 mp->_spp_msg_id = SPP_API_CNAT_V4_BULK_ADD_DELETE_STATIC_PORT;
1445 mp->num_static_port_entries = spp_host_to_net_byte_order_32(3);
1447 mp_sp = (spp_api_cnat_v4_add_static_port_t *) &(mp->pad2);
1449 mp_sp->_spp_msg_id = spp_host_to_net_byte_order_16(
1450 SPP_API_CNAT_V4_ADD_STATIC_PORT);
1452 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x1);
1453 mp_sp->i_ip = spp_host_to_net_byte_order_32(0x11111111);
1454 mp_sp->i_port = spp_host_to_net_byte_order_16(0x7777);
1459 mp_sp->_spp_msg_id = spp_host_to_net_byte_order_16(
1460 SPP_API_CNAT_V4_ADD_STATIC_PORT);
1462 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x1);
1463 mp_sp->i_ip = spp_host_to_net_byte_order_32(0x22222222);
1464 mp_sp->i_port = spp_host_to_net_byte_order_16(0x6666);
1469 mp_sp->_spp_msg_id = spp_host_to_net_byte_order_16(
1470 SPP_API_CNAT_V4_ADD_STATIC_PORT);
1472 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x1);
1473 mp_sp->i_ip = spp_host_to_net_byte_order_32(0x33333333);
1474 mp_sp->i_port = spp_host_to_net_byte_order_16(0x5555);
1483 spp_api_cnat_v4_bulk_vrf_map_t *mp;
1486 u32 mp_size =
sizeof(spp_api_cnat_v4_bulk_vrf_map_t) +
1489 mp = spp_msg_api_alloc(mp_size);
1490 memset(mp, 0, mp_size);
1492 mp->_spp_msg_id = SPP_API_CNAT_V4_BULK_VRF_MAP;
1494 mp->num_vrfmap_entries = spp_host_to_net_byte_order_32(3);
1497 &(mp->vrf_policy_enable);
1499 mp_sp->i_vrf_id = spp_host_to_net_byte_order_32(0xe0000001);
1500 mp_sp->o_vrf_id = spp_host_to_net_byte_order_32(0xe0000000);
1501 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x1);
1502 mp_sp->o_vrf = spp_host_to_net_byte_order_16(0x0);
1503 mp_sp->start_addr = spp_host_to_net_byte_order_32(0x11111100);
1504 mp_sp->end_addr = spp_host_to_net_byte_order_32(0x111111ff);
1505 mp_sp->vrf_policy_enable = spp_host_to_net_byte_order_16(0x3);
1506 mp_sp->tcp_mss_value = spp_host_to_net_byte_order_16(0x111);
1507 mp_sp->vrf_nfv9_logging_ipv4_address = spp_host_to_net_byte_order_32(0x11000001);
1508 mp_sp->vrf_nfv9_logging_udp_port = spp_host_to_net_byte_order_16(0x1001);
1509 mp_sp->vrf_nfv9_refresh_rate = spp_host_to_net_byte_order_16(0x100);
1510 mp_sp->vrf_nfv9_timeout_rate = spp_host_to_net_byte_order_16(0x10);
1511 mp_sp->vrf_nfv9_path_mtu = spp_host_to_net_byte_order_16(0x100);
1515 mp_sp->i_vrf_id = spp_host_to_net_byte_order_32(0xe0000002);
1516 mp_sp->o_vrf_id = spp_host_to_net_byte_order_32(0xe0000000);
1517 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x2);
1518 mp_sp->o_vrf = spp_host_to_net_byte_order_16(0x0);
1519 mp_sp->start_addr = spp_host_to_net_byte_order_32(0x22220000);
1520 mp_sp->end_addr = spp_host_to_net_byte_order_32(0x2222ffff);
1521 mp_sp->vrf_policy_enable = spp_host_to_net_byte_order_16(0x1);
1522 mp_sp->tcp_mss_value = spp_host_to_net_byte_order_16(0x222);
1523 mp_sp->vrf_nfv9_logging_ipv4_address = spp_host_to_net_byte_order_32(0x22000002);
1524 mp_sp->vrf_nfv9_logging_udp_port = spp_host_to_net_byte_order_16(0x2002);
1525 mp_sp->vrf_nfv9_refresh_rate = spp_host_to_net_byte_order_16(0x200);
1526 mp_sp->vrf_nfv9_timeout_rate = spp_host_to_net_byte_order_16(0x20);
1527 mp_sp->vrf_nfv9_path_mtu = spp_host_to_net_byte_order_16(0x200);
1531 mp_sp->i_vrf_id = spp_host_to_net_byte_order_32(0xe0000003);
1532 mp_sp->o_vrf_id = spp_host_to_net_byte_order_32(0xe0000007);
1533 mp_sp->i_vrf = spp_host_to_net_byte_order_16(0x3);
1534 mp_sp->o_vrf = spp_host_to_net_byte_order_16(0x7);
1535 mp_sp->start_addr = spp_host_to_net_byte_order_32(0x33333000);
1536 mp_sp->end_addr = spp_host_to_net_byte_order_32(0x33333fff);
1537 mp_sp->vrf_policy_enable = spp_host_to_net_byte_order_16(0x1);
1538 mp_sp->tcp_mss_value = spp_host_to_net_byte_order_16(0x333);
1539 mp_sp->vrf_nfv9_logging_ipv4_address = spp_host_to_net_byte_order_32(0x33000003);
1540 mp_sp->vrf_nfv9_logging_udp_port = spp_host_to_net_byte_order_16(0x3003);
1541 mp_sp->vrf_nfv9_refresh_rate = spp_host_to_net_byte_order_16(0x300);
1542 mp_sp->vrf_nfv9_timeout_rate = spp_host_to_net_byte_order_16(0x30);
1543 mp_sp->vrf_nfv9_path_mtu = spp_host_to_net_byte_order_16(0x300);
1551 spp_api_cnat_v4_bulk_policy_knob_t *mp;
1554 sizeof(spp_api_cnat_v4_bulk_policy_knob_t) +
1557 mp = spp_msg_api_alloc(mp_size);
1558 memset(mp, 0, mp_size);
1560 mp->_spp_msg_id = SPP_API_CNAT_V4_BULK_POLICY_KNOB;
1562 mp->port_limit = spp_host_to_net_byte_order_16(345);
1563 mp->icmp_timeout = spp_host_to_net_byte_order_16(300);
1564 mp->udp_init_timeout = spp_host_to_net_byte_order_16(175);
1565 mp->udp_act_timeout = spp_host_to_net_byte_order_16(133);
1566 mp->tcp_init_timeout = spp_host_to_net_byte_order_16(222);
1567 mp->tcp_act_timeout = spp_host_to_net_byte_order_16(2345);
1569 mp->nat_policy_enable = spp_host_to_net_byte_order_32(0x7);
1571 mp->global_nfv9_logging_ipv4_address = spp_host_to_net_byte_order_32(0x77777777);
1572 mp->global_nfv9_logging_udp_port = spp_host_to_net_byte_order_16(0x7007);
1573 mp->global_nfv9_refresh_rate = spp_host_to_net_byte_order_16(0x700);
1574 mp->global_nfv9_timeout_rate = spp_host_to_net_byte_order_16(0x70);
1575 mp->global_nfv9_path_mtu = spp_host_to_net_byte_order_16(0x700);
1583 printf(
"\nargv[2] = %d", argv[2]);
1584 printf(
"\n2. bulk cmd [0=static-port, 1=bulk_vrf, 2=policy_knob+bulk_vrf]");
1588 platform_send_msg(mp_send);
1591 void cnat_nfv9_delete_cmd (
int argc,
unsigned long *argv)
1596 printf(
"nfv9 delete i_vrf ");
1600 mp = spp_msg_api_alloc (
sizeof (*mp));
1601 memset(mp, 0,
sizeof (*mp));
1602 mp->_spp_msg_id = SPP_API_CNAT_V4_CONFIG_NFV9_LOGGING;
1604 mp->i_vrf = spp_host_to_net_byte_order_16(argv[0]);
1605 platform_send_msg(mp);
1608 void cnat_generic_cmd (
int argc,
unsigned long *argv)
1610 spp_api_cnat_generic_command_request_t *mp;
1613 printf(
"generic command core type p1 p2 p3 p4 p5 p6 p7 ");
1620 mp = spp_msg_api_alloc (MAX_DEBUG_BUFFER_SIZE);
1621 memset(mp, 0, MAX_DEBUG_BUFFER_SIZE);
1622 mp->_spp_msg_id = SPP_API_CNAT_GENERIC_COMMAND_REQUEST;
1623 mp->core_num = argv[0];
1624 mp->params[0] = spp_host_to_net_byte_order_32(argv[1]);
1625 mp->params[1] = spp_host_to_net_byte_order_32(argv[2]);
1626 mp->params[2] = spp_host_to_net_byte_order_32(argv[3]);
1627 mp->params[3] = spp_host_to_net_byte_order_32(argv[4]);
1628 mp->params[4] = spp_host_to_net_byte_order_32(argv[5]);
1629 mp->params[5] = spp_host_to_net_byte_order_32(argv[6]);
1630 mp->params[6] = spp_host_to_net_byte_order_32(argv[7]);
1631 mp->params[7] = spp_host_to_net_byte_order_32(argv[8]);
1632 platform_send_msg(mp);
1635 u32 icmp_sent_timestamps;
1636 u8 v4_pkt_count = 0;
1640 #ifdef DISABLE_ICMP_THROTTLE_FOR_DEBUG_PURPOSE 1643 u32 current_timestamp;
1644 spp_node_main_vector_t *nmv;
1645 u32 updated_timestamp;
1649 nmv = spp_get_node_main_vectorized_inline();
1651 current_timestamp = nmv->ticks / nmv->ticks_per_second;
1653 PLATFORM_UPDATE_TIMESTAMP
1654 if (
PREDICT_FALSE(icmp_sent_timestamps != updated_timestamp)) {
1657 icmp_sent_timestamps = updated_timestamp;
1667 u32 v6_icmp_sent_timestamps;
1668 u8 v6_pkt_count = 0;
1672 #ifdef DISABLE_ICMP_THROTTLE_FOR_DEBUG_PURPOSE 1675 u32 current_timestamp;
1676 spp_node_main_vector_t *nmv;
1677 u32 updated_timestamp;
1679 nmv = spp_get_node_main_vectorized_inline();
1681 current_timestamp = nmv->ticks / nmv->ticks_per_second;
1682 PLATFORM_UPDATE_TIMESTAMP
1685 if (
PREDICT_FALSE(v6_icmp_sent_timestamps != updated_timestamp)) {
1688 v6_icmp_sent_timestamps = updated_timestamp;
1698 u32 v4_udp_crc_zero_timestamps;
1699 u32 v4_udp_crc_zero_pkt_count = 0;
1702 PLATFORM_V4_CRC_ZERO_UDP_ALLOWED
1704 spp_node_main_vector_t *nmv;
1705 u32 hash_value, current_timestamp;
1707 nmv = spp_get_node_main_vectorized_inline();
1709 current_timestamp = nmv->ticks / nmv->ticks_per_second;
1710 v4_udp_crc_zero_pkt_count++;
1711 if (
PREDICT_FALSE(v4_udp_crc_zero_timestamps != current_timestamp)) {
1712 v4_udp_crc_zero_pkt_count = 1;
1713 v4_udp_crc_zero_timestamps = current_timestamp;
1734 old = ntohs(*(
u16 *)&ipv4->
ttl);
1740 checksum = old + (~ntohs(*(
u16 *)&ipv4->
ttl) & 0xFFFF);
1742 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1743 ipv4->
checksum = htons(checksum + (checksum >> 16));
1749 u16 *data = (
u16 *) ipv4;
1755 ipv4->
checksum = spp_host_to_net_byte_order_16(((
u16) (~(
u16)checksum)));
1759 void calc_v4_icmp_checksum (
icmp_v4_t *icmp,
int ipv4_payload_size))
1761 u16 *data = (
u16 *) icmp;
1762 int num_hwords = (ipv4_payload_size)/2;
1769 *((
u8 *)data + ipv4_payload_size) = 0;
1771 while (num_hwords) {
1772 checksum += (
u32)spp_net_to_host_byte_order_16(data++);
1777 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1779 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1781 icmp->
checksum = spp_host_to_net_byte_order_16(((
u16) (~(
u16)checksum)));
1791 int num_hwords = (ip_payload_size)/2;
1796 data = (
u16 *) icmp;
1803 *((
u8 *)data + ip_payload_size) = 0;
1817 pseudo_header.
payload_length = spp_host_to_net_byte_order_16(ip_payload_size);
1820 data1 = (
u16 *) &pseudo_header;
1823 for (i = 0; i < 18; i++) {
1824 checksum += (
u32)spp_net_to_host_byte_order_16(data1++);
1830 checksum += (
u32)spp_net_to_host_byte_order_16(data);
1837 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1839 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1841 icmp->
checksum = spp_host_to_net_byte_order_16(((
u16) (~(
u16)checksum)));
1845 u8 icmp_code,
u16 uidb_index) {
1847 u16 ip_hdr_len, ip_payload_size;
1848 u32 *src_p, * dst_p;
1852 u16 icmp_payload_len;
1859 free_all_but_first_chained_buffers(ctx);
1868 icmp_payload_len = ip_hdr_len +
1884 icmp->
type = icmp_type;
1885 icmp->
code = icmp_code;
1888 VERSION_TRAFFICCLASS_FLOWLABEL);
1889 ip_new->
payload_length = spp_host_to_net_byte_order_16(ip_payload_size);
1907 calc_v6_icmp_checksum(ip_new, ip_payload_size);
1910 printf(
"Hoplimit = 0x%x\n", ip_new->
hop_limit);
1912 printf(
"Next header = 0x%x\n", ip_new->
next_header);
1913 printf(
"Src add0 = 0x%x\n", ip_new->
src_addr[0]);
1914 printf(
"Src add1 = 0x%x\n", ip_new->
src_addr[1]);
1915 printf(
"Src add2 = 0x%x\n", ip_new->
src_addr[2]);
1916 printf(
"Src add3 = 0x%x\n", ip_new->
src_addr[3]);
1917 printf(
"Dst add0 = 0x%x\n", ip_new->
dst_addr[0]);
1918 printf(
"Dst add1 = 0x%x\n", ip_new->
dst_addr[1]);
1919 printf(
"Dst add2 = 0x%x\n", ip_new->
dst_addr[2]);
1920 printf(
"Dst add3 = 0x%x\n", ip_new->
dst_addr[3]);
1921 printf(
"Icmp type = 0x%x\n", icmp->
type);
1922 printf(
"Icmp code = 0x%x\n", icmp->
code);
1924 printf(
"\n\nICMP packet:\n");
1925 for (i = 0; i < 10; i ++) {
1926 printf(
"0x%x " , *((
u8 *)icmp + i));
1934 ctx->current_length = ip_payload_size + ip_hdr_len;
1942 u16 ip_hdr_len, ip_payload_size;
1943 u32 *src_p, * dst_p;
1948 ip_payload_size =
sizeof(
icmp_v4_t) + ip_hdr_len +
1949 ICMP_UNREACHABLE_IP_PAYLOAD_SIZE;
1952 ((
u8*)ip + ip_hdr_len + ICMP_UNREACHABLE_IP_PAYLOAD_SIZE - 4);
1956 while(src_p >= (
u32*)ip) *dst_p-- = *src_p--;
1959 icmp->
type = icmp_type;
1960 icmp->
code = icmp_code;
1964 icmp->
sequence = spp_host_to_net_byte_order_16(mtu);
1977 ip->
src_addr = spp_host_to_net_byte_order_32(src_ip);
1981 calc_ipv4_checksum(ip);
1987 u8 icmp_code,
u16 uidb_index) {
1989 u16 ip_hdr_len, ip_payload_size;
1990 u32 *src_p, * dst_p;
1995 ip_payload_size =
sizeof(
icmp_v4_t) + ip_hdr_len +
1996 ICMP_UNREACHABLE_IP_PAYLOAD_SIZE;
1999 ((
u8*)ip + ip_hdr_len + ICMP_UNREACHABLE_IP_PAYLOAD_SIZE - 4);
2003 while(src_p >= (
u32*)ip) *dst_p-- = *src_p--;
2006 icmp->
type = icmp_type;
2007 icmp->
code = icmp_code;
2026 calc_ipv4_checksum(ip);
2033 printf(
"ttl = 0x%x\n", ip->
ttl);
2034 printf(
"Protocol = 0x%x\n", ip->
protocol);
2035 printf(
"checksum = 0x%x\n", ip->
checksum);
2036 printf(
"Dest addr = 0x%x\n", ip->
dest_addr);
2037 printf(
"Src addr = 0x%x\n", ip->
src_addr);
2038 printf(
"Icmp type = 0x%x\n", icmp->
type);
2039 printf(
"Icmp code = 0x%x\n", icmp->
code);
2045 int icmp_type,
int icmp_code,
2050 u16 rx_uidb_index = ctx->ru.rx.uidb_index;
2052 free_all_but_first_chained_buffers(ctx);
2053 icmp_error_generate_v2(ipv4, icmp_type, icmp_code, mtu, src_ip);
2054 ctx->current_length = (
u16)
2055 ((
u8*)ctx->current_header - ctx->packet_data) +
2072 free_all_but_first_chained_buffers(ctx);
2076 icmp_error_generate(ipv4, icmp_type, icmp_code, rx_uidb_index);
2077 ctx->current_length = (
u16)
2078 ((
u8*)ctx->current_header - ctx->packet_data) +
2092 free_all_but_first_chained_buffers(ctx);
2094 icmp_error_generate(ipv4, type, code, rx_uidb_index);
2095 ctx->current_length = (
u16)
2096 ((
u8*)ctx->current_header - ctx->packet_data) +
2137 u8 check_options = 0;
2152 u8 *ptr = (
u8*)(options_ptr + 2);
2181 cnat_syslog_nat44_tcp_seq_mismatch(db, vrfmap);
2185 static int cnat_util_init (
void *notused)
2188 spp_msg_api_set_handler(SPP_API_CNAT_PORT_ALLOCATE,
2189 spp_api_cnat_port_allocate_t_handler);
2192 spp_msg_api_set_handler(SPP_API_CNAT_PORT_CLEAR,
2193 spp_api_cnat_port_clear_t_handler);
2196 spp_msg_api_set_handler(SPP_API_CNAT_PORT_CREATE,
2197 spp_api_cnat_port_create_t_handler);
2199 spp_msg_api_set_handler(SPP_API_CNAT_PORT_DELETE,
2200 spp_api_cnat_port_delete_t_handler);
2207 u32 i, total_len, l4_len=0;
2209 u8 *pkt = (
u8 *) ip;
2214 if(total_len > 200) {
2218 printf(
"\n======== PRINTING PKT START======\n");
2219 printf(
"======== IPv6 PAYLOAD LEN %d ===========\n", total_len);
2220 for (i=0; i < 40; i++) {
2221 printf(
" %02X ", *(pkt + i));
2227 printf(
"\n======== TCP HEADER =================\n");
2231 printf(
"\n======== UDP HEADER =================\n");
2235 printf(
"\n======== ICMP HEADER =================\n");
2239 for (i=40; i < (l4_len + 40); i++) {
2240 printf(
" %02X ", *(pkt + i));
2243 printf(
"\n======== LAYER4 PAYLOAD ===================\n");
2244 for (i=(l4_len + 40); i < total_len; i++) {
2245 printf(
" %02X ", *(pkt + i));
2250 printf(
"\n======== PRINTING PKT END =======\n");
2255 PLATFORM_SPP_INIT_FUNCTION(cnat_util_init);
cnat_main_db_entry_t * cnat_main_db
sll srl srl sll sra u16x4 i
void icmp_error_generate_v6(spp_ctx_t *ctx, u8 icmp_type, u8 icmp_code, u16 uidb_index)
#define COUNTER_BUFFER_SIZE
u32 cnat_main_db_icmp_rate_limit_core
void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
Fixed length block allocator.
u16 cnat_static_port_range
cnat_icmp_msg_t v6_icmp_msg_gen_allowed()
#define CNAT_MAIN_HASH_SIZE
index_slist_t in2out_hash
void cnat_log_nat44_tcp_seq_mismatch(cnat_main_db_entry_t *db, cnat_vrfmap_t *vrfmap)
#define CNAT_TRANSLATION_ENTRY_STATIC
index_slist_t out2in_hash
index_slist_t * cnat_in2out_hash
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
void cnat_port_free_v2(cnat_portmap_v2_t *pm, int index, port_pair_t pair_type, u16 base_port, u16 static_port_range)
cnat_main_db_entry_t * cnat_get_main_db_entry_v2(cnat_db_key_bucket_t *ki, port_pair_t port_pair_type, port_type_t port_type, cnat_gen_icmp_info *info, cnat_key_t *dest_info)
u16 * cnat_portmap_indices_by_vrf
index_slist_t * cnat_user_hash
static pool_header_t * pool_header(void *v)
Get pool header from user pool pointer.
#define CNAT_TAC_SEQ_MISMATCH
u16 ** cnat_portmaps_inuse
cnat_svi_params_entry svi_params_array[CNAT_MAX_VRFMAP_ENTRIES]
struct _spp_api_cnat_v4_config_nfv9_logging spp_api_cnat_v4_config_nfv9_logging_t
int icmpv6_generate_with_throttling(spp_ctx_t *ctx, ipv6_header_t *ipv4, u16 rx_uidb_index)
int icmpv4_generate_with_throttling(spp_ctx_t *ctx, ipv4_header *ipv4, u16 rx_uidb_index)
cnat_user_db_entry_t * cnat_user_db
void calculate_window_scale(tcp_hdr_type *tcp_header, u8 *scale)
cnat_errno_t cnat_dynamic_port_alloc_v2(cnat_portmap_v2_t *pm, port_alloc_t atype, port_pair_t pair_type, u32 *index, u32 *o_ipv4_address, u16 *o_port, u16 static_port_range, bulk_alloc_size_t bulk_size, int *nfv9_log_req, u16 ip_n_to_1, u32 *rseed_ip)
struct _spp_api_cnat_v4_show_outside_entry_req spp_api_cnat_v4_show_outside_entry_req_t
struct _spp_api_cnat_v4_add_vrf_map spp_api_cnat_v4_add_vrf_map_t
static uword clib_bitmap_get(uword *ai, uword i)
Gets the ith bit value from a bitmap.
#define BULKSIZE_FROM_VRFMAP(vrfmap)
#define CNAT_DEBUG_GLOBAL_ALL
index_slist_t * cnat_out2in_hash
Bitmaps built as vectors of machine words.
struct _spp_api_cnat_v4_show_inside_entry_req spp_api_cnat_v4_show_inside_entry_req_t
cnat_portmap_t ** cnat_portmaps
struct counter_array_t err_cnt_arr[COUNTER_BUFFER_SIZE]
void print_ipv6_pkt(ipv6_header_t *ip)
void cnat_delete_main_db_entry_v2(cnat_main_db_entry_t *ep)
cnat_icmp_msg_t icmp_msg_gen_allowed()
cnat_vrfmap_t * cnat_map_by_vrf
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define CNAT_USER_HASH_SIZE
struct _spp_ctx spp_ctx_t
struct _spp_api_cnat_v4_single_vrf_map_req spp_api_cnat_v4_single_vrf_map_req
int v4_crc_zero_udp_allowed()
static void * vec_header(void *v, uword header_bytes)
Find a user vector header.
u32 db_free_entry(void *p)
u32 crc_zero_udp_rate_limit_core
CLIB vectors are ubiquitous dynamically resized arrays with by user defined "headers".