/* ** Copyright (C) 2001-2007 by Carnegie Mellon University. ** ** @OPENSOURCE_HEADER_START@ ** ** Use of the SILK system and related source code is subject to the terms ** of the following licenses: ** ** GNU Public License (GPL) Rights pursuant to Version 2, June 1991 ** Government Purpose License Rights (GPLR) pursuant to DFARS 252.225-7013 ** ** NO WARRANTY ** ** ANY INFORMATION, MATERIALS, SERVICES, INTELLECTUAL PROPERTY OR OTHER ** PROPERTY OR RIGHTS GRANTED OR PROVIDED BY CARNEGIE MELLON UNIVERSITY ** PURSUANT TO THIS LICENSE (HEREINAFTER THE "DELIVERABLES") ARE ON AN ** "AS-IS" BASIS. CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY ** KIND, EITHER EXPRESS OR IMPLIED AS TO ANY MATTER INCLUDING, BUT NOT ** LIMITED TO, WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE, ** MERCHANTABILITY, INFORMATIONAL CONTENT, NONINFRINGEMENT, OR ERROR-FREE ** OPERATION. CARNEGIE MELLON UNIVERSITY SHALL NOT BE LIABLE FOR INDIRECT, ** SPECIAL OR CONSEQUENTIAL DAMAGES, SUCH AS LOSS OF PROFITS OR INABILITY ** TO USE SAID INTELLECTUAL PROPERTY, UNDER THIS LICENSE, REGARDLESS OF ** WHETHER SUCH PARTY WAS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. ** LICENSEE AGREES THAT IT WILL NOT MAKE ANY WARRANTY ON BEHALF OF ** CARNEGIE MELLON UNIVERSITY, EXPRESS OR IMPLIED, TO ANY PERSON ** CONCERNING THE APPLICATION OF OR THE RESULTS TO BE OBTAINED WITH THE ** DELIVERABLES UNDER THIS LICENSE. ** ** Licensee hereby agrees to defend, indemnify, and hold harmless Carnegie ** Mellon University, its trustees, officers, employees, and agents from ** all claims or demands made against them (and any related losses, ** expenses, or attorney's fees) arising out of, or relating to Licensee's ** and/or its sub licensees' negligent use or willful misuse of or ** negligent conduct or willful misconduct regarding the Software, ** facilities, or other rights or assistance granted by Carnegie Mellon ** University under this License, including, but not limited to, any ** claims of product liability, personal injury, death, damage to ** property, or violation of any laws or regulations. ** ** Carnegie Mellon University Software Engineering Institute authored ** documents are sponsored by the U.S. Department of Defense under ** Contract F19628-00-C-0003. Carnegie Mellon University retains ** copyrights in all material produced under this contract. The U.S. ** Government retains a non-exclusive, royalty-free license to publish or ** reproduce these documents, or allow others to do so, for U.S. ** Government purposes only pursuant to the copyright license under the ** contract clause at 252.227.7013. ** ** @OPENSOURCE_HEADER_END@ */ #ifndef _RWCOUNT_H #define _RWCOUNT_H #include "silk.h" RCSIDENTVAR(rcsID_RWCOUNT_H, "$SiLK: rwcount.h 8269 2007-08-03 18:54:48Z mthomas $"); #include "utils.h" #include "rwpack.h" #include "iochecks.h" #include "sksite.h" /* * rwcount.h * header file for the rwcount utility. */ /* DEFINES AND TYPEDEFS */ /* Binary file version */ #define RWCO_VERSION 1 /* * How to display the time on each bin(row) */ typedef enum { BIN_LABEL_EPOCH=0, BIN_LABEL_INDEX, BIN_LABEL_GMT, BIN_LABEL_BINARY } bin_label_enum_t; /* * bin loading schemata */ typedef enum { LOAD_MEAN=0, LOAD_START, LOAD_END, LOAD_MIDDLE, LOAD_DURATION } bin_load_scheme_enum_t; #define MAX_LOAD_SCHEME LOAD_DURATION #define DEFAULT_LOAD_SCHEME LOAD_DURATION /* * bin geometry. */ #define DEFAULT_BINSIZE 30 /* * The data structure used is an array of doubles, where every * three values create a "bin" that contains the flow-count, * byte-count, and packet-count for that bin. */ /* number of values per row */ #define ROW_BINS 3 /* index for each value */ #define RECS 0 #define BYTES 1 #define PKTS 2 /* * Miscellaneous handy constants */ #define DAY_SECS 86400 #define RWCO_ERR_GENERAL -1 #define RWCO_ERR_MALLOC -2 #define RWCO_ERR_FILE -3 /* Value to use for the start_epoch to denote that it is not set */ #define RWCO_START_EPOCH_UNSET 0 /* * countFile IO * data Structures */ typedef struct countFileHeader { genericHeader gHdr; /* size of each bin, in seconds */ uint32_t binSize; /* total number of bins that are allocated */ uint32_t totalBins; /* time on the first bin, in UNIX epoch seconds */ uint32_t initOffset; /* * command line parameters that need to be preserved * to properly display ascii output after serialization */ /* starting epoch for printing of data */ uint32_t start_epoch; /* bin loading scheme */ uint8_t bin_load_scheme; /* how to label the bins */ uint8_t bin_label_flag; /* when non-zero, do not print column titles */ uint8_t no_titles; /* when non-zero, do not print bins with zero counts */ uint8_t skip_zeroes; /* delimiter between columns */ char delimiter; /* when non-zero, do not print column titles */ uint8_t no_columns; } countFileHeader; typedef struct countFile { size_t binMallocSize; /* bytes of memory allocated for bins */ countFileHeader *fileHeader; double *bins; } countFile; /* IMPORTED FUNCTIONS */ extern int readCountFile(char *, countFile *); extern int writeCountFile(char *, countFile *, int); extern int dumpText(FILE *tgtFile, countFile *countData); extern int dumpBinary(FILE *tgtFile, countFile *countData); extern int _writeCountFileHeader(FILE *, countFileHeader *); extern void appSetup(int argc, char **argv); extern void appTeardown(void); /* IMPORTED VARIABLES */ /* I/O stuff */ extern rwIOStruct_t *rwIOS; extern iochecksInfoStruct_t *ioISP; /* the header */ extern countFile countData; /* * Flags for use during the actual running of the application. */ extern int dryRunFlag; /* dry run the data */ extern int printFNameFlag; /* print the filename */ /* name of program to run to page output */ extern char *pager; #endif /* _RWCOUNT_H */ /* ** Local variables: ** mode:c ** indent-tabs-mode:nil ** c-basic-offset:4 ** End: */