FD.io VPP  v16.09
Vector Packet Processing
cnat_v4_functions.h File Reference
+ Include dependency graph for cnat_v4_functions.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tcp_logging_struct
 

Macros

#define TCP_LOGGING_DISABLE   0
 
#define TCP_LOGGING_ENABLE   1
 
#define TCP_LOGGING_PACKET_DUMP   2
 
#define TCP_LOGGING_SUMMARY_DUMP   3
 
#define MAX_TCP_LOGGING_COUNT   1024
 
#define JLI   printf("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); fflush(stdout);
 
#define CNAT_ICMP_DEST_UNREACHABLE   100
 
#define INCREMENT_NODE_COUNTER(c)   em->counters[node_counter_base_index + c] += 1;
 
#define V4_TCP_UPDATE_SESSION_FLAG(db, tcp)
 
#define V4_TCP_UPDATE_SESSION_DB_FLAG(sdb, tcp)
 
#define CNAT_UPDATE_TCP_SEQ_ACK_CHECKSUM(old_val32, new_val32)
 
#define CNAT_UPDATE_L3_CHECKSUM_DECLARE
 
#define CNAT_UPDATE_L3_CHECKSUM(old_l3_1, old_l3_2, old_l3_c, new_l3_1, new_l3_2)
 
#define CNAT_UPDATE_L3_L4_CHECKSUM_DECLARE
 
#define CNAT_UPDATE_L3_L4_CHECKSUM(old_l3_1, old_l3_2, old_l4, old_l3_c, old_l4_c, new_l3_1, new_l3_2, new_l4)
 
#define CNAT_UPDATE_L3_ICMP_CHECKSUM(old_l3_1, old_l3_2, old_l4, old_l3_c, old_l4_c, new_l3_1, new_l3_2, new_l4)
 
#define CNAT_UPDATE_ICMP_ERR_CHECKSUM_DECLARE
 
#define CNAT_UPDATE_ICMP_ERR_CHECKSUM(old_ip_1, old_ip_2, old_ip_port, old_ip_c, old_icmp_c, new_ip_1, new_ip_2, new_ip_port, new_ip_c)
 
#define FILL_CHECKSUM(checksum_field, sum32)
 

Typedefs

typedef struct tcp_logging_struct tcp_logging_struct_t
 

Functions

void tcp_debug_logging_dump (void)
 
void tcp_debug_logging_enable_disable (u32 enable_flag)
 
void tcp_debug_logging (u32 seq_num, u32 ack_num, u32 old_ip, u32 new_ip, u16 old_port, u16 new_port, u16 old_ip_crc, u16 new_ip_crc, u16 old_tcp_crc, u16 new_tcp_crc)
 
static void cnat_v4_recalculate_tcp_checksum (ipv4_header *ip, tcp_hdr_type *tcp, u32 *ip_addr_ptr, u16 *tcp_port_addr_ptr, u32 new_ip, u16 new_port)
 
void tcp_in2out_nat_mss_n_checksum (ipv4_header *ip, tcp_hdr_type *tcp, u32 ipv4_addr, u16 port, cnat_main_db_entry_t *db)
 
void hex_dump (u8 *p, int len)
 
u32 get_my_svi_intf_ip_addr ()
 
u32 icmp_msg_gen_allowed ()
 
cnat_icmp_msg_t v6_icmp_msg_gen_allowed ()
 
int v4_crc_zero_udp_allowed ()
 
void ipv4_decr_ttl_n_calc_csum (ipv4_header *ipv4)
 
int icmpv4_generate_with_throttling (spp_ctx_t *ctx, ipv4_header *ipv4, u16 rx_uidb_index)
 
int icmpv6_generate_with_throttling (spp_ctx_t *ctx, ipv6_header_t *ipv4, u16 rx_uidb_index)
 
void icmp_error_generate_v6 (spp_ctx_t *ctx, u8 icmp_type, u8 icmp_code, u16 uidb_index)
 
void calculate_window_scale (tcp_hdr_type *tcp_header, u8 *scale)
 
void cnat_log_nat44_tcp_seq_mismatch (cnat_main_db_entry_t *db, cnat_vrfmap_t *vrfmap)
 
