File: argus_parse.h

package info (click to toggle)
argus 1%3A2.0.6.fixes.1-16.3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,016 kB
  • ctags: 4,025
  • sloc: ansic: 23,022; sh: 5,734; makefile: 380; yacc: 255; lex: 234
file content (1558 lines) | stat: -rwxr-xr-x 51,590 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
/*
 * Copyright (c) 2000-2004 QoSient, LLC
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * Copyright (c) 1993, 1994 Carnegie Mellon University.
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and
 * its documentation for any purpose and without fee is hereby granted, 
 * provided that the above copyright notice appear in all copies and
 * that both that copyright notice and this permission notice appear
 * in supporting documentation, and that the name of CMU not be
 * used in advertising or publicity pertaining to distribution of the
 * software without specific, written prior permission.  
 * 
 * CMU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
 * CMU BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
 * SOFTWARE.
 *
 */

#ifndef ArgusParse_h
#define ArgusParse_h

#include <unistd.h>
#include <stdlib.h>
#include <netdb.h>

#include <syslog.h>

#include <argus_out.h>
#include <argus_def.h>
#include <argus_util.h>


#define MINOR_VERSION_0    0
#define MINOR_VERSION_1    1
#define MINOR_VERSION_2    2
#define MINOR_VERSION_3    3
#define MINOR_VERSION_4    4
#define MINOR_VERSION_5    5
#define MINOR_VERSION_6    6
#define MINOR_VERSION_7    7
#define MINOR_VERSION_8    8
#define MINOR_VERSION_9    9
#define MAJOR_VERSION_1    1
#define MAJOR_VERSION_2    2
#define MAJOR_VERSION_3    3
#define MAJOR_VERSION_4    4
#define MAJOR_VERSION_5    5
#define VERSION_MAJOR      MAJOR_VERSION_2
#define VERSION_MINOR      MINOR_VERSION_0

#ifndef MAXPATHNAMELEN
#define MAXPATHNAMELEN          BUFSIZ
#endif

#define ARGUS_DEFAULTPORT	561
#define ARGUS_MAX_SORT_ALG	32

#define ARGUS_ENCODE_ASCII	0
#define ARGUS_ENCODE_64		1
 
struct naddrmem {
   struct naddrmem *nxt;
   unsigned int addr;
   unsigned short port;
};

struct ArgusInterfaceStruct {
   int value;
   char *label;
   char *desc;
};

#define MAXSTRLEN		4096
#define MAXTIME			100000
#define READ_REMOTE_CON		0x40000000
#define READ_LOCAL_CON		0x20000000


#ifdef ArgusParse

struct timeval RaClientTimeout = {1,0};
#define MAXPROCSTATE		7

char *process_state_strings [MAXPROCSTATE] = {
   "REQ", "ACC", "EST", "CLO", "TIM", "RST", "FIN",
};

char *RaSortAlgorithmStrings[ARGUS_MAX_SORT_ALG];
int RaSortIndex = 0;
int ArgusGrepSource = 0;
int ArgusGrepDestination = 0;

struct timeval ArgusGlobalTime;
struct timeval ArgusNowTime;

struct bpf_program ArgusFilterCode;

struct tm *RaTmStruct = NULL;
char *RaInputFilter = NULL;
char *RaTimeFormat = "%d %b %y %T";
char  RaFieldDelimiter = '\0';

int RaPrintStartTime = 0;
int RaPrintLastTime = 0;

struct naddrmem *naddrtable [HASHNAMESIZE];

char *exceptfile =  NULL, *wfile =  NULL;

struct ARGUS_INPUT *ArgusInput = NULL;
struct ARGUS_INPUT *ArgusInputFileList = NULL;
struct ARGUS_INPUT *ArgusRemoteHostList = NULL;

char *tag_string = "Argus Version ";
int major_version = VERSION_MAJOR;
int minor_version = VERSION_MINOR;
int read_size = 0, detail = 0;
int read_mode = 0;

struct ArgusRecord *initCon = NULL;

unsigned int ArgusLocalNet, ArgusNetMask;

char ArgusOriginalBuffer[MAXSTRLEN];
struct ArgusRecord *ArgusOriginal = (struct ArgusRecord *) ArgusOriginalBuffer;

int totalrecords = 0;
int farrecords = 0;
int marrecords = 0;

int explicit_date = 0;
 
time_t starTimeFilter_t = 0;
time_t lastTimeFilter_t = 0;

time_t lasttime_t = 0;
time_t startime_t = 0;

struct tm tm_lasttime;
struct tm tm_startime;

struct tm starTimeFilter;
struct tm lastTimeFilter;

char *ArgusProgramName = NULL;
char *ArgusProgramOptions = NULL;
char *dataarg = NULL;
char *timearg = NULL;
char *servicesfile = NULL;
char *ArgusFlowModelFile = NULL;
struct bpf_program ArgusFilterCode;

char *cmdline = NULL;	/* For David Brumley's amazingly long cmdlines ;o) */ 

int RaWriteOut = 1;

long long tcp_dst_count = 0;
long long tcp_src_count = 0;
long long udp_dst_count = 0;
long long udp_src_count = 0;
long long icmp_dst_count = 0;
long long icmp_src_count = 0;
long long ip_dst_count = 0;
long long ip_src_count = 0;
long long arp_dst_count = 0;
long long arp_src_count = 0;
long long nonip_dst_count = 0;
long long nonip_src_count = 0;

long long tcp_dst_bytes = 0;
long long tcp_src_bytes = 0;
long long udp_dst_bytes = 0;
long long udp_src_bytes = 0;
long long icmp_dst_bytes = 0;
long long icmp_src_bytes = 0;
long long ip_dst_bytes = 0;
long long ip_src_bytes = 0;
long long arp_dst_bytes = 0;
long long arp_src_bytes = 0;
long long nonip_dst_bytes = 0;
long long nonip_src_bytes = 0;

