Navigation


Changeset 639:95a784729cac in freeDiameter for libfreeDiameter/dispatch.c


Ignore:
Timestamp:
Dec 20, 2010, 1:07:06 PM (13 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added new opaque pointer to fd_sess_handler_create and fd_disp_register for usability. Bumped API version number.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfreeDiameter/dispatch.c

    r398 r639  
    5656        enum disp_how    how;   /* Copy of registration parameter */
    5757        struct disp_when when;  /* Copy of registration parameter */
    58         int             (*cb)( struct msg **, struct avp *, struct session *, enum disp_action *);      /* The callback itself */
     58        int             (*cb)( struct msg **, struct avp *, struct session *, void *, enum disp_action *);      /* The callback itself */
     59        void            *opaque; /* opaque data passed back to the callback */
    5960};
    6061
     
    9394               
    9495                /* We have a match, the cb must be called. */
    95                 CHECK_FCT( (*hdl->cb)(msg, avp, sess, action) );
     96                CHECK_FCT( (*hdl->cb)(msg, avp, sess, hdl->opaque, action) );
    9697               
    9798                if (*action != DISP_ACT_CONT)
     
    109110
    110111/* Create a new handler and link it */
    111 int fd_disp_register ( int (*cb)( struct msg **, struct avp *, struct session *, enum disp_action *),
    112                         enum disp_how how, struct disp_when * when, struct disp_hdl ** handle )
     112int fd_disp_register ( int (*cb)( struct msg **, struct avp *, struct session *, void *, enum disp_action *),
     113                        enum disp_how how, struct disp_when * when, void * opaque, struct disp_hdl ** handle )
    113114{
    114115        struct fd_list * cb_list = NULL;
     
    171172        }
    172173        new->cb = cb;
     174        new->opaque = opaque;
    173175       
    174176        /* Now, link this new element in the appropriate lists */
     
    186188
    187189/* Delete a handler */
    188 int fd_disp_unregister ( struct disp_hdl ** handle )
     190int fd_disp_unregister ( struct disp_hdl ** handle, void ** opaque )
    189191{
    190192        struct disp_hdl * del;
     
    199201        CHECK_POSIX( pthread_rwlock_unlock(&fd_disp_lock) );
    200202       
     203        if (opaque)
     204                *opaque = del->opaque;
     205       
    201206        free(del);
    202207        return 0;
     
    208213        TRACE_ENTRY("");
    209214        while (!FD_IS_LIST_EMPTY(&all_handlers)) {
    210                 CHECK_FCT_DO( fd_disp_unregister((void *)&(all_handlers.next->o)), /* continue */ );
     215                CHECK_FCT_DO( fd_disp_unregister((void *)&(all_handlers.next->o), NULL), /* continue */ );
    211216        }
    212217        return;
Note: See TracChangeset for help on using the changeset viewer.