Good day!
Now I test new style AVP's for radius response storing. Today additional radius responses return in special radpair:
SIP-AVP - name, string "email:sr-users@lists.sip-router.org session-timeout#161 nexthopip:h323/0001111@myvoip-gate.kamailio.org" - value.
I don't know why developers chose this way. But it's addition kamailio's feature, so let it be. But if radius server responded with standard pairs?
Sending Access-Accept of id 60 to 172.16.X.X port 59736 Session-Timeout = 4261674 next-hop-ip = "SIP/00111222333444@cisco-out" SIP-AVP = "email:sr-users@lists.sip-router.org session-timeout#161 next-hop-ip:h323/0001111@myvoip-gate.kamailio.org" session-protocol = "SIP"
No chance to get full radius response at this moment. Only parse SIP-AVP pair. This mean that when you wanna integrate K. in existing infrastructure (in my case - billing), u need work with K. and radius. But why, if you already had worked voip devices?
I think more flexible solution ADD in misc_radius function to get radpairs as AVP's. See that i got: misc_radius [functions.c:159]: AVP 'Session-Timeout'/0='null'/4261674 has been added misc_radius [functions.c:143]: AVP 'next-hop-ip'/0='SIP/005555777888@cisco-out'/0 has been added misc_radius [functions.c:143]: AVP 'session-protocol'/0='SIP'/0 has been added
After radius response i get: $avp(Session-Timeout)=4261674 (integer) $avp(next-hop-ip)="SIP/005555777888@cisco-out" (string) $avp(session-protocol)="SIP" (string)
I think its usable and more flexible.
I see 3 way to integrate it: 1. additionally with existing radius_load_caller_avps/radius_load_callee_avps (i make same for test) 2. new function in same module, like radius_authorize_request (caller,callee). 3. replace existing style. it's bad for backward compability, of cause.
Or it stay my local patch :)
If it really needed and usable i may made any (1..3) way with doc and examples :)
diff --git a/modules/misc_radius/functions.c b/modules/misc_radius/functions.c index 2a42024..f156939 100644 --- a/modules/misc_radius/functions.c +++ b/modules/misc_radius/functions.c @@ -107,6 +107,60 @@ error: return -1; }
+static void 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; + } +} +
/* Generate AVPs from Radius reply items */ static void generate_avps(struct attr *attrs, VALUE_PAIR* received) @@ -212,6 +266,7 @@ int radius_load_caller_avps(struct sip_msg* _m, char* _caller, char* _s2) LM_DBG("success\n"); rc_avpair_free(send); generate_avps(caller_attrs, received); + generate_avps_rad(received); rc_avpair_free(received); return 1; } else {
-- WBR, Victor JID: coyote@bks.tv JID: coyote@bryansktel.ru I use FREE operation system: 3.8.4-calculate GNU/Linux
Hello,
can you make the behavior configurable via module parameter? The patch does not seem to be that intrusive, by just making this option configurable would be no reason to not accept it, the old style can still be used. As said previously, I am not using radius myself, just looked at the patch.
Cheers, Daniel
On 5/6/13 3:09 PM, Victor V. Kustov wrote:
Good day!
Now I test new style AVP's for radius response storing. Today additional radius responses return in special radpair:
SIP-AVP - name, string "email:sr-users@lists.sip-router.org session-timeout#161 nexthopip:h323/0001111@myvoip-gate.kamailio.org" - value.
I don't know why developers chose this way. But it's addition kamailio's feature, so let it be. But if radius server responded with standard pairs?
Sending Access-Accept of id 60 to 172.16.X.X port 59736 Session-Timeout = 4261674 next-hop-ip = "SIP/00111222333444@cisco-out" SIP-AVP = "email:sr-users@lists.sip-router.org session-timeout#161 next-hop-ip:h323/0001111@myvoip-gate.kamailio.org" session-protocol = "SIP"
No chance to get full radius response at this moment. Only parse SIP-AVP pair. This mean that when you wanna integrate K. in existing infrastructure (in my case - billing), u need work with K. and radius. But why, if you already had worked voip devices?
I think more flexible solution ADD in misc_radius function to get radpairs as AVP's. See that i got: misc_radius [functions.c:159]: AVP 'Session-Timeout'/0='null'/4261674 has been added misc_radius [functions.c:143]: AVP 'next-hop-ip'/0='SIP/005555777888@cisco-out'/0 has been added misc_radius [functions.c:143]: AVP 'session-protocol'/0='SIP'/0 has been added
After radius response i get: $avp(Session-Timeout)=4261674 (integer) $avp(next-hop-ip)="SIP/005555777888@cisco-out" (string) $avp(session-protocol)="SIP" (string)
I think its usable and more flexible.
I see 3 way to integrate it:
- additionally with existing radius_load_caller_avps/radius_load_callee_avps (i make same for test)
- new function in same module, like radius_authorize_request (caller,callee).
- replace existing style. it's bad for backward compability, of cause.
Or it stay my local patch :)
If it really needed and usable i may made any (1..3) way with doc and examples :)
diff --git a/modules/misc_radius/functions.c b/modules/misc_radius/functions.c index 2a42024..f156939 100644 --- a/modules/misc_radius/functions.c +++ b/modules/misc_radius/functions.c @@ -107,6 +107,60 @@ error: return -1; }
+static void 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;
- }
+}
/* Generate AVPs from Radius reply items */ static void generate_avps(struct attr *attrs, VALUE_PAIR* received)
@@ -212,6 +266,7 @@ int radius_load_caller_avps(struct sip_msg* _m, char* _caller, char* _s2) LM_DBG("success\n"); rc_avpair_free(send); generate_avps(caller_attrs, received);
generate_avps_rad(received); rc_avpair_free(received); return 1; } else {
-- WBR, Victor JID: coyote@bks.tv JID: coyote@bryansktel.ru I use FREE operation system: 3.8.4-calculate GNU/Linux
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On 5/8/13 10:14 AM, Victor V. Kustov wrote:
Hello, Daniel-Constantin!
Hello,
can you make the behavior configurable via module parameter?
I think yes, with documentation, it took some days.
ok, attach the patch as a file on the mailing list or bug tracker, don't paste it inline because it is not easy to apply.
Cheers, Daniel
Hello, Daniel-Constantin!
I think yes, with documentation, it took some days.
ok, attach the patch as a file on the mailing list or bug tracker,
ready, attached
don't paste it inline because it is not easy to apply.
I think need documentation patch too.
what we get:
modparam("misc_radius", "common_response", 1) // default is 0
when common_response is 0 (default) load_caller_avps and load_callee_avps work as before: look SIP-AVP in response and parse result for avp's.
when common_response is 1 (set in config) load_caller_avps and load_callee_avps parse radius server response and all avpairs save in avp.
integer and string values are parsed, other - skipped. examples that i posted before are ok.
-- WBR, Victor JID: coyote@bks.tv JID: coyote@bryansktel.ru I use FREE operation system: 3.8.4-calculate GNU/Linux
Hello,
I just applied it along with a new one for the readme and docbook files.
Don't forget to update the documentation located in doc/ subfolder of the module when you send a patch that adds a module parameter or function for config file. This time I did it.
Cheers, Daniel
On 5/10/13 10:26 AM, Victor V. Kustov wrote:
Hello, Daniel-Constantin!
I think yes, with documentation, it took some days.
ok, attach the patch as a file on the mailing list or bug tracker,
ready, attached
don't paste it inline because it is not easy to apply.
I think need documentation patch too.
what we get:
modparam("misc_radius", "common_response", 1) // default is 0
when common_response is 0 (default) load_caller_avps and load_callee_avps work as before: look SIP-AVP in response and parse result for avp's.
when common_response is 1 (set in config) load_caller_avps and load_callee_avps parse radius server response and all avpairs save in avp.
integer and string values are parsed, other - skipped. examples that i posted before are ok.
-- WBR, Victor JID: coyote@bks.tv JID: coyote@bryansktel.ru I use FREE operation system: 3.8.4-calculate GNU/Linux
Hello, Daniel-Constantin!
Don't forget to update the documentation located in doc/ subfolder of the module when you send a patch that adds a module parameter or function for config file. This time I did it.
OK, thank you. I think need example and more detailed description. See attach, but i think need corrections.
-- WBR, Victor JID: coyote@bks.tv JID: coyote@bryansktel.ru I use FREE operation system: 3.8.4-calculate GNU/Linux