From c7d5ddfadc507d1cc9811229f938abe8c8004c0d Mon Sep 17 00:00:00 2001 From: laforge Date: Mon, 20 Nov 2000 11:43:22 +0000 Subject: huge reorganization for 0.9 - added hashtables everywhere - no more dynamic allocation for each packet - mysql output plugin - more keys in ulogd_BASE - moved libipulog into ulogd directory - introduced autoconf --- ulogd/include/ulogd/conffile.h | 69 ++++++++++++++++++++++++++++++++++++++++++ ulogd/include/ulogd/ulogd.h | 42 +++++++++++++------------ 2 files changed, 91 insertions(+), 20 deletions(-) create mode 100644 ulogd/include/ulogd/conffile.h (limited to 'ulogd/include') diff --git a/ulogd/include/ulogd/conffile.h b/ulogd/include/ulogd/conffile.h new file mode 100644 index 0000000..ba16c35 --- /dev/null +++ b/ulogd/include/ulogd/conffile.h @@ -0,0 +1,69 @@ +/* config file parser functions + * + * (C) 2000 by Harald Welte + * + * $Id: conffile.h,v 1.5 2000/09/12 14:29:37 laforge Exp $ + * + * This code is distributed under the terms of GNU GPL */ + +#ifndef _CONFFILE_H +#define _CONFFILE_H + +#include + +/* errors returned by config functions */ +enum { + ERRNONE = 0, + ERROPEN, /* unable to open config file */ + ERROOM, /* out of memory */ + ERRMULT, /* non-multiple option occured more than once */ + ERRMAND, /* mandatory option not found */ + ERRUNKN, /* unknown config key */ +}; + +/* maximum line lenght of config file entries */ +#define LINE_LEN 255 + +/* maximum lenght of config key name */ +#define CONFIG_KEY_LEN 30 + +/* maximum lenght of string config value */ +#define CONFIG_VAL_STRING_LEN 225 + +/* valid config types */ +#define CONFIG_TYPE_INT 0x0001 +#define CONFIG_TYPE_STRING 0x0002 +#define CONFIG_TYPE_CALLBACK 0x0003 + +/* valid config options */ +#define CONFIG_OPT_NONE 0x0000 +#define CONFIG_OPT_MANDATORY 0x0001 +#define CONFIG_OPT_MULTI 0x0002 + +typedef struct config_entry { + struct config_entry *next; /* the next one in linked list */ + char key[CONFIG_KEY_LEN]; /* name of config directive */ + u_int8_t type; /* type; see above */ + u_int8_t options; /* options; see above */ + u_int8_t hit; /* found? */ + union { + char string[CONFIG_VAL_STRING_LEN]; + int value; + int (*parser)(char *argstr); + } u; +} config_entry_t; + +/* if an error occurs, config_errce is set to the erroneous ce */ +config_entry_t *config_errce; + +/* tell us the name of the config file */ +int config_register_file(const char *file); + +/* parse the config file , presume all config keys are registered + * if final==1 */ +int config_parse_file(int final); + +/* register a linked list of config entries */ +int config_register_key(config_entry_t *ce); + +#endif /* ifndef _CONFFILE_H */ diff --git a/ulogd/include/ulogd/ulogd.h b/ulogd/include/ulogd/ulogd.h index 186de9e..b3468ce 100644 --- a/ulogd/include/ulogd/ulogd.h +++ b/ulogd/include/ulogd/ulogd.h @@ -1,15 +1,15 @@ #ifndef _ULOGD_H #define _ULOGD_H -/* ulogd, Version $Revision: 1.8 $ +/* ulogd, Version $Revision: 1.9 $ * - * first try of a logging daemon for my netfilter ULOG target - * for the linux 2.4 netfilter subsystem. + * userspace logging daemon for netfilter ULOG target + * of the linux 2.4 netfilter subsystem. * - * (C) 2000 by Harald Welte + * (C) 2000 by Harald Welte * * this code is released under the terms of GNU GPL * - * $Id: ulogd.h,v 1.8 2000/11/16 17:20:52 laforge Exp $ + * $Id: ulogd.h,v 1.9 2000/11/16 21:15:30 laforge Exp $ */ #include @@ -49,10 +49,11 @@ /* maximum length of ulogd key */ #define ULOGD_MAX_KEYLEN 32 -#define ULOGD_DEBUG 1 -#define ULOGD_NOTICE 5 -#define ULOGD_ERROR 8 - +#define ULOGD_DEBUG 1 /* debugging information */ +#define ULOGD_INFO 3 +#define ULOGD_NOTICE 5 /* abnormal/unexpected condition */ +#define ULOGD_ERROR 7 /* error condition, requires user action */ +#define ULOGD_FATAL 8 /* fatal, program aborted */ extern FILE *logfile; @@ -106,9 +107,16 @@ typedef struct ulog_output { /* name of this ouput plugin */ char name[ULOGD_MAX_KEYLEN]; /* callback function */ - int* (*output)(ulog_iret_t *ret); + int (*output)(ulog_iret_t *ret); } ulog_output_t; +/* entries of the key hash */ +struct ulogd_keyh_entry { + ulog_interpreter_t *interp; /* interpreter for this key */ + unsigned int offset; /* offset within interpreter */ + const char *name; /* name of this particular key */ +}; + /*********************************************************************** * PUBLIC INTERFACE ***********************************************************************/ @@ -124,7 +132,6 @@ ulog_iret_t *alloc_ret(const u_int16_t type, const char*); /* write a message to the daemons' logfile */ void ulogd_log(int level, const char *message, ...); - /* backwards compatibility */ #define ulogd_error(format, args...) ulogd_log(ULOGD_ERROR, format, ## args) @@ -138,15 +145,10 @@ unsigned int keyh_getid(const char *name); ulog_iret_t *keyh_getres(unsigned int id); /* the key hash itself */ -struct ulogd_keyh_entry ulogd_keyh[100]; - -/* entries of the key hash */ -struct ulogd_keyh_entry { - ulog_interpreter_t *interp; /* interpreter for this key */ - unsigned int offset; /* offset within interpreter */ - const char *name; /* name of this particular key */ -}; +struct ulogd_keyh_entry *ulogd_keyh; +#define IS_VALID(x) (x.flags & ULOGD_RETF_VALID) +#define SET_VALID(x) (x.flags |= ULOGD_RETF_VALID) -#endif +#endif /* _ULOGD_H */ -- cgit v1.2.3