Azinix

nm.h

Go to the documentation of this file.
00001 /** \file nm.h 
00002 
00003   \brief Main package of azinix 
00004 
00005 */
00006 
00007 #ifndef _NM
00008 #define _NM
00009 
00010 /*---------------------------------------------------------------------------*/
00011 /* Nested includes                                                           */
00012 /*---------------------------------------------------------------------------*/
00013 
00014 // to make  gcc -Wall quieter
00015 #include <stdlib.h>
00016 #include <malloc.h>
00017 
00018 #include <string.h>
00019 #include <stdio.h>
00020 #include <sys/stat.h>
00021 #include <unistd.h>     // to get read and write syscalls
00022 #include <netinet/in.h>     // for ntoh type functions
00023 #include <fcntl.h>
00024 #include <time.h>
00025 #include <signal.h>
00026 
00027 #include <libnet.h>
00028 
00029 // the version with the std install is out of date, doesn't 
00030 // include pcap_direction() the one below does
00031 // #include "/nfs/narya/pf/libpcap-0.9x.20070323/pcap.h"
00032 #include "pcap.h"
00033 
00034 #include "tcl.h"
00035 // \todo add gui capbility at some future date
00036 // #include "tk.h"
00037 #include "pcre.h"
00038 
00039 #include "util.h"
00040 #include "error.h"
00041 #include "avl.h"
00042 #include "var_set.h"
00043 #include "array.h"
00044 #include "st.h"
00045 #include "list.h"
00046 #include "heap.h"
00047 
00048 #include "os.h"
00049 
00050 // major compile problems if we define bool to int in c++, e.g., with vec<int> and vec<bool>
00051 #ifndef __cplusplus
00052 #define bool int
00053 #define false 0
00054 #define true 1
00055 #endif
00056 
00057 #ifdef __cplusplus
00058 extern "C" {
00059 #endif
00060 
00061 
00062 /**
00063   * \brief  Tcl return codes
00064   * 
00065   */
00066 
00067 typedef enum
00068 {
00069   Nm_TclRetCodeFALSE_c,
00070   Nm_TclRetCodeTRUE_c,
00071   Nm_TclRetCodeUndecided_c,
00072   Nm_TclNumRetCodes_c,
00073 } Nm_TclCmdReturnCodes_t;
00074 
00075 /**
00076   * \brief Structure used to pass return values around
00077   *     as integers.
00078   */
00079 
00080 struct Nm_TclCD_t
00081 {
00082   array_t *idToPtr;
00083   array_t *freeIds;
00084 };
00085 
00086 typedef struct Nm_TclCD_t Nm_TclCD_t;
00087 
00088 
00089 /*---------------------------------------------------------------------------*/
00090 /* Constant declarations                                                     */
00091 /*---------------------------------------------------------------------------*/
00092 
00093 /** \brief Infinity - works with signed/unsigned ints */
00094 
00095 #define INFINITY    (1 << 30)
00096 
00097 
00098 /**
00099   * \brief  Macros for int, true and false
00100   * 
00101   * Macros for int, true and false.   These must be defined somewhere
00102   * but I'm taking the easy way our for now.
00103   * 
00104   */
00105 
00106 // these cause problems with stl - ..<int> and ..<int>
00107 // #define int int
00108 // #define true 1
00109 // #define false 0
00110 
00111 
00112 /** \brief Typedef to get extproto to correctly parse functions with 
00113     function pointer arguments
00114 */
00115 
00116 typedef void (*handler_t) ();
00117 
00118 
00119 /**AutomaticStart*************************************************************/
00120 
00121 /*---------------------------------------------------------------------------*/
00122 /* Extern function prototypes                                                */
00123 /*---------------------------------------------------------------------------*/
00124 
00125 extern void Nm_Init (int argc, char **argv);
00126 extern void Nm_End ();
00127 extern int main (int argc, char **argv);
00128 extern void Nm_Init (int argc, char **argv);
00129 extern void Nm_End ();
00130 extern int Nm_Tcl (Tcl_Interp * interp, Nm_TclCD_t * cd);
00131 extern int sourceTclrc (Tcl_Interp * interp);
00132 extern void Nm_TclResult (Tcl_Interp * interp, ClientData cd, void *ptr);
00133 extern int Nm_TclGetStringVar (Tcl_Interp * interp, char *tclVarName,
00134                 char **result);
00135 extern int Nm_TclGetDoubleVar (Tcl_Interp * interp, char *tclVarName,
00136                 double *result);
00137 extern int Nm_TclGetArrayVar (Tcl_Interp * interp, char *tclVarName,
00138                    array_t * result);
00139 extern int Nm_TclGetIntVar (Tcl_Interp * interp, char *tclVarName,
00140                  int *result);
00141 extern Nm_TclCD_t *Nm_TclCDInit ();
00142 extern int Nm_TclCDStorePtr (Nm_TclCD_t * cd, void *ptr);
00143 extern void *Nm_TclCDReadPtrFromObj (Tcl_Interp * interp, Nm_TclCD_t * cd,
00144                      Tcl_Obj * const obj);
00145 extern void *Nm_TclCDReadPtr (Nm_TclCD_t * cd, int id);
00146 extern void Nm_TclCDReuseId (Nm_TclCD_t * cd, int id);
00147 extern int pktReadTcpInfo (ClientData cd, Tcl_Interp * interp, int objc,
00148                Tcl_Obj * const objv[]);
00149 
00150 /**AutomaticEnd***************************************************************/
00151 
00152 #ifdef __cplusplus
00153 }
00154 #endif
00155 
00156 #endif /* _NM */