1 /* vim: set shiftwidth=3 softtabstop=3 expandtab: */ 2 3 /** \file opm.h 4 * \brief Main header for libopm. 5 * \author Erik Fears 6 * \version $Id: opm.h,v 1.26 2003/06/20 04:18:44 andy Exp $ 7 */ 8 9 #ifndef OPM_H 10 #define OPM_H 11 12 #include "opm_common.h" 13 14 /* Stuff to shut up warnings about rcsid being unused. */ 15 #define USE_VAR(var) static char sizeof##var = sizeof(sizeof##var) + sizeof(var) 16 /* RCS tag. */ 17 #define RCSID(x) static char rcsid[] = x; USE_VAR(rcsid); 18 19 20 typedef struct _OPM_CONFIG OPM_CONFIG_T; 21 typedef struct _OPM OPM_T; 22 typedef struct _OPM_REMOTE OPM_REMOTE_T; 23 typedef struct _OPM_CALLBACK OPM_CALLBACK_T; 24 25 typedef int OPM_ERR_T; 26 27 typedef void OPM_CALLBACK_FUNC (OPM_T *, OPM_REMOTE_T *, int, void *); 28 29 struct _OPM_CALLBACK { 30 OPM_CALLBACK_FUNC *func; 31 void *data; 32 }; 33 34 struct _OPM_CONFIG { 35 void **vars; 36 }; 37 38 struct _OPM { 39 OPM_CONFIG_T *config; /* Individual scanner configuration */ 40 OPM_LIST_T *queue; /* List of scans in the queue (not yet established) */ 41 OPM_LIST_T *scans; /* List of scans (each scan containing a list of connections) */ 42 OPM_LIST_T *protocols; /* List of protocols this scanner handles */ 43 unsigned int fd_use; /* Number of file descriptors in use */ 44 45 OPM_CALLBACK_T *callbacks; /* Scanner wide callbacks */ 46 }; 47 48 struct _OPM_REMOTE { 49 50 char *ip; /* Readable IP address */ 51 52 unsigned short int port; /* Port passed back on certain callbacks */ 53 unsigned short int protocol; /* Protocol passed back on certain callbacks */ 54 unsigned short int bytes_read; /* Bytes read passed back on certain callbacks */ 55 56 OPM_LIST_T *protocols; /* Remote specific protocols */ 57 58 void *data; /* Arbitrary data that the client can point to for any purpose*/ 59 }; 60 61 OPM_T *opm_create(void); 62 void opm_free(OPM_T *); 63 64 OPM_REMOTE_T *opm_remote_create(const char *); 65 void opm_remote_free(OPM_REMOTE_T *); 66 67 OPM_ERR_T opm_config(OPM_T *, int, void *); 68 OPM_ERR_T opm_scan(OPM_T *, OPM_REMOTE_T *); 69 void opm_end(OPM_T *, OPM_REMOTE_T *); 70 void opm_endscan(OPM_T *, OPM_REMOTE_T *); 71 72 OPM_ERR_T opm_addtype(OPM_T *, int, unsigned short int); 73 OPM_ERR_T opm_remote_addtype(OPM_REMOTE_T *, int, unsigned short int); 74 OPM_ERR_T opm_callback(OPM_T *, int, OPM_CALLBACK_FUNC *, void *); 75 76 void opm_cycle(OPM_T *); 77 78 size_t opm_active(OPM_T *); 79 80 #endif /* OPM_H */ 81