ul_callback.h
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
00027
00028
00029
00030
00031
00032 #ifndef _UL_CALLBACKS_H
00033 #define _UL_CALLBACKS_H
00034
00035 #include "ucontact.h"
00036
00037
00038 #define UL_CONTACT_INSERT (1<<0)
00039 #define UL_CONTACT_UPDATE (1<<1)
00040 #define UL_CONTACT_DELETE (1<<2)
00041 #define UL_CONTACT_EXPIRE (1<<3)
00042 #define ULCB_MAX ((1<<4)-1)
00043
00044
00045 typedef void (ul_cb) (ucontact_t *c, int type, void *param);
00046
00047 typedef int (*register_ulcb_t)( int cb_types, ul_cb f, void *param);
00048
00049
00050 struct ul_callback {
00051 int id;
00052 int types;
00053 ul_cb* callback;
00054 void *param;
00055 struct ul_callback* next;
00056 };
00057
00058 struct ulcb_head_list {
00059 struct ul_callback *first;
00060 int reg_types;
00061 };
00062
00063
00064 extern struct ulcb_head_list* ulcb_list;
00065
00066
00067 #define exists_ulcb_type(_types_) \
00068 ( (ulcb_list->reg_types)|(_types_) )
00069
00070
00071 int init_ulcb_list(void);
00072
00073 void destroy_ulcb_list(void);
00074
00075
00076
00077 int register_ulcb( int types, ul_cb f, void *param );
00078
00079
00080 static inline void run_ul_callbacks( int type , ucontact_t *c)
00081 {
00082 struct ul_callback *cbp;
00083
00084 for (cbp=ulcb_list->first; cbp; cbp=cbp->next) {
00085 if(cbp->types&type) {
00086 LM_DBG("contact=%p, callback type %d/%d, id %d entered\n",
00087 c, type, cbp->types, cbp->id );
00088 cbp->callback( c, type, cbp->param );
00089 }
00090 }
00091 }
00092
00093
00094
00095 #endif