int hfield = 15;
int pfield = 12;
int Aflag = 0;
int aflag = 0;
int Bflag = 0;
int bflag = 0;
int eflag = 0;
char *estr = NULL;
int Dflag = 0;
int Eflag = 0;
int fflag = 0;
int gflag = 0;
int idflag = 0;
int Gflag = 0;
int cflag = 0;
int Cflag = 0;
int Lflag = 0;
int lflag = 0;
int mflag = 0;
char *Mflag = NULL;
int nflag = 0;
int Nflag = 0;
int Normflag = 0;
int Netflag = 0;
int notNetflag = 0;
int Oflag = 0;
int Wflag = 0;
int Fflag = 0;
int Hflag = 0;
int pflag = 0;
int Pflag = 0;
char *sflag = NULL;
int dflag = 0;
int Argusdflag = 0;
 
int qflag = 0;
int tflag = 0;
int uflag = 0;
char *ustr = NULL;
char *pstr = NULL;
int Uflag = 6;
int vflag = 0;
int Vflag = 0;
int iflag = 0;
 
int Iflag = 0;
int Tflag = 0;
int rflag = 0;
int Rflag = 0;
int Sflag = 0;
int Xflag = 0;
int XMLflag = 0;

int zflag = 0;
int Zflag = 0;
 
long thiszone;
 
int total_nets = 0;
int total_hosts = 0;

#define ARGUS_MAX_REMOTE_CONN		5

struct ARGUS_INPUT *ArgusRemoteFDs[ARGUS_MAX_REMOTE_CONN];
int ArgusActiveServers = 0;

extern int ArgusAuthenticate (struct ARGUS_INPUT *);
extern void ArgusClientInit (void);
extern void usage (void);
extern void parse_arg (void);

extern void process_man (struct ArgusRecord *);
extern void process_tcp (struct ArgusRecord *);
extern void process_icmp (struct ArgusRecord *);
extern void process_udp (struct ArgusRecord *);
extern void process_ip (struct ArgusRecord *);
extern void process_arp (struct ArgusRecord *);
extern void process_non_ip (struct ArgusRecord *);

void ArgusShutDown (int);
extern void RaParseComplete (int);

void argus_parse_init (struct ARGUS_INPUT *);
char *argus_lookupdev(char *);

void read_udp_services (char *);

int ArgusHandleDatum (struct ArgusRecord *, struct bpf_program *);
void ArgusReformatRecord (struct ArgusRecord *, struct ArgusRecord *);

int ArgusReadConnection (struct ARGUS_INPUT *, char *);
void ArgusReadStream (void);
void ArgusProcessRecord (struct ArgusRecord *);

void ArgusGenerateCanonicalRecord (struct ArgusRecord *, struct ArgusCanonicalRecord *);

int ArgusGetServerSocket (struct ARGUS_INPUT *);
int ArgusAddFileList (char *);
void ArgusDeleteFileList (void);
int ArgusAddHostList (char *);
void ArgusDeleteHostList (void);

int ArgusWriteNewLogfile (char *, struct ArgusRecord *);

int check_time (struct ArgusRecord *);
int parseUserDataArg (char **, char **, int);
int parseTimeArg (char **, char **, int, struct tm *);
int check_time_format (struct tm *tm, char *str);
int parseTime (struct tm *, struct tm *, char *);

#if defined(_LITTLE_ENDIAN)
void ArgusNtoH (struct ArgusRecord *argus);
void ArgusHtoN (struct ArgusRecord *argus);
#endif



