dessert.h File Reference

#include <net/if.h>
#include <net/ethernet.h>
#include <pcap.h>
#include <stdint.h>
#include <syslog.h>
#include <stdlib.h>
#include <libcli.h>
Include dependency graph for dessert.h:

Go to the source code of this file.

Data Structures

struct  dessert_msg
 A basic message send on des-sert layer2.5. More...
struct  dessert_msg_proc
 local processing struct for dessert_msg_t More...
struct  dessert_ext
 a extension record to add to a dessert_msg More...
struct  dessert_meshif
 an interface used for dessert_msg frames More...
struct  dessert_sysif
 A tun/tap interface used to inject packets to dessert implemented daemons. More...
struct  dessert_periodic
 definition of a periodic tasklist entry More...
struct  dessert_agentx_appstats
 An abstract data type representing some statistical datum. More...
struct  dessert_agentx_appparams
 An abstract data type representing some parameter. More...
struct  dessert_agentx_appstats_cb_entry
 A callback entry representing a statistical datum. More...
struct  dessert_agentx_appparams_cb_entry
 A callback entry representing a parameter. More...

Defines

#define DESSERT_ETHPROTO   0x8042
 ethernet protocol used on layer 2
#define DESSERT_MAXFRAMELEN   ETHER_MAX_LEN
 maximum frame size to assemble as dessert_msg
#define DESSERT_MAXEXTDATALEN   253
 maximum size of the data part in dessert_ext
#define DESSERT_PROTO_STRLEN   4
 length of protocol string used in dessert_msg
#define DESSERT_LBUF_LEN   1024
 size of local message processing buffer
#define DESSERT_OK   0
 return code for many dessert_* functions
#define DESSERT_ERR   1
 return code for many dessert_* functions
#define DESSERT_FRAMEID_MAX   ((uint64_t)-1)
 type for local unique packet identification
#define DESSERT_OPT_DAEMONIZE   0x0100
 flag for dessert_init - daemonize when calling disables logging to STDERR
#define DESSERT_OPT_NODAEMONIZE   0x0200
 flag for dessert_init - do not daemonize when calling
#define DESSERT_OPT_PID   0x0400
 flag for dessert_init - create and write pid file
#define DESSERT_OPT_NOPID   0x0800
 flag for dessert_init - do not create and write pid file
#define DESSERT_LOG_SYSLOG   0x0001
 flag for dessert_logcfg - enable syslog logging
#define DESSERT_LOG_NOSYSLOG   0x0002
 flag for dessert_logcfg - disable syslog logging
#define DESSERT_LOG_FILE   0x0004
 flag for dessert_logcfg - enable logfile logging
#define DESSERT_LOG_NOFILE   0x0008
 flag for dessert_logcfg - disable logfile logging
#define DESSERT_LOG_STDERR   0x0010
 flag for dessert_logcfg - enable logging to stderr
#define DESSERT_LOG_NOSTDERR   0x0020
 flag for dessert_logcfg - disable logging to stderr
#define DESSERT_LOG_RBUF   0x0040
 flag for dessert_logcfg - enable logging to ringbuffer
#define DESSERT_LOG_NORBUF   0x0080
 flag for dessert_logcfg - disable logging to ringbuffer
#define DESSERT_LOG_DEBUG   0x0100
 flag for dessert_logcfg - enable debug loglevel
#define DESSERT_LOG_NODEBUG   0x0200
 flag for dessert_logcfg - disable debug loglevel
#define dessert_debug(...)   _dessert_log(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at DEBUG level
#define dessert_info(...)   _dessert_log(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at INFO level
#define dessert_notice(...)   _dessert_log(LOG_NOTICE, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at NOTICE level
#define dessert_warn(...)   _dessert_log(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at WARNING level
#define dessert_warning(...)   _dessert_log(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at WARNING level
#define dessert_err(...)   _dessert_log(LOG_ERR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at ERR level
#define dessert_crit(...)   _dessert_log(LOG_CRIT, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at CRIT level
#define dessert_alert(...)   _dessert_log(LOG_ALERT, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at ALERT level
#define dessert_emerg(...)   _dessert_log(LOG_EMERG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
 log at EMERG level
#define DESSERT_MSG_NEEDNOSPARSE   1
 return code for dessert_meshrxcb_t - forces to copy the message and call again
