[sr-dev] git:master: dispatcher: new parameter to specify the pv where to store attrs for matched address in ds_is_from_list ()

Daniel-Constantin Mierla miconda at gmail.com
Thu Jul 11 16:27:03 CEST 2013


Module: sip-router
Branch: master
Commit: 09a7a4cd718c0e26d3a948515ec4f6f6a68c64c4
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=09a7a4cd718c0e26d3a948515ec4f6f6a68c64c4

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Thu Jul 11 16:25:06 2013 +0200

dispatcher: new parameter to specify the pv where to store attrs for matched address in ds_is_from_list()

- attrs_pvname can be set to get attributes of matched address in
  config file

---

 modules/dispatcher/dispatch.c   |   12 ++++++++++++
 modules/dispatcher/dispatch.h   |    2 ++
 modules/dispatcher/dispatcher.c |   16 ++++++++++++++++
 3 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c
index 0f6e8b0..2783675 100644
--- a/modules/dispatcher/dispatch.c
+++ b/modules/dispatcher/dispatch.c
@@ -2244,6 +2244,18 @@ int ds_is_from_list(struct sip_msg *_m, int group)
 							return -2;
 						}
 					}
+					if(ds_attrs_pvname.s!=0 && list->dlist[j].attrs.body.len>0)
+					{
+						memset(&val, 0, sizeof(pv_value_t));
+						val.flags = PV_VAL_STR;
+						val.rs = list->dlist[j].attrs.body;
+						if(ds_attrs_pv.setf(_m, &ds_attrs_pv.pvp,
+									(int)EQ_T, &val)<0)
+						{
+							LM_ERR("setting attrs pv failed\n");
+							return -3;
+						}
+					}
 					return 1;
 				}
 			}
diff --git a/modules/dispatcher/dispatch.h b/modules/dispatcher/dispatch.h
index db055ee..912a3e0 100644
--- a/modules/dispatcher/dispatch.h
+++ b/modules/dispatcher/dispatch.h
@@ -87,6 +87,8 @@ extern pv_elem_t * hash_param_model;
 
 extern str ds_setid_pvname;
 extern pv_spec_t ds_setid_pv;
+extern str ds_attrs_pvname;
+extern pv_spec_t ds_attrs_pv;
 
 /* Structure containing pointers to TM-functions */
 extern struct tm_binds tmb;
diff --git a/modules/dispatcher/dispatcher.c b/modules/dispatcher/dispatcher.c
index cf79d90..4af6757 100644
--- a/modules/dispatcher/dispatcher.c
+++ b/modules/dispatcher/dispatcher.c
@@ -136,6 +136,8 @@ str ds_table_name        = str_init(DS_TABLE_NAME);
 
 str ds_setid_pvname   = {NULL, 0};
 pv_spec_t ds_setid_pv;
+str ds_attrs_pvname   = {NULL, 0};
+pv_spec_t ds_attrs_pv;
 
 /** module functions */
 static int mod_init(void);
@@ -211,6 +213,7 @@ static param_export_t params[]={
 	{"attrs_avp",       STR_PARAM, &attrs_avp_param.s},
 	{"hash_pvar",       STR_PARAM, &hash_pvar_param.s},
 	{"setid_pvname",    STR_PARAM, &ds_setid_pvname.s},
+	{"attrs_pvname",    STR_PARAM, &ds_attrs_pvname.s},
 	{"ds_probing_threshhold", INT_PARAM, &probing_threshhold},
 	{"ds_ping_method",     STR_PARAM, &ds_ping_method.s},
 	{"ds_ping_from",       STR_PARAM, &ds_ping_from.s},
@@ -282,6 +285,8 @@ static int mod_init(void)
 		hash_pvar_param.len = strlen(hash_pvar_param.s);
 	if (ds_setid_pvname.s)
 		ds_setid_pvname.len = strlen(ds_setid_pvname.s);
+	if (ds_attrs_pvname.s)
+		ds_attrs_pvname.len = strlen(ds_attrs_pvname.s);
 	if (ds_ping_from.s) ds_ping_from.len = strlen(ds_ping_from.s);
 	if (ds_ping_method.s) ds_ping_method.len = strlen(ds_ping_method.s);
 	if (ds_outbound_proxy.s) ds_outbound_proxy.len = strlen(ds_outbound_proxy.s);
@@ -462,6 +467,17 @@ static int mod_init(void)
 			return -1;
 		}
 	}
+
+	if(ds_attrs_pvname.s!=0)
+	{
+		if(pv_parse_spec(&ds_attrs_pvname, &ds_attrs_pv)==NULL
+				|| !pv_is_w(&ds_attrs_pv))
+		{
+			LM_ERR("[%s]- invalid attrs_pvname\n", ds_attrs_pvname.s);
+			return -1;
+		}
+	}
+
 	if (dstid_avp_param.s && dstid_avp_param.len > 0)
 	{
 		if(ds_hash_size>0)




More information about the sr-dev mailing list