20 #ifndef __CNAT_PCP_SERVER_H__ 21 #define __CNAT_PCP_SERVER_H__ 26 #define PCP_DBG(debug, ...) \ 27 if(PREDICT_FALSE(cnat_pcp_debug_flag >= debug)) { \ 28 printf("%s:%s:%d - ", \ 29 __FILE__, __FUNCTION__, __LINE__);\ 34 #define PCP_DUMP_PDATA \ 35 if(PREDICT_FALSE(cnat_pcp_debug_flag >= 100)) { \ 36 printf("%s:%s:%d - \n", \ 37 __FILE__, __FUNCTION__, __LINE__);\ 38 printf("src - ip = %X, proto = %d, port = %d i_vrf = %d, o_vrf = %d\n", \ 39 pcp_data.src_ip[3], pcp_data.proto, pcp_data.src_port, pcp_data.i_vrf, pcp_data.o_vrf); \ 40 printf(" third party ip = %X\n", pcp_data.third_party_ip[3]); \ 41 printf("map - ip = %X, port = %d \n", \ 42 pcp_data.ext_ip[3], pcp_data.ext_port);\ 43 printf("remote - ip = %X, port = %d \n", \ 44 pcp_data.peer_ip[3], pcp_data.peer_port); \ 45 printf("req life time = %d \n", pcp_data.req_lifetime); \ 46 printf("drop = %d \n", pcp_data.drop);\ 47 printf("udp_len = %d \n", pcp_data.udp_len); \ 48 printf("pm = %p \n", pcp_data.pm); \ 49 printf("cnat_proto = %X \n", pcp_data.cnat_proto); \ 50 printf("inst_id = %X \n", pcp_data.inst_id); \ 51 printf("======================================================\n"); \ 54 #define PCP_DUMP_PACKET(ip, len) pcp_hex_dump(ip, len) 57 #define PCP_INCR(counter) pcp_counters.pcp_##counter++ ; 59 #define PCP_INCR(counter) 162 #define PCP_DISABLED 0 163 #define PCP_ENABLED 1 167 #define PCP_STATIC_LIFETIME 0xFFFFFFFF 168 #define PCP_MAX_LIFETIME 0x00015180 170 #define PCP_VERSION_SUPPORTED 1 172 #define PCP_NO_PREF_FAIL_OPTION 0 173 #define PCP_PREF_FAIL_OPTION 1 175 #define CNAT_DEF_PCP_PORT 5351 177 #define PCP_REQ_RESP_BIT 0x80 178 #define PCP_RESPONSE(r_opcode) (r_opcode & PCP_REQ_RESP_BIT) 179 #define PCP_REQUEST(r_opcode) !(PCP_RESPONSE(r_opcode)) 181 #define PCP_REQ_OPCODE(r_opcode) (r_opcode & 0x7F) 184 #define PCP_COMMON_HDR_LEN sizeof(pcp_request_t) 187 #define UDP_HDR_LEN sizeof(udp_hdr_type_t) 189 #define PCP_PREF_FAIL_OPTION_SIZE \ 190 sizeof(pcp_prefer_fail_option_t) 192 #define PCP_3RD_PARTY_OPTION_SIZE \ 193 sizeof(pcp_3rd_party_option_t) 195 #define PCP_MIN_LEN PCP_COMMON_HDR_LEN 198 #define PCP_MIN_UDP_LEN (PCP_MIN_LEN + UDP_HDR_LEN) 200 #define PCP_MAX_LEN 1024 203 #define PCP_MAX_UDP_LEN (PCP_MAX_LEN + UDP_HDR_LEN) 206 #define PCP_MAP_OPCODE_MIN_LEN (PCP_COMMON_HDR_LEN + \ 207 sizeof( pcp_map_option_specific_data_t)) 210 #define PCP_PEER_OPCODE_MIN_LEN (PCP_COMMON_HDR_LEN + \ 211 sizeof( pcp_peer_option_specific_data_t)) 214 #define PCP_MAP_OPCODE_MIN_UDP_LEN (PCP_MAP_OPCODE_MIN_LEN + \ 217 #define PCP_GET_MAP_OPTION_OFFSET(req) \ 218 ((u8*)req + PCP_MAP_OPCODE_MIN_LEN) 220 #define PCP_GET_PEER_OPTION_OFFSET(req) \ 221 ((u8*)req + PCP_PEER_OPCODE_MIN_LEN) 224 #define PCP_REQ_TOTAL_LEN(udp) (udp->udp_length - \ 227 #define PCP_MAP_OPCODE_PREF_FAIL_OPTION_LEN \ 228 (PCP_MAP_OPCODE_MIN_UDP_LEN + \ 229 sizeof(pcp_prefer_fail_option_t)) 233 #define PCP_PEER_OPCODE_MIN_UDP_LEN (PCP_PEER_OPCODE_MIN_LEN + \ 236 #define PCP_MUST_OPTION(option_code) (option_code & 0x80) 241 #define PCP_DSLITE_MAP_OPCODE_MIN_UDP_LEN \ 242 ( PCP_MAP_OPCODE_MIN_UDP_LEN + \ 243 PCP_3RD_PARTY_OPTION_SIZE) 246 #define PCP_DSLITE_MAP_OPCODE_MAX_UDP_LEN \ 247 ( PCP_MAP_OPCODE_PREF_FAIL_OPTION_LEN + \ 248 PCP_3RD_PARTY_OPTION_SIZE) 251 #define PCP_DSLITE_PEER_OPCODE_MIN_UDP_LEN \ 252 ( PCP_PEER_OPCODE_MIN_UDP_LEN + \ 253 PCP_3RD_PARTY_OPTION_SIZE) 256 #define PCP_SET_CNAT_PROTO(proto) \ 257 pcp_data.cnat_proto = (proto == TCP_PROT) ? CNAT_TCP: \ 258 (proto == UDP_PROT)? CNAT_UDP : CNAT_ICMP; 260 #define PCP_SET_REQ_LIFETIME() \ 261 if(pcp_data.db->flags & CNAT_DB_FLAG_STATIC_PORT) { \ 262 pcp_data.db->proto_data.seq_pcp.pcp_lifetime = \ 263 PCP_STATIC_LIFETIME; \ 264 pcp_data.req_lifetime = PCP_STATIC_LIFETIME; \ 266 pcp_data.db->proto_data.seq_pcp.pcp_lifetime = \ 267 pcp_data.req_lifetime + cnat_current_time ; \ 276 #define PCP_THROTTLE_LIMIT 2 388 #define PCP_SERVICE_NAT44 1 389 #define PCP_SERVICE_DSLITE 2 390 #define PCP_SERVICE_NAT64 3 393 #define PCP_REQ_ENTRY_PRESENT 1 394 #define PCP_REQ_EXT_MAP_PRESENT 1 u64 pcp_map_invalid_delete_req
enum pcp_opcode pcp_opcode_t
u64 pcp_noexact_db_allocated
struct pcp_response pcp_response_t
struct pcp_prefer_fail_option pcp_prefer_fail_option_t
u64 pcp_map_invalid_option_len
dslite_table_entry_t * inst_ptr
pcp_result_codes_t ret_code
cnat_main_db_entry_t * db
u64 pcp_static_entry_present
u64 pcp_exact_db_alloc_failed
u64 pcp_map_invalid_option
u64 pcp_invalid_client_ip
u64 pcp_map_pref_fail_option
struct pcp_debug_counters pcp_debug_counters_t
struct pcp_peer_option_specific_data pcp_peer_option_specific_data_t
enum pcp_options pcp_options_t
u64 pcp_peer_addr_mistmatch
struct pcp_map_option_specific_data pcp_map_option_specific_data_t
enum pcp_result_codes pcp_result_codes_t
pcp_options_t third_party
struct pcp_3rd_party_option pcp_3rd_party_option_t
pcp_debug_counters_t counters
u64 pcp_exact_entry_created
struct pcp_request pcp_request_t
struct pcp_options_hdr pcp_options_hdr_t
struct pcp_pipeline_data pcp_pipeline_data_t