From 9bb946f4d89591027cd084beb0ce9b607d719191 Mon Sep 17 00:00:00 2001 From: herlesupreeth Date: Wed, 9 Jun 2021 18:08:08 +0200 Subject: [PATCH] Fix condition for In-Dialog IPSec forwarding --- pcscf/route/mo.cfg | 17 +++++++++++++++-- pcscf/route/mt.cfg | 20 +++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/pcscf/route/mo.cfg b/pcscf/route/mo.cfg index acff204..30d35ca 100644 --- a/pcscf/route/mo.cfg +++ b/pcscf/route/mo.cfg @@ -162,12 +162,25 @@ route[MO_indialog] { xnotice("Contact header: $ct\n"); setflag(FLT_MOBILE_ORIG); t_on_reply("MO_indialog_reply"); - if ($du != "" && $ru != "") { + + if ($du != "" && $ru != "" && $fs != "") { # Remove sips: and sip: from destination URI for comparision $var(destination) = $(du{re.subst,/sips://g}); $var(destination) = $(var(destination){re.subst,/sip://g}); $var(destination_alias) = $(var(destination){re.subst,/:/~/g}); - if (is_request() && $dp != 5060 && ($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*")) { + + # $var(fs_bck) = $fs; + # $var(fs_proto) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\1/g}); + # $var(fs_ip) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\2/g}); + # $var(fs_port) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\3/g}); + + # if (($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*") && + # ($var(fs_ip) == IPSEC_LISTEN_ADDR && + # (($var(fs_port) >= IPSEC_CLIENT_PORT && $var(fs_port) <= IPSEC_CLIENT_PORT + IPSEC_MAX_CONN) || + # ($var(fs_port) >= IPSEC_SERVER_PORT && $var(fs_port) <= IPSEC_SERVER_PORT + IPSEC_MAX_CONN)))) { + # ipsec_forward("location"); + # } + if ($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*") { ipsec_forward("location"); } } diff --git a/pcscf/route/mt.cfg b/pcscf/route/mt.cfg index b3f80a1..1c0eaec 100644 --- a/pcscf/route/mt.cfg +++ b/pcscf/route/mt.cfg @@ -87,15 +87,25 @@ route[MT_indialog] { xnotice("Contact header: $ct\n"); #resetflag(FLT_MOBILE_ORIG); t_on_reply("MT_indialog_reply"); - if ($du != "" && $ru != "") { + if ($du != "" && $ru != "" && $fs != "") { # Remove sips: and sip: from destination URI for comparision $var(destination) = $(du{re.subst,/sips://g}); $var(destination) = $(var(destination){re.subst,/sip://g}); $var(destination_alias) = $(var(destination){re.subst,/:/~/g}); - $var(alias_proto) = $(ru{re.subst,/^(.*);alias=.*~[0-9]*~//g}); - if (is_request() && $var(alias_proto) == 2 && ($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*")) { - $du = $du+";transport=tcp"; - $fs = $(fs{re.subst,/udp/tcp/g}); + + # $var(fs_bck) = $fs; + # $var(fs_proto) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\1/g}); + # $var(fs_ip) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\2/g}); + # $var(fs_port) = $(var(fs_bck){re.subst,/^([^:]*):([^:]*):([^:]*)/\3/g}); + + # if (($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*") && + # ($var(fs_ip) == IPSEC_LISTEN_ADDR && + # (($var(fs_port) >= IPSEC_CLIENT_PORT && $var(fs_port) <= IPSEC_CLIENT_PORT + IPSEC_MAX_CONN) || + # ($var(fs_port) >= IPSEC_SERVER_PORT && $var(fs_port) <= IPSEC_SERVER_PORT + IPSEC_MAX_CONN)))) { + # ipsec_forward("location"); + # } + if ($ru =~ ".*" + $var(destination) + ".*" || $ru =~ ".*" + $var(destination_alias) + ".*") { + ipsec_forward("location"); } } }