DES-SERT - A Simple and Extensible Routing Framework for Testbeds: dessert.h Source File

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# dessert.h

Go to the documentation of this file.

    00001 /***************************************************************************/
    00030 /***************************************************************************/
    00327 #ifndef DESSERT_H
    00328 #define DESSERT_H
    00329
    00330 #ifdef TARGET_DARWIN
    00331 #include <net/if_dl.h>
    00332 #define TUN_BSD
    00333 #endif
    00334
    00335 #ifdef TARGET_LINUX
    00336 #define TUN_LINUX
    00337 #endif
    00338
    00339 #include <net/if.h>
    00340 #include <net/ethernet.h>
    00341 #include <pcap.h>
    00342 #include <stdint.h>
    00343 #include <syslog.h>
    00344 #include <stdlib.h>
    00345 #include <libcli.h>
    00346
    00347 /***************************************************************************/
    00356 /******************************************************************************
    00357  * #defines
    00358  ******************************************************************************/
    00359
    00361 #define DESSERT_ETHPROTO 0x8042
    00362
    00364 #define DESSERT_MAXFRAMELEN ETHER_MAX_LEN
    00365
    00367 #define DESSERT_MAXEXTDATALEN 253
    00368
    00370 #define DESSERT_PROTO_STRLEN 4
    00371
    00373 #define DESSERT_LBUF_LEN 1024
    00374
    00376 #define DESSERT_OK                  0
    00377
    00379 #define DESSERT_ERR                 1
    00380
    00381 /******************************************************************************
    00382  * typedefs
    00383  ******************************************************************************/
    00385 typedef uint64_t dessert_frameid_t;
    00386
    00388 typedef struct __attribute__ ((__packed__)) dessert_msg {
    00390     struct     ether_header l2h;
    00392     char       proto[DESSERT_PROTO_STRLEN];
    00394     uint8_t    ver;
    00396     uint8_t    flags;
    00397     union {
    00399         uint32_t u32;
    00400         struct __attribute__ ((__packed__)) {
    00402             uint8_t    ttl;
    00404             uint8_t    u8;
    00406             uint16_t   u16;
    00407         };
    00408     };
    00410     uint16_t   hlen;
    00412     uint16_t   plen;
    00413 } dessert_msg_t;
    00414
    00416 typedef struct dessert_msg_proc {
    00418     uint16_t    lflags;
    00420     uint16_t    lreserved;
    00422     char        lbuf[DESSERT_LBUF_LEN];
    00423 } dessert_msg_proc_t;
    00424
    00426 typedef struct __attribute__ ((__packed__)) dessert_ext {
    00429     uint8_t    type;
    00430
    00434     uint8_t    len;
    00435
    00437     uint8_t       data[DESSERT_MAXEXTDATALEN];
    00438 } dessert_ext_t;
    00439
    00441 typedef struct dessert_meshif {
    00443     struct dessert_meshif    *next;
    00445     struct dessert_meshif    *prev;
    00447     char                if_name[IFNAMSIZ];
    00449     unsigned int        if_index;
    00451     uint8_t             hwaddr[ETHER_ADDR_LEN]; /* uthash key*/
    00453     pthread_mutex_t     cnt_mutex;
    00455     uint64_t            ipkts;
    00457     uint64_t            opkts;
    00459     uint64_t            ibytes;
    00461     uint64_t            obytes;
    00463     pcap_t              *pcap;
    00465     char                pcap_err[PCAP_ERRBUF_SIZE];
    00467     pthread_t           worker;
    00468 } dessert_meshif_t;
    00469
    00476 typedef struct dessert_sysif {
    00478     struct dessert_sysif   *next;
    00480     char                if_name[IFNAMSIZ];
    00482     unsigned int        if_index;
    00484     uint8_t             hwaddr[ETHER_ADDR_LEN];
    00486     pthread_mutex_t     cnt_mutex;
    00488     uint64_t            ipkts;
    00490     uint64_t            opkts;
    00492     uint64_t            ibytes;
    00494     uint64_t            obytes;
    00496     int                 fd;
    00498     uint8_t             flags;
    00500     pthread_t           worker;
    00501 } dessert_sysif_t;
    00502
    00525 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);
    00526
    00543 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);
    00544
    00556 typedef int dessert_periodiccallback_t(void *data, struct timeval *scheduled, struct timeval *interval);
    00557
    00559 typedef struct dessert_periodic {
    00561     dessert_periodiccallback_t *c;
    00563     struct timeval scheduled;
    00565     struct timeval interval;
    00567     void *data;
    00569     struct dessert_periodic  *next;
    00570 } dessert_periodic_t;
    00571
    00572 /***************************************************************************/
    00582 /******************************************************************************
    00583  *  #defines
    00584  ******************************************************************************/
    00585
    00587 #define DESSERT_FRAMEID_MAX ((uint64_t)-1)
    00588
    00591 #define DESSERT_OPT_DAEMONIZE    0x0100
    00592
    00594 #define DESSERT_OPT_NODAEMONIZE  0x0200
    00595
    00597 #define DESSERT_OPT_PID         0x0400
    00598
    00600 #define DESSERT_OPT_NOPID       0x0800
    00601
    00602 /******************************************************************************
    00603  * globals
    00604  ******************************************************************************/
    00605
    00607 extern char        dessert_proto[DESSERT_PROTO_STRLEN+1];
    00608
    00610 extern u_int8_t    dessert_ver;
    00611
    00613 extern u_int8_t    dessert_l25_defsrc[ETHER_ADDR_LEN];
    00614
    00615
    00617 extern u_char      ether_broadcast[ETHER_ADDR_LEN];
    00618
    00620 extern u_char      ether_null[ETHER_ADDR_LEN];
    00621
    00623 extern pthread_rwlock_t dessert_cfglock;
    00624
    00625 /******************************************************************************
    00626  * functions
    00627  ******************************************************************************/
    00628
    00629 int dessert_init(const char* proto, int version, uint16_t opts, char* pidfile);
    00630
    00631 int dessert_run(void);
    00632 void dessert_exit(void);
    00633
    00634 /***************************************************************************/
    00644 /******************************************************************************
    00645  * globals
    00646  ******************************************************************************/
    00647
    00648 extern struct cli_def *dessert_cli;
    00649
    00650 extern struct cli_command *dessert_cli_show;
    00651 extern struct cli_command *dessert_cli_cfg_iface;
    00652 extern struct cli_command *dessert_cli_cfg_no;
    00653 extern struct cli_command *dessert_cli_cfg_no_iface;
    00654 extern struct cli_command *dessert_cli_cfg_set;
    00655 extern struct cli_command *dessert_cli_cfg_logging;
    00656 extern struct cli_command *dessert_cli_cfg_no_logging;
    00657
    00658 /******************************************************************************
    00659  * functions
    00660  ******************************************************************************/
    00661
    00662 int dessert_cli_run(void);
    00663 FILE* dessert_cli_get_cfg(int argc, char** argv);
    00664 int dessert_set_cli_port(uint16_t port);
    00665
    00666 int dessert_cli_cmd_addsysif(struct cli_def *cli, char *command, char *argv[], int argc);
    00667 int dessert_cli_cmd_addmeshif(struct cli_def *cli, char *command, char *argv[], int argc);
    00668
    00669 /***************************************************************************/
    00679 /******************************************************************************
    00680  * #defines
    00681  ******************************************************************************/
    00682
    00684 #define DESSERT_LOG_SYSLOG    0x0001
    00685
    00687 #define DESSERT_LOG_NOSYSLOG  0x0002
    00688
    00691 #define DESSERT_LOG_FILE      0x0004
    00692
    00694 #define DESSERT_LOG_NOFILE    0x0008
    00695
    00697 #define DESSERT_LOG_STDERR    0x0010
    00698
    00700 #define DESSERT_LOG_NOSTDERR  0x0020
    00701
    00703 #define DESSERT_LOG_RBUF      0x0040
    00704
    00706 #define DESSERT_LOG_NORBUF    0x0080
    00707
    00709 #define DESSERT_LOG_DEBUG     0x0100
    00710
    00712 #define DESSERT_LOG_NODEBUG   0x0200
    00713
    00714 /******************************************************************************
    00715  * functions
    00716  ******************************************************************************/
    00717 int dessert_logcfg(uint16_t opts);
    00718 void _dessert_log(int level, const char* func, const char* file, int line, const char *fmt, ...);
    00720 #define dessert_debug(...) _dessert_log(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00721
    00722 #define dessert_info(...) _dessert_log(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00723
    00724 #define dessert_notice(...) _dessert_log(LOG_NOTICE, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00725
    00726 #define dessert_warn(...) _dessert_log(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00727
    00728 #define dessert_warning(...) _dessert_log(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00729
    00730 #define dessert_err(...) _dessert_log(LOG_ERR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00731
    00732 #define dessert_crit(...) _dessert_log(LOG_CRIT, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00733
    00734 #define dessert_alert(...) _dessert_log(LOG_ALERT, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00735
    00736 #define dessert_emerg(...) _dessert_log(LOG_EMERG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)
    00737
    00738 /***************************************************************************/
    00748 /******************************************************************************
    00749  * #defines
    00750  ******************************************************************************/
    00751
    00753 #define DESSERT_MSG_NEEDNOSPARSE     1
    00754
    00756 #define DESSERT_MSG_NEEDMSGPROC      2
    00757
    00759 #define DESSERT_MSG_KEEP             0
    00760
    00762 #define DESSERT_MSG_DROP             -1
    00763
    00765 #define DESSERT_IF_PROMISC 0x0
    00766
    00768 #define DESSERT_IF_NOPROMISC 0x1
    00769
    00771 #define DESSERT_IF_FILTER 0x0
    00772
    00774 #define DESSERT_IF_NOFILTER 0x2
    00775
    00776 /******************************************************************************
    00777  * functions
    00778  ******************************************************************************/
    00779
    00780 /* sending messages */
    00781 int dessert_meshsend(const dessert_msg_t* msgin, const dessert_meshif_t *iface);
    00782 int dessert_meshsend_allbutone(const dessert_msg_t* msgin, const dessert_meshif_t *iface);
    00783 int dessert_meshsend_hwaddr(const dessert_msg_t* msgin, const uint8_t hwaddr[ETHER_ADDR_LEN]);
    00784 int dessert_meshsend_randomized(const dessert_msg_t* msgin);
    00785
    00786 int dessert_meshsend_fast(dessert_msg_t* msg, const dessert_meshif_t *iface);
    00787 int dessert_meshsend_fast_allbutone(dessert_msg_t* msg, const dessert_meshif_t *iface);
    00788 int dessert_meshsend_fast_hwaddr(dessert_msg_t* msg, const uint8_t hwaddr[ETHER_ADDR_LEN]);
    00789 int dessert_meshsend_fast_randomized(dessert_msg_t* msgin);
    00790 int dessert_meshsend_raw(dessert_msg_t* msg, const dessert_meshif_t *iface);
    00791
    00792 /* meshrx-callback handling */
    00793 int dessert_meshrxcb_add(dessert_meshrxcb_t* c, int prio);
    00794 int dessert_meshrxcb_del(dessert_meshrxcb_t* c);
    00795
    00796 /* mesh interface handling */
    00797 int dessert_meshif_add(const char* dev, uint8_t flags);
    00798 int dessert_meshif_del(const char* dev);
    00799
    00800 dessert_meshif_t * dessert_meshif_get_name(const char* dev);
    00801 dessert_meshif_t * dessert_meshif_get_hwaddr(const uint8_t hwaddr[ETHER_ADDR_LEN]);
    00802 dessert_meshif_t * dessert_meshiflist_get(void);
    00803 /*\}*/
    00804 /***************************************************************************/
    00814 /******************************************************************************
    00815  * #defines
    00816  ******************************************************************************/
    00817
    00819 #define DESSERT_TUN          0x00
    00820
    00822 #define DESSERT_TAP          0x01
    00823
    00825 #define DESSERT_MAKE_DEFSRC  0x02
    00826
    00828 #define _DESSERT_TAP_NOMAC   0x80
    00829
    00830 /******************************************************************************
    00831  * functions
    00832  ******************************************************************************/
    00833
    00834 int dessert_sysif_init(char* name, uint8_t flags);
    00835
    00836 int dessert_sysrxcb_add(dessert_sysrxcb_t* c, int prio);
    00837 int dessert_sysrxcb_del(dessert_sysrxcb_t* c);
    00838
    00839 int dessert_syssend_msg(dessert_msg_t *msg);
    00840 int dessert_syssend(const struct ether_header *eth, size_t len);
    00841
    00842 /***************************************************************************/
    00852 /******************************************************************************
    00853  * #defines
    00854  ******************************************************************************/
    00855
    00858 #define DESSERT_FLAG_SPARSE 0x1
    00859
    00860 /* *********************** */
    00861
    00863 #define DESSERT_LFLAG_SRC_SELF 0x0002
    00864
    00866 #define DESSERT_LFLAG_DST_MULTICAST 0x0004
    00867
    00869 #define DESSERT_LFLAG_DST_SELF 0x0008
    00870
    00872 #define DESSERT_LFLAG_DST_BROADCAST 0x0010
    00873
    00875 #define DESSERT_LFLAG_PREVHOP_SELF 0x0020
    00876
    00878 #define DESSERT_LFLAG_NEXTHOP_SELF 0x0040
    00879
    00881 #define DESSERT_LFLAG_NEXTHOP_BROADCAST 0x0080
    00882
    00886 #define DESSERT_LFLAG_DST_SELF_OVERHEARD 0x0100
    00887
    00891 #define DESSERT_LFLAG_NEXTHOP_SELF_OVERHEARD 0x0200
    00892
    00893 /* *********************** */
    00894
    00896 #define DESSERT_EXTLEN (sizeof(struct dessert_ext) - DESSERT_MAXEXTDATALEN)
    00897
    00899 #define DESSERT_EXT_ANY 0x00
    00900
    00902 #define DESSERT_EXT_ETH 0x01
    00903
    00905 #define DESSERT_EXT_TRACE 0x02
    00906
    00908 #define DESSERT_EXT_USER 0x40
    00909
    00910 /* *********************** */
    00911
    00913 #define DESSERT_MSG_TRACE_HOST (ETHER_ADDR_LEN)
    00914
    00916 #define DESSERT_MSG_TRACE_IFACE (3*ETHER_ADDR_LEN)
    00917
    00918 /* *********************** */
    00919
    00921 #define dessert_ext_getdatalen(ext) (ext->len - DESSERT_EXTLEN)
    00922
    00923 /******************************************************************************
    00924  * functions
    00925  ******************************************************************************/
    00926
    00927 int dessert_msg_new(dessert_msg_t **msgout);
    00928 int dessert_msg_clone(dessert_msg_t **msgnew, const dessert_msg_t *msgold, uint8_t sparse);
    00929 int dessert_msg_check(const dessert_msg_t* msg, size_t len);
    00930 void dessert_msg_dump(const dessert_msg_t* msg, size_t len, char *buf, size_t blen);
    00931 void dessert_msg_destroy(dessert_msg_t* msg);
    00932
    00933 int dessert_msg_ethencap(const struct ether_header* eth, size_t eth_len, dessert_msg_t **msgout);
    00934 int dessert_msg_ethdecap(const dessert_msg_t* msg, struct ether_header** ethout);
    00935 struct ether_header* dessert_msg_getl25ether (const dessert_msg_t* msg);
    00936
    00937 int dessert_msg_proc_clone(dessert_msg_proc_t **procnew, const dessert_msg_proc_t *procold);
    00938 void dessert_msg_proc_dump(const dessert_msg_t* msg, size_t len, const dessert_msg_proc_t *proc, char *buf, size_t blen);
    00939 void dessert_msg_proc_destroy(dessert_msg_proc_t* proc);
    00940
    00941 int dessert_msg_addpayload(dessert_msg_t* msg, void** payload, int len);
    00942 int dessert_msg_getpayload(dessert_msg_t *msg, void **payload);
    00943 int dessert_msg_addext(dessert_msg_t* msg, dessert_ext_t** ext, uint8_t type, size_t len);
    00944 int dessert_msg_delext(dessert_msg_t *msg, dessert_ext_t *ext);
    00945 int dessert_msg_resizeext(dessert_msg_t *msg, dessert_ext_t *ext, size_t new_len);
    00946 int dessert_msg_getext(const dessert_msg_t* msg, dessert_ext_t** ext, uint8_t type, int index);
    00947 int dessert_msg_get_ext_count(const dessert_msg_t* msg, uint8_t type);
    00948
    00949 int dessert_msg_trace_initiate(dessert_msg_t* msg, int mode);
    00950 int dessert_msg_trace_dump(const dessert_msg_t* msg, char* buf, int blen);
    00951
    00952 int dessert_msg_dump_cb(dessert_msg_t* msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id);
    00953 int dessert_msg_check_cb(dessert_msg_t* msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id);
    00954 int dessert_msg_trace_cb(dessert_msg_t* msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *iface, dessert_frameid_t id);
    00955 int dessert_msg_ifaceflags_cb(dessert_msg_t* msg, size_t len, dessert_msg_proc_t *proc, const dessert_meshif_t *riface, dessert_frameid_t id);
    00956
    00957 /***************************************************************************/
    00967 dessert_periodic_t *dessert_periodic_add(dessert_periodiccallback_t* c, void *data, const struct timeval *scheduled, const struct timeval *interval);
    00968 dessert_periodic_t *dessert_periodic_add_delayed(dessert_periodiccallback_t* c, void *data, int delay);
    00969 int dessert_periodic_del(dessert_periodic_t *p);
    00970
    00971 /***************************************************************************/
    00981 /******************************************************************************
    00982  * #defines
    00983  ******************************************************************************/
    00985 #define DESSERT_APPSTATS_VALUETYPE_BOOL         0
    00986
    00988 #define DESSERT_APPSTATS_VALUETYPE_INT32        1
    00989
    00991 #define DESSERT_APPSTATS_VALUETYPE_UINT32       2
    00992
    00994 #define DESSERT_APPSTATS_VALUETYPE_COUNTER64    3
    00995
    00997 #define DESSERT_APPSTATS_VALUETYPE_OCTETSTRING  4
    00998
    00999 /* *********************** */
    01000
    01002 #define DESSERT_APPSTATS_NODEORLINK_NONE        0
    01003
    01005 #define DESSERT_APPSTATS_NODEORLINK_NODE        1
    01006
    01008 #define DESSERT_APPSTATS_NODEORLINK_LINK        2
    01009
    01010 /* *********************** */
    01011
    01013 #define DESSERT_APPSTATS_BOOL_TRUE  1
    01014
    01016 #define DESSERT_APPSTATS_BOOL_FALSE 0
    01017
    01018 /* *********************** */
    01019
    01021 #define DESSERT_APPPARAMS_VALUETYPE_BOOL         0
    01022
    01024 #define DESSERT_APPPARAMS_VALUETYPE_INT32        1
    01025
    01027 #define DESSERT_APPPARAMS_VALUETYPE_UINT32       2
    01028
    01030 #define DESSERT_APPPARAMS_VALUETYPE_OCTETSTRING  3
    01031
    01032 /* *********************** */
    01033
    01035 #define DESSERT_APPPARAMS_BOOL_TRUE  1
    01036
    01038 #define DESSERT_APPPARAMS_BOOL_FALSE 0
    01039
    01040 /* *********************** */
    01041
    01043 #define DESSERT_APPSTATS_CB_BULK   1
    01044
    01045 #define DESSERT_APPSTATS_CB_NOBULK 2
    01046
    01047 /******************************************************************************
    01048  * typedefs
    01049  ******************************************************************************/
    01050
    01052 typedef struct dessert_agentx_appstats {
    01053
    01055     struct dessert_agentx_appstats *prev;
    01057     struct dessert_agentx_appstats *next;
    01058
    01060     char name[256];
    01062     char desc[256];
    01063
    01072     int value_type;
    01079     int node_or_link;
    01080
    01082     uint8_t macaddress1 [ETHER_ADDR_LEN];
    01084     uint8_t macaddress2 [ETHER_ADDR_LEN];
    01085
    01086     union {
    01092         uint8_t  bool;
    01094         int32_t  int32;
    01096         uint32_t uint32;
    01098         uint64_t counter64;
    01099
    01100         struct {
    01102             uint8_t octetstring_len;
    01104             char *octetstring;
    01105         };
    01106     };
    01107
    01108 } dessert_agentx_appstats_t;
    01109
    01111 typedef struct dessert_agentx_appparams {
    01112
    01114     struct dessert_agentx_appparams *prev;
    01116     struct dessert_agentx_appparams *next;
    01117
    01119     uint8_t index;
    01120
    01122     char name[256];
    01124     char desc[256];
    01125
    01133     int value_type;
    01134
    01135     union {
    01141         uint8_t  bool;
    01143         int32_t  int32;
    01145         uint32_t uint32;
    01146
    01147         struct {
    01149             uint16_t octetstring_len;
    01151             char *octetstring;
    01152         };
    01153     };
    01154
    01155 } dessert_agentx_appparams_t;
    01156
    01166 typedef int dessert_agentx_appstatscb_get_t(struct dessert_agentx_appstats *appstats);
    01167
    01177 typedef int dessert_agentx_appparamscb_get_t(struct dessert_agentx_appparams *appparams);
    01178
    01189 typedef int dessert_agentx_appparamscb_set_t(struct dessert_agentx_appparams *appparams);
    01190
    01192 typedef struct dessert_agentx_appstats_cb_entry {
    01193
    01195     struct dessert_agentx_appstats_cb_entry *prev;
    01197     struct dessert_agentx_appstats_cb_entry *next;
    01198
    01200     uint8_t isbulk_flag;
    01201
    01203     dessert_agentx_appstatscb_get_t *c;
    01204
    01205 } dessert_agentx_appstats_cb_entry_t;
    01206
    01208 typedef struct dessert_agentx_appparams_cb_entry {
    01209
    01211     struct dessert_agentx_appparams_cb_entry *prev;
    01213     struct dessert_agentx_appparams_cb_entry *next;
    01214
    01216     uint8_t index;
    01217
    01219     dessert_agentx_appparamscb_get_t *get;
    01221     dessert_agentx_appparamscb_set_t *set;
    01222
    01223 } dessert_agentx_appparams_cb_entry_t;
    01224
    01225
    01226 /******************************************************************************
    01227  * globals
    01228  ******************************************************************************/
    01229
    01230
    01231 /******************************************************************************
    01232  * functions
    01233  ******************************************************************************/
    01234 dessert_agentx_appstats_t *dessert_agentx_appstats_new(void);
    01235 void dessert_agentx_appstats_destroy(dessert_agentx_appstats_t *appstat);
    01236
    01237 dessert_agentx_appstats_cb_entry_t *dessert_agentx_appstats_add(dessert_agentx_appstatscb_get_t *c);
    01238 dessert_agentx_appstats_cb_entry_t *dessert_agentx_appstats_add_bulk(dessert_agentx_appstatscb_get_t *c);
    01239 int dessert_agentx_appstats_del(dessert_agentx_appstats_cb_entry_t *e);
    01240
    01241 dessert_agentx_appparams_t *dessert_agentx_appparam_new(void);
    01242 void dessert_agentx_appparam_destroy(dessert_agentx_appparams_t *appparam);
    01243
    01244 dessert_agentx_appparams_cb_entry_t *dessert_agentx_appparams_add(dessert_agentx_appparamscb_get_t *get, dessert_agentx_appparamscb_set_t *set);
    01245 int dessert_agentx_appparams_del(dessert_agentx_appparams_cb_entry_t *e);
    01246
    01247 /**************************************************************************/
    01275 #define MESHIFLIST_ITERATOR_START(__interface) \
    01276 pthread_rwlock_rdlock(&dessert_cfglock); \
    01277 DL_FOREACH(dessert_meshiflist_get(), __interface) {
    01278
    01283 #define MESHIFLIST_ITERATOR_STOP } pthread_rwlock_unlock(&dessert_cfglock)
    01284
    01299 #define TIMEVAL_ADD(__tv, __sec, __usec)       \
    01300     do {                                       \
    01301         (__tv)->tv_sec  += __sec;              \
    01302         (__tv)->tv_usec += __usec;             \
    01303         if((__tv)->tv_usec >= 1000000) {       \
    01304             ++(__tv)->tv_sec;                  \
    01305             (__tv)->tv_usec -= 1000000;        \
    01306         }                                      \
    01307     } while(0)
    01308
    01309 #define likely(x)       (__builtin_expect((x),1))
    01310 #define unlikely(x)     (__builtin_expect((x),0))
    01311
    01312 #define __dessert_assert(func, file, line, e) \
    01313     ((void)_dessert_log(LOG_EMERG, func, file, line, "assertion `%s' failed!\n", e), abort)
    01314
    01315 #ifdef NDEBUG
    01316 #define assert(e)       ((void)0)
    01317 #else
    01318 #define assert(e) \
    01319     (__builtin_expect(!(e), 0) ? __dessert_assert(__FUNCTION__, __FILE__, __LINE__, #e) : (void)0)
    01320 #endif
    01321
    01324 /******************************************************************************
    01325  *
    01326  * ! ! ! ! O L D ! ! ! T O D O ! ! ! !
    01327  *
    01328  ******************************************************************************/
    01329
    01331 //extern uint16_t dessert_cfgflags;   // TODO not used! to be removed??!?
    01332
    01334 //#define dessert_msg_buflen(x) ((x->flags&DESSERT_FLAG_SPARSE)?(x->hlen+x->plen):(DESSERT_MAXFRAMELEN+DESSERT_MSGPROCLEN))
    01335
    01336 //#define dessert_frameid_overflow(x, y) ((x>y)&&((x-y)>(DESSERT_FRAMEID_MAX/2)))
    01337
    01338
    01339 #endif /* DESSERT_H*/