Hey all;
I am trying to remote registration between Kamailio and Asterisk. I
tried remote Registration with UAC module. But this module doesn't work
online. So that i wrote my remote registration code, is below. But there
is a little problem that i cant take Authentication header to
onfailure_route so that cannot forward Auth to client. it is working
well with uac_auth but gets this error (" run_failure_handlers(): ERROR:
run_failure_handlers: Error in run_top_route ") so cannot trust this
function.
How can i get Auth header to add
Thanks for helps.
My Code:
route[REMOTEREG]{
xlog("L_INFO","Remote Reg: $fd : $rm : $fU : $si : ");
sql_xquery("ca","CALL kamailio.route_3xx( '$fd',
'$rm'); ","ra");
xlog("L_INFO","Remote Reg:ip_addr:$xavp(ra=>ip_addr):
\n");
if($xavp(ra=>ip_addr)!=$null){
$avp(ipmiz)=$xavp(ra=>ip_addr);
xlog("L_INFO","pump
it:$rU:$avp(ipmiz):$ru:$rd");
$ru="sip:"+$fU+"@"+$avp(ipmiz);
xlog("L_INFO","pump it
:new::$avp(ipmiz)");
t_on_failure("REMOTE_AUTH");
t_on_reply("REGISTER_SUC");
if(!t_relay()){
t_reply("408", "have a
problem");
exit;
}
exit;
}
return;
}
failure_route[REMOTE_AUTH]{
xlog("L_INFO","REMOTE_AUTH:$fU:$si$rm:$ci:$adu:ar:$ar");
if ($T_reply_code == 401 or $T_reply_code == 407) {
xlog("L_NOTICE", "Remote asked for authentication
");
#uac_auth();
## need to add Authentication header.
append_to_reply("Allow:$hdr(Allow) \r\n");
t_reply("$T_reply_code","Unauthorized");
}
}
onreply_route[REGISTER_SUC]{
xlog("L_INFO","REGISTER_SUC");
if(t_check_status("200")){
if (!save("location"))
{
xlog("L_NOTICE", "Register yapilamadi");
}
exit;
}
}
Request-Line: REGISTER sip:K1;transport=UDP SIP/2.0
Message Header
Via: SIP/2.0/UDP
U1:61185;branch=z9hG4bK-d8754z-597229c1c2842862-1---d8754z-;rport
Max-Forwards: 70
Contact:
<sip:At1@U1:61185;rinstance=0e0e0d00e8aa79f1;transport=UDP>
To: "At1"<sip:At1@K1;transport=UDP>
From: "At1"<sip:At1@K1;transport=UDP>;tag=cc6f1214
Call-ID: MjYwOGQ0MTRmZTEwMzcxNDc2YjBhM2FlYTU3MjU5OWE.
CSeq: 1 REGISTER
Expires: 3600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer,
X-cisco-serviceuri
User-Agent: Z 3.0.19632 r19608
Allow-Events: presence, kpml
Content-Length: 0
Request-Line: REGISTER sip:At1@UAS1 SIP/2.0
Message Header
Via: SIP/2.0/UDP
K1;branch=z9hG4bKc19c.d20e7767bea000b39f25e178c4831a2b.0
Via: SIP/2.0/UDP
U1:61185;branch=z9hG4bK-d8754z-597229c1c2842862-1---d8754z-;rport=61185
Max-Forwards: 70
Contact:
<sip:At1@U1:61185;rinstance=0e0e0d00e8aa79f1;transport=UDP>
To: "At1"<sip:At1@K1;transport=UDP>
From: "At1"<sip:At1@K1;transport=UDP>;tag=cc6f1214
Call-ID: MjYwOGQ0MTRmZTEwMzcxNDc2YjBhM2FlYTU3MjU5OWE.
CSeq: 1 REGISTER
Expires: 3600
Allow: INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
OPTIONS, INFO, SUBSCRIBE
Supported: replaces, norefersub, extended-refer, timer,
X-cisco-serviceuri
User-Agent: Z 3.0.19632 r19608
Allow-Events: presence, kpml
Content-Length: 0
Message Header
Via: SIP/2.0/UDP
K1;branch=z9hG4bKc19c.d20e7767bea000b39f25e178c4831a2b.0;received=K1;rport=5060
Via: SIP/2.0/UDP
U1:61185;branch=z9hG4bK-d8754z-597229c1c2842862-1---d8754z-;rport=61185
From: "At1"<sip:At1@K1;transport=UDP>;tag=cc6f1214
To: "At1"<sip:At1@K1;transport=UDP>;tag=as63346477
Call-ID: MjYwOGQ0MTRmZTEwMzcxNDc2YjBhM2FlYTU3MjU5OWE.
CSeq: 1 REGISTER
Server: Thirdlane2
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE,
NOTIFY, INFO, PUBLISH
Supported: replaces, timer
WWW-Authenticate: Digest algorithm=MD5, realm="aaaa",
nonce="1b23af8f"
Content-Length: 0
Status-Line: SIP/2.0 401 Unauthorized
Message Header
Via: SIP/2.0/UDP
U1:61185;branch=z9hG4bK-d8754z-597229c1c2842862-1---d8754z-;rport=61185
To:
"At1"<sip:At1@K1;transport=UDP>;tag=a98c7436060b0c2b493a17bc0f200923-ed9e
From: "At1"<sip:At1@K1;transport=UDP>;tag=cc6f1214
Call-ID: MjYwOGQ0MTRmZTEwMzcxNDc2YjBhM2FlYTU3MjU5OWE.
CSeq: 1 REGISTER
Allow:INVITE, ACK, CANCEL, BYE, NOTIFY, REFER, MESSAGE,
OPTIONS, INFO, SUBSCRIBE
Server: NetGSM
Content-Length: 0