Hello
Here is the most important part of my configuration.
What could be creating the loops? My t_relay is in the ENUM lookup...
but It should work this way.
Do I need t_relay in route[2] after forwarding to the PSTN gateway?
Thanks
Joao Pereira
route{
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
};
if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
exit;
};
# --------------------------------------------------
# PRESENCE Section
# --------------------------------------------------
if (has_totag()) {
log(3, "LOG - has_totag \n");
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the
transaction fails
}
route(1);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(6);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful
ACK; must be an A
t_relay();
exit;
} else {
# ACK without matching
transaction ... ignore and
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
if( is_method("PUBLISH|SUBSCRIBE"))
route(6);
if (!method=="REGISTER")
record_route();
if (loose_route()) {
# mark routing logic in request
append_hf("P-hint: rr-enforced\r\n");
route(1);
};
# --------------------------------------------------
# OPTIONS Section
# --------------------------------------------------
if (method=="OPTIONS") {
options_reply();
return;
};
if (!uri==myself) {
append_hf("P-hint: outbound\r\n");
route(1);
};
# --------------------------------------------------
# Users Registration
# --------------------------------------------------
# if the request is for other domain use UsrLoc
# (in case, it does not work, use the following command
# with proper names and addresses in it)
if (uri==myself) {
if (method=="REGISTER") {
# Uncomment this if you want to use digest
authentication
if (!www_authorize("mydomain.pt",
"subscriber")) {
www_challenge("mydomain.pt", "0");
exit;
};
save("location");
exit;
};
# --------------------------------------------------
# Call Routing Section
# --------------------------------------------------
if (!lookup("location")) {
if (is_method("INVITE")) {
log(3, "LOG: CALL ROUTING - method = invite\n");
# ENUM
if ( method=="INVITE" &&
uri=~"sip:\+[1-9][0-9]*@mydomain.pt") {
if(!enum_query("e164.org.")) {
log(1, "LOG: ENUM: failed!!! :( \n");
}else{
log(1, "LOG: ENUM: query exists!!! :) \n");
if (!method=="REGISTER") record_route();
t_relay();
return;
}
}
# Route E.164 numbers to PSTN Gateway
if (uri=~"sip:\+[1-9][0-9]*@mydomain.pt" ) {
if (isflagset(29)){
# gateway 1
route(2);
return;
} else{
#gateway 2
route(3);
return;
}
}
}
}
route(1);
}
route[1] {
xlog("LOG: route 1 $ru/$du\n");
if (check_route_param("nat=yes")) {
setbflag(6);
}
if (isflagset(5) || isbflagset(6)) {
route(5);
}
t_on_reply("1");
# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
if (!t_relay()) {
sl_reply_error();
};
exit;
}
# PSTN Gateway
route[2]
{
log(3, "LOG: route 2 \n");
if (check_route_param("nat=yes")) {
setbflag(6);
}
if (isflagset(5) || isbflagset(6)) {
route(5);
}
t_on_reply("1");
# forward to PSTN gateway
rewritehostport("gateway_IP:5060");
if (!t_relay()) {
sl_reply_error();
};
}
# Caller NAT detection route
route[4]{
log(3, "LOG: route 4 \n");
force_rport();
if (nat_uac_test("19")) {
if (method=="REGISTER") {
fix_nated_register();
} else {
fix_nated_contact();
}
setflag(5);
}
return;
}
# RTPProxy control
route[5] {
if (is_method("BYE")) {
unforce_rtp_proxy();
} else if (is_method("INVITE")){
force_rtp_proxy();
}
if (!has_totag()) add_rr_param(";nat=yes");
return;
}
onreply_route[1] {
xdbg("incoming reply\n");
if ((isflagset(5) || isbflagset(6)) &&
status=~"(183)|(2[0-9][0-9])") {
force_rtp_proxy();
}
if (isbflagset(6)) {
fix_nated_contact();
}
}
failure_route[1] {
if (is_method("INVITE")
&& (isbflagset(6) || isflagset(5))) {
unforce_rtp_proxy();
}
if (t_was_cancelled()) {
exit;
}
}
IƱaki Baz Castillo wrote:
2009/4/9 Joao Gomes Pereira
<gomespereira(a)startel.pt>pt>:
Hello
I did ngrep -d lo port 5060
And there are loops, because the message "513 Message too big " appears lots
of times, and always from my IP to my IP
What parts of the configuration could be creating these loops?
Obviously we don't know your configuration.
But tipically, a loop occurs when Kamailio does t_relay() and the
request leaves the proxy with the RURI unchanged (so pointed to
itself).
You must inspect the ngrep capture and determine why the request is
looped. A very basic example of looping:
route {
t_relay();
}
--
StarTel - A Rede Livre
Joao Gomes Pereira
www.startel.pt
+351 304500650
sip: gomespereira(a)startel.pt