2 *------------------------------------------------------------------
3 * cnat_global.c - global variables
5 * Copyright (c) 2008-2009, 2012 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 /* gloable variables */
22 #include <vlib/vlib.h>
23 #include <vnet/vnet.h>
24 #include <vppinfra/error.h>
25 #include <vnet/buffer.h>
27 #include "dslite_defs.h"
28 #include "tcp_header_definitions.h"
29 u32 cnat_current_time;
30 u8 nfv9_configured = 0;
31 /* ctx/sf alloc error counters */
46 /* TOBE_PORTED : Remove following once we bring DSLite */
47 u32 dslite_config_debug_level = 1;
48 u32 dslite_data_path_debug_level = 1;
49 u32 dslite_defrag_debug_level = 1;
50 u32 dslite_debug_level = 1;
52 dslite_table_entry_t *dslite_table_db_ptr;
55 * ipv4_decr_ttl_n_calc_csum()
56 * - It decrements the TTL and calculates the incremental IPv4 checksum
59 /* TOBE_PORTED: Following is in cnat_util.c */
60 always_inline __attribute__((unused))
61 void ipv4_decr_ttl_n_calc_csum(ipv4_header *ipv4)
68 old = clib_net_to_host_u16(ttl);
73 /* Calculate incremental checksum */
74 checksum = old + (~clib_net_to_host_u16(ttl) & 0xFFFF);
75 checksum += clib_net_to_host_u16(ipv4->checksum);
76 checksum = (checksum & 0xFFFF) + (checksum >> 16);
77 ipv4->checksum = clib_host_to_net_u32(checksum + (checksum >> 16));