浏览代码

script callback: modules updated to the new API

Miklos Tirpak 16 年之前
父节点
当前提交
8216129fc2

+ 4 - 4
modules/tm/tm.c

@@ -635,13 +635,13 @@ static int fixup_t_check_status(void** param, int param_no)
 
 
 /***************************** init functions *****************************/
-static int w_t_unref( struct sip_msg *foo, void *bar)
+static int w_t_unref( struct sip_msg *foo, unsigned int flags, void *bar)
 {
 	return t_unref(foo);
 }
 
 
-static int script_init( struct sip_msg *foo, void *bar)
+static int script_init( struct sip_msg *foo, unsigned int flags, void *bar)
 {
 	/* we primarily reset all private memory here to make sure
 	 * private values left over from previous message will
@@ -756,12 +756,12 @@ static int mod_init(void)
 	}
 
 	/* register post-script clean-up function */
-	if (register_script_cb( w_t_unref, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0 ) {
+	if (register_script_cb( w_t_unref, POST_SCRIPT_CB|REQUEST_CB, 0)<0 ) {
 		LOG(L_ERR,"ERROR:tm:mod_init: failed to register POST request "
 			"callback\n");
 		return -1;
 	}
-	if (register_script_cb( script_init, PRE_SCRIPT_CB|REQ_TYPE_CB , 0)<0 ) {
+	if (register_script_cb( script_init, PRE_SCRIPT_CB|REQUEST_CB , 0)<0 ) {
 		LOG(L_ERR,"ERROR:tm:mod_init: failed to register PRE request "
 			"callback\n");
 		return -1;

+ 3 - 3
modules/utils/utils.c

@@ -136,7 +136,7 @@ static int init_shmlock(void)
 }
 
 
-static int pre_script_filter(struct sip_msg *msg, void *unused)
+static int pre_script_filter(struct sip_msg *msg, unsigned int flags, void *unused)
 {
 	/* use id 0 for pre script callback */
 	utils_forward(msg, 0, PROTO_UDP);
@@ -198,11 +198,11 @@ static int mod_init(void)
 
 	if (forward_active == 1) {
 		/* register callback for id 0 */
-		if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|REQ_TYPE_CB, 0) < 0) {
+		if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) {
 			LM_CRIT("cannot register script callback for requests.\n");
 			return -1;
 		}
-		if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|RPL_TYPE_CB, 0) < 0) {
+		if (register_script_cb(pre_script_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) < 0) {
 			LM_CRIT("cannot register script callback for replies.\n");
 			return -1;
 		}

+ 3 - 3
modules_k/dialog/dialog.c

@@ -488,18 +488,18 @@ static int mod_init(void)
 		return -1;
 	}
 
-	if (register_script_cb( profile_cleanup, POST_SCRIPT_CB|REQ_TYPE_CB,0)<0) {
+	if (register_script_cb( profile_cleanup, POST_SCRIPT_CB|REQUEST_CB,0)<0) {
 		LM_ERR("cannot regsiter script callback");
 		return -1;
 	}
 	if (register_script_cb(dlg_cfg_cb,
-				PRE_SCRIPT_CB|REQ_TYPE_CB,0)<0)
+				PRE_SCRIPT_CB|REQUEST_CB,0)<0)
 	{
 		LM_ERR("cannot regsiter pre-script ctx callback\n");
 		return -1;
 	}
 	if (register_script_cb(dlg_cfg_cb,
-				POST_SCRIPT_CB|REQ_TYPE_CB,0)<0)
+				POST_SCRIPT_CB|REQUEST_CB,0)<0)
 	{
 		LM_ERR("cannot regsiter post-script ctx callback\n");
 		return -1;

+ 3 - 3
modules_k/dialog/dlg_handlers.c

@@ -627,7 +627,7 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
 	return 0;
 error:
 	unref_dlg(dlg,1);
-	profile_cleanup(msg, NULL);
+	profile_cleanup(msg, 0, NULL);
 	update_stat(failed_dlgs, 1);
 	return -1;
 }