void print_icmp_pkt (ipv4_header *ip)
 
void print_udp_pkt (ipv4_header *ip)
 
void print_tcp_pkt (ipv4_header *ip)
 
void print_ipv6_pkt (ipv6_header_t *ip)
 

Macro Definition Documentation

#define CNAT_ICMP_DEST_UNREACHABLE   100

Definition at line 70 of file cnat_v4_functions.h.

#define CNAT_UPDATE_ICMP_ERR_CHECKSUM (   old_ip_1,
  old_ip_2,
  old_ip_port,
  old_ip_c,
  old_icmp_c,
  new_ip_1,
  new_ip_2,
  new_ip_port,
  new_ip_c 
)
Value:
old_ip_1r = ~(old_ip_1); \
old_ip_2r = ~(old_ip_2); \
old_ip_port_r = ~(old_ip_port); \
old_ip_cr = ~(old_ip_c); \
old_icmp_cr = ~(old_icmp_c); \
sum32 = old_ip_1r + old_ip_2r + new_ip_1 + new_ip_2 + \
old_ip_port_r + new_ip_port + old_ip_cr + new_ip_c; \
new32 = old_icmp_cr + sum32; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_icmp_c = ~((u16)new32); \
unsigned short u16
Definition: types.h:57

Definition at line 206 of file cnat_v4_functions.h.

#define CNAT_UPDATE_ICMP_ERR_CHECKSUM_DECLARE
Value:
u16 old_ip_1r, old_ip_2r, old_ip_port_r, old_ip_cr, old_icmp_cr; \
u16 new_icmp_c; \
u32 sum32;
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57

Definition at line 200 of file cnat_v4_functions.h.

#define CNAT_UPDATE_L3_CHECKSUM (   old_l3_1,
  old_l3_2,
  old_l3_c,
  new_l3_1,
  new_l3_2 
)
Value:
old_l3_1r = ~(old_l3_1); \
old_l3_2r = ~(old_l3_2); \
old_l3_cr = ~(old_l3_c); \
new32 = old_l3_cr + old_l3_1r + old_l3_2r + new_l3_1 + new_l3_2; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_l3_c = ~((u16)new32);
unsigned short u16
Definition: types.h:57

Definition at line 128 of file cnat_v4_functions.h.

#define CNAT_UPDATE_L3_CHECKSUM_DECLARE
Value:
u16 old_l3_1r, old_l3_2r; \
u16 old_l3_cr, new_l3_c; \
u32 new32;
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57

Definition at line 123 of file cnat_v4_functions.h.

#define CNAT_UPDATE_L3_ICMP_CHECKSUM (   old_l3_1,
  old_l3_2,
  old_l4,
  old_l3_c,
  old_l4_c,
  new_l3_1,
  new_l3_2,
  new_l4 
)
Value:
old_l3_1r = ~(old_l3_1); \
old_l3_2r = ~(old_l3_2); \
old_l3_cr = ~(old_l3_c); \
sum32 = old_l3_1r + old_l3_2r + new_l3_1 + new_l3_2; \
new32 = old_l3_cr + sum32; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_l3_c = ~((u16)new32); \
old_l4r = ~(old_l4); \
old_l4_cr = ~(old_l4_c); \
sum32 = old_l4r + new_l4; \
new32 = old_l4_cr + sum32; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_l4_c = ~((u16)new32);
unsigned short u16
Definition: types.h:57

Definition at line 172 of file cnat_v4_functions.h.

#define CNAT_UPDATE_L3_L4_CHECKSUM (   old_l3_1,
  old_l3_2,
  old_l4,
  old_l3_c,
  old_l4_c,
  new_l3_1,
  new_l3_2,
  new_l4 
)
Value:
old_l3_1r = ~(old_l3_1); \
old_l3_2r = ~(old_l3_2); \
old_l3_cr = ~(old_l3_c); \
sum32 = old_l3_1r + old_l3_2r + new_l3_1 + new_l3_2; \
new32 = old_l3_cr + sum32; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_l3_c = ~((u16)new32); \
old_l4r = ~(old_l4); \
old_l4_cr = ~(old_l4_c); \
sum32 += old_l4r + new_l4; \
new32 = old_l4_cr + sum32; \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new32 = (new32 & 0xffff) + ((new32 >> 16) & 0xffff); \
new_l4_c = ~((u16)new32);
unsigned short u16
Definition: types.h:57

