2 *------------------------------------------------------------------
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:
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 #ifndef __CNAT_V4_FTP_ALG_H__
21 #define __CNAT_V4_FTP_ALG_H__
24 #include <vlib/vlib.h>
25 #include <vnet/vnet.h>
27 #include "tcp_header_definitions.h"
28 #include "dslite_defs.h"
29 #include "dslite_db.h"
31 /* shorter form of byte order functions */
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)
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 */
59 typedef struct tcptype_ {
63 u32 acknowledgementnumber;
67 /* bypass the ENDIAN part */
94 int watch_ftp_port_cmd (iphdrtype *ip,
100 u8 * ftp_test_pkt_gen (u32 ip_addr, u16 port);
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);
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
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);
118 #define FTP_ALG_DEBUG_PRINTF_ENABLED 1
120 #ifdef FTP_ALG_DEBUG_PRINTF_ENABLED
122 #define FTP_ALG_DEBUG_PRINTF(...) { \
123 if (global_debug_flag & CNAT_DEBUG_FTP_ALG) { \
124 printf(__VA_ARGS__); \
129 #define FTP_ALG_DEBUG_PRINTF(...)
133 #endif /* __CNAT_V4_FTP_ALG_H__ */