19 #ifndef __DSLITE_DB_H__ 20 #define __DSLITE_DB_H__ 28 #define DSLITE_PRINTF(level, ...) \ 29 if (dslite_debug_level > level) PLATFORM_DEBUG_PRINT(__VA_ARGS__); 37 #define HASH_ENHANCE 4 39 #define DSLITE_MAIN_DB_SIZE (20000000 / PLATFORM_CNAT_INSTS) 40 #define DSLITE_MAIN_HASH_SIZE \ 41 (HASH_ENHANCE * PLATFORM_CNAT_MAIN_PRELIM_HASH_SIZE) 43 #define DSLITE_MAIN_HASH_MASK (DSLITE_MAIN_HASH_SIZE-1) 47 #define DSLITE_USER_HASH_SIZE CNAT_USER_HASH_SIZE 48 #define DSLITE_USER_HASH_MASK (DSLITE_USER_HASH_SIZE-1) 51 #define DSLITE_TIMEOUT_HASH_SIZE 1000 52 #define DSLITE_TIMEOUT_HASH_MASK (DSLITE_TIMEOUT_HASH_SIZE - 1) 53 #define DSLITE_TIMEOUT_FULL_MASK 0xFFFFFFFFFFFFFFFF 55 #define CNAT_MAX_SESSIONS_PER_BIB 0xFFFF 60 #define DSLITE_UDP_DEFAULT 300 61 #define DSLITE_UDP_MIN 120 62 #define DSLITE_TCP_TRANS 240 63 #define DSLITE_TCP_EST 7200 64 #define DSLITE_TCP_V4_SYN 6 65 #define DSLITE_FRAG_MIN 2 66 #define DSLITE_ICMP_DEFAULT 60 77 #define DSLITE_V6_GET_HASH(in_key, hash, mask) \ 78 a = in_key->ipv6[0] ^ in_key->ipv6[1] ^ in_key->ipv6[2] ^ in_key->ipv6[3] \ 79 ^ in_key->ipv4_key.k.ipv4 ^ ((in_key->ipv4_key.k.port << 16) | in_key->ipv4_key.k.vrf); \ 80 DSLITE_PRINTF(1, "%x:%x:%x:%x:%x:%x:%x\n", in_key->ipv6[0], in_key->ipv6[1], in_key->ipv6[2], in_key->ipv6[3], \ 81 in_key->ipv4_key.k.ipv4, in_key->ipv4_key.k.port, in_key->ipv4_key.k.vrf); \ 84 hash_mix32(a, b, c); \ 88 #define DSLITE_V6_GET_USER_HASH(ipv6, hash, mask) \ 89 a = ipv6[0] ^ ipv6[1] ^ ipv6[2] ^ ipv6[3]; \ 92 hash_mix32(a, b, c); \ 95 #define DSLITE_V4_GET_HASH(in_key, hash, mask) \ 96 a = in_key.ipv4 ^ ((in_key.port << 16) | in_key.vrf); \ 99 hash_mix32(a, b, c); \ 102 #define PRIVATE_V4_ADDR_CHECK(addr, invalid) \ 104 int range1 = ((addr & 0xFF000000) >> 24); \ 105 int range2 = ((addr & 0xFFF00000) >> 20); \ 106 int range3 = ((addr & 0xFFFF0000) >> 16); \ 107 int range4 = ((addr & 0xFFFFFFF8) >> 3); \ 108 if(range1 != 0xa && range2 != 0xac1 && range3 != 0xc0a8 && range4 != 0x18000000) \ 111 #define V4_MAPPED_V6_CHECK(v6_addr, invalid) \ 113 int word1 = v6_addr[0]; \ 114 int word2 = v6_addr[1]; \ 115 int word3 = v6_addr[2]; \ 116 if(!((word1 == 0) && (word2 == 0) && (word3 == 0x0000FFFF))) \ 123 #define DSLITE_CMP_V6_KEY(key1, key2) \ 124 memcmp(key1, key2, sizeof(dslite_v6_key_t)) 126 #define DSLITE_CMP_V4_KEY(key1, key2) \ 127 memcmp(key1, key2, sizeof(dslite_v4_key_t)) 130 #define DSLITE_CMP_V6_IP(ip1, ip2) \ 131 memcmp(ip1, ip2, (sizeof(u32) * 4)) 134 #define DSLITE_CMP_V6_KEY1(key1, key2) \ 135 (key1.ipv6[0] == key2.ipv6[0]) && (key1.ipv6[1] == key2.ipv6[1]) && \ 136 (key1.ipv6[2] == key2.ipv6[2]) && (key1.ipv6[3] == key2.ipv6[3]) && \ 137 (key1.port == key2.port) && (key1.vrf == key2.vrf) 140 #define DSLITE_CMP_V6_IP1(ip1, ip2) \ 141 ((ip1[0] == ip2[0]) && (ip1[1] == ip2[1]) && \ 142 (ip1[2] == ip2[2]) && (ip1[3] == ip2[3])) 144 #define DSLITE_CMP_V4_KEY1(key1, key2) \ 145 (key1.key64 == key2.key64)
cnat_user_db_entry_t * dslite_user_db_lookup_entry(dslite_db_key_bucket_t *uki)
u32 dslite_translation_create_count
dslite_table_entry_t * dslite_table_ptr
cnat_main_db_entry_t * dslite_get_main_db_entry_v2(dslite_db_key_bucket_t *ki, port_pair_t port_pair_type, port_type_t port_type, cnat_gen_icmp_info *info, dslite_table_entry_t *dslite_entry_ptr, cnat_key_t *dest_info)
cnat_user_db_entry_t * dslite_user_db_create_entry(dslite_db_key_bucket_t *uki, u32 portmap_index)
u32 dslite_in2out_forwarding_count
u32 dslite_translation_delete_rate
#define DSLITE_MAX_DSLITE_ENTRIES
u32 dslite_out2in_forwarding_count
cnat_main_db_entry_t * dslite_create_main_db_entry_and_hash(dslite_db_key_bucket_t *ki, cnat_db_key_bucket_t *ko, cnat_user_db_entry_t *udb)
u32 dslite_translation_delete_count
cnat_main_db_entry_t * dslite_main_db_lookup_entry(dslite_db_key_bucket_t *ki)
u32 dslite_translation_create_rate
u32 dslite_in2out_forwarding_rate
u32 dslite_out2in_forwarding_rate