Module: sip-router
Branch: carstenbock/ims
Commit: f98c79f1bb109460a9dfeee0fdd71093c6c3490c
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=f98c79f…
Author: Carsten Bock <carsten(a)bock.info>
Committer: Carsten Bock <carsten(a)bock.info>
Date: Thu Jan 27 09:04:13 2011 +0100
- more fixes to the configuration
---
modules/pcscf/pcscf.cfg | 79 ++++++++++++++++++-----------------------------
1 files changed, 30 insertions(+), 49 deletions(-)
diff --git a/modules/pcscf/pcscf.cfg b/modules/pcscf/pcscf.cfg
index 104e2ac..0427216 100644
--- a/modules/pcscf/pcscf.cfg
+++ b/modules/pcscf/pcscf.cfg
@@ -153,6 +153,7 @@ loadmodule "pv.so"
loadmodule "xlog.so"
loadmodule "textops.so"
loadmodule "path.so"
+loadmodule "siputils.so"
#!ifdef K_TESTING
loadmodule "sst.so"
loadmodule "dialog.so"
@@ -329,12 +330,11 @@ modparam("tls", "config",
"/etc/kamailio/tls.cfg")
# main routing logic
route {
- xlog("L_ERR", "$rm $ru (From $fu to $tu)\n");
+ xlog("L_ERR", "$rm $ru (From $fu / $si)\n");
# Basic checks for Sanity of the request and Request flooding.
route(Sanity_Checks);
- # Add-
# Thus P_check_via_sent_by/P_add_via_received is no longer required.
route(NAT);
@@ -358,13 +358,13 @@ route {
break;
}
- xlog("L_ERR", "$$route_uri = $route_uri\n");
+ xlog("L_ERR", "$$route_uri = $route_uri\n");
if !($route_uri =~
"sip:term@"+HOSTNAME_ESC+"."+NETWORKNAME_ESC+".*") {
# Request Initiated by the UE
#!ifdef K_TESTING
if (is_in_profile("orig")){
#!else
- if (P_is_in_dialog("orig")){
+ if (P_is_in_dialog("orig") || has_totag()){
#!endif
if (!is_method("CANCEL")) route(Orig_Subsequent);
else route(Orig_Standalone);
@@ -373,12 +373,13 @@ route {
#!ifdef K_TESTING
if (is_in_profile("term")){
#!else
- if (P_is_in_dialog("term")){
+ if (P_is_in_dialog("term") || has_totag()){
#!endif
if (!is_method("CANCEL")) route(Term_Subsequent);
else route(Orig_Standalone);
break;
- }
+ }
+ xlog("L_ERR", "No dialog yet\n");
# No dialog yet - ACK not relayed as hop-to-hop
if (is_method("ACK"))
break;
@@ -543,7 +544,7 @@ route[REGISTER_494]
route[add_charging_vector]
{
- $var(charging_vector) =
"icid-value=\""+ICID_VALUE_PREFIX+$(Ts{s.encode.hexa})+$(shv(charging_icid_value_counter){s.encode.hexa})+"\";icid-generated-at="+ICID_VALUE_PREFIX+";orig-ioi=\""+ORIG_IOI+"\"";
+ $var(charging_vector) =
"icid-value=\""+ICID_VALUE_PREFIX+$(Ts{s.encode.hexa})+$(shv(charging_icid_value_counter){s.encode.hexa})+"\";icid-generated-at="+ICID_GENERATOR_ADDR+";orig-ioi=\""+ORIG_IOI+"\"";
append_hf("P-Charging-Vector: $var(charging_vector)\r\n");
# Increase counter by one:
@@ -681,9 +682,8 @@ onreply_route[REGISTER_reply]
else P_AAR("register");
}
#!ifdef WITH_TLS
- if (!P_security_relay())
+ P_security_relay();
#!endif
- P_NAT_relay();
}
failure_route[REGISTER_failure]
@@ -706,7 +706,6 @@ route[NOTIFY]
####### ORIGINATING
route[Orig_Initial]
{
- xlog("L_ERR", "route[Orig_Initial]\n");
if (P_emergency_ruri()){
route(Orig_Initial_Emergency);
break;
@@ -722,7 +721,6 @@ route[Orig_Initial]
};
# add IBCF/THIG route here if required
loose_route();
- xlog("L_ERR", "1) $$du = $du\n");
if (!P_follows_service_routes()){
#Variant 1 - deny access to the network
#send_reply("400","Bad Request - Not following indicated
Service-Routes");
@@ -730,10 +728,8 @@ route[Orig_Initial]
#Variant 2 - enforce routes and let the dialog continue
P_enforce_service_routes();
}
- xlog("L_ERR", "2) $$du = $du\n");
P_record_route("orig");
- xlog("L_ERR", "3) $$du = $du\n");
# Check for "sec-agree" in the Require header:
if ($hdr(Require)) {
@@ -765,14 +761,11 @@ route[Orig_Initial]
send_reply("514","Originating dialog save failure - P-CSCF maximum
dialog count reached!");
exit;
}
- xlog("L_ERR", "10) $$du = $du\n");
- if (is_method("INVITE")){
+ if (isflagset(NAT_FLAG) && is_method("INVITE")){
#P_local_policy(); #check, if sdp is allowed, if not return with allowed sdp
- P_NAT_relay();
route(RTPPROXY);
}
- xlog("L_ERR", "11) $$du = $du\n");
t_on_reply("Orig_Initial_reply");
t_on_failure("Orig_Initial_failure");
@@ -834,7 +827,7 @@ route[Orig_Initial_Emergency]
exit;
}
- if (method=="INVITE"){
+ if (isflagset(NAT_FLAG) && is_method("INVITE")){
route(RTPPROXY);
}
@@ -944,6 +937,7 @@ route[Orig_Subsequent]
log(1,">> Orig_Subsequent\n");
if (P_is_registered()){
if (!P_assert_identity("non-emerg")){
+ xlog("L_ERR", "Not registered!\n");
send_reply("403","Forbidden - You must register first with a
S-CSCF");
break;
};
@@ -954,13 +948,6 @@ route[Orig_Subsequent]
};
}
-# else{
- # let it continue as this probably does not come from an UE
- #send_reply("403","Forbidden - Not Registered! You must register
first with a S-CSCF");
- #break;
-
-# }
-
loose_route();
if (method!="CANCEL" &&
!P_follows_dialog_routes("orig")){
@@ -988,7 +975,6 @@ route[Orig_Subsequent]
}
if (method=="BYE" || method=="CANCEL"){
- #end_media_session();
P_STR("orig");
}
@@ -999,8 +985,9 @@ route[Orig_Subsequent]
# reply routes unused as empty at the moment
t_on_reply("Orig_Subsequensend_reply");
#t_on_failure("Orig_Subsequent_failure");
-
+ xlog("L_ERR", "$rm: Forward to $ru ($du)\n");
if (!t_relay()) {
+ xlog("L_ERR", "Could not forward\n");
send_reply("500","Error forwarding originating subsequent
request");
break;
};
@@ -1010,14 +997,11 @@ onreply_route[Orig_Subsequensend_reply]
{
if (t_check_status("[1-2]..")){
P_update_dialog("orig");
- # P_replace_contact();???
}
if (t_check_status("2..") && P_generates_aar("orig")){
if (!P_AAR("orig")) {
P_release_call_onreply("orig");
- #end_media_session();
-
}
}
@@ -1114,8 +1098,6 @@ failure_route[Orig_Standalone_failure]
route[Term_Initial]
{
- xlog("L_ERR", "Term_Initial\n");
-
P_record_route("term");
route(Check_Session_Expires);
@@ -1124,20 +1106,18 @@ route[Term_Initial]
send_reply("514","Terminating dialog save failure - P-CSCF maximum
dialog count reached!");
exit;
}
- xlog("L_ERR", "Route: $hdr(Route)\n");
loose_route();
- xlog("L_ERR", "1) $$du = $du\n");
+ if (check_route_param("received=.*")) setflag(NAT_FLAG);
+ if (isflagset(NAT_FLAG)) xlog("L_ERR", "Callee is behind NAT!\n");
t_on_reply("Term_Initial_reply");
#t_on_failure("Term_Initial_failure");
- if (method=="INVITE") {
+ if (is_method("INVITE") && isflagset(NAT_FLAG)) {
route(RTPPROXY);
}
- if (!P_security_relay())
- P_NAT_relay();
+ P_security_relay();
- xlog("L_ERR", "2) $$du = $du\n");
t_on_reply("Term_Initial_reply");
t_on_failure("Term_Initial_failure");
if (!t_relay()) {
@@ -1151,14 +1131,16 @@ route[Term_Initial]
onreply_route[Term_Initial_reply]
{
if (t_check_status("(180)|(183)|([2-9]..)")){
- route(RTPPROXY_REPLY);
+ if (isflagset(NAT_FLAG)) {
+ # Fix Contact Header in Reply to INVITE
+ fix_nated_contact();
+ # Use RTP-Proxy, if required:
+ route(RTPPROXY_REPLY);
+ }
if(P_generates_aar("term")){
# check if QoS is ok, orig - originating, term - terminating
if (!P_AAR("term")) {
P_release_call_onreply("term");
- # end_media_session();
- #} else {
- # use_media_proxy();
}
}
}
@@ -1206,6 +1188,8 @@ failure_route[Term_Initial_failure]
route[Term_Subsequent]
{
+ log(1,">> Term_Subsequent\n");
+
route(Check_Session_Expires);
P_update_dialog("term");
@@ -1220,7 +1204,6 @@ route[Term_Subsequent]
if (method=="BYE") {
P_STR("term"); # terminate authorization session
- #end_media_session();
}
# Check for "sec-agree" in the Require header:
@@ -1247,9 +1230,9 @@ route[Term_Subsequent]
t_on_reply("Term_Subsequensend_reply");
#t_on_failure("Term_Subsequent_failure");
- if (!P_security_relay())
- P_NAT_relay();
- xlog("L_ERR", "$$du = $du\n");
+ P_security_relay();
+
+ xlog("L_ERR", "$rm: Forward to $ru ($du)\n");
if (!t_relay()) {
send_reply("500","Error forwarding terminating subsequent
request");
break;
@@ -1298,9 +1281,7 @@ route[Term_Standalone]
t_on_reply("Term_Standalone_reply");
#t_on_failure("Term_Standalone_failure");
- if (!P_security_relay())
- P_NAT_relay();
- xlog("L_ERR", "$$du = $du\n");
+ P_security_relay();
if (!t_relay()) {
send_reply("500","Error forwarding terminating standalone
request");
break;