AVP radius kamailio

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
static int generate_avps_rad(VALUE_PAIR* received)
{
int_str name, val;
unsigned short flags;
VALUE_PAIR *vp;
vp = received;
for( ; vp ; vp=vp->next) {
flags = AVP_NAME_STR;
switch(vp->type)
{
case PW_TYPE_STRING:
flags |= AVP_VAL_STR;
name.s.len = strlen(vp->name);
val.s.len = strlen(vp->strvalue);
name.s.s = vp->name;
val.s.s = vp->strvalue;
if (add_avp( flags, name, val ) < 0) {
LM_ERR("unable to create a new AVP\n");
} else {
LM_DBG("AVP '%.*s'/%d='%.*s'/%d has been added\n",
(flags&AVP_NAME_STR)?name.s.len:4,
(flags&AVP_NAME_STR)?name.s.s:"null",
(flags&AVP_NAME_STR)?0:name.n,
(flags&AVP_VAL_STR)?val.s.len:4,
(flags&AVP_VAL_STR)?val.s.s:"null",
(flags&AVP_VAL_STR)?0:val.n );
}
continue;
case PW_TYPE_INTEGER:
name.s.len = strlen(vp->name);
name.s.s = vp->name;
val.n = vp->lvalue;
if (add_avp( flags, name, val ) < 0) {
LM_ERR("unable to create a new AVP\n");
} else {
LM_DBG("AVP '%.*s'/%d='%.*s'/%d has been added\n",
(flags&AVP_NAME_STR)?name.s.len:4,
(flags&AVP_NAME_STR)?name.s.s:"null",
(flags&AVP_NAME_STR)?0:name.n,
(flags&AVP_VAL_STR)?val.s.len:4,
(flags&AVP_VAL_STR)?val.s.s:"null",
(flags&AVP_VAL_STR)?0:val.n );
}
continue;
default:
LM_ERR("skip attribute type %d (non-string)", vp->type);
continue;
}
return;
}
}