#ifndef NFC_AGGREGATIONDEFINITION_H
#define NFC_AGGREGATIONDEFINITION_H
/* $Id: argus_parse.h,v 1.46 2004/02/23 15:00:36 argus Exp $
 * $Source: /usr/local/cvsroot/argus/include/argus_parse.h,v $
 *------------------------------------------------------------------
 * Definition of "Key" and "Value" fields used for purpose of 
 * aggregation
 *
 * Cisco NetFlow FlowCollector 3.0
 *
 * September 1998, Anders Fung
 *
 * Copyright (c) 1996-1998 by Cisco Systems, Inc.
 * All rights reserved.
 *------------------------------------------------------------------
 * $Log: argus_parse.h,v $
 * Revision 1.46  2004/02/23 15:00:36  argus
 * *** empty log message ***
 *
 * Revision 1.45  2003/03/27 04:11:13  argus
 * Updated for copyright
 *
 * Revision 1.44  2002/05/31 12:18:24  argus
 * Updated
 *
 * Revision 1.43  2002/05/03 17:33:38  argus
 * Merged 2.0.4 into main line
 *
 * Revision 1.39.4.2.2.7  2001/10/17 14:30:30  argus
 * Fix for argus_filter so that it generates a canonical record before
 * doing the matching.
 *
 * Revision 1.39.4.2.2.6  2001/10/11 19:43:46  argus
 * Updated and modified for Peter's fixes
 *
 * Revision 1.39.4.2.2.5  2001/10/01 14:20:38  argus
 * Switch to GPL for argus-2.0.2.redux
 *
 * Revision 1.39.4.2.2.4  2001/07/10 13:58:35  argus
 * Mods for little endian fix for FreeBSD
 *
 * Revision 1.39.4.2.2.3  2001/06/22 14:00:14  argus
 * Updated
 *
 * Revision 1.39.4.2  2001/04/24 16:29:03  argus
 * Updated copyright notice for 2001
 *
 * Revision 1.39.4.1  2001/04/24 12:36:49  argus
 * Updated
 *
 * Revision 1.40  2001/04/06 17:06:00  argus
 * Version Updated
 *
 * Revision 1.39  2001/03/06 23:30:41  argus
 * Fix for Davids incredibly long command lines.
 *
 * Revision 1.38  2001/02/03 21:39:08  argus
 * Mods to support -d option
 *
 * Revision 1.37  2000/12/19 16:19:41  argus
 * Mods to get ramon() to the same level as ra() with regard to dynamic
 * labels.  Also FreeBSD/NetBSD port support for racount().
 *
 * Revision 1.36  2000/12/19 05:59:03  argus
 * Mods to help in getting pretty output when not using -n.
 *
 * Revision 1.35  2000/12/10 20:59:13  argus
 * Mods to add support for RA_AUTH_PASS (pstr)
 *
 * Revision 1.34  2000/12/07 19:00:39  argus
 * Mods to convert from ArgusError to ArgusLog
 *
 * Revision 1.33  2000/12/07 17:51:48  argus
 * Move Uflag (precision option) to -p option.
 *
 * Revision 1.32  2000/11/23 01:58:29  argus
 * Mods to support GSSAPI authentication
 *
 * Revision 1.31  2000/11/16 15:20:34  argus
 * Update for SASL
 *
 * Revision 1.30  2000/11/13 21:51:38  argus
 * Mods to support ragrep().
 *
 * Revision 1.29  2000/11/13 15:05:14  argus
 * Fixes for raxml not printing out user data in all protocol types.
 *
 * Revision 1.28  2000/10/31 19:35:01  argus
 * Mods to support new timestats and user data.
 *
 * Revision 1.27  2000/10/27 13:45:42  argus
 * Fix support for multiple remote sources.
 *
 * Revision 1.26  2000/10/27 01:48:50  argus
 * Fixes for multiple source data.
 *
 * Revision 1.25  2000/10/26 15:38:09  argus
 * Mods for qflag defintions and some constants
 *
 * Revision 1.24  2000/10/25 22:23:30  argus
 * Mods to try to fix the LITTLE_ENDIAN issues for Neil.
 *
 * Revision 1.23  2000/10/16 21:55:48  argus
 * support for various .rc's.
 *
 * Revision 1.22  2000/10/11 12:51:37  argus
 * Added Zflag
 *
 * Revision 1.21  2000/10/10 14:50:51  argus
 * Fixes to support XML printing (print_time changes) and a bunch to support
 * TCP fixes.
 *
 * Revision 1.20  2000/10/05 15:04:47  argus
 * Addition of output labels for ra data.
 *
 * Revision 1.19  2000/10/03 23:04:29  argus
 * Mods for more complete cisco netflow parsing and -CS support.  Needs testing.
 *
 * Revision 1.18  2000/10/01 14:27:45  argus
 * Put the filter in a global so we can all get to it.
 *
 * Revision 1.17  2000/09/30 15:03:13  argus
 * Addition of netflow record definitions.
 *
 *------------------------------------------------------------------
 * $Endlog$
 */

/* 
 * AGGREGATION_DEFINITION describes the "Key" and "Value" fields seen in
 * the datafile. The definition comprise of keywords and delimiters. 
 * By reading the AGGREGATION_DEFINITION, one can interpret what and in what
 * order are the "Key" and "Value" fields being presented in the datafile.
 * Datafile consumers can also deduce what aggregation scheme is used 
 * by parsing AGGREGATION_DEFINITION..
 *
 * The order of keywords seen in the AGGREGATION_DEFINITION represents the true
 * order of the "Key" and "Value" fields presented in the datafile. Each 
 * keyword is delimited by either '|' or ','.
 *
 * As part of the new changes to the datafile header, the FORMAT field
 * will have a value of "B". Please note that the FORMAT may change 
 * if there is any change to any of the existing keywords, definition format,
 * adding new keyword, or any other header changes.
 * Also, the delimiter used in the datafile will be prepended at the 
 * beginning of each header. Since AGGREGATION_DEFINITION becomes the 2nd 
 * line of the header, the 1st line of the header will append a 
 * new field, namely "Header", which describes the total number of 
 * lines in the header.
 * 
 * The AGGREGATION_DEFINITION keywords have the following assignemnts ...
 *
 *      keyword           Description
 *      -------           -----------------------
 *      srcaddr           Source IP Address
 *      dstaddr           Destination IP Address
 *      src_subnet        Source SubNet
 *      dst_subnet        Destination SubNet
 *      src_mask          Source SubNet Mask 
 *      dst_mask          Destination SubNet Mask 
 *      src_user_subnet   Source User SubNet
 *      dst_user_subnet   Destination User SubNet
 *      src_as            Source AS
 *      dst_as            Destination AS
 *      srcport           Source Port
 *      dstport           Destination Port
 *      prot              Prot field
 *      protocol          Protocol (srcport, dstport, and prot lookup)
 *      input             Input Interface 
 *      output            Output Interface
 *      tos               Type of Service
 *      nexthop           Next Hop IP Address
 *
 *      pkts              Packets
 *      octets            Octets
 *      flows             Flow Count
 *      starttime         First Flow Stamp (UTC sec)
 *      endtime           Last Flow Stamp (UTC sec)
 *      activetime        Total Active Time (msec)
 */

