Navigation


Changeset 1128:7c5449ddc434 in freeDiameter


Ignore:
Timestamp:
May 15, 2013, 12:18:30 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

New macro HOOK_MASK to ease call of the fd_hook_register function

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_msg_dumps/dbg_msg_dumps.c

    r1126 r1128  
    6464        TRACE_ENTRY("%p", conffile);
    6565       
    66         CHECK_FCT( fd_hook_register( ((1 << HOOK_MESSAGE_RECEIVED) | (1 << HOOK_MESSAGE_SENT)),
     66        CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT ),
    6767                                        md_hook_cb, NULL, NULL, &md_hdl) );
    6868       
  • extensions/dbg_msg_timings/dbg_msg_timings.c

    r1121 r1128  
    117117        CHECK_FCT( fd_hook_data_register( sizeof(struct fd_hook_permsgdata), NULL, NULL, &mt_data_hdl ) );
    118118       
    119         CHECK_FCT( fd_hook_register( ((1 << HOOK_MESSAGE_RECEIVED) | (1 << HOOK_MESSAGE_SENT) | (1 << HOOK_DATA_RECEIVED)),
     119        CHECK_FCT( fd_hook_register( HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT, HOOK_DATA_RECEIVED ),
    120120                                        mt_hook_cb, NULL, mt_data_hdl, &mt_hdl) );
    121121       
  • include/freeDiameter/libfdcore.h

    r1127 r1128  
    10771077struct fd_hook_hdl;
    10781078
     1079/* Helper for building a mask of hooks for registration */
     1080#define HOOK_MASK(hooklist...)  fd_hook_mask_helper(0, ## hooklist, -1)
     1081
    10791082/*
    10801083 * FUNCTION:    fd_hook_register
    10811084 *
    10821085 * PARAMETERS:
    1083  *  type_mask     : A bitmask of fd_hook_type bits for which this cb is registered, e.g. ((1 << HOOK_MESSAGE_RECEIVED) | (1 << HOOK_MESSAGE_SENT))
     1086 *  type_mask     : A bitmask of fd_hook_type bits for which this cb is registered, e.g. HOOK_MASK( HOOK_MESSAGE_RECEIVED, HOOK_MESSAGE_SENT )
    10841087 *  fd_hook_cb    : The callback function to register (see prototype above).
    10851088 *  regdata       : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
     
    11101113struct fd_hook_permsgdata * fd_hook_get_request_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * answer);
    11111114
     1115/* The following is used by HOOK_MASK macro */
     1116uint32_t fd_hook_mask_helper(int dummy, ...);
    11121117
    11131118/*============================================================*/
  • libfdcore/hooks.c

    r1120 r1128  
    263263}
    264264
     265/* Create a mask */
     266uint32_t fd_hook_mask_helper(int dummy, ...)
     267{
     268        va_list ap;
     269        uint32_t ret = 0;
     270        int next;
     271       
     272        va_start(ap, dummy);
     273        while ((next = va_arg(ap, int)) >= 0) {
     274                if (next > HOOK_PEER_LAST)
     275                        break; /* invalid parameter */
     276                ret |= (1<<next);
     277        }
     278        va_end(ap);
     279
     280        return ret;
     281}
     282
    265283/* The function that does the work of calling the extension's callbacks and also managing the permessagedata structures */
    266284void   fd_hook_call(enum fd_hook_type type, struct msg * msg, struct fd_peer * peer, void * other, struct fd_msg_pmdl * pmdl)
Note: See TracChangeset for help on using the changeset viewer.