1/* --------------------------------------------------------------------------------------------------------------
2 * FILE NAME       l7_filter_main.h (for Linux Platform)
3 * DATE            10/25/2007
4 * AUTHOR/S        Max Ding
5 * Description     Layer 7 filter
6 * --------------------------------------------------------------------------------------------------------------
7 */
8
9#ifndef __LAYER7_FILTER_MAIN_H
10#define __LAYER7_FILTER_MAIN_H
11
12//#define L7_DEBUG_ON
13
14/* enum of these protocol*/
15#define L7_ENUM_INIT            0xff
16#define L7_ENUM_BITTORRENT      1
17#define L7_ENUM_FASTTRACK       2
18#define L7_ENUM_EDONKEY         3
19#define L7_ENUM_GNUTELLA        4
20#define L7_ENUM_SKYPETOSKYPE    5
21#define L7_ENUM_SKYPEOUT        6
22#define L7_ENUM_NETGEAREVA      7   /*foxconn add by pingod, 07/12/2008*/
23#define L7_ENUM_TOTAL           L7_ENUM_NETGEAREVA    /* make this equal the to the last app */
24
25#define APP_DATA_BUF_MAX_LEN    8192
26
27#define L7_SUCCESS 0
28#define L7_ERROR 1
29
30/* for connection direction */
31#define AG_INBOUND   0
32#define AG_OUTBOUND  1
33
34#ifndef IN
35#define IN
36#endif
37
38#ifndef OUT
39#define OUT
40#endif
41
42#ifndef INOUT
43#define INOUT
44#endif
45
46#ifndef BYTE
47#define BYTE        unsigned char
48#endif
49
50#ifndef WORD
51#define WORD        unsigned short  /* 2-byte */
52#endif
53
54#ifndef DWORD
55#define DWORD       unsigned long    /* 4-byte */
56#endif
57
58#ifndef BOOL
59#define BOOL        int
60#endif
61
62#ifndef TRUE
63#define TRUE        1
64#endif
65
66#ifndef FALSE
67#define FALSE       0
68#endif
69
70#ifndef UINT16
71#define UINT16      unsigned short  /* 2-byte */
72#endif
73
74#ifndef UINT32
75#define UINT32      unsigned int    /* 4-byte */
76#endif
77
78#ifndef RT_HANDLE
79#define RT_HANDLE void*
80#endif
81
82/* ip field definition */
83#define         IPVERSION4          4
84#define         IPVERSION6          6
85#define         ICMP_PROTOCOL       0x01
86#define         TCP_PROTOCOL        0x06
87#define         UDP_PROTOCOL        0x11
88#define         ESP_PROTOCOL        0x32
89#define         AH_PROTOCOL         0x33
90#define         GRE_PROTOCOL        0x2f
91#define         Broadcast_IP        0xffffffff
92
93/* for bNatType, must be the same as bRuleNatType */
94#define AG_BASIC_NAT           0
95#define AG_NAPT                1
96#define AG_PORT_FORWARDING     2
97#define AG_RNAT                3
98
99#define         EVA_PORT_START      49152
100#define         EVA_PORT_END        49155
101
102//#define ntohs(x) ((UINT16)( ( ( (x) & 0x00ff ) << 8 ) | \
103//                            ( ( (x) & 0xff00 ) >> 8 ) ) )
104
105typedef struct _proto_regexp
106{
107    char * const proto_name;
108    //unsigned char proto_pri;
109    unsigned char proto_enum;
110    int proto_packet_count;/*Foxconn added by Max Ding for test, 10/26/2007 */
111    char *proto_regexp;
112} s_proto_regexp;
113
114typedef struct _pattern_cache {
115    char * regex_string;
116    regexp * pattern;
117    struct pattern_cache * next;
118    //unsigned char proto_pri;
119    unsigned char proto_enum;/*Foxconn added by Max Ding, 10/12/2007 */
120    char *proto_name;
121} s_pattern_cache;
122
123
124/*Attention: The following code should sync with agconntbl.h and agUserApi.h*/
125typedef struct S_ConnHashEntry
126{
127    unsigned short iInNextConnId;
128    unsigned short iOutNextConnId;
129    BYTE           bEntryReady;    //Foxconn added, nathan, 07/06/2006 @cdrouter_ipsec
130} T_ConnHashEntry;
131
132typedef struct S_ConnEntry
133{
134    T_ConnHashEntry tHash;
135    BYTE bEntryReady;//Foxconn add, FredPeng, 01/11/2008@fvs114
136    short iConnId;
137    short iAlg;
138#define wServerEspSpiHalf2 iAlgSession    //Ambit add, Peter Chen, 10/28/2004
139    short iAlgSession;
140    UINT32 dwSourceIp;
141    UINT32 dwDestIp;
142    UINT32 dwModifiedIp;
143    UINT32 dwTimestamp;
144#define wClientEspSpiHalf1 wSourcePort  //Ambit add, Peter Chen, 10/28/2004
145#define wIcmpIdentity wSourcePort
146    UINT16 wSourcePort; /*use to save id field if packet type is icmp, network order*/
147#define wClientEspSpiHalf2 wDestPort    //Ambit add, Peter Chen, 10/28/2004
148#define wIcmpSequence wDestPort
149    UINT16 wDestPort;  /*use to save seq field if packet type is icmp, network order*/
150#define wServerEspSpiHalf1 wModifiedPort  //Ambit add, Peter Chen, 10/28/2004
151#define wIcmpModifiedSequence wModifiedPort
152    UINT16 wModifiedPort; /*use to save modified seq field if packet type is icmp, network order*/
153    BYTE bProtocol; /* same with ip->proto */
154    BYTE bConnState:4,
155         bNatType:4; /*Basic NAT, NAPT, Port Forwarding */
156/* Foxconn added start, Eddic, 11/25/2004 */
157    BYTE bSelf:4,
158         bTcpStatus:4;/* Foxconn modified by Max Ding, 12/17/2007 for Dos log */
159    UINT32 dwTimeOut;
160/* Foxconn added end, Eddic, 11/25/2004 */
161
162//Ambit add start, Peter Chen, 12/22/2004
163//Foxconn modify start, Tim Liu, 10/18/2005
164#ifdef __VXWORKS__
165    struct rtentry  *pOut_rtentry;
166    struct rtentry  *pIn_rtentry;
167#elif __LINUX__
168    RT_HANDLE pOut_rtentry;
169    RT_HANDLE pIn_rtentry;
170#endif
171//Foxconn modify end, Tim Liu, 10/18/2005
172//Ambit add end, Peter Chen, 12/22/2004
173
174    /*Foxconn added start by EricHuang, 7/20/2005*/
175#ifdef INCLUDE_TMSS
176    #define URL_DENY    0
177    #define URL_ALLOW   1
178    BYTE bIsDeny;
179    char tmssURLHostString[256];
180    char tmssURLPathString[512];
181#endif
182    /*Foxconn added end by EricHuang, 7/20/2005*/
183    /*Foxconn add start, Max Ding, 10/13/2007 */
184#ifdef INCLUDE_L7_FILTER
185    BYTE packet_count;
186    BYTE proto_enum;
187#endif
188    /*Foxconn add end, Max Ding, 10/13/2007 */
189
190} T_ConnEntry;
191
192#endif /*__LAYER7_FILTER_MAIN_H*/
193