#define DESSERT_MSG_NEEDMSGPROC   2
 return code for dessert_meshrxcb_t - forces to generate processing info and call again
#define DESSERT_MSG_KEEP   0
 return code for dessert_meshrxcb_t and dessert_sysrxcb_t
#define DESSERT_MSG_DROP   -1
 return code for dessert_meshrxcb_t and dessert_sysrxcb_t
#define DESSERT_IF_PROMISC   0x0
 flag for dessert_meshif_add - set interface in promiscuous-mode (default)
#define DESSERT_IF_NOPROMISC   0x1
 flag for dessert_meshif_add - do not set interface in promiscuous-mode
#define DESSERT_IF_FILTER   0x0
 flag for dessert_meshif_add - filter out non-des-sert frames in libpcap (default)
#define DESSERT_IF_NOFILTER   0x2
 flag for dessert_meshif_add - do not filter out non-des-sert frames in libpcap
#define DESSERT_TUN   0x00
 flag for dessert_sysif_init - open tun (ip/ipv6) device
#define DESSERT_TAP   0x01
 flag for dessert_sysif_init - open tap (ethernet) device
#define DESSERT_MAKE_DEFSRC   0x02
 flag for dessert_sysif_init - set dessert_l25_defsrc to mac of tap device
#define _DESSERT_TAP_NOMAC   0x80
 flag for dessert_sysif_init - get mac for tap failed - try mac in src of first packet
#define DESSERT_FLAG_SPARSE   0x1
 flag for dessert_msg.flags - message len is hlen+plen if not set buffer len is assumed as DESSERT_MAXFRAMELEN + DESSERT_MSGPROCLEN
#define DESSERT_LFLAG_SRC_SELF   0x0002
 flag for dessert_msg_proc.lflags - l25 src is one of our interfaces
#define DESSERT_LFLAG_DST_MULTICAST   0x0004
 flag for dessert_msg_proc.lflags - l25 dst is multicast address
#define DESSERT_LFLAG_DST_SELF   0x0008
 flag for dessert_msg_proc.lflags - l25 dst is one of our interfaces
#define DESSERT_LFLAG_DST_BROADCAST   0x0010
 flag for dessert_msg_proc.lflags - l25 dst is broadcast
#define DESSERT_LFLAG_PREVHOP_SELF   0x0020
 flag for dessert_msg_proc.lflags - l2 src is one of our interfaces
#define DESSERT_LFLAG_NEXTHOP_SELF   0x0040
 flag for dessert_msg_proc.lflags - l2 dst is one of our interfaces
#define DESSERT_LFLAG_NEXTHOP_BROADCAST   0x0080
 flag for dessert_msg_proc.lflags - l2 dst is broadcast
#define DESSERT_LFLAG_DST_SELF_OVERHEARD   0x0100
 flag for dessert_msg_proc.lflags - l25 dst is one of our interfaces, but we received the message not via the indented interface, e.g.
#define DESSERT_LFLAG_NEXTHOP_SELF_OVERHEARD   0x0200
 flag for dessert_msg_proc.lflags - l2 dst is one of our interfaces, but we received the message not via the indented interface, e.g.
#define DESSERT_EXTLEN   (sizeof(struct dessert_ext) - DESSERT_MAXEXTDATALEN)
 length of dessert_ext header
#define DESSERT_EXT_ANY   0x00
 dessert_ext type wildcard - any extension
#define DESSERT_EXT_ETH   0x01
 dessert_ext type for ethernet header
#define DESSERT_EXT_TRACE   0x02
 dessert_ext type for packet tracing
#define DESSERT_EXT_USER   0x40
 first dessert_ext type for usage by the user
#define DESSERT_MSG_TRACE_HOST   (ETHER_ADDR_LEN)
 packet tracing flag - only record hosts
#define DESSERT_MSG_TRACE_IFACE   (3*ETHER_ADDR_LEN)
 packet tracing flag - record interfaces
#define dessert_ext_getdatalen(ext)   (ext->len - DESSERT_EXTLEN)
 Returns the length of a given extension.
#define DESSERT_APPSTATS_VALUETYPE_BOOL   0
 Flag indicating the dessert_agentx_appstats_t is of type bool.
#define DESSERT_APPSTATS_VALUETYPE_INT32   1
 Flag indicating the dessert_agentx_appstats_t is of type int32.
