FD.io VPP  v17.01.1-3-gc6833f8
Vector Packet Processing
cnat_v4_ftp_alg.h
Go to the documentation of this file.
1 /*
2  *------------------------------------------------------------------
3  * cnat_v4_ftp_alg.h
4  *
5  * Copyright (c) 2012-2013 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:
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
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  *------------------------------------------------------------------
18  */
19 
20 #ifndef __CNAT_V4_FTP_ALG_H__
21 #define __CNAT_V4_FTP_ALG_H__
22 
23 
24 #include <vlib/vlib.h>
25 #include <vnet/vnet.h>
26 
27 #include "tcp_header_definitions.h"
28 #include "dslite_defs.h"
29 #include "dslite_db.h"
30 
31 /* shorter form of byte order functions */
32 
33 #define net2host16(x) clib_net_to_host_u16( x)
34 #define net2host32(x) clib_net_to_host_u32( x)
35 #define net2host64(x) clib_net_to_host_u64( x)
36 #define host2net16(x) clib_host_to_net_u16(x)
37 #define host2net32(x) clib_host_to_net_u32(x)
38 #define host2net64(x) clib_host_to_net_u64(x)
39 
40 //#define BIGENDIAN
41 
42 typedef struct iphdrtype_ {
43  u8 v_ihl; /* version and IP header length */
44  u8 tos; /* type of service */
45  u16 tl; /* total length */
46  u16 id; /* identifier */
50  u16 fo: 13; /* fragment offset */
51  u8 ttl; /* time to live */
52  u8 prot; /* protocol type */
53  u16 checksum; /* checksum */
54  u32 srcadr; /* IP source address */
55  u32 dstadr; /* IP destination address */
56 } iphdrtype;
57 
58 
59 typedef struct tcptype_ {
66 #if 0
67 /* bypass the ENDIAN part */
68 #ifdef BIGENDIAN
69  u8 reserved: 2;
70  u8 urg: 1;
71  u8 ack: 1;
72  u8 psh: 1;
73  u8 rst: 1;
74  u8 syn: 1;
75  u8 fin: 1;
76 #else
77  u8 fin: 1;
78  u8 syn: 1;
79  u8 rst: 1;
80  u8 psh: 1;
81  u8 ack: 1;
82  u8 urg: 1;
83  u8 reserved2: 2;
84 #endif
85 #endif
86 
90  u8 data[0];
91 } tcptype ;
92 
93 
95  tcptype *tcp,
96  u32 * ip_addr,
97  u16 * port);
98 
99 
100 u8 * ftp_test_pkt_gen (u32 ip_addr, u16 port);
101 
102 int update_ftp_port(u8 * pkt, u32 new_ip, u16 new_port, i8 * delta,
103  cnat_main_db_entry_t *db_tcp_control,
104  dslite_table_entry_t *dslite_entry_ptr,
105  ipv6_header_t *ipv6_hdr);
106 /*
107  * caller needs to check if it's a ftp packet
108  * this function returns 1
109  * if packet being updated for PORT
110  * otherwise return 0.
111  * Assume IP header DOES NOT have option fields
112  */
113 
114 int cnat_ftp_alg ( u8* pkt, i8 * delta, cnat_main_db_entry_t *db,
115  dslite_table_entry_t *dslite_entry_ptr,
116  ipv6_header_t *ipv6_hdr);
117 
118 #define FTP_ALG_DEBUG_PRINTF_ENABLED 1
119 
120 #ifdef FTP_ALG_DEBUG_PRINTF_ENABLED
121 
122 #define FTP_ALG_DEBUG_PRINTF(...) { \
123  if (global_debug_flag & CNAT_DEBUG_FTP_ALG) { \
124  printf(__VA_ARGS__); \
125  } }
126 
127 #else
128 
129 #define FTP_ALG_DEBUG_PRINTF(...)
130 
131 #endif
132 
133 #endif /* __CNAT_V4_FTP_ALG_H__ */
u16 urgentpointer
u32 sequencenumber
int update_ftp_port(u8 *pkt, u32 new_ip, u16 new_port, i8 *delta, cnat_main_db_entry_t *db_tcp_control, dslite_table_entry_t *dslite_entry_ptr, ipv6_header_t *ipv6_hdr)
Definition: cnat_db.h:153
int cnat_ftp_alg(u8 *pkt, i8 *delta, cnat_main_db_entry_t *db, dslite_table_entry_t *dslite_entry_ptr, ipv6_header_t *ipv6_hdr)
Definition: dslite_defs.h:106
char i8
Definition: types.h:45
struct iphdrtype_ iphdrtype
int watch_ftp_port_cmd(iphdrtype *ip, tcptype *tcp, u32 *ip_addr, u16 *port)
struct tcptype_ tcptype
u32 acknowledgementnumber
unsigned int u32
Definition: types.h:88
u16 destinationport
unsigned short u16
Definition: types.h:57
unsigned char u8
Definition: types.h:56
u8 * ftp_test_pkt_gen(u32 ip_addr, u16 port)