Skip to content

Commit

Permalink
siputils: exported $pcv(name) var and sip_p_charing_vector() func
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
neutrino38 authored and miconda committed Feb 3, 2016
1 parent ede4a83 commit 2a9b4da
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 1 deletion.
35 changes: 35 additions & 0 deletions modules/siputils/chargingvector.c
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions modules/siputils/chargingvector.h
Expand Up @@ -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
12 changes: 11 additions & 1 deletion modules/siputils/siputils.c
Expand Up @@ -77,6 +77,7 @@
#include "contact_ops.h"
#include "sipops.h"
#include "config.h"
#include "chargingvector.h"

MODULE_VERSION

Expand Down Expand Up @@ -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}
};

Expand All @@ -194,14 +197,21 @@ 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 */
cmds, /* Exported functions */
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 */
Expand Down

0 comments on commit 2a9b4da

Please sign in to comment.