From cf6bc4f21f8f379c80fd814a5e1b8f1cef02036b Mon Sep 17 00:00:00 2001 From: laforge Date: Sun, 22 Aug 2004 21:42:28 +0000 Subject: commit my latest changes from Ottawa (July 2004) --- include/ipfix_protocol.h | 29 ++++++++++ include/ulogd/select.h | 2 + include/ulogd/ulogd.h | 134 +++++++++++++++++++++++++++++------------------ 3 files changed, 114 insertions(+), 51 deletions(-) create mode 100644 include/ipfix_protocol.h (limited to 'include') diff --git a/include/ipfix_protocol.h b/include/ipfix_protocol.h new file mode 100644 index 0000000..3bcf05c --- /dev/null +++ b/include/ipfix_protocol.h @@ -0,0 +1,29 @@ +#ifndef _IPFIX_PROTOCOL_H +#define _IPFIX_PROTOCOL_H + +/* This header file defines structures for the IPFIX protocol in accordance with + * draft-ietf-ipfix-protocol-03.txt */ + +/* Section 8.1 */ +struct ipfix_msg_hdr { + u_int16_t version; + u_int16_t length; + u_int32_t export_time; + u_int32_t seq; + u_int32_t source_id; +}; + +/* Section 8.2 */ +struct ipfix_ietf_field { + u_int16_t type; + u_int16_t length; +}; + +struct ipfix_vendor_field { + u_int16_t type; + u_int16_t length; + u_int32_t enterprise_num; +}; + + +#endif diff --git a/include/ulogd/select.h b/include/ulogd/select.h index 9562a6e..4558555 100644 --- a/include/ulogd/select.h +++ b/include/ulogd/select.h @@ -1,6 +1,8 @@ #ifndef ULOGD_SELECT_H #define ULOGD_SELECT_H +#include + #define ULOGD_FD_F_READ 0x0001 #define ULOGD_FD_F_WRITE 0x0002 diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h index d79fbba..db8df34 100644 --- a/include/ulogd/ulogd.h +++ b/include/ulogd/ulogd.h @@ -12,7 +12,7 @@ * $Id$ */ -#include +#include #include #include /* need this because of extension-sighandler */ @@ -45,6 +45,8 @@ #define ULOGD_RETF_NONE 0x0000 #define ULOGD_RETF_VALID 0x0001 /* contains a valid result */ #define ULOGD_RETF_FREE 0x0002 /* ptr needs to be free()d */ +#define ULOGD_RETF_NEEDED 0x0004 /* this parameter is actually needed + * by some downstream plugin */ /* maximum length of ulogd key */ @@ -58,11 +60,17 @@ extern FILE *logfile; -typedef struct ulog_iret { +enum ulogd_dtype { + ULOGD_DTYPE_NULL, + ULOGD_DTYPE_RAW, + ULOGD_DTYPE_PACKET, + ULOGD_DTYPE_FLOW, +}; + +/* structure describing an input / output parameter of a plugin */ +typedef struct ulogd_key { /* next interpreter return (key) in the global list */ struct ulog_iret *next; - /* next interpreter in linked list for current result */ - struct ulog_iret *cur_next; /* length of the returned value (only for lengthed types */ u_int32_t len; /* type of the returned value (ULOGD_IRET_...) */ @@ -70,52 +78,78 @@ typedef struct ulog_iret { /* flags (i.e. free, ...) */ u_int16_t flags; /* name of this key */ - char key[ULOGD_MAX_KEYLEN]; - /* and finally the returned value */ + char name[ULOGD_MAX_KEYLEN]; + /* IETF IPFIX attribute ID */ + struct { + u_int32_t vendor; + u_int16_t field_id; + } ipfix; + union { - u_int8_t b; - u_int8_t ui8; - u_int16_t ui16; - u_int32_t ui32; - u_int64_t ui64; - int8_t i8; - int16_t i16; - int32_t i32; - int64_t i64; - void *ptr; - } value; -} ulog_iret_t; - -typedef struct ulog_interpreter { - /* next interpreter in old-style linked list */ - struct ulog_interpreter *next; - /* name of this interpreter (predefined by plugin) */ + /* and finally the returned value */ + union { + u_int8_t b; + u_int8_t ui8; + u_int16_t ui16; + u_int32_t ui32; + u_int64_t ui64; + int8_t i8; + int16_t i16; + int32_t i32; + int64_t i64; + void *ptr; + } value; + struct ulog_ket *source; + } u; +} ulogd_iret_t; + +typedef struct ulogd_plugin { + /* global list of plugins */ + struct list_head list; + /* name of this plugin (predefined by plugin) */ char name[ULOGD_MAX_KEYLEN]; - /* ID for this interpreter (dynamically assigned) */ + /* ID for this plugin (dynamically assigned) */ unsigned int id; + struct { + /* possible input keys of this interpreter */ + struct ulogd_key *keys; + /* number of keys this interpreter has */ + unsigned int num_keys; + /* type */ + enum ulogd_dtype type; + } input; + struct { + /* possible input keys of this interpreter */ + struct ulogd_key *keys; + /* number of keys this interpreter has */ + unsigned int num_keys; + /* type */ + enum ulogd_dtype type; + } output; + /* function to call for each packet */ - ulog_iret_t* (*interp)(struct ulog_interpreter *ip, - ulog_packet_msg_t *pkt); - /* number of keys this interpreter has */ - unsigned int key_num; - /* keys of this particular interpreter */ - ulog_iret_t *result; -} ulog_interpreter_t; - -typedef struct ulog_output { - /* next output in the linked list */ - struct ulog_output *next; - /* name of this ouput plugin */ - char name[ULOGD_MAX_KEYLEN]; - /* callback for initialization */ - int (*init)(void); - /* callback for de-initialization */ - void (*fini)(void); - /* callback function */ - int (*output)(ulog_iret_t *ret); - /* callback function for signals (SIGHUP, ..) */ - void (*signal)(int signal); -} ulog_output_t; + int (*interp)(struct ulogd_pluginstance *instance); + /* function to construct a new pluginstance */ + struct ulogd_pluginstance *(*constructor)(struct ulogd_plugin *pl); + /* function to destruct an existing pluginstance */ + int (*destructor)(struct ulogd_pluginstance *instance); + /* configuration parameters */ + config_entry_t *configs; +} ulogd_interpreter_t; + +/* an instance of a plugin, element in a stack */ +typedef struct ulogd_pluginstance { + /* local list of plugins in this stack */ + struct list_head list; + /* plugin (master) */ + struct ulogd_plugin *plugin; + /* per-instance input keys */ + struct ulogd_input *input; + /* per-instance output keys */ + struct ulogd_iret *output; + /* private data */ + char private[0]; +} ulogd_pluginstance_t; /* entries of the key hash */ struct ulogd_keyh_entry { @@ -129,10 +163,7 @@ struct ulogd_keyh_entry { ***********************************************************************/ /* register a new interpreter plugin */ -void register_interpreter(ulog_interpreter_t *me); - -/* register a new output target */ -void register_output(ulog_output_t *me); +void ulogd_register_plugin(ulog_plugin_t *me); /* allocate a new ulog_iret_t */ ulog_iret_t *alloc_ret(const u_int16_t type, const char*); @@ -158,7 +189,8 @@ ulog_iret_t *keyh_getres(unsigned int id); extern struct ulogd_keyh_entry *ulogd_keyh; #define IS_VALID(x) (x.flags & ULOGD_RETF_VALID) - #define SET_VALID(x) (x.flags |= ULOGD_RETF_VALID) +#define IS_NEEDED(x) (x.flags & ULOGD_RETF_NEEDED) +#define SET_NEEDED(x) (x.flags |= ULOGD_RETF_NEEDED) #endif /* _ULOGD_H */ -- cgit v1.2.3