3 /* ulogd, Version $Revision: 5369 $
5 * userspace logging daemon for netfilter ULOG target
6 * of the linux 2.4 netfilter subsystem.
8 * (C) 2000 by Harald Welte <laforge@gnumonks.org>
10 * this code is released under the terms of GNU GPL
12 * $Id: ulogd.h 5369 2005-05-04 01:16:57Z laforge $
15 #include <libipulog/libipulog.h>
17 #include <signal.h> /* need this because of extension-sighandler */
19 /* All types with MSB = 1 make use of value.ptr
20 * other types use one of the union's member */
22 /* types without length */
23 #define ULOGD_RET_NONE 0x0000
25 #define ULOGD_RET_INT8 0x0001
26 #define ULOGD_RET_INT16 0x0002
27 #define ULOGD_RET_INT32 0x0003
28 #define ULOGD_RET_INT64 0x0004
30 #define ULOGD_RET_UINT8 0x0011
31 #define ULOGD_RET_UINT16 0x0012
32 #define ULOGD_RET_UINT32 0x0013
33 #define ULOGD_RET_UINT64 0x0014
35 #define ULOGD_RET_BOOL 0x0050
37 #define ULOGD_RET_IPADDR 0x0100
39 /* types with length field */
40 #define ULOGD_RET_STRING 0x8020
41 #define ULOGD_RET_RAW 0x8030
45 #define ULOGD_RETF_NONE 0x0000
46 #define ULOGD_RETF_VALID 0x0001 /* contains a valid result */
47 #define ULOGD_RETF_FREE 0x0002 /* ptr needs to be free()d */
50 /* maximum length of ulogd key */
51 #define ULOGD_MAX_KEYLEN 32
53 #define ULOGD_DEBUG 1 /* debugging information */
55 #define ULOGD_NOTICE 5 /* abnormal/unexpected condition */
56 #define ULOGD_ERROR 7 /* error condition, requires user action */
57 #define ULOGD_FATAL 8 /* fatal, program aborted */
59 typedef struct ulog_iret {
60 /* next interpreter return (key) in the global list */
61 struct ulog_iret *next;
62 /* next interpreter in linked list for current result */
63 struct ulog_iret *cur_next;
64 /* length of the returned value (only for lengthed types */
66 /* type of the returned value (ULOGD_IRET_...) */
68 /* flags (i.e. free, ...) */
70 /* name of this key */
71 char key[ULOGD_MAX_KEYLEN];
72 /* and finally the returned value */
87 typedef struct ulog_interpreter {
88 /* next interpreter in old-style linked list */
89 struct ulog_interpreter *next;
90 /* name of this interpreter (predefined by plugin) */
91 char name[ULOGD_MAX_KEYLEN];
92 /* ID for this interpreter (dynamically assigned) */
94 /* function to call for each packet */
95 ulog_iret_t* (*interp)(struct ulog_interpreter *ip,
96 ulog_packet_msg_t *pkt);
97 /* number of keys this interpreter has */
99 /* keys of this particular interpreter */
101 } ulog_interpreter_t;
103 typedef struct ulog_output {
104 /* next output in the linked list */
105 struct ulog_output *next;
106 /* name of this ouput plugin */
107 char name[ULOGD_MAX_KEYLEN];
108 /* callback for initialization */
110 /* callback for de-initialization */
112 /* callback function */
113 int (*output)(ulog_iret_t *ret);
114 /* callback function for signals (SIGHUP, ..) */
115 void (*signal)(int signal);
118 /* entries of the key hash */
119 struct ulogd_keyh_entry {
120 ulog_interpreter_t *interp; /* interpreter for this key */
121 unsigned int offset; /* offset within interpreter */
122 const char *name; /* name of this particular key */
125 /***********************************************************************
127 ***********************************************************************/
129 /* register a new interpreter plugin */
130 void register_interpreter(ulog_interpreter_t *me);
132 /* register a new output target */
133 void register_output(ulog_output_t *me);
135 /* allocate a new ulog_iret_t */
136 ulog_iret_t *alloc_ret(const u_int16_t type, const char*);
138 /* write a message to the daemons' logfile */
139 void __ulogd_log(int level, char *file, int line, const char *message, ...);
140 /* macro for logging including filename and line number */
141 #define ulogd_log(level, format, args...) \
142 __ulogd_log(level, __FILE__, __LINE__, format, ## args)
143 /* backwards compatibility */
144 #define ulogd_error(format, args...) ulogd_log(ULOGD_ERROR, format, ## args)
146 /* get an interpreter hash id by name */
147 unsigned int interh_getid(const char *name);
149 /* get a key id if you have the name */
150 unsigned int keyh_getid(const char *name);
152 /* get a result for a given key id */
153 ulog_iret_t *keyh_getres(unsigned int id);
155 /* the key hash itself */
156 extern struct ulogd_keyh_entry *ulogd_keyh;
158 #define IS_VALID(x) (x.flags & ULOGD_RETF_VALID)
160 #define SET_VALID(x) (x.flags |= ULOGD_RETF_VALID)
162 #endif /* _ULOGD_H */