#define DESSERT_APPSTATS_VALUETYPE_UINT32   2
 Flag indicating the dessert_agentx_appstats_t is of type uint32.
#define DESSERT_APPSTATS_VALUETYPE_COUNTER64   3
 Flag indicating the dessert_agentx_appstats_t is of type counter64.
#define DESSERT_APPSTATS_VALUETYPE_OCTETSTRING   4
 Flag indicating the dessert_agentx_appstats_t is of type octetstring.
#define DESSERT_APPSTATS_NODEORLINK_NONE   0
 Flag indicating the dessert_agentx_appstats_t does not contain information regarding a node or a link.
#define DESSERT_APPSTATS_NODEORLINK_NODE   1
 Flag indicating the dessert_agentx_appstats_t contains information regarding a node.
#define DESSERT_APPSTATS_NODEORLINK_LINK   2
 Flag indicating the dessert_agentx_appstats_t contains information regarding a link.
#define DESSERT_APPSTATS_BOOL_TRUE   1
 What is considered to be TRUE in a dessert_agentx_appstats_t.
#define DESSERT_APPSTATS_BOOL_FALSE   0
 What is considered to be FALSE in a dessert_agentx_appstats_t.
#define DESSERT_APPPARAMS_VALUETYPE_BOOL   0
 Flag indicating the dessert_agentx_appparams_t is of type bool.
#define DESSERT_APPPARAMS_VALUETYPE_INT32   1
 Flag indicating the dessert_agentx_appparams_t is of type int32.
#define DESSERT_APPPARAMS_VALUETYPE_UINT32   2
 Flag indicating the dessert_agentx_appparams_t is of type uint32.
#define DESSERT_APPPARAMS_VALUETYPE_OCTETSTRING   3
 Flag indicating the dessert_agentx_appparams_t is of type octetstring.
#define DESSERT_APPPARAMS_BOOL_TRUE   1
 What is considered to be TRUE in a dessert_agentx_appparams_t.
#define DESSERT_APPPARAMS_BOOL_FALSE   0
 What is considered to be FALSE in a dessert_agentx_appparams_t.
#define DESSERT_APPSTATS_CB_BULK   1
 Flag indicating if a appstats callback entry is of type bulk.
#define DESSERT_APPSTATS_CB_NOBULK   2
 Flag indicating if a appstats callback entry is of type nobulk.
#define MESHIFLIST_ITERATOR_START(__interface)
 A convenience macro to safely iterate the list of mesh interfaces.
#define MESHIFLIST_ITERATOR_STOP   } pthread_rwlock_unlock(&dessert_cfglock)
 A convenience macro to safely iterate the list of mesh interfaces.
#define TIMEVAL_ADD(__tv, __sec, __usec)
 A convenience macro to safely add __sec seconds and __usec microseconds to the struct timeval __tv in an invariant respecting manner.
#define likely(x)   (__builtin_expect((x),1))
#define unlikely(x)   (__builtin_expect((x),0))
#define __dessert_assert(func, file, line, e)   ((void)_dessert_log(LOG_EMERG, func, file, line, "assertion `%s' failed!\n", e), abort)
#define assert(e)   (__builtin_expect(!(e), 0) ? __dessert_assert(__FUNCTION__, __FILE__, __LINE__, #e) : (void)0)

Typedefs

typedef uint64_t dessert_frameid_t
 runtime-unique frame id
typedef struct dessert_msg dessert_msg_t
 A basic message send on des-sert layer2.5.
typedef struct dessert_msg_proc dessert_msg_proc_t
 local processing struct for dessert_msg_t
typedef struct dessert_ext dessert_ext_t
 a extension record to add to a dessert_msg
typedef struct dessert_meshif dessert_meshif_t
 an interface used for dessert_msg frames
typedef struct dessert_sysif dessert_sysif_t
 A tun/tap interface used to inject packets to dessert implemented daemons.
typedef int dessert_meshrxcb_t (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id)
 Callback type to call if a packed is received via a dessert mesh interface.
typedef int dessert_sysrxcb_t (dessert_msg_t *msg, size_t len, dessert_msg_proc_t *proc, dessert_sysif_t *sysif, dessert_frameid_t id)
 Callback type to call if a packed should be injected into dessert via a tun/tap interface.
typedef int