/* Key Fields */
#define SRC_ADDR                      "srcaddr"
#define DST_ADDR                      "dstaddr"
#define SRC_SUBNET                    "src_subnet"
#define DST_SUBNET                    "dst_subnet"
#define SRC_SUBNET_MASK               "src_mask"
#define DST_SUBNET_MASK               "dst_mask"
#define SRC_USER_SUBNET               "src_user_subnet"
#define DST_USER_SUBNET               "dst_user_subnet"
#define SRC_AS                        "src_as"
#define DST_AS                        "dst_as"
#define SRC_PORT                      "srcport"
#define DST_PORT                      "dstport"
#define PROT                          "prot"
#define PROTOCOL_KEY                  "protocol"
#define IN_INTF                       "input"
#define OUT_INTF                      "output"
#define TOS_BIT                       "tos"
#define NEXT_HOP                      "nexthop"

/* Value Fields */
#define PACKET                        "pkts"
#define OCTET                         "octets"
#define FLOW_CNT                      "flows"
#define F_FLOW_STAMP                  "starttime"
#define L_FLOW_STAMP                  "endtime"
#define TOT_ACTIVE_TIME               "activetime"

/* Delimiter */                       /* Could be either "|" or "," */
#define DEL                           "%c" 

/* Aggregation Mask */
const char * const SourceNodeDef        = SRC_ADDR DEL 
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const DestNodeDef          = DST_ADDR DEL 
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const HostMatrixDef        = SRC_ADDR DEL 
                                          DST_ADDR DEL 
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const SourcePortDef        = SRC_PORT DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const DestPortDef          = DST_PORT DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const ProtocolDef          = PROTOCOL_KEY DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const DetailSourceNodeDef  = SRC_ADDR DEL 
                                          SRC_PORT DEL 
                                          DST_PORT DEL
                                          PROTOCOL_KEY DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const DetailDestNodeDef    = DST_ADDR DEL 
                                          SRC_PORT DEL 
                                          DST_PORT DEL
                                          PROTOCOL_KEY DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const DetailHostMatrixDef  = SRC_ADDR DEL 
                                          DST_ADDR DEL 
                                          SRC_PORT DEL 
                                          DST_PORT DEL
                                          PROTOCOL_KEY DEL
                                          PACKET DEL OCTET DEL FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP;

const char * const DetailInterfaceDef   = SRC_ADDR DEL
                                          DST_ADDR DEL
                                          IN_INTF DEL
                                          OUT_INTF DEL
                                          NEXT_HOP DEL
                                          PACKET DEL OCTET DEL FLOW_CNT;

const char * const CallRecordDef        = SRC_ADDR DEL  
                                          DST_ADDR DEL  
                                          SRC_PORT DEL  
                                          DST_PORT DEL  
                                          PROT DEL  
                                          TOS_BIT DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const ASMatrixDef          = SRC_AS DEL  
                                          DST_AS DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT; 

const char * const DetailASMatrixDef    = SRC_ADDR DEL
                                          DST_ADDR DEL
                                          SRC_AS DEL  
                                          DST_AS DEL  
                                          IN_INTF DEL  
                                          OUT_INTF DEL  
                                          SRC_PORT DEL
                                          DST_PORT DEL
                                          PROTOCOL_KEY DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT;

const char * const NetMatrixDef         = SRC_SUBNET DEL  
                                          SRC_SUBNET_MASK DEL  
                                          IN_INTF DEL  
                                          DST_SUBNET DEL  
                                          DST_SUBNET_MASK DEL  
                                          OUT_INTF DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT;

const char * const ASHostMatrixDef      = SRC_ADDR DEL  
                                          DST_ADDR DEL  
                                          SRC_AS DEL  
                                          DST_AS DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const HostMatrixInterfaceDef
                                        = SRC_ADDR DEL  
                                          DST_ADDR DEL  
                                          IN_INTF DEL  
                                          OUT_INTF DEL  
                                          PROTOCOL_KEY DEL
                                          PACKET DEL  OCTET DEL  FLOW_CNT;

const char * const DetailCallRecordDef  = SRC_ADDR DEL  
                                          DST_ADDR DEL  
                                          SRC_PORT DEL  
                                          DST_PORT DEL  
                                          IN_INTF DEL  
                                          OUT_INTF DEL  
                                          PROTOCOL_KEY DEL  
                                          TOS_BIT DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const RouterASDef          = SRC_AS DEL  
                                          DST_AS DEL  
                                          IN_INTF DEL  
                                          OUT_INTF DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const RouterProtoPortDef   = SRC_PORT DEL  
                                          DST_PORT DEL  
                                          PROT DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const RouterSrcPrefixDef   = SRC_SUBNET DEL  
                                          SRC_SUBNET_MASK DEL  
                                          IN_INTF DEL  
                                          SRC_AS DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const RouterDstPrefixDef   = DST_SUBNET DEL  
                                          DST_SUBNET_MASK DEL  
                                          OUT_INTF DEL  
                                          DST_AS DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;

const char * const RouterPrefixDef      = SRC_SUBNET DEL  
                                          DST_SUBNET DEL  
                                          SRC_SUBNET_MASK DEL  
                                          DST_SUBNET_MASK DEL  
                                          IN_INTF DEL  
                                          OUT_INTF DEL  
                                          SRC_AS DEL  
                                          DST_AS DEL  
                                          PACKET DEL  OCTET DEL  FLOW_CNT DEL
                                          F_FLOW_STAMP DEL L_FLOW_STAMP DEL 
                                          TOT_ACTIVE_TIME;
#endif


