2 *------------------------------------------------------------------
3 * cnat_util.c - cnat helpers
5 * Copyright (c) 2009-2014 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
20 #include <vlib/vlib.h>
21 #include <vnet/vnet.h>
22 #include <vppinfra/vec.h>
23 #include <vppinfra/bitmap.h>
24 #include <vppinfra/hash.h>
25 #include <vppinfra/pool.h>
26 #include <vppinfra/clib.h>
27 #include <vppinfra/error.h>
29 #include "tcp_header_definitions.h"
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
48 (spp_api_cnat_v4_show_outside_entry_req_t *mp);
50 void spp_api_cnat_v4_show_inside_entry_req_t_handler
51 (spp_api_cnat_v4_show_inside_entry_req_t *mp);
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)
61 cnat_db_key_bucket_t key_info;
62 cnat_main_db_entry_t *db;
63 cnat_gen_icmp_info info;
64 cnat_key_t dest_info_dummy;
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++) {
72 key_info.k.k.vrf = CNAT_TCP | (1 & CNAT_VRF_MASK);
73 key_info.k.k.ipv4 = 0x0c000001+i;
74 key_info.k.k.port = 1024+j;
76 db = cnat_get_main_db_entry_v2(&key_info, PORT_SINGLE,
77 PORT_TYPE_DYNAMIC, &info, &dest_info_dummy);
80 printf ("OOPS: cnat_main_db_create failed users %d trans %d\n", i, j);
84 db->entry_expires = cnat_current_time;
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)
106 spp_api_cnat_v4_show_inside_entry_req_t mp1[2000];
107 spp_api_cnat_v4_show_outside_entry_req_t mp2[30000];
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;
188 mp6[0].flags = CNAT_TRANSLATION_ENTRY_STATIC;
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)
202 cnat_main_db_entry_t * db;
205 pool_header_t * p = vec_header(cnat_main_db, sizeof(pool_header_t) );
207 for(index = 0; index < vec_len(cnat_main_db); index++) {
209 if ( !clib_bitmap_get(p->free_bitmap, index)) {
211 db = cnat_main_db + index;
212 cnat_delete_main_db_entry_v2(db);
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];
236 spp_printf(error_code, num_args, arg);
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;
252 cnat_user_db_entry_t * udb;
253 u32 hash_depth[MAX_DEPTH];
255 memset(hash_depth, 0, sizeof(u32)*MAX_DEPTH);
257 n = vec_len(cnat_user_hash);
263 index = cnat_user_hash[i].next;
266 if (index != EMPTY) used++;
268 while (index != EMPTY) {
270 udb = cnat_user_db + index;
271 index = udb->user_hash.next;
274 if(len < (MAX_DEPTH-1) ) {
277 hash_depth[MAX_DEPTH-1]++;
282 max_idx = cnat_user_hash[i].next;
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;
301 cnat_main_db_entry_t * db;
302 u32 hash_depth[MAX_DEPTH];
304 memset(hash_depth, 0, sizeof(u32)*MAX_DEPTH);
306 n = vec_len(cnat_in2out_hash);
312 index = cnat_in2out_hash[i].next;
315 if (index != EMPTY) used++;
317 while (index != EMPTY) {
319 db = cnat_main_db + index;
320 index = db->in2out_hash.next;
323 if(len < (MAX_DEPTH-1) ) {
326 hash_depth[MAX_DEPTH-1]++;
331 max_idx = cnat_in2out_hash[i].next;
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);
348 n = vec_len(cnat_out2in_hash);
354 index = cnat_out2in_hash[i].next;
357 if (index != EMPTY) used++;
359 while (index != EMPTY) {
361 db = cnat_main_db + index;
362 index = db->out2in_hash.next;
365 if(len < (MAX_DEPTH-1) ) {
368 hash_depth[MAX_DEPTH-1]++;
373 max_idx = cnat_in2out_hash[i].next;
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]);
390 u32 db_free_entry (void * p) {
397 free = p == 0 ? 0: vec_len(h->free_indices);
402 void cnat_db_summary (int argc, unsigned long *argv) {
404 PLATFORM_DEBUG_PRINT("\n-----------------------------------------");
405 PLATFORM_DEBUG_PRINT("\nSummary DB");
406 PLATFORM_DEBUG_PRINT("\n-----------------------------------------\n");
407 u32 count1, count2, i;
409 extern void nat64_session_db_summary();
411 /* main db active entry count*/
412 count1 = vec_len(cnat_main_db);
413 count2 = db_free_entry(cnat_main_db);
415 PLATFORM_DEBUG_PRINT("main db entries: total %u, active %u, free %u\n", count1, count1 - count2, count2);
417 /* user db active entry count */
418 count1 = vec_len(cnat_user_db);
419 count2 = db_free_entry(cnat_user_db);
421 PLATFORM_DEBUG_PRINT("user db entries: total %u, active %u, free %u\n", count1, count1 - count2, count2);
424 /* user db active entry count */
426 nat64_session_db_summary();
429 /* main db hash i2o o2i usage count */
433 for (i=0; i< CNAT_MAIN_HASH_SIZE; i++) {
435 if(cnat_in2out_hash[i].next != ~0) count1++;
436 if(cnat_out2in_hash[i].next != ~0) count2++;
440 PLATFORM_DEBUG_PRINT("main hash in2out: total %6u, used %u (%.2f%%)\n",
441 CNAT_MAIN_HASH_SIZE, count1,
442 (100.0*count1)/CNAT_MAIN_HASH_SIZE);
444 PLATFORM_DEBUG_PRINT("main hash out2in: total %6u, used %u (%.2f%%)\n",
445 CNAT_MAIN_HASH_SIZE, count2,
446 (100.0 * count1)/CNAT_MAIN_HASH_SIZE);
448 /* use db hashing usage count */
452 for (i=0; i< CNAT_USER_HASH_SIZE; i++) {
453 if(cnat_user_hash[i].next != ~0) count1++;
456 PLATFORM_DEBUG_PRINT("user db hash: total %6u, used %u (%.2f%%)\n",
457 CNAT_USER_HASH_SIZE, count1,
458 (100.0*count1)/CNAT_USER_HASH_SIZE);
460 PLATFORM_DEBUG_PRINT("\nNull pointer exceptions:\n");
461 PLATFORM_DEBUG_PRINT("packet_pool: null enq : %10u, null deq : %10u\n",null_enq_pkt, null_deq_pkt);
462 PLATFORM_DEBUG_PRINT("ctx_pool : null enq : %10u, null deq : %10u\n",null_enq_ctx, null_deq_ctx);
463 PLATFORM_DEBUG_PRINT("wqe_pool : null enq : %10u, null deq : %10u\n",null_enq_wqe, null_deq_wqe);
465 PLATFORM_DEBUG_PRINT("\nReceived Packet Errors on SPI:\n");
466 PLATFORM_DEBUG_PRINT("rcv_pkt_errs: %10u\n",rcv_pkt_errs);
468 PLATFORM_DEBUG_PRINT("\nctx/sf allocation failure errors: \n");
469 #ifndef CGN_PERF_SCALE_DEBUG
470 PLATFORM_DEBUG_PRINT("Warning: collection of error counts <with timestamp> is disabled.\n");
471 PLATFORM_DEBUG_PRINT("sf alloc errors: %10u, ctx alloc errors: %10u\n",sf_alloc_errs,ctx_alloc_errs);
473 for(i=0;i<COUNTER_BUFFER_SIZE;i++)
474 PLATFORM_DEBUG_PRINT("<%2d>Timestamp <sec>: %10u, sf errors: %10u, ctx errors: %10u\n",\
475 i,err_cnt_arr[i].timestamp,\
476 err_cnt_arr[i].sf_error_counter, \
477 err_cnt_arr[i].ctx_error_counter);
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();
490 * This function is now deprecated...
494 int cnat_port_alloc (cnat_portmap_t *cnat_portmap, u16 *portmap_inuse,
496 port_alloc_t atype, port_pair_t ptype,
497 int *index, u32 *ipv4_address, u16 *base_port)
499 int cnat_port_alloc (cnat_portmap_t *cnat_portmap, u16 *portmap_inuse,
500 port_alloc_t atype, port_pair_t ptype,
501 int *index, u32 *ipv4_address, u16 *base_port)
510 * This function is now deprecated...
514 void cnat_port_free (cnat_portmap_t *cnat_portmap, u16 *portmap_inuse,
515 int instance, int index, port_pair_t ptype, u16 base_port)
517 void cnat_port_free (cnat_portmap_t *cnat_portmap, u16 *portmap_inuse,
518 int index, port_pair_t ptype, 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;
531 port_alloc_t pt1, pt2;
532 cnat_portmap_t *pm = 0;
541 char out_r[12] = "allocated-r";
542 char out_o[12] = "allocated-o";
543 char out_e[12] = "allocated-e";
547 * this command is run after db create portmap
548 * vrf is hardcode to 1
551 /* Already have a portmap vector for this VRF? */
552 for (i = 0; i < vec_len(cnat_portmap_indices_by_vrf); i++) {
553 if (cnat_portmap_indices_by_vrf[i] == mp->vrf) {
554 pm = cnat_portmaps[i];
555 pm_inuse = cnat_portmaps_inuse[i];
560 printf("need to run db create portmaps first 0x%d\n",
561 vec_len(cnat_portmap_indices_by_vrf));
565 nr_ports = mp->nr_ports;
566 nodd_ports = mp->nodd_ports;
567 neven_ports = mp->neven_ports;
569 if ((nr_ports + nodd_ports + neven_ports ) > (PORTS_PER_ADDR)) {
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,
587 PORT_ALLOC_ANY, PORT_S_ODD,
588 &pm_index, &ipv4_address, &aport);
590 rv = cnat_port_alloc (pm, pm_inuse,
591 PORT_ALLOC_ANY, PORT_S_ODD,
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,
607 PORT_ALLOC_DIRECTED, PORT_SINGLE,
608 &pm_index, &ipv4_address, &aport);
610 rv = cnat_port_alloc (pm, pm_inuse,
611 PORT_ALLOC_DIRECTED, PORT_SINGLE,
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,
643 PORT_ALLOC_DIRECTED, pt1,
644 &pm_index, &ipv4_address, &aport);
646 rv = cnat_port_alloc (pm, pm_inuse,
647 PORT_ALLOC_DIRECTED, pt1,
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,
661 PORT_ALLOC_DIRECTED, pt2,
662 &pm_index, &ipv4_address, &aport);
664 rv = cnat_port_alloc (pm, pm_inuse,
665 PORT_ALLOC_DIRECTED, pt2,
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;
774 spp_host_to_net_byte_order_16(CNAT_DEBUG_GENERIC_COMMAND_DEBUG_FLAGS);
776 if (spp_host_to_net_byte_order_32(argv[0]) == 1) {
777 mp->param[0] = spp_host_to_net_byte_order_32(
778 CNAT_DEBUG_FLAG_UDP_INSIDE_PACKET_DUMP);
780 mp->param[0] = spp_host_to_net_byte_order_32(
781 CNAT_DEBUG_FLAG_UDP_OUTSIDE_PACKET_DUMP);
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;
801 spp_host_to_net_byte_order_16(CNAT_DEBUG_GENERIC_COMMAND_DEBUG_FLAGS);
803 if (spp_host_to_net_byte_order_32(argv[0]) == 1) {
804 mp->param[0] = spp_host_to_net_byte_order_32(
805 CNAT_DEBUG_FLAG_UDP_INSIDE_CHECKSUM_MODIFY);
807 mp->param[0] = spp_host_to_net_byte_order_32(
808 CNAT_DEBUG_FLAG_UDP_OUTSIDE_CHECKSUM_MODIFY);
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)
853 cnat_portmap_t *pm = 0;
861 * this command is run after db create port
862 * vrf is hardcode to 1
865 /* Already have a portmap vector for this VRF? */
866 for (i = 0; i < vec_len(cnat_portmap_indices_by_vrf); i++) {
867 if (cnat_portmap_indices_by_vrf[i] == mp->vrf) {
868 pm = cnat_portmaps[i];
869 pm_inuse = cnat_portmaps_inuse[i];
874 printf("portmap is not created 0x%d\n",
875 vec_len(cnat_portmap_indices_by_vrf));
879 if (mp->pm_index >= vec_len(pm)) {
880 printf("invalid port_index 0x%d >= 0x%d\n",
881 mp->pm_index, vec_len(pm));
886 cnat_port_free(pm, pm_inuse, my_instance,
887 mp->pm_index, PORT_SINGLE, mp->port);
889 cnat_port_free(pm, pm_inuse,
890 mp->pm_index, PORT_SINGLE, mp->port);
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
930 (spp_api_cnat_v4_add_vrf_map_t *mp);
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)
944 spp_api_cnat_v4_add_vrf_map_t *mp;
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]);
960 * Some hardcoded values for the vrf ids
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;
1019 port_alloc_t pt1, pt2;
1020 cnat_vrfmap_t *my_vrfmap;
1021 cnat_portmap_v2_t *pm = 0;
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;
1042 * this command is run after db create vrfmap
1043 * or using vrf id in init function
1045 /* Already have a portmap vector for this VRF? */
1046 pool_foreach (my_vrfmap, cnat_map_by_vrf, ({
1047 if ((my_vrfmap->status == S_RUN) &&
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);
1062 if ((nr_ports + nodd_ports + neven_ports ) > (PORTS_PER_ADDR)) {
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);
1078 rv = cnat_dynamic_port_alloc_v2 (pm, PORT_ALLOC_ANY, PORT_S_ODD,
1079 &my_index, &ipv4_address, &aport,
1080 cnat_static_port_range
1081 #ifndef NO_BULK_LOGGING
1082 , BULKSIZE_FROM_VRFMAP(my_vrfmap),
1086 &(my_vrfmap->rseed_ip)
1089 if (rv != CNAT_SUCCESS) {
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++) {
1099 rv = cnat_dynamic_port_alloc_v2 (pm, PORT_ALLOC_DIRECTED, PORT_SINGLE,
1100 &my_index, &ipv4_address, &aport,
1101 cnat_static_port_range
1102 #ifndef NO_BULK_LOGGING
1103 , BULKSIZE_FROM_VRFMAP(my_vrfmap),
1107 &(my_vrfmap->rseed_ip)
1110 if (rv == CNAT_SUCCESS) {
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++) {
1137 rv = cnat_dynamic_port_alloc_v2 (pm, PORT_ALLOC_DIRECTED, pt1,
1138 &my_index, &ipv4_address, &aport,
1139 cnat_static_port_range
1140 #ifndef NO_BULK_LOGGING
1141 , BULKSIZE_FROM_VRFMAP(my_vrfmap),
1145 &(my_vrfmap->rseed_ip)
1148 if (rv == CNAT_SUCCESS) {
1149 printf("%s %8d %10x %8d\n", out1,
1150 my_index, ipv4_address, aport);
1152 printf("%s failed\n", __FUNCTION__);
1157 rv = cnat_dynamic_port_alloc_v2 (pm, PORT_ALLOC_DIRECTED, pt2,
1158 &my_index, &ipv4_address, &aport,
1159 cnat_static_port_range
1160 #ifndef NO_BULK_LOGGING
1161 , BULKSIZE_FROM_VRFMAP(my_vrfmap),
1165 &(my_vrfmap->rseed_ip)
1168 if (rv == CNAT_SUCCESS) {
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)
1212 cnat_vrfmap_t *my_vrfmap;
1213 cnat_portmap_v2_t *pm = 0;
1215 u32 my_index, my_port;
1218 u32 my_instance = 1;
1221 my_index = mp->pm_index;
1226 * this command is run after db create port
1228 pool_foreach (my_vrfmap, cnat_map_by_vrf, ({
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",
1239 vec_len(cnat_portmap_indices_by_vrf));
1243 if (my_index >= pm_len) {
1244 printf("invalid port_index 0x%d >= 0x%d\n",
1250 cnat_port_free_v2(pm, my_instance,
1251 my_index, PORT_SINGLE, mp->port,cnat_static_port_range);
1253 cnat_port_free_v2(pm, my_index, PORT_SINGLE, mp->port,cnat_static_port_range);
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)
1347 spp_api_cnat_v4_config_nfv9_logging_t *mp;
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;
1401 mp->debug_flag = CNAT_DEBUG_GLOBAL_ALL;
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;
1414 mp->debug_flag = CNAT_DEBUG_NONE;
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;
1484 spp_api_cnat_v4_single_vrf_map_req *mp_sp;
1486 u32 mp_size = sizeof(spp_api_cnat_v4_bulk_vrf_map_t) +
1487 (sizeof(spp_api_cnat_v4_single_vrf_map_req))*2;
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);
1496 mp_sp = (spp_api_cnat_v4_single_vrf_map_req *)
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) +
1555 (sizeof(spp_api_cnat_v4_single_vrf_map_req))*2;
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)
1593 spp_api_cnat_v4_config_nfv9_logging_t *mp;
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 ");
1618 * Allocate a large buffer for message req and resp structure
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; /* 32 KB array per core */
1636 u8 v4_pkt_count = 0;
1638 cnat_icmp_msg_t icmp_msg_gen_allowed ()
1640 #ifdef DISABLE_ICMP_THROTTLE_FOR_DEBUG_PURPOSE
1641 return CNAT_ICMP_MSG;
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)) {
1656 /* update timestamp */
1657 icmp_sent_timestamps = updated_timestamp;
1659 if (PREDICT_TRUE(v4_pkt_count <= cnat_main_db_icmp_rate_limit_core)) {
1660 return CNAT_ICMP_MSG;
1662 return CNAT_NO_ICMP_MSG;
1667 u32 v6_icmp_sent_timestamps; /* 32 KB array per core */
1668 u8 v6_pkt_count = 0;
1670 cnat_icmp_msg_t v6_icmp_msg_gen_allowed ()
1672 #ifdef DISABLE_ICMP_THROTTLE_FOR_DEBUG_PURPOSE
1673 return CNAT_ICMP_MSG;
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)) {
1687 /* update timestamp */
1688 v6_icmp_sent_timestamps = updated_timestamp;
1690 if (PREDICT_TRUE(v6_pkt_count <= cnat_main_db_icmp_rate_limit_core)) {
1691 return CNAT_ICMP_MSG;
1693 return CNAT_NO_ICMP_MSG;
1698 u32 v4_udp_crc_zero_timestamps;
1699 u32 v4_udp_crc_zero_pkt_count = 0;
1700 int v4_crc_zero_udp_allowed ()
1702 PLATFORM_V4_CRC_ZERO_UDP_ALLOWED
1703 /* Currently not supported for Brahmos. we need to take care of this */
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;
1715 if (PREDICT_TRUE(v4_udp_crc_zero_pkt_count <=
1716 crc_zero_udp_rate_limit_core)) {
1724 * ipv4_decr_ttl_n_calc_csum()
1725 * - It decrements the TTL and calculates the incremental IPv4 checksum
1729 void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4))
1734 old = ntohs(*(u16 *)&ipv4->ttl);
1739 /* Calculate incremental checksum */
1740 checksum = old + (~ntohs(*(u16 *)&ipv4->ttl) & 0xFFFF);
1741 checksum += ntohs(ipv4->checksum);
1742 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1743 ipv4->checksum = htons(checksum + (checksum >> 16));
1747 void calc_ipv4_checksum (ipv4_header *ipv4))
1749 u16 *data = (u16 *) ipv4;
1752 checksum = crc_calc(ipv4);
1754 /* Now produce the 1's complement */
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;
1766 if (PREDICT_FALSE((ipv4_payload_size%2) != 0)) {
1768 /* Append 0's in the last octet */
1769 *((u8 *)data + ipv4_payload_size) = 0;
1771 while (num_hwords) {
1772 checksum += (u32)spp_net_to_host_byte_order_16(data++);
1776 /* Add in the carry of the original sum */
1777 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1778 /* Add in the carry of the final sum */
1779 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1780 /* Now produce the 1's complement */
1781 icmp->checksum = spp_host_to_net_byte_order_16(((u16) (~(u16)checksum)));
1785 void calc_v6_icmp_checksum (ipv6_header_t *ipv6, u16 ip_payload_size))
1791 int num_hwords = (ip_payload_size)/2;
1793 pseudo_v6_header_t pseudo_header;
1795 icmp = (icmp_v6_t *) ((u8 *)ipv6 + IPV6_HDR_LEN);
1796 data = (u16 *) icmp;
1800 if (PREDICT_FALSE((ip_payload_size%2) != 0)) {
1802 /* Append 0's in the last octet */
1803 *((u8 *)data + ip_payload_size) = 0;
1807 /* construct the pseudo header */
1809 pseudo_header.src_addr[0] = ipv6->src_addr[0];
1810 pseudo_header.src_addr[1] = ipv6->src_addr[1];
1811 pseudo_header.src_addr[2] = ipv6->src_addr[2];
1812 pseudo_header.src_addr[3] = ipv6->src_addr[3];
1813 pseudo_header.dst_addr[0] = ipv6->dst_addr[0];
1814 pseudo_header.dst_addr[1] = ipv6->dst_addr[1];
1815 pseudo_header.dst_addr[2] = ipv6->dst_addr[2];
1816 pseudo_header.dst_addr[3] = ipv6->dst_addr[3];
1817 pseudo_header.payload_length = spp_host_to_net_byte_order_16(ip_payload_size);
1818 pseudo_header.next_header = spp_host_to_net_byte_order_16(ipv6->next_header);
1820 data1 = (u16 *) &pseudo_header;
1822 /* sizeof(pseudo_v6_header_t) = 36 */
1823 for (i = 0; i < 18; i++) {
1824 checksum += (u32)spp_net_to_host_byte_order_16(data1++);
1829 if (PREDICT_TRUE(num_hwords)) {
1830 checksum += (u32)spp_net_to_host_byte_order_16(data);
1836 /* Add in the carry of the original sum */
1837 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1838 /* Add in the carry of the final sum */
1839 checksum = (checksum & 0xFFFF) + (checksum >> 16);
1840 /* Now produce the 1's complement */
1841 icmp->checksum = spp_host_to_net_byte_order_16(((u16) (~(u16)checksum)));
1844 void icmp_error_generate_v6 (spp_ctx_t *ctx, u8 icmp_type,
1845 u8 icmp_code, u16 uidb_index) {
1847 u16 ip_hdr_len, ip_payload_size;
1848 u32 *src_p, * dst_p;
1851 ipv6_header_t *ip_old, *ip_new;
1852 u16 icmp_payload_len;
1855 * As per RFC 2463, we limit the maximum size of generated ICMPv6 message to * 1280. And hence if the packet is bigger than 1280, then it needs to be
1856 * truncated. Also, if the packet had multiple chained buffers, we need to
1857 * free all chained buffers, except the first one.
1859 free_all_but_first_chained_buffers(ctx);
1861 ip_hdr_len = IPV6_HDR_LEN;
1862 /* offset to ip payload */
1864 ip_old = (ipv6_header_t *)PLATFORM_CTX_CURRENT_HDR;
1865 ip_new = (ipv6_header_t *) ((u8 *) PLATFORM_CTX_CURRENT_HDR - ICMPV6_ERR_SIZE);
1866 icmp = (icmp_v6_t*) ( (u8*)ip_new + ip_hdr_len);
1868 icmp_payload_len = ip_hdr_len +
1869 spp_net_to_host_byte_order_16(&(ip_old->payload_length)) ;
1871 ip_payload_size = ICMPV6_HDR_SIZE + icmp_payload_len;
1873 * There is no easy way to predict this case as the probablity that the IPv6
1874 * pkt is big depends on the type of traffic. Let us optimize the big
1875 * pkt case as it involves more processing
1877 * If the pkt size exceeds IPV6_MIN_PATH_MTU truncate it to IPV6_MIN_PATH_MTU
1879 if (PREDICT_TRUE((ip_payload_size + ip_hdr_len) > IPV6_MIN_PATH_MTU)) {
1880 ip_payload_size = IPV6_MIN_PATH_MTU - ip_hdr_len;
1883 /* Following ICMP op has to be after ip header being copied */
1884 icmp->type = icmp_type;
1885 icmp->code = icmp_code;
1887 ip_new->version_trafficclass_flowlabel = spp_host_to_net_byte_order_32(
1888 VERSION_TRAFFICCLASS_FLOWLABEL);
1889 ip_new->payload_length = spp_host_to_net_byte_order_16(ip_payload_size);
1890 ip_new->next_header = IPV6_PROTO_ICMPV6;
1891 ip_new->hop_limit = 64;
1892 ip_new->dst_addr[0] = ip_old->src_addr[0];
1893 ip_new->dst_addr[1] = ip_old->src_addr[1];
1894 ip_new->dst_addr[2] = ip_old->src_addr[2];
1895 ip_new->dst_addr[3] = ip_old->src_addr[3];
1897 ip_new->src_addr[0] =
1898 spp_host_to_net_byte_order_32(svi_params_array[uidb_index].ipv6_addr[0]);
1899 ip_new->src_addr[1] =
1900 spp_host_to_net_byte_order_32(svi_params_array[uidb_index].ipv6_addr[1]);
1901 ip_new->src_addr[2] =
1902 spp_host_to_net_byte_order_32(svi_params_array[uidb_index].ipv6_addr[2]);
1903 ip_new->src_addr[3] =
1904 spp_host_to_net_byte_order_32(svi_params_array[uidb_index].ipv6_addr[3]);
1905 /* calc checksum for icmp */
1907 calc_v6_icmp_checksum(ip_new, ip_payload_size);
1909 printf("Flow = 0x%x\n", ip_new->version_trafficclass_flowlabel);
1910 printf("Hoplimit = 0x%x\n", ip_new->hop_limit);
1911 printf("Length= 0x%x\n", ip_new->payload_length);
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));
1933 ctx->current_header -= ICMPV6_ERR_SIZE;
1934 ctx->current_length = ip_payload_size + ip_hdr_len;
1935 PLATFORM_CNAT_SET_TX_VRF(ctx,uidb_index);
1938 void icmp_error_generate_v2 (ipv4_header *ip, u8 icmp_type,
1939 u8 icmp_code, u16 mtu, u32 src_ip)
1942 u16 ip_hdr_len, ip_payload_size;
1943 u32 *src_p, * dst_p;
1946 ip_hdr_len = (ip->version_hdr_len_words & 0xf) << 2; /* offset to ip payload */
1947 icmp = (icmp_v4_t*) ( (u8*)ip + ip_hdr_len);
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);
1953 dst_p = (u32*) ((u8*)src_p + sizeof(ipv4_header) +
1956 while(src_p >= (u32*)ip) *dst_p-- = *src_p--;
1958 /* Following ICMP op has to be after ip header being copied */
1959 icmp->type = icmp_type;
1960 icmp->code = icmp_code;
1961 icmp->identifier = 0;
1963 if(PREDICT_FALSE(mtu != 0)) {
1964 icmp->sequence = spp_host_to_net_byte_order_16(mtu);
1968 /* build icmp header, keep original tos, identification values */
1969 ip->version_hdr_len_words = 0x45;
1970 ip->total_len_bytes = sizeof(ipv4_header) + ip_payload_size;
1971 ip->total_len_bytes = spp_host_to_net_byte_order_16(ip->total_len_bytes);
1972 ip->frag_flags_offset = 0;
1974 ip->protocol = ICMP_PROT;
1976 ip->dest_addr = ip->src_addr;
1977 ip->src_addr = spp_host_to_net_byte_order_32(src_ip);
1979 /* calc checksum for ip and icmp */
1981 calc_ipv4_checksum(ip);
1982 calc_v4_icmp_checksum( (icmp_v4_t *) ((u8*) ip + sizeof(ipv4_header)),
1986 void icmp_error_generate (ipv4_header *ip, u8 icmp_type,
1987 u8 icmp_code, u16 uidb_index) {
1989 u16 ip_hdr_len, ip_payload_size;
1990 u32 *src_p, * dst_p;
1993 ip_hdr_len = (ip->version_hdr_len_words & 0xf) << 2; /* offset to ip payload */
1994 icmp = (icmp_v4_t*) ( (u8*)ip + ip_hdr_len);
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);
2000 dst_p = (u32*) ((u8*)src_p + sizeof(ipv4_header) +
2003 while(src_p >= (u32*)ip) *dst_p-- = *src_p--;
2005 /* Following ICMP op has to be after ip header being copied */
2006 icmp->type = icmp_type;
2007 icmp->code = icmp_code;
2008 icmp->identifier = 0;
2012 /* build icmp header, keep original tos, identification values */
2013 ip->version_hdr_len_words = 0x45;
2014 ip->total_len_bytes = sizeof(ipv4_header) + ip_payload_size;
2015 ip->total_len_bytes = spp_host_to_net_byte_order_16(ip->total_len_bytes);
2016 ip->frag_flags_offset = 0;
2018 ip->protocol = ICMP_PROT;
2020 ip->dest_addr = ip->src_addr;
2022 ip->src_addr = spp_host_to_net_byte_order_32(svi_params_array[uidb_index].ipv4_addr);
2024 /* calc checksum for ip and icmp */
2026 calc_ipv4_checksum(ip);
2027 calc_v4_icmp_checksum( (icmp_v4_t *) ((u8*) ip + sizeof(ipv4_header)),
2030 printf("version_hdr_len_words = 0x%x\n", ip->version_hdr_len_words);
2031 printf("total_len_bytes = 0x%x\n", ip->total_len_bytes);
2032 printf("Frag = 0x%x\n", ip->frag_flags_offset);
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);
2044 int icmpv4_generate_with_throttling_v2 (spp_ctx_t *ctx, ipv4_header *ipv4,
2045 int icmp_type, int icmp_code,
2046 u16 mtu, u32 src_ip)
2050 u16 rx_uidb_index = ctx->ru.rx.uidb_index;
2051 if (icmp_msg_gen_allowed()) {
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) +
2056 spp_net_to_host_byte_order_16(&ipv4->total_len_bytes);
2057 PLATFORM_CNAT_SET_TX_VRF(ctx,rx_uidb_index);
2064 int icmpv4_generate_with_throttling (spp_ctx_t *ctx, ipv4_header *ipv4,
2070 if (icmp_msg_gen_allowed()) {
2071 /* ICMP error would be small, so one buffer is enough. Clear the other */
2072 free_all_but_first_chained_buffers(ctx);
2074 icmp_type = ICMPV4_TIMEEXCEEDED;
2075 icmp_code = ICMPV4_TIMTTL;
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) +
2079 spp_net_to_host_byte_order_16(&ipv4->total_len_bytes);
2080 PLATFORM_CNAT_SET_TX_VRF(ctx,rx_uidb_index);
2087 int icmpv4_generate_with_throttling_v1 (spp_ctx_t *ctx, ipv4_header *ipv4,
2088 u16 rx_uidb_index, u32 type, u32 code)
2090 if (icmp_msg_gen_allowed()) {
2091 /* ICMP error would be small, so one buffer is enough. Clear the other */
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) +
2097 spp_net_to_host_byte_order_16(&ipv4->total_len_bytes);
2098 PLATFORM_CNAT_SET_TX_VRF(ctx,rx_uidb_index);
2106 int icmpv6_generate_with_throttling (spp_ctx_t *ctx, ipv6_header_t *ipv6,
2112 if (v6_icmp_msg_gen_allowed()) {
2113 icmp_type = ICMPV6_TIMEEXCEEDED;
2114 icmp_code = ICMPV6_TIMTTL;
2115 icmp_error_generate_v6(ctx, icmp_type, icmp_code, rx_uidb_index);
2122 int icmpv6_generate_with_throttling_v1 (spp_ctx_t *ctx, ipv6_header_t *ipv6,
2123 u16 rx_uidb_index, u32 type, u32 code)
2126 if (v6_icmp_msg_gen_allowed()) {
2127 icmp_error_generate_v6(ctx, type, code, rx_uidb_index);
2135 void calculate_window_scale(tcp_hdr_type *tcp_header, u8 *scale) {
2137 u8 check_options = 0;
2140 check_options = ((tcp_header->flags & TCP_FLAG_SYN) &&
2141 (((tcp_header->hdr_len>>4) << 2) > sizeof(tcp_hdr_type)));
2143 if (PREDICT_FALSE(check_options)) {
2144 u8 *options_ptr = tcp_findoption(tcp_header, TCP_OPTION_WINDOW_SCALE);
2147 * TCP option field: | kind 1B | len 1B | value 2B|
2148 * where kind != [0, 1]
2150 if (PREDICT_TRUE(options_ptr &&
2151 (options_ptr[1] == TCP_OPTION_WINDOW_SCALE))) {
2152 u8 *ptr = (u8*)(options_ptr + 2);
2155 if(PREDICT_FALSE(*scale >= 14)) {
2166 void cnat_log_nat44_tcp_seq_mismatch(
2167 cnat_main_db_entry_t *db,
2168 cnat_vrfmap_t *vrfmap))
2170 /* As of now, Netflow does not require this to be logged
2173 if(PREDICT_TRUE(db->flags & CNAT_TAC_SEQ_MISMATCH)) {
2174 /* Already logged ..*/
2177 /* else, set the flag and call the log API */
2179 db->flags = db->flags | CNAT_TAC_SEQ_MISMATCH;
2181 cnat_syslog_nat44_tcp_seq_mismatch(db, vrfmap);
2185 static int cnat_util_init (void *notused)
2187 /* run SPP_API_CNAT_PORTMAP_CREATE first*/
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);
2195 /* run vrfmap config first */
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);
2205 print_ipv6_pkt (ipv6_header_t *ip)
2207 u32 i, total_len, l4_len=0;
2209 u8 *pkt = (u8 *) ip;
2211 total_len = spp_net_to_host_byte_order_16(&ip->payload_length);
2213 /* we rarely need to debug > 200 bytes of packet */
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));
2226 if (ip->next_header == IPV6_PROTO_TCP) {
2227 printf("\n======== TCP HEADER =================\n");
2230 else if (ip->next_header == IPV6_PROTO_UDP) {
2231 printf("\n======== UDP HEADER =================\n");
2234 else if (ip->next_header == IPV6_PROTO_ICMPV6) {
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);