1 /*
2  * Argus Software Common include files - Parser
3  * Copyright (c) 2000-2015 QoSient, LLC
4  * All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10 
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15 
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  *
20  */
21 
22 /*
23  * $Id: //depot/argus/argus/include/argus_parser.h#21 $
24  * $DateTime: 2015/04/06 10:38:44 $
25  * $Change: 2973 $
26  */
27 
28 
29 #if !defined(Argus_parser_h)
30 #define Argus_parser_h
31 
32 #include <argus_compat.h>
33 
34 #if defined(ARGUS_THREADS)
35 #include <pthread.h>
36 #endif
37 
38 #ifdef ARGUS_SASL
39 #include <sasl/sasl.h>
40 #endif
41 
42 #include <argus_debug.h>
43 #include <argus_def.h>
44 #include <argus_int.h>
45 
46 #define ARGUS_PRINTSRC	0x0001
47 #define ARGUS_PRINTDST	0x0002
48 #define ARGUS_ACTTIME	0x0004
49 #define ARGUS_IDLETIME	0x0008
50 #define ARGUS_DIST	0x0010
51 
52 #define ARGUS_PRINTGMT	0x0020
53 #define ARGUS_PRINTNET	0x0022
54 
55 
56 #define ARGUS_ENCODE_ASCII       0
57 #define ARGUS_ENCODE_64          1
58 #define ARGUS_ENCODE_32          2
59 
60 #define ARGUS_MAX_S_OPTIONS      34
61 #define HASHNAMESIZE		256
62 
63 #define ARGUS_FORCE_LOCAL_SRC           0x02
64 #define ARGUS_FORCE_LOCAL_DST           0x04
65 #define ARGUS_SUGGEST_LOCAL_SRC         0x08
66 #define ARGUS_SUGGEST_LOCAL_DST         0x10
67 
68 #define ARGUS_PORT_SERVICES             0x100
69 #define ARGUS_PORT_WELLKNOWN            0x200
70 #define ARGUS_PORT_REGISTERED           0x400
71 
72 #define ARGUS_ADDR_DIR_MASK (ARGUS_SUGGEST_LOCAL_SRC | ARGUS_SUGGEST_LOCAL_DST | ARGUS_FORCE_LOCAL_SRC | ARGUS_FORCE_LOCAL_DST)
73 #define ARGUS_PORT_DIR_MASK (ARGUS_PORT_SERVICES | ARGUS_PORT_WELLKNOWN | ARGUS_PORT_REGISTERED)
74 
75 #include <netinet/in.h>
76 
77 struct h6namemem {
78    struct in6_addr addr;
79    char *name;
80    struct h6namemem *nxt;
81 };
82 
83 struct hnamemem {
84    u_int addr;
85    char *name;
86    struct hnamemem *nxt;
87 };
88 
89 struct enamemem {
90    u_short e_addr0;
91    u_short e_addr1;
92    u_short e_addr2;
93    char *e_name;
94    u_char *e_nsap;         /* used only for nsaptable[] */
95    struct enamemem *e_nxt;
96 };
97 
98 
99 struct protoidmem {
100    u_int p_oui;
101    u_short p_proto;
102    char *p_name;
103    struct protoidmem *p_nxt;
104 };
105 
106 
107 struct ArgusCIDRAddr {
108    u_char type, len, masklen, opmask;
109    u_int addr[4], mask[4];
110 };
111 
112 struct ArgusParserStruct {
113    int status;
114    char fflag, nflag, tflag, uflag, Wflag;
115    char Iflag, Tflag, rflag, Rflag, Sflag, xflag;
116    char Xflag, XMLflag, zflag, Zflag, pflag;
117 
118    int RaCumulativeMerge, RaFlowMajorModified;
119    int RaAllocHashTableHealers, RaAllocArgusRecord;
120    int RaThisActiveIndex, RaThisFlowNum;
121    int RaThisModelNum, RaParseError;
122    int ArgusSessionId, NonBlockingDNS, ArgusDSCodePoints;
123    int ArgusDirectionFunction;
124 
125    char *RaFlowModelFile, *ArgusFlowModelFile, *ArgusRemoteFilter;
126    struct RaFlowModelStruct *RaFlowModel;
127 
128    struct ArgusCIDRAddr ArgusCIDRBuffer, *ArgusCIDRPtr;
129 
130    struct ArgusModeStruct *ArgusModeList;
131    struct ArgusInput *ArgusCurrentInput;
132 
133    int ArgusFilterFiledes[2];
134    int ArgusControlFiledes[2];
135 
136    int ArgusSrvInit;
137 
138    unsigned int f_localnet, f_netmask;
139    struct protoidmem protoidtable[HASHNAMESIZE];
140    struct enamemem enametable[HASHNAMESIZE];
141    struct enamemem nsaptable[HASHNAMESIZE];
142 
143  #define ARGUS_MAXEPROTODB   0x10000
144    struct ArgusEtherTypeStruct *argus_eproto_db[ARGUS_MAXEPROTODB];
145 
146    struct h6namemem h6nametable[HASHNAMESIZE];
147    struct hnamemem  hnametable[HASHNAMESIZE];
148    struct hnamemem  tporttable[HASHNAMESIZE];
149    struct hnamemem  uporttable[HASHNAMESIZE];
150    struct hnamemem  eprototable[HASHNAMESIZE];
151    struct hnamemem  nnametable[HASHNAMESIZE];
152    struct hnamemem  llcsaptable[HASHNAMESIZE];
153 };
154 
155 
156 #define ARGUSMONITOR_EQUAL      0x01
157 #define ARGUSMONITOR_NOTEQUAL   0x02
158 
159 struct ArgusCIDRAddr *RaParseCIDRAddr (struct ArgusParserStruct *, char *);
160 
161 #if defined(Argus_Parser)
162 struct ArgusParserStruct *ArgusNewParser(char *);
163 void ArgusCloseParser(struct ArgusParserStruct *);
164 struct ArgusParserStruct *ArgusParser;
165 
166 #else
167 extern struct ArgusParserStruct *ArgusNewParser(char *);
168 extern void ArgusCloseParser(struct ArgusParserStruct *);
169 extern struct ArgusParserStruct *ArgusParser;
170 
171 #endif
172 
173 #endif
174