#ifndef NFC_DATAFILE_H
#define NFC_DATAFILE_H
/*
 *------------------------------------------------------------------ 
 * $Id: argus_parse.h,v 1.46 2004/02/23 15:00:36 argus Exp $
 * $Source: /usr/local/cvsroot/argus/include/argus_parse.h,v $
 *------------------------------------------------------------------
 * Definition of datafile formats.
 *
 * Binary datafile : Each binary datafiles contains a header and 
 *                   a list of records. 
 *
 *                   The header contains format, aggregation, 
 *                   agg_version, source, period, starttime, endtime, 
 *                   activetime, flows, missed, and records.
 * 
 *                   Each record structure contains a set of "Keys" 
 *                   and a "Values" that is specific to the 
 *                   aggregation scheme being used.
 *
 * Cisco NetFlow FlowCollector 3.0
 *
 * October 1998, Anders Fung
 *
 * Copyright (c) 1998 by Cisco Systems, Inc.
 * All rights reserved.
 *------------------------------------------------------------------
 * $Log: argus_parse.h,v $
 * Revision 1.46  2004/02/23 15:00:36  argus
 * *** empty log message ***
 *
 * Revision 1.45  2003/03/27 04:11:13  argus
 * Updated for copyright
 *
 * Revision 1.44  2002/05/31 12:18:24  argus
 * Updated
 *
 * Revision 1.43  2002/05/03 17:33:38  argus
 * Merged 2.0.4 into main line
 *
 * Revision 1.39.4.2.2.7  2001/10/17 14:30:30  argus
 * Fix for argus_filter so that it generates a canonical record before
 * doing the matching.
 *
 * Revision 1.39.4.2.2.6  2001/10/11 19:43:46  argus
 * Updated and modified for Peter's fixes
 *
 * Revision 1.39.4.2.2.5  2001/10/01 14:20:38  argus
 * Switch to GPL for argus-2.0.2.redux
 *
 * Revision 1.39.4.2.2.4  2001/07/10 13:58:35  argus
 * Mods for little endian fix for FreeBSD
 *
 * Revision 1.39.4.2.2.3  2001/06/22 14:00:14  argus
 * Updated
 *
 * Revision 1.39.4.2  2001/04/24 16:29:03  argus
 * Updated copyright notice for 2001
 *
 * Revision 1.39.4.1  2001/04/24 12:36:49  argus
 * Updated
 *
 * Revision 1.40  2001/04/06 17:06:00  argus
 * Version Updated
 *
 * Revision 1.39  2001/03/06 23:30:41  argus
 * Fix for Davids incredibly long command lines.
 *
 * Revision 1.38  2001/02/03 21:39:08  argus
 * Mods to support -d option
 *
 * Revision 1.37  2000/12/19 16:19:41  argus
 * Mods to get ramon() to the same level as ra() with regard to dynamic
 * labels.  Also FreeBSD/NetBSD port support for racount().
 *
 * Revision 1.36  2000/12/19 05:59:03  argus
 * Mods to help in getting pretty output when not using -n.
 *
 * Revision 1.35  2000/12/10 20:59:13  argus
 * Mods to add support for RA_AUTH_PASS (pstr)
 *
 * Revision 1.34  2000/12/07 19:00:39  argus
 * Mods to convert from ArgusError to ArgusLog
 *
 * Revision 1.33  2000/12/07 17:51:48  argus
 * Move Uflag (precision option) to -p option.
 *
 * Revision 1.32  2000/11/23 01:58:29  argus
 * Mods to support GSSAPI authentication
 *
 * Revision 1.31  2000/11/16 15:20:34  argus
 * Update for SASL
 *
 * Revision 1.30  2000/11/13 21:51:38  argus
 * Mods to support ragrep().
 *
 * Revision 1.29  2000/11/13 15:05:14  argus
 * Fixes for raxml not printing out user data in all protocol types.
 *
 * Revision 1.28  2000/10/31 19:35:01  argus
 * Mods to support new timestats and user data.
 *
 * Revision 1.27  2000/10/27 13:45:42  argus
 * Fix support for multiple remote sources.
 *
 * Revision 1.26  2000/10/27 01:48:50  argus
 * Fixes for multiple source data.
 *
 * Revision 1.25  2000/10/26 15:38:09  argus
 * Mods for qflag defintions and some constants
 *
 * Revision 1.24  2000/10/25 22:23:30  argus
 * Mods to try to fix the _LITTLE_ENDIAN issues for Neil.
 *
 * Revision 1.23  2000/10/16 21:55:48  argus
 * support for various .rc's.
 *
 * Revision 1.22  2000/10/11 12:51:37  argus
 * Added Zflag
 *
 * Revision 1.21  2000/10/10 14:50:51  argus
 * Fixes to support XML printing (print_time changes) and a bunch to support
 * TCP fixes.
 *
 * Revision 1.20  2000/10/05 15:04:47  argus
 * Addition of output labels for ra data.
 *
 * Revision 1.19  2000/10/03 23:04:29  argus
 * Mods for more complete cisco netflow parsing and -CS support.  Needs testing.
 *
 * Revision 1.18  2000/10/01 14:27:45  argus
 * Put the filter in a global so we can all get to it.
 *
 * Revision 1.17  2000/09/30 15:03:13  argus
 * Addition of netflow record definitions.
 *
 *------------------------------------------------------------------
 * $Endlog$
 */


#define LABEL_LEN         16
#define IP_LEN            15
#define ASCII_HEADER_LEN  511
#define BIN_FILE_SUFFIX   ".bin"


#ifndef __NFC__
enum Aggregation
{
  noAgg,             /* reserved */
  RawFlows,          /* Not supported in binary files */
  SourceNode,
  DestNode,
  HostMatrix,
  SourcePort,
  DestPort,
  Protocol,
  DetailDestNode,
  DetailHostMatrix,
  DetailInterface,
  CallRecord,
  ASMatrix,
  NetMatrix,
  DetailSourceNode,
  DetailASMatrix,
  ASHostMatrix,
  HostMatrixInterface,
  DetailCallRecord,
  RouterAS,
  RouterProtoPort,
  RouterSrcPrefix,
  RouterDstPrefix,
  RouterPrefix
};
#endif