@@ -969,12 +969,12 @@ void dlg_ontimeout( struct dlg_tl *tl)
 	{
 		dlg_set_ctx_dialog(dlg);
 		fmsg = faked_msg_next();
-		if (exec_pre_req_cb(fmsg)>0)
+		if (exec_pre_script_cb(fmsg, REQUEST_CB_TYPE)>0)
 		{
 			LM_DBG("executing route %d on timeout\n", dlg->toroute);
 			set_route_type(REQUEST_ROUTE);
 			run_top_route(main_rt.rlist[dlg->toroute], fmsg);
-			exec_post_req_cb(fmsg);
+			exec_post_script_cb(fmsg, REQUEST_CB_TYPE);
 		}
 	}
 

+ 2 - 1
modules_k/dialog/dlg_profile.c

@@ -296,10 +296,11 @@ void destroy_linkers(struct dlg_profile_link *linker)
 /*!
  * \brief Cleanup a profile
  * \param msg SIP message
+ * \param flags unused
  * \param unused
  * \return 1
  */
-int profile_cleanup( struct sip_msg *msg, void *param )
+int profile_cleanup( struct sip_msg *msg, unsigned int flags, void *param )
 {
 	current_dlg_msg_id = 0;
 	if (current_dlg_pointer) {

+ 2 - 1
modules_k/dialog/dlg_profile.h

@@ -107,10 +107,11 @@ struct dlg_profile_table* search_dlg_profile(str *name);
 /*!
  * \brief Cleanup a profile
  * \param msg SIP message
+ * \param flags unused
  * \param unused
  * \return 1
  */
-int profile_cleanup( struct sip_msg *msg, void *param );
+int profile_cleanup( struct sip_msg *msg, unsigned int flags, void *param );
 
 
 /*!

+ 1 - 1
modules_k/dialog/dlg_var.c

@@ -26,7 +26,7 @@
 
 dlg_ctx_t _dlg_ctx;
 
-int dlg_cfg_cb(struct sip_msg *foo, void *bar)
+int dlg_cfg_cb(struct sip_msg *foo, unsigned int flags, void *bar)
 {
 	memset(&_dlg_ctx, 0, sizeof(dlg_ctx_t));
 

+ 1 - 1
modules_k/dialog/dlg_var.h

@@ -50,7 +50,7 @@ int pv_get_dlg(struct sip_msg *msg,  pv_param_t *param,
 		pv_value_t *res);
 int pv_parse_dlg_name(pv_spec_p sp, str *in);
 
-int dlg_cfg_cb(struct sip_msg *foo, void *bar);
+int dlg_cfg_cb(struct sip_msg *foo, unsigned int flags, void *bar);
 
 void dlg_set_ctx_dialog(struct dlg_cell *dlg);
 struct dlg_cell* dlg_get_ctx_dialog(void);

+ 3 - 3
modules_k/nat_traversal/nat_traversal.c

@@ -183,7 +183,7 @@ static INLINE char* shm_strdup(char *source);
 
 static int  mod_init(void);
 static void mod_destroy(void);
-static int  preprocess_request(struct sip_msg *msg, void *param);
+static int  preprocess_request(struct sip_msg *msg, unsigned int flags, void *param);
 static int  reply_filter(struct sip_msg *reply);
 
 static int pv_parse_nat_contact_name(pv_spec_p sp, str *in);
@@ -1745,7 +1745,7 @@ mod_init(void)
         }
 
         // register a pre-script callback to automatically enable dialog tracing
-        if (register_script_cb(preprocess_request, PRE_SCRIPT_CB|REQ_TYPE_CB, 0)!=0) {
+        if (register_script_cb(preprocess_request, PRE_SCRIPT_CB|REQUEST_CB, 0)!=0) {
             LM_ERR("could not register request preprocessing callback\n");
             return -1;
         }
@@ -1815,7 +1815,7 @@ mod_destroy(void)
 // during the dialog and it is not renewed.
 //
 static int
-preprocess_request(struct sip_msg *msg, void *_param)
+preprocess_request(struct sip_msg *msg, unsigned int flags, void *_param)
 {
     str totag;
 

+ 1 - 1
modules_k/pua_usrloc/pua_usrloc.c

@@ -182,7 +182,7 @@ static int mod_init(void)
 	pua_send_subscribe= pua.send_subscribe;
 	
 	/* register post-script pua_unset_publish unset function */
-	if(register_script_cb(pua_unset_publish, POST_SCRIPT_CB|REQ_TYPE_CB, 0)<0)
+	if(register_script_cb(pua_unset_publish, POST_SCRIPT_CB|REQUEST_CB, 0)<0)
 	{
 		LM_ERR("failed to register POST request callback\n");
 		return -1;

+ 1 - 1
modules_k/pua_usrloc/pua_usrloc.h

@@ -29,7 +29,7 @@
 extern send_publish_t pua_send_publish;
 extern send_subscribe_t pua_send_subscribe;
 void ul_publish(ucontact_t* c, int type, void* param);
-int pua_unset_publish(struct sip_msg* msg , void* param);
+int pua_unset_publish(struct sip_msg* msg, unsigned int flags, void* param);
 
 extern str pres_prefix;
 #endif

+ 1 - 1
modules_k/pua_usrloc/ul_publish.c

@@ -45,7 +45,7 @@ int pua_set_publish(struct sip_msg* msg , char* s1, char* s2)
 	return 1;
 }
 
-int pua_unset_publish(struct sip_msg* msg , void* param)
+int pua_unset_publish(struct sip_msg* msg, unsigned int flags, void* param)
 {
 	pua_ul_publish= 0;
 	return 1;

+ 2 - 2
modules_k/rtimer/rtimer_mod.c

@@ -188,11 +188,11 @@ void stm_timer_exec(unsigned int ticks, void *param)
 		/* update local parameters */
 		_stm_msg.id=_stm_msg_no++;
 		clear_branches();
-		if (exec_pre_req_cb(&_stm_msg)==0 )
+		if (exec_pre_script_cb(&_stm_msg, REQUEST_CB_TYPE)==0 )
 			continue; /* drop the request */
 		set_route_type(REQUEST_ROUTE);
 		run_top_route(main_rt.rlist[rt->route], &_stm_msg);
-		exec_post_req_cb(&_stm_msg);
+		exec_post_script_cb(&_stm_msg, REQUEST_CB_TYPE);
 	}
 }
 

+ 2 - 1
modules_k/siputils/ring.c

@@ -318,10 +318,11 @@ static int conv183(struct sip_msg *msg)
 /*!
  * \brief Callback function that does the work inside the server.
  * \param msg SIP message
+ * \param flags unused
  * \param bar unused
  * \return 1 on success, -1 on failure
  */
-int ring_filter(struct sip_msg *msg, void *bar)
+int ring_filter(struct sip_msg *msg, unsigned int flags, void *bar)
 {
 	int contains_callid;
 

+ 2 - 1
modules_k/siputils/ring.h

@@ -70,10 +70,11 @@ void ring_destroy_hashtable(void);
 /*!
  * \brief Callback function that does the work inside the server.
  * \param msg SIP message
+ * \param flags unused
  * \param bar unused
  * \return 1 on success, -1 on failure
  */
-int ring_filter(struct sip_msg *msg, void *bar);
+int ring_filter(struct sip_msg *msg, unsigned int flags, void *bar);
 
 
 /*!

+ 1 - 1
modules_k/siputils/siputils.c

@@ -129,7 +129,7 @@ static int mod_init(void)
 			LM_CRIT("cannot initialize lock.\n");
 			return -1;
 		}
-		if (register_script_cb(ring_filter, PRE_SCRIPT_CB|RPL_TYPE_CB, 0) != 0) {
+		if (register_script_cb(ring_filter, PRE_SCRIPT_CB|ONREPLY_CB, 0) != 0) {
 			LM_ERR("could not insert callback");
 			return -1;
 		}

+ 1 - 1
modules_k/sl/sl.c

@@ -166,7 +166,7 @@ static int mod_init(void)
 #endif
 
 	/* filter all ACKs before script */
-	if (register_script_cb(sl_filter_ACK, PRE_SCRIPT_CB|REQ_TYPE_CB, 0 )!=0) {
+	if (register_script_cb(sl_filter_ACK, PRE_SCRIPT_CB|REQUEST_CB, 0 )!=0) {
 		LM_ERR("register_script_cb failed\n");
 		return -1;
 	}

+ 1 - 1
modules_k/sl/sl_funcs.c

@@ -295,7 +295,7 @@ int sl_reply_error(struct sip_msg *msg )
  * Filter ACKs
  * \return 0 for ACKs to a local reply, -1 on error, 1 is not an ACK or a non-local ACK
  */
-int sl_filter_ACK(struct sip_msg *msg, void *bar )
+int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar )
 {
 	str *tag_str;
 

+ 1 - 1
modules_k/sl/sl_funcs.h

@@ -40,7 +40,7 @@ int sl_startup(void);
 int sl_shutdown(void);
 int sl_send_reply( struct sip_msg *msg, int code, str *reason);
 int sl_send_reply_dlg( struct sip_msg *msg, int code, str *reason, str *tag);
-int sl_filter_ACK( struct sip_msg *msg, void *foo );
+int sl_filter_ACK( struct sip_msg *msg, unsigned int flags, void *foo );
 int sl_reply_error( struct sip_msg *msg );
 int sl_get_reply_totag(struct sip_msg *msg, str *totag);
 

+ 2 - 2
modules_s/avp_db/extra_attrs.c

@@ -426,7 +426,7 @@ int extra_attrs_fixup(void** param, int param_no)
 gen_lock_t *locks = NULL; /* set of mutexes allocated in shared memory */
 int lock_counters[LOCK_CNT]; /* set of counters (each proces has its own counters) */
 
-static int avpdb_post_script_cb(struct sip_msg *msg, void *param) {
+static int avpdb_post_script_cb(struct sip_msg *msg, unsigned int flags, void *param) {
 	int i;
 
 	for (i=0; i<LOCK_CNT; i++) {
@@ -468,7 +468,7 @@ int init_extra_avp_locks()
 		t = t->next;
 	}
 
-	register_script_cb(avpdb_post_script_cb, REQ_TYPE_CB | RPL_TYPE_CB| POST_SCRIPT_CB, 0);
+	register_script_cb(avpdb_post_script_cb, REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0);
 
 	return 0;
 }

+ 6 - 6
modules_s/db_ops/db_ops.c

@@ -963,12 +963,12 @@ static int dbops_close_query_func(struct sip_msg* m, char* handle, char* dummy)
 	return 1;
 }
 
-static int dbops_pre_script_cb(struct sip_msg *msg, void *param) {
+static int dbops_pre_script_cb(struct sip_msg *msg, unsigned int flags, void *param) {
 	xlbuf_tail = xlbuf;
 	return 1;
 }
 
-static int dbops_post_script_cb(struct sip_msg *msg, void *param) {
+static int dbops_post_script_cb(struct sip_msg *msg, unsigned int flags, void *param) {
 	struct dbops_handle *a;
 	for (a = dbops_handles; a; a=a->next) {
 		dbops_close_query_func(msg, (char*) a, 0);
@@ -1051,8 +1051,8 @@ static int mod_init(void) {
 			return res;
 	}
 
-	register_script_cb(dbops_pre_script_cb, REQ_TYPE_CB | RPL_TYPE_CB| PRE_SCRIPT_CB, 0);
-	register_script_cb(dbops_post_script_cb, REQ_TYPE_CB | RPL_TYPE_CB| POST_SCRIPT_CB, 0);
+	register_script_cb(dbops_pre_script_cb, REQUEST_CB | ONREPLY_CB | PRE_SCRIPT_CB, 0);
+	register_script_cb(dbops_post_script_cb, REQUEST_CB | ONREPLY_CB | POST_SCRIPT_CB, 0);
 	register_select_table(sel_declaration);
 
 	return 0;
@@ -1492,8 +1492,8 @@ static int declare_handle(modparam_t type, char* param) {
 }
 
 static int dbops_proper_func(struct sip_msg* m, char* dummy1, char* dummy2) {
-	dbops_pre_script_cb(m, NULL);
-	dbops_post_script_cb(m, NULL);
+	dbops_pre_script_cb(m, 0, NULL);
+	dbops_post_script_cb(m, 0, NULL);
 	return 1;
 }
 

+ 2 - 2
modules_s/eval/eval.c

@@ -361,7 +361,7 @@ static int declare_register(modparam_t type, char* param) {
 	return 0;
 }
 
-static int mod_pre_script_cb(struct sip_msg *msg, void *param) {
+static int mod_pre_script_cb(struct sip_msg *msg, unsigned int flags, void *param) {
 	destroy_stack();
 	destroy_register_values();
 	return 1;
@@ -2000,7 +2000,7 @@ select_row_t sel_declaration[] = {
 
 static int mod_init() {
 
-	register_script_cb(mod_pre_script_cb, REQ_TYPE_CB | RPL_TYPE_CB| PRE_SCRIPT_CB, 0);
+	register_script_cb(mod_pre_script_cb, REQUEST_CB | ONREPLY_CB | PRE_SCRIPT_CB, 0);
 	register_select_table(sel_declaration);
 	return 0;
 }

+ 2 - 2
modules_s/iptrtpproxy/iptrtpproxy.c

@@ -728,7 +728,7 @@ select_row_t sel_declaration[] = {
 	{ NULL, SEL_PARAM_INT, STR_NULL, NULL, 0}
 };
 
-static int mod_pre_script_cb(struct sip_msg *msg, void *param) {
+static int mod_pre_script_cb(struct sip_msg *msg, unsigned int flags, void *param) {
 	sdp_ip.s = "";
 	sdp_ip.len = 0;
 	global_session_ids = NULL;
@@ -758,7 +758,7 @@ static int mod_init(void) {
 		xt_RTPPROXY_release_switchboards(&handle, out_switchboard);
 	}
 
-	register_script_cb(mod_pre_script_cb, REQ_TYPE_CB | RPL_TYPE_CB| PRE_SCRIPT_CB, 0);
+	register_script_cb(mod_pre_script_cb, REQUEST_CB | ONREPLY_CB | PRE_SCRIPT_CB, 0);
 	register_select_table(sel_declaration);
 	return 0;
 err:

+ 1 - 1
modules_s/sl/sl.c

@@ -130,7 +130,7 @@ static int mod_init(void)
 	}
 
 	     /* if SL loaded, filter ACKs on beginning */
-	if (register_script_cb( sl_filter_ACK, PRE_SCRIPT_CB|REQ_TYPE_CB, 0 )<0) {
+	if (register_script_cb( sl_filter_ACK, PRE_SCRIPT_CB|REQUEST_CB, 0 )<0) {
 		ERR("Failed to install SCRIPT callback\n");
 		return -1;
 	}

+ 1 - 1
modules_s/sl/sl_funcs.c

@@ -213,7 +213,7 @@ int sl_reply_error(struct sip_msg *msg )
     -1 : error
     1  : is not an ACK  or a non-local ACK
 */
-int sl_filter_ACK(struct sip_msg *msg, void *bar )
+int sl_filter_ACK(struct sip_msg *msg, unsigned int flags, void *bar )
 {
 	str *tag_str;
 

+ 1 - 1
modules_s/sl/sl_funcs.h

@@ -42,7 +42,7 @@ int sl_shutdown();
 typedef int (*sl_send_reply_f)(struct sip_msg* msg, int code, char* reason);
 int sl_send_reply(struct sip_msg* msg, int code, char* reason);
 
-int sl_filter_ACK(struct sip_msg*, void *bar );
+int sl_filter_ACK(struct sip_msg*, unsigned int flags, void *bar );
 int sl_reply_error(struct sip_msg *msg );
 
 

+ 2 - 2
modules_s/timer/timer.c

@@ -184,7 +184,7 @@ static ticks_t timer_handler(ticks_t ticks, struct timer_ln* tl, void* data) {
 		/* ... clear branches from previous message */
 		clear_branches();
 		reset_static_buffer();
-		if (exec_pre_req_cb(msg)==0 )
+		if (exec_pre_script_cb(msg, REQUEST_CB_TYPE)==0 )
 			goto end; /* drop the request */
 		/* exec the routing script */
 		timer_executed = a;
@@ -192,7 +192,7 @@ static ticks_t timer_handler(ticks_t ticks, struct timer_ln* tl, void* data) {
 		run_actions(&ra_ctx, main_rt.rlist[a->route_no], msg);
 		timer_executed = 0;
 		/* execute post request-script callbacks */
-		exec_post_req_cb(msg);
+		exec_post_script_cb(msg, REQUEST_CB_TYPE);
 	end:
 		reset_avps();
 		DEBUG(MODULE_NAME": handler: cleaning up\n");

+ 3 - 3
modules_s/xmlrpc/xmlrpc.c

@@ -58,7 +58,7 @@
 #include "../sl/sl.h"
 #include "../../nonsip_hooks.h"
 #include "../../action.h" /* run_actions */
-#include "../../script_cb.h" /* exec_*_req_cb */
+#include "../../script_cb.h" /* exec_*_script_cb */
 #include "../../route.h" /* route_get */
 #include "http.h"
 
@@ -1742,7 +1742,7 @@ static int em_receive_request(sip_msg_t* orig_msg,
 		BUG("xmlrpc: strange message: %.*s\n", msg->len, msg->buf);
 		goto error;
 	}
-	if (exec_pre_req_cb(msg) == 0) {
+	if (exec_pre_script_cb(msg, REQUEST_CB_TYPE) == 0) {
 		goto end; /* drop request */
 	}
 	/* exec routing script */
@@ -1752,7 +1752,7 @@ static int em_receive_request(sip_msg_t* orig_msg,
 		goto end;
 	}
  end:
-	exec_post_req_cb(msg); /* needed for example if tm is used */
+	exec_post_script_cb(msg, REQUEST_CB_TYPE); /* needed for example if tm is used */
 	/* reset_avps(); non needed, performed by the real receive_msg */
 	if (msg != orig_msg) { /* avoid double free (freed from receive_msg
 							  too) */

+ 6 - 6
receive.c

@@ -164,7 +164,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		   (like presence of at least one via), so you can count
 		   on via1 being parsed in a pre-script callback --andrei
 		*/
-		if (exec_pre_req_cb(msg)==0 )
+		if (exec_pre_script_cb(msg, REQUEST_CB_TYPE)==0 )
 			goto end; /* drop the request */
 
 		set_route_type(REQUEST_ROUTE);
@@ -185,7 +185,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 #endif
 
 		/* execute post request-script callbacks */
-		exec_post_req_cb(msg);
+		exec_post_script_cb(msg, REQUEST_CB_TYPE);
 	}else if (msg->first_line.type==SIP_REPLY){
 		/* sanity checks */
 		if ((msg->via1==0) || (msg->via1->error!=PARSE_OK)){
@@ -206,7 +206,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 		   (like presence of at least one via), so you can count
 		   on via1 being parsed in a pre-script callback --andrei
 		*/
-		if (exec_pre_rpl_cb(msg)==0 )
+		if (exec_pre_script_cb(msg, ONREPLY_CB_TYPE)==0 )
 			goto end; /* drop the request */
 
 		/* exec the onreply routing script */
@@ -232,7 +232,7 @@ int receive_msg(char* buf, unsigned int len, struct receive_info* rcv_info)
 #endif
 
 		/* execute post reply-script callbacks */
-		exec_post_rpl_cb(msg);
+		exec_post_script_cb(msg, ONREPLY_CB_TYPE);
 	}
 
 end:
@@ -250,13 +250,13 @@ end:
 	return 0;
 error_rpl:
 	/* execute post reply-script callbacks */
-	exec_post_rpl_cb(msg);
+	exec_post_script_cb(msg, ONREPLY_CB_TYPE);
 	reset_avps();
 	goto error02;
 error_req:
 	DBG("receive_msg: error:...\n");
 	/* execute post request-script callbacks */
-	exec_post_req_cb(msg);
+	exec_post_script_cb(msg, REQUEST_CB_TYPE);
 	/* free possible loaded avps -bogdan */
 	reset_avps();
 error02: