Module: sip-router
Branch: carstenbock/ims
Commit: e87da704cb62f71863dc7bb70f928ef0ac8ba61e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e87da70…
Author: Carsten Bock <carsten(a)bock.info>
Committer: Carsten Bock <carsten(a)bock.info>
Date: Thu Jan 27 19:25:46 2011 +0100
- Fixed some Regular Expressions
---
modules/pcscf/pcscf.cfg | 98 +++++++++++++++++++++++++++++-----------------
1 files changed, 62 insertions(+), 36 deletions(-)
diff --git a/modules/pcscf/pcscf.cfg b/modules/pcscf/pcscf.cfg
index 0427216..9c78aa3 100644
--- a/modules/pcscf/pcscf.cfg
+++ b/modules/pcscf/pcscf.cfg
@@ -554,7 +554,8 @@ route[add_charging_vector]
route[REGISTER]
{
#!ifndef WITH_EMERGENCY
- if ($(ct{uri.params}{param.value,sos})) {
+ $var(ct_uri) = $(ct{re.subst,/\".*\"[
]*//i}{re.subst,/<//i}{re.subst,/>//i});
+ if ($(var(ct_uri){uri.params}{param.value,sos})) {
# P_380_em_alternative_serv("no Emergency Services support at this PCSCF");
#TODO: Fix XML-Body
set_reply_body("<xml>no Emergency Services support at this
PCSCF</xml>",
"application/3gpp-ims+xml;schemaversion=\"1\"");
@@ -576,12 +577,11 @@ route[REGISTER]
# break;
#}
remove_hf("Security-Client");
+
# Set the "integrity protected tag in the Authorization-Header:
- if (is_present_hf("Authorization")){
+ if (is_present_hf("Authorization") && $hdr(Authorization) =~
".*integrity-protected.*"){
remove_hf("Authorization");
- $var(new_hdr) = $(hdr(Authorization){re.subst,/,[
]*integrity-protected=\"(a-zA-Z0-9)*\"//i});
- xlog("L_ERR", "$$var(new_hdr) = $var(new_hdr)\n");
- $var(new_hdr) = $hdr(Authorization);
+ $var(new_hdr) = $(hdr(Authorization){re.subst,/[,
]*integrity-protected=\"[a-zA-Z0-9]*\"//i});
append_hf("Authorization: $var(new_hdr),
integrity-protected=\"no\"\r\n");
}
}else{
@@ -593,30 +593,28 @@ route[REGISTER]
remove_hf("Security-Client");
# Set the "integrity protected tag in the Authorization-Header:
- if (is_present_hf("Authorization")){
+ if (is_present_hf("Authorization") && $hdr(Authorization) =~
".*integrity-protected.*"){
remove_hf("Authorization");
- $var(new_hdr) = $(hdr(Authorization){re.subst,/,[
]*integrity-protected=\"(a-zA-Z0-9)*\"//i});
- xlog("L_ERR", "$$var(new_hdr) = $var(new_hdr)\n");
- $var(new_hdr) = $hdr(Authorization);
+ $var(new_hdr) = $(hdr(Authorization){re.subst,/[,
]*integrity-protected=\"[a-zA-Z0-9]*\"//i});
append_hf("Authorization: $var(new_hdr),
integrity-protected=\"yes\"\r\n");
}
};
# Check for "sec-agree" in the Require header:
- if (is_present_hf("Require")) {
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Require: $var(new_hdr)\r\n");
}
}
# Check for "sec-agree" in the Proxy-Require header:
- if (is_present_hf("Proxy-Require")) {
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Proxy-Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Proxy-Require: $var(new_hdr)\r\n");
}
@@ -657,13 +655,23 @@ route[REGISTER]
onreply_route[REGISTER_reply]
{
if (t_check_status("401")){
+ xlog("L_ERR", "401:\n");
# Check for "sec-agree" in the Proxy-Require header:
- if ($hdr(WWW-Authenticate)) {
- # The new Require-Header:
+ if (is_present_hf("WWW-Authenticate") && ($hdr(WWW-Authenticate) =~
".*ck=.*" || $hdr(WWW-Authenticate) =~ ".*ik=.*")) {
+ $var(new_hdr) = $hdr(WWW-Authenticate);
+ xlog("L_ERR", "$$var(new_hdr) = $var(new_hdr)\n");
+ if ($var(new_hdr) =~ ".*ck=.*") {
+ # Replace ", (ck/ik)" with ""
+ $var(new_hdr) = $(var(new_hdr){re.subst,/[, ]*ck=\"[0-9A-Za-z]*\"//i});
+ xlog("L_ERR", "CK: $$var(new_hdr) = $var(new_hdr)\n");
+ }
+ if ($var(new_hdr) =~ ".*ik=.*") {
+ # Replace ", (ck/ik)" with ""
+ $var(new_hdr) = $(var(new_hdr){re.subst,/[, ]*ik=\"[0-9A-Za-z]*\"//i});
+ xlog("L_ERR", "IK: $$var(new_hdr) = $var(new_hdr)\n");
+ }
+ # Replace the header:
remove_hf("WWW-Authenticate");
- # Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(WWW-Authenticate){re.subst,/[,
\r\n\t]*ck=\"(a-zA-Z0-9)*\"//gi});
- $var(new_hdr) = $(var(new_hdr){re.subst,/[,
\r\n\t]*ik=\"(a-zA-Z0-9)*\"//gi});
append_hf("WWW-Authenticate: $var(new_hdr)\r\n");
} else {
# send_reply("500","P-CSCF Error on hiding CK, IK");
@@ -732,21 +740,21 @@ route[Orig_Initial]
P_record_route("orig");
# Check for "sec-agree" in the Require header:
- if ($hdr(Require)) {
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//i});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Require: $var(new_hdr)\r\n");
}
}
# Check for "sec-agree" in the Proxy-Require header:
- if ($hdr(Proxy-Require)) {
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Proxy-Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//i});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Proxy-Require: $var(new_hdr)\r\n");
}
@@ -784,21 +792,21 @@ route[Orig_Initial_Emergency]
P_record_route("orig");
# Check for "sec-agree" in the Require header:
- if ($hdr(Require)) {
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Require: $var(new_hdr)\r\n");
}
}
# Check for "sec-agree" in the Proxy-Require header:
- if ($hdr(Proxy-Require)) {
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Proxy-Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Proxy-Require: $var(new_hdr)\r\n");
}
@@ -978,8 +986,26 @@ route[Orig_Subsequent]
P_STR("orig");
}
- P_remove_header_tag("Require","sec-agree");
- P_remove_header_tag("Proxy-Require","sec-agree");
+ # Check for "sec-agree" in the Require header:
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
+ # The new Require-Header:
+ remove_hf("Require");
+ # Replace ", sec-agree" with ""
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
+ if ($(var(new_hdr){s.len}) > 0) {
+ append_hf("Require: $var(new_hdr)\r\n");
+ }
+ }
+ # Check for "sec-agree" in the Require header:
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
+ # The new Require-Header:
+ remove_hf("Proxy-Require");
+ # Replace ", sec-agree" with ""
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
+ if ($(var(new_hdr){s.len}) > 0) {
+ append_hf("Proxy-Require: $var(new_hdr)\r\n");
+ }
+ }
P_remove_security_verify();
# reply routes unused as empty at the moment
@@ -1047,21 +1073,21 @@ route[Orig_Standalone]
# add IBCF/THIG route here if required
# Check for "sec-agree" in the Require header:
- if ($hdr(Require)) {
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Require: $var(new_hdr)\r\n");
}
}
# Check for "sec-agree" in the Proxy-Require header:
- if ($hdr(Proxy-Require)) {
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Proxy-Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Proxy-Require: $var(new_hdr)\r\n");
}
@@ -1207,21 +1233,21 @@ route[Term_Subsequent]
}
# Check for "sec-agree" in the Require header:
- if ($hdr(Require)) {
+ if (is_present_hf("Require") && $hdr(Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Require: $var(new_hdr)\r\n");
}
}
# Check for "sec-agree" in the Proxy-Require header:
- if ($hdr(Proxy-Require)) {
+ if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~
".*sec-agree.*") {
# The new Require-Header:
remove_hf("Proxy-Require");
# Replace ", sec-agree" with ""
- $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, \r\n\t]*sec-agree//gi});
+ $var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
if ($(var(new_hdr){s.len}) > 0) {
append_hf("Proxy-Require: $var(new_hdr)\r\n");
}