typedef struct {
    u_short format;             /* Header format, it is 2 in this round */
    char    newline;            /* Newline character, '\n' */
    char    ascii_header[ASCII_HEADER_LEN];  /* Header in ASCII */
    u_char  aggregation;        /* Aggregation scheme used */
    u_char  agg_version;        /* Version of the aggregation scheme used */
    char    source[IP_LEN];     /* Source IP/Name */
    u_char  period;             /* Aggregation period, 0 means PARTIAL */
    u_long  starttime;          /* Beginning of aggregation period */
    u_long  endtime;            /* End of aggregation period */
    u_long  flows;              /* Number of flows aggregated */
    int     missed;             /* Number of flows missed, -1 means not avail*/
    u_long  records;            /* Number of records in this datafile */
} BinaryHeaderF2;

#define HEADER_FORMAT_2 2


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */

} BinaryRecord_SourceNode_V1;

#define SOURCENODE_V1 1


typedef struct {
                                /* Keys */
    u_long  dstaddr;            /* Destination IP */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DestNode_V1;

#define DESTNODE_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_HostMatrix_V1;

#define HOSTMATRIX_V1 1


typedef struct {
                                /* Keys */
    char    srcport[LABEL_LEN]; /* Source Port Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_SourcePort_V1;

#define SOURCEPORT_V1 1


typedef struct {
                                /* Keys */
    char    dstport[LABEL_LEN]; /* Destination Port Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DestPort_V1;

#define DESTPORT_V1 1


typedef struct {
                                /* Keys */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_Protocol_V1;

#define PROTOCOL_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DetailSourceNode_V1;

#define DETAIL_SOURCENODE_V1 1


typedef struct {
                                /* Keys */
    u_long  dstaddr;            /* Destination IP */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DetailDestNode_V1;

#define DETAIL_DESTNODE_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
} BinaryRecord_DetailHostMatrix_V1;

#define DETAIL_HOSTMATRIX_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */
    u_long  nexthop;            /* Next Hop IP */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DetailInterface_V1;

#define DETAIL_INTERFACE_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    u_short srcport;            /* Source Port Number */
    u_short dstport;            /* Destination Port Number */
    u_char  prot;               /* Protocol Number */
    u_char  tos;                /* Type of Service */
    u_short reserved;           /* Data alignment */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_CallRecord_V1;

#define CALLRECORD_V1 1


typedef struct {
                                /* Keys */
    char    src_as[LABEL_LEN];  /* Source AS */
    char    dst_as[LABEL_LEN];  /* Destination AS */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_ASMatrix_V1;

#define ASMATRIX_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    char    src_as[LABEL_LEN];  /* Source AS */
    char    dst_as[LABEL_LEN];  /* Destination AS */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_DetailASMatrix_V1;

#define DETAIL_ASMATRIX_V1 1


typedef struct {
                                /* Keys */
    u_long  src_subnet;         /* Source SubNet */
    u_short src_mask;           /* Source SubNet Mask */
    u_short input;              /* Input Interface Number */
    u_long  dst_subnet;         /* Destination SubNet */
    u_short dst_mask;           /* Destination SubNet Mask */
    u_short output;             /* Output Interface Number */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_NetMatrix_V1;

#define NETMATRIX_V1 1


typedef struct {
                                /* Keys */
    char    src_as[LABEL_LEN];  /* Source AS */
    char    dst_as[LABEL_LEN];  /* Destination AS */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_RouterAS_V1;

#define ROUTERAS_V1 1


typedef struct {
                                /* Keys */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    u_char  prot;               /* Protocol Number */
    u_char  pad;                /* Data alignment */
    u_short reserved;           /* Data alignment */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_RouterProtoPort_V1;

#define ROUTERPROTOPORT_V1 1


typedef struct {
                                /* Keys */
    u_long  src_subnet;         /* Source SubNet */
    u_short src_mask;           /* Source SubNet Mask */
    u_short input;              /* Input Interface Number */
    char    src_as[LABEL_LEN];  /* Source AS */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_RouterSrcPrefix_V1;

#define ROUTERSRCPREFIX_V1 1


typedef struct {
                                /* Keys */
    u_long  dst_subnet;         /* Destination SubNet */
    u_short dst_mask;           /* Destination SubNet Mask */
    u_short output;             /* Output Interface Number */
    char    dst_as[LABEL_LEN];  /* Destination AS */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_RouterDstPrefix_V1;

#define ROUTERDSTPREFIX_V1 1


typedef struct {
                                /* Keys */
    u_long  src_subnet;         /* Source SubNet */
    u_long  dst_subnet;         /* Destination SubNet */
    u_short src_mask;           /* Source SubNet Mask */
    u_short dst_mask;           /* Destination SubNet Mask */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */
    char    src_as[LABEL_LEN];  /* Source AS */
    char    dst_as[LABEL_LEN];  /* Destination AS */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_RouterPrefix_V1;

#define ROUTERPREFIX_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    char    src_as[LABEL_LEN];  /* Source AS */
    char    dst_as[LABEL_LEN];  /* Destination AS */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_ASHostMatrix_V1;

#define ASHOSTMATRIX_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */
    char    protocol[LABEL_LEN];/* Protocol Key */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
} BinaryRecord_HostMatrixInterface_V1;

#define HOSTMATRIXINTERFACE_V1 1


typedef struct {
                                /* Keys */
    u_long  srcaddr;            /* Source IP */
    u_long  dstaddr;            /* Destination IP */
    char    srcport[LABEL_LEN]; /* Source Port Key */
    char    dstport[LABEL_LEN]; /* Destination Port Key */
    u_short input;              /* Input Interface Number */
    u_short output;             /* Output Interface Number */
    char    protocol[LABEL_LEN];/* Protocol Key */
    u_char  tos;                /* Type of Service */
    u_char  pad;                /* Data alignment */
    u_short reserved;           /* Data alignment */

                                /* Values */
    u_long  pkts;               /* Packet count */
    u_long  octets;             /* Byte count */
    u_long  flows;              /* Flow count */
    u_long  starttime;          /* Start time */
    u_long  endtime;            /* End time */
    u_long  activetime;         /* Total Active Time */
} BinaryRecord_DetailCallRecord_V1;

#define DETAILCALLRECORD_V1 1


typedef struct {
    BinaryHeaderF2 header;
    union {
            BinaryRecord_SourceNode_V1          * srcnode;
            BinaryRecord_DestNode_V1            * dstnode;
            BinaryRecord_HostMatrix_V1          * hostmatrix;
            BinaryRecord_SourcePort_V1          * srcport;
            BinaryRecord_DestPort_V1            * dstport;
            BinaryRecord_Protocol_V1            * protocol;
            BinaryRecord_DetailSourceNode_V1    * detailsrcnode;
            BinaryRecord_DetailDestNode_V1      * detaildstnode;
            BinaryRecord_DetailHostMatrix_V1    * detailhostmatix;
            BinaryRecord_DetailInterface_V1     * detailinterface;
            BinaryRecord_CallRecord_V1          * callrecord;
            BinaryRecord_ASMatrix_V1            * asmatrix;
            BinaryRecord_DetailASMatrix_V1      * detailasmatrix;
            BinaryRecord_NetMatrix_V1           * netmatrix;
            BinaryRecord_ASHostMatrix_V1        * ashostmatrix;
            BinaryRecord_HostMatrixInterface_V1 * hostmatrixinterface;
            BinaryRecord_DetailCallRecord_V1    * detailcallrecord;
            BinaryRecord_RouterAS_V1            * routeras;
            BinaryRecord_RouterProtoPort_V1     * routerprotoport;
            BinaryRecord_RouterSrcPrefix_V1     * routersrcprefix;
            BinaryRecord_RouterDstPrefix_V1     * routerdstprefix;
            BinaryRecord_RouterPrefix_V1        * routerprefix;
    } record;
} BinaryDatafile;


#define MAX_BINARY_HEADER_F2 \
            (sizeof(BinaryHeaderF2))

#define MAX_BINARY_RECORD_SOURCE_NODE_SIZE \
            (sizeof(BinaryRecord_SourceNode_V1))

#define MAX_BINARY_RECORD_DESTINATION_NODE_SIZE \
            (sizeof(BinaryRecord_DestNode_V1))

#define MAX_BINARY_RECORD_HOST_MATRIX_SIZE \
            (sizeof(BinaryRecord_HostMatrix_V1))

#define MAX_BINARY_RECORD_SOURCE_PORT_SIZE \
            (sizeof(BinaryRecord_SourcePort_V1))

#define MAX_BINARY_RECORD_DESTINATION_PORT_SIZE \
            (sizeof(BinaryRecord_DestPort_V1))

#define MAX_BINARY_RECORD_PROTOCOL_SIZE \
            (sizeof(BinaryRecord_Protocol_V1))

#define MAX_BINARY_RECORD_DETAIL_SOURCE_NODE_SIZE \
            (sizeof(BinaryRecord_DetailSourceNode_V1))

#define MAX_BINARY_RECORD_DETAIL_DESTINATION_NODE_SIZE \
            (sizeof(BinaryRecord_DetailDestNode_V1))

#define MAX_BINARY_RECORD_DETAIL_HOST_MATRIX_SIZE \
            (sizeof(BinaryRecord_DetailHostMatrix_V1))

#define MAX_BINARY_RECORD_DETAIL_INTERFACE_SIZE \
            (sizeof(BinaryRecord_DetailInterface_V1))

#define MAX_BINARY_RECORD_CALL_RECORD_SIZE \
            (sizeof(BinaryRecord_CallRecord_V1))

#define MAX_BINARY_RECORD_AS_MATRIX_SIZE \
            (sizeof(BinaryRecord_ASMatrix_V1))

#define MAX_BINARY_RECORD_DETAIL_AS_MATRIX_SIZE \
            (sizeof(BinaryRecord_DetailASMatrix_V1))

#define MAX_BINARY_RECORD_NET_MATRIX_SIZE \
            (sizeof(BinaryRecord_NetMatrix_V1))

#define MAX_BINARY_RECORD_AS_HOST_MATRIX_SIZE \
            (sizeof(BinaryRecord_ASHostMatrix_V1))

#define MAX_BINARY_RECORD_HOST_MATRIX_INTERFACE_SIZE \
            (sizeof(BinaryRecord_HostMatrixInterface_V1))

#define MAX_BINARY_RECORD_DETAIL_CALL_RECORD_SIZE \
            (sizeof(BinaryRecord_DetailCallRecord_V1))

#define MAX_BINARY_RECORD_ROUTER_AS_SIZE \
            (sizeof(BinaryRecord_RouterAS_V1))

#define MAX_BINARY_RECORD_ROUTER_PROTO_PORT_SIZE \
            (sizeof(BinaryRecord_RouterProtoPort_V1))

#define MAX_BINARY_RECORD_ROUTER_SRC_PREFIX_SIZE \
            (sizeof(BinaryRecord_RouterSrcPrefix_V1))

#define MAX_BINARY_RECORD_ROUTER_DST_PREFIX_SIZE \
            (sizeof(BinaryRecord_RouterDstPrefix_V1))

#define MAX_BINARY_RECORD_ROUTER_PREFIX_SIZE \
            (sizeof(BinaryRecord_RouterPrefix_V1))

#endif /* __NFC_DATAFILE_H__ */

#else /* ArgusParse */
 
extern char *ArgusProgramName;
extern char *cmdline;
extern char *process_state_strings [];

extern struct timeval ArgusGlobalTime;
extern struct timeval ArgusNowTime;
extern struct timeval RaClientTimeout;

extern char *RaSortAlgorithmStrings[];
extern int RaSortIndex;

extern struct tm *RaTmStruct;
extern char *RaInputFilter;
extern char *RaTimeFormat;
extern char  RaFieldDelimiter;

extern int RaPrintStartTime;
extern int RaPrintLastTime;

extern struct naddrmem *naddrtable [HASHNAMESIZE];

extern char *exceptfile, *wfile;

extern struct ARGUS_INPUT *ArgusInput;
extern struct ARGUS_INPUT *ArgusInputFileList;
extern struct ARGUS_INPUT *ArgusRemoteHostList;

extern char *tag_string;
extern int major_version;
extern int minor_version;
extern int read_size;
extern int read_mode;

extern struct ArgusRecord *initCon;

extern unsigned int ArgusLocalNet, ArgusNetMask;

extern struct ArgusRecord *ArgusOriginal;

extern int totalrecords;
extern int farrecords;
extern int marrecords;
extern int explicit_date;
 
extern time_t lasttime_t;
extern time_t startime_t;

extern struct tm tm_lasttime;
extern struct tm tm_startime;
extern struct tm starTimeFilter;
extern struct tm lastTimeFilter;

extern char *progname;
extern char *dataarg;
extern char *timearg;
extern char *servicesfile;

extern char *ArgusFlowModelFile;
extern struct bpf_program ArgusFilterCode;

extern char *cmdline;	/* For David Brumley's amazingly long cmdlines ;o) */ 

extern int RaWriteOut;

extern long long tcp_dst_count;
extern long long tcp_src_count;
extern long long udp_dst_count;
extern long long udp_src_count;
extern long long icmp_dst_count;
extern long long icmp_src_count;
extern long long ip_dst_count;
extern long long ip_src_count;
extern long long arp_dst_count;
extern long long arp_src_count;
extern long long nonip_dst_count;
extern long long nonip_src_count;

extern long long tcp_dst_bytes;
extern long long tcp_src_bytes;
extern long long udp_dst_bytes;
extern long long udp_src_bytes;
extern long long icmp_dst_bytes;
extern long long icmp_src_bytes;
extern long long ip_dst_bytes;
extern long long ip_src_bytes;
extern long long arp_dst_bytes;
extern long long arp_src_bytes;
extern long long nonip_dst_bytes;
extern long long nonip_src_bytes;

extern int hfield;
extern int pfield;
extern int Aflag;
extern int aflag;
extern int Bflag;
extern int bflag;
extern int eflag;
extern char *estr;
extern int Dflag;
extern int Eflag;
extern int fflag;
extern int gflag;
extern int idflag;
extern int Gflag;
extern int cflag;
extern int Cflag;
extern int Lflag;
extern int lflag;
extern int mflag;
extern char *Mflag;
extern int nflag;
extern int Nflag;
extern int Normflag;
extern int Netflag;
extern int notNetflag;
extern int Oflag;
extern int Wflag;
extern int Fflag;
extern int Hflag;
extern int pflag;
extern int Pflag;
extern char *sflag;
extern int dflag;
extern int Argusdflag;

extern int qflag;
extern int tflag;
extern int uflag;
extern char *ustr;
extern char *pstr;
extern int Uflag;
extern int vflag;
extern int Vflag;
extern int iflag;

extern int Iflag;
extern int Tflag;
extern int rflag;
extern int Rflag;
extern int Sflag;
extern int Xflag;
extern int XMLflag;
extern int zflag;
extern int Zflag;

extern long thiszone;

extern int total_nets;
extern int total_hosts;

extern void ArgusShutDown (int);
extern void argus_parse_init (struct ARGUS_INPUT *);
extern char *argus_lookupdev(char *);

extern void read_udp_services (char *);

extern int ArgusHandleDatum (struct ArgusRecord *, struct bpf_program *);
extern void ArgusReformatRecord (struct ArgusRecord *, struct ArgusRecord *);
extern int ArgusReadRemoteConnection (int, struct bpf_program *);
extern int ArgusReadConnection (struct ARGUS_INPUT *, struct bpf_program *);

extern void ArgusReadRemote (int, struct bpf_program *);
extern int read_file (int fd, struct bpf_program *);
extern void ArgusProcessRecord (struct ArgusRecord *);
extern void ArgusGenerateCanonicalRecord (struct ArgusRecord *, struct ArgusCanonicalRecord *);

extern int ArgusGetServerSocket (struct ARGUS_INPUT *);
extern int ArgusAddFileList (char *);
extern void ArgusDeleteFileList (void);
extern int ArgusAddHostList (char *);
extern void ArgusDeleteHostList (void);
extern int ArgusWriteNewLogfile (char *, struct ArgusRecord *);

extern int check_time (struct ArgusRecord *);
extern int parseUserDataArg (char **, char **, int);
extern int parseTimeArg (char **, char **, int, struct tm *);
extern int check_time_format (struct tm *tm, char *str);
extern int parseTime (struct tm *, struct tm *, char *);

#if defined(_LITTLE_ENDIAN)
extern void ArgusNtoH (struct ArgusRecord *argus);
extern void ArgusHtoN (struct ArgusRecord *argus);
#endif


#endif
#endif /* ArgusParse_h */