Thank you Daniel and Morten for your assistance and prompt reply.
To use the tobody transformation, i see that i would need to upgrade to 4.1
right? Im currently on 3.3.
I tried the below code:
$var(i)=0;
while($(hdr(Diversion)[$var(i)]) != $null ) {
$avp(s:divhdr) =
$(hdr(Diversion)[$var(i)]);
avp_subst("$avp(s:divhdr)",
"/.*sip:(.*)(@.*)/\1/");
xlog("L_WARN", "$avp(s:divhdr)");
if (!is_user_in("$avp(s:divhdr)",
"7")) {
sl_send_reply("403", "NOT ALLOWED");
exit;
};
$var(i) = $var(i) +1;
}
However, it seems like group module cant parse the output 313 as seen below:
Apr 10 13:16:43 SipProxy-Test /usr/local/sbin/kamailio[7471]: WARNING:
<script>: 313
Apr 10 13:16:43 SipProxy-Test /usr/local/sbin/kamailio[7471]: ERROR: group
[group.c:114]: failed to parse URI <313>
Apr 10 13:16:43 SipProxy-Test /usr/local/sbin/kamailio[7471]: ERROR: group
[group.c:158]: failed to get username@domain
A bigger issue is that a certain client is sending more than one diversion
header with different format as seen below:
Diversion: <tel:22030009>;reason=no-answer;screen=no;privacy=off
Diversion: "Solonas A" <sip:16@10.10.10.22>;reason=unconditional
So in this case i cant really know how to extract the diversion number
using a static substitution. Is there a way to adapt to different formats
to extract the diversion number?
Thanking you in advance
Phillip
Date: Tue, 09 Apr 2013 16:43:56 +0200
From: Daniel-Constantin Mierla <miconda(a)gmail.com>
Subject: Re: [SR-Users] Diversion header authentication
To: "Kamailio (SER) - Users Mailing List"
<sr-users(a)lists.sip-router.org>
Message-ID: <5164292C.4080408(a)gmail.com>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
Hello,
just adding that the tobody transformation could be handy to extract the
user or uri part of a Diversion header, not to fight with subst expressions:
-
http://www.kamailio.org/wiki/cookbooks/devel/transformations#to-body_transf…
Cheers,
Daniel
On 4/9/13 3:16 PM, Morten Isaksen wrote:
Hi,
I have not tested this, but try:
$avp(s:divhdr) = $(hdr(Diversion)[$var(i)]);
avp_subst("$avp(s:divhdr)", "/.*sip:\+45(.*)(@.*)/\1/"); # Extract
number between +45 and @
if (is_user_in("$avp(s:divhdr)", "1") { ... }
Please note that there can be more than one Diverseion header. In that
case you can use:
$var(i)=0;
while($(hdr(Diversion)[$var(i)]) != $null ) {
$avp(s:divhdr) =
$(hdr(Diversion)[$var(i)]);
xlog("L_WARN", "$avp(s:divhdr)");
$var(i) = $var(i) +1;
}
/Morten