Definition at line 150 of file cnat_v4_functions.h.

#define CNAT_UPDATE_L3_L4_CHECKSUM_DECLARE
Value:
u16 old_l3_1r, old_l3_2r, old_l4r; \
u16 old_l3_cr, old_l4_cr; \
u16 new_l3_c, new_l4_c; \
u32 sum32, new32;
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57

Definition at line 144 of file cnat_v4_functions.h.

#define CNAT_UPDATE_TCP_SEQ_ACK_CHECKSUM (   old_val32,
  new_val32 
)
Value:
{ \
u16 old_val_lower, old_val_upper, old_tcp_cr; \
u16 new_val_lower, new_val_upper, new_tcp_cr; \
u32 sum32; \
\
old_val_lower = ~((u16) old_val32); \
old_val_upper = ~((u16) (old_val32 >> 16)); \
old_tcp_cr = ~net2host16(&tcp->tcp_checksum); \
new_val_lower = (u16) new_val32; \
new_val_upper = (u16) (new_val32 >> 16); \
\
sum32 = old_val_lower + old_val_upper + old_tcp_cr + \
new_val_lower + new_val_upper; \
\
sum32 = (sum32 & 0xffff) + ((sum32 >> 16) & 0xffff); \
sum32 = (sum32 & 0xffff) + ((sum32 >> 16) & 0xffff); \
new_tcp_cr = ~((u16)sum32); \
\
tcp->tcp_checksum = host2net16(new_tcp_cr); \
}
#define net2host16(x)
unsigned int u32
Definition: types.h:88
unsigned short u16
Definition: types.h:57
#define host2net16(x)

Definition at line 97 of file cnat_v4_functions.h.

#define FILL_CHECKSUM (   checksum_field,
  sum32 
)
Value:
{ \
sum32 = (sum32 & 0xffff) + ((sum32>>16) & 0xffff); \
sum32 = (sum32 & 0xffff) + ((sum32>>16) & 0xffff); \
checksum_field = clib_host_to_net_u16(~((u16) sum32)); \
}
unsigned short u16
Definition: types.h:57

Definition at line 225 of file cnat_v4_functions.h.

#define INCREMENT_NODE_COUNTER (   c)    em->counters[node_counter_base_index + c] += 1;

Definition at line 71 of file cnat_v4_functions.h.

#define JLI   printf("%s %s %d\n", __FILE__, __FUNCTION__, __LINE__); fflush(stdout);

Definition at line 68 of file cnat_v4_functions.h.

#define MAX_TCP_LOGGING_COUNT   1024

Definition at line 37 of file cnat_v4_functions.h.

#define TCP_LOGGING_DISABLE   0

Definition at line 32 of file cnat_v4_functions.h.

#define TCP_LOGGING_ENABLE   1

Definition at line 33 of file cnat_v4_functions.h.

#define TCP_LOGGING_PACKET_DUMP   2

Definition at line 34 of file cnat_v4_functions.h.

#define TCP_LOGGING_SUMMARY_DUMP   3

Definition at line 35 of file cnat_v4_functions.h.

#define V4_TCP_UPDATE_SESSION_DB_FLAG (   sdb,
  tcp 
)
Value:
if ((tcp->flags & TCP_FLAG_ACK) && (tcp->flags & TCP_FLAG_SYN)) { \
sdb->flags |= CNAT_DB_FLAG_TCP_ACTIVE; \
} \
if ((tcp->flags & TCP_FLAG_RST) || (tcp->flags & TCP_FLAG_FIN)) { \
sdb->flags &= ~CNAT_DB_FLAG_TCP_ACTIVE; \
sdb->flags |= CNAT_DB_FLAG_TCP_CLOSING; \
}
#define TCP_FLAG_ACK
#define CNAT_DB_FLAG_TCP_CLOSING
Definition: cnat_db.h:186
#define TCP_FLAG_SYN
#define TCP_FLAG_RST
#define CNAT_DB_FLAG_TCP_ACTIVE
Definition: cnat_db.h:161
#define TCP_FLAG_FIN

