Module: kamailio
Branch: master
Commit: 2a9b4da18eac72f09e8b69cf447afeb978842ae1
URL:
https://github.com/kamailio/kamailio/commit/2a9b4da18eac72f09e8b69cf447afeb…
Author: Emmanuel BUU <emmanuel.buu(a)ives.fr>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-02-03T21:56:30+01:00
siputils: exported $pcv(name) var and sip_p_charing_vector() func
- based on GH #215
- $pcv(all) = whole field
- $pcv(value) = icid-value field (see RFC3455 section 5.6)
- $pcv(genaddr) = icid-generated-at field (see RFC3455 section 5.6)
---
Modified: modules/siputils/chargingvector.c
Modified: modules/siputils/chargingvector.h
Modified: modules/siputils/siputils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/2a9b4da18eac72f09e8b69cf447afeb…
Patch:
https://github.com/kamailio/kamailio/commit/2a9b4da18eac72f09e8b69cf447afeb…
---
diff --git a/modules/siputils/chargingvector.c b/modules/siputils/chargingvector.c
index 4380b8c..5133054 100644
--- a/modules/siputils/chargingvector.c
+++ b/modules/siputils/chargingvector.c
@@ -454,3 +454,38 @@ int pv_get_charging_vector(struct sip_msg *msg, pv_param_t *param,
pv_value_t *r
return pv_get_null(msg, param, res);
}
+
+int pv_parse_charging_vector_name(pv_spec_p sp, str *in)
+{
+ if(sp==NULL || in==NULL || in->len<=0)
+ return -1;
+
+ switch(in->len)
+ {
+ case 3:
+ if(strncmp(in->s, "all", 3)==0)
+ sp->pvp.pvn.u.isname.name.n = 1;
+ else goto error;
+ break;
+ case 5:
+ if(strncmp(in->s, "value", 5)==0)
+ sp->pvp.pvn.u.isname.name.n = 3;
+ else goto error;
+ break;
+ case 7:
+ if(strncmp(in->s, "genaddr", 7)==0)
+ sp->pvp.pvn.u.isname.name.n = 2;
+ else goto error;
+ break;
+ default:
+ goto error;
+ }
+ sp->pvp.pvn.type = PV_NAME_INTSTR;
+ sp->pvp.pvn.u.isname.type = 0;
+
+ return 0;
+
+error:
+ LM_ERR("unknown pcv name %.*s\n", in->len, in->s);
+ return -1;
+}
diff --git a/modules/siputils/chargingvector.h b/modules/siputils/chargingvector.h
index 8bfaf57..d2c027f 100644
--- a/modules/siputils/chargingvector.h
+++ b/modules/siputils/chargingvector.h
@@ -42,4 +42,5 @@
int sip_handle_pcv(sip_msg_t *msg, char *flags, char *str2);
int pv_get_charging_vector(sip_msg_t *msg, pv_param_t *param, pv_value_t *res);
+int pv_parse_charging_vector_name(pv_spec_p sp, str *in);
#endif
diff --git a/modules/siputils/siputils.c b/modules/siputils/siputils.c
index b6358ad..08692f3 100644
--- a/modules/siputils/siputils.c
+++ b/modules/siputils/siputils.c
@@ -77,6 +77,7 @@
#include "contact_ops.h"
#include "sipops.h"
#include "config.h"
+#include "chargingvector.h"
MODULE_VERSION
@@ -177,6 +178,8 @@ static cmd_export_t cmds[]={
0, ANY_ROUTE},
{"is_numeric", (cmd_function)is_numeric, 1, fixup_spve_null,
0, ANY_ROUTE},
+ {"sip_p_charging_vector", (cmd_function)sip_handle_pcv, 1, fixup_spve_null,
+ fixup_free_spve_null, ANY_ROUTE},
{0,0,0,0,0,0}
};
@@ -194,6 +197,13 @@ static param_export_t params[] = {
};
+ static pv_export_t mod_pvs[] = {
+ { {"pcv", (sizeof("pvc")-1)}, PVT_OTHER, pv_get_charging_vector,
+ 0, pv_parse_charging_vector_name, 0, 0, 0},
+
+ { {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
+};
+
struct module_exports exports= {
"siputils",
DEFAULT_DLFLAGS, /* dlopen flags */
@@ -201,7 +211,7 @@ struct module_exports exports= {
params, /* param exports */
0, /* exported statistics */
0, /* exported MI functions */
- 0, /* exported pseudo-variables */
+ mod_pvs, /* exported pseudo-variables */
0, /* extra processes */
mod_init, /* initialization function */
0, /* Response function */