Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00032 #ifndef _UL_CALLBACKS_H
00033 #define _UL_CALLBACKS_H
00034
00035 #include "../../dprint.h"
00036
00037
00038 struct ucontact;
00039
00040 #define UL_CONTACT_INSERT (1<<0)
00041 #define UL_CONTACT_UPDATE (1<<1)
00042 #define UL_CONTACT_DELETE (1<<2)
00043 #define UL_CONTACT_EXPIRE (1<<3)
00044 #define ULCB_MAX ((1<<4)-1)
00045
00047 typedef void (ul_cb) (struct ucontact *c, int type, void *param);
00049 typedef int (*register_ulcb_t)( int cb_types, ul_cb f, void *param);
00050
00051
00052 struct ul_callback {
00053 int id;
00054 int types;
00055 ul_cb* callback;
00056 void *param;
00057 struct ul_callback* next;
00058 };
00059
00060 struct ulcb_head_list {
00061 struct ul_callback *first;
00062 int reg_types;
00063 };
00064
00065
00066 extern struct ulcb_head_list* ulcb_list;
00067
00068
00069 #define exists_ulcb_type(_types_) \
00070 ( (ulcb_list->reg_types)|(_types_) )
00071
00072
00073 int init_ulcb_list(void);
00074
00075 void destroy_ulcb_list(void);
00076
00077
00079 int register_ulcb( int types, ul_cb f, void *param );
00080
00082 static inline void run_ul_callbacks( int type , struct ucontact *c)
00083 {
00084 struct ul_callback *cbp;
00085
00086 for (cbp=ulcb_list->first; cbp; cbp=cbp->next) {
00087 if(cbp->types&type) {
00088 LM_DBG("contact=%p, callback type %d/%d, id %d entered\n",
00089 c, type, cbp->types, cbp->id );
00090 cbp->callback( c, type, cbp->param );
00091 }
00092 }
00093 }
00094
00095
00096
00097 #endif