Definition at line 83 of file cnat_v4_functions.h.

#define V4_TCP_UPDATE_SESSION_FLAG (   db,
  tcp 
)
Value:
if ((tcp->flags & TCP_FLAG_ACK) && (tcp->flags & TCP_FLAG_SYN)) { \
db->flags |= CNAT_DB_FLAG_TCP_ACTIVE; \
} \
if ((tcp->flags & TCP_FLAG_RST) || (tcp->flags & TCP_FLAG_FIN)) { \
db->flags &= ~CNAT_DB_FLAG_TCP_ACTIVE; \
db->flags |= CNAT_DB_FLAG_TCP_CLOSING; \
}
#define TCP_FLAG_ACK
#define CNAT_DB_FLAG_TCP_CLOSING
Definition: cnat_db.h:186
#define TCP_FLAG_SYN
#define TCP_FLAG_RST
#define CNAT_DB_FLAG_TCP_ACTIVE
Definition: cnat_db.h:161
#define TCP_FLAG_FIN

Definition at line 74 of file cnat_v4_functions.h.

Typedef Documentation

Function Documentation

void calculate_window_scale ( tcp_hdr_type tcp_header,
u8 scale 
)

Definition at line 2135 of file cnat_util.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void cnat_log_nat44_tcp_seq_mismatch ( cnat_main_db_entry_t db,
cnat_vrfmap_t vrfmap 
)

+ Here is the caller graph for this function:

static void cnat_v4_recalculate_tcp_checksum ( ipv4_header ip,
tcp_hdr_type tcp,
u32 ip_addr_ptr,
u16 tcp_port_addr_ptr,
u32  new_ip,
u16  new_port 
)
inlinestatic

Definition at line 232 of file cnat_v4_functions.h.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

u32 get_my_svi_intf_ip_addr ( )

Definition at line 362 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void hex_dump ( u8 p,
int  len 
)

Definition at line 154 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void icmp_error_generate_v6 ( spp_ctx_t ctx,
u8  icmp_type,
u8  icmp_code,
u16  uidb_index 
)

+ Here is the caller graph for this function:

u32 icmp_msg_gen_allowed ( )

Definition at line 448 of file cnat_syslog.c.

+ Here is the caller graph for this function:

int icmpv4_generate_with_throttling ( spp_ctx_t ctx,
ipv4_header ipv4,
u16  rx_uidb_index 
)

+ Here is the caller graph for this function:

int icmpv6_generate_with_throttling ( spp_ctx_t ctx,
ipv6_header_t ipv4,
u16  rx_uidb_index 
)

+ Here is the caller graph for this function:

void ipv4_decr_ttl_n_calc_csum ( ipv4_header ipv4)

+ Here is the caller graph for this function:

void print_icmp_pkt ( ipv4_header ip)

Definition at line 165 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void print_ipv6_pkt ( ipv6_header_t ip)

+ Here is the caller graph for this function:

void print_tcp_pkt ( ipv4_header ip)

Definition at line 226 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void print_udp_pkt ( ipv4_header ip)

Definition at line 193 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void tcp_debug_logging ( u32  seq_num,
u32  ack_num,
u32  old_ip,
u32  new_ip,
u16  old_port,
u16  new_port,
u16  old_ip_crc,
u16  new_ip_crc,
u16  old_tcp_crc,
u16  new_tcp_crc 
)

Definition at line 41 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void tcp_debug_logging_dump ( void  )

Definition at line 76 of file cnat_v4_functions.c.

+ Here is the caller graph for this function:

void tcp_debug_logging_enable_disable ( u32  enable_flag)

Definition at line 115 of file cnat_v4_functions.c.

+ Here is the call graph for this function:

void tcp_in2out_nat_mss_n_checksum ( ipv4_header ip,
tcp_hdr_type tcp,
u32  ipv4_addr,
u16  port,
cnat_main_db_entry_t db 
)
inline

Definition at line 267 of file cnat_v4_functions.c.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int v4_crc_zero_udp_allowed ( )

+ Here is the caller graph for this function:

cnat_icmp_msg_t v6_icmp_msg_gen_allowed ( )

+ Here is the caller graph for this function: