[Serusers] header matching

Jan Janak jan at iptel.org
Sun Sep 21 00:26:29 CEST 2003


On 20-09 11:32, Jakob Schlyter wrote:
> there is sometimes a need to set the privacy parameter at runtime, e.g.
> the user might want to select the level of privacy when the number is
> dialed (in sweden we do this in the PSTN with a special prefix, #31#).
>

I made a quick change and turned rpid_prefix and rpid_suffix parameters
into parameters of append_rpid_hf function. That will allow you to
specify different prefix and suffix in every call to the function from
the script.

This will allow you to do something like this:

if (number begins with #31#) {
	append_rpid_hf("prefix", "suffix with privacy");
} else {
	append_rpid_hf("prefix", "suffix witout privacy");
};


NOTE: The patch is against the stable release and I didn't test it !

  let me know if it works, Jan.
-------------- next part --------------
diff -Naur /home/janakj/ser/stable/modules/auth/auth_mod.c /home/janakj/ser/stable.new/modules/auth/auth_mod.c
--- /home/janakj/ser/stable/modules/auth/auth_mod.c	2003-07-31 17:54:35.000000000 +0200
+++ /home/janakj/ser/stable.new/modules/auth/auth_mod.c	2003-09-21 00:13:26.000000000 +0200
@@ -66,6 +66,7 @@
 
 
 static int challenge_fixup(void** param, int param_no);
+static int rpid_fixup(void** param, int param_no);
 
 /*  
  * Convert char* parameter to str* parameter   
@@ -90,20 +91,6 @@
 
 
 /*
- * Default Remote-Party-ID prefix
- */
-char* rpid_prefix_param = "";
-str rpid_prefix;
-
-
-/*
- * Default Remote-Party-ID suffix
- */
-char* rpid_suffix_param = ";party=calling;id-type=subscriber;screen=yes";
-str rpid_suffix;
-
-
-/*
  * Exported functions 
  */
 static cmd_export_t cmds[] = {
@@ -111,7 +98,7 @@
 	{"proxy_challenge",     proxy_challenge,         2, challenge_fixup, REQUEST_ROUTE},
 	{"consume_credentials", consume_credentials,     0, 0,               REQUEST_ROUTE},
 	{"is_rpid_user_e164",   is_rpid_user_e164,       0, 0,               REQUEST_ROUTE},
-        {"append_rpid_hf",      append_rpid_hf,          0, 0,               REQUEST_ROUTE},
+        {"append_rpid_hf",      append_rpid_hf,          2, rpid_fixup,      REQUEST_ROUTE},
 	{"pre_auth",            (cmd_function)pre_auth,  0, 0,               0            },
 	{"post_auth",           (cmd_function)post_auth, 0, 0,               0            },
 	{0, 0, 0, 0, 0}
@@ -124,8 +111,6 @@
 static param_export_t params[] = {
 	{"secret",       STR_PARAM, &sec_param        },
 	{"nonce_expire", INT_PARAM, &nonce_expire     },
-        {"rpid_prefix",  STR_PARAM, &rpid_prefix_param},
-	{"rpid_suffix",  STR_PARAM, &rpid_suffix_param},
 	{0, 0, 0}
 };
 
@@ -198,12 +183,6 @@
 		secret.len = strlen(secret.s);
 	}
 
-	rpid_prefix.s = rpid_prefix_param;
-	rpid_prefix.len = strlen(rpid_prefix.s);
-	
-	rpid_suffix.s = rpid_suffix_param;
-	rpid_suffix.len = strlen(rpid_suffix.s);
-
 	return 0;
 }
 
@@ -260,3 +239,14 @@
 	
 	return 0;
 }
+
+
+static int rpid_fixup(void** param, int param_no)
+{
+	if (param_no == 1) {
+		return str_fixup(param, 1);
+	} else if (param_no == 2) {
+		return str_fixup(param, 1);
+	}
+	return 0;
+}
diff -Naur /home/janakj/ser/stable/modules/auth/auth_mod.h /home/janakj/ser/stable.new/modules/auth/auth_mod.h
--- /home/janakj/ser/stable/modules/auth/auth_mod.h	2003-07-31 17:54:35.000000000 +0200
+++ /home/janakj/ser/stable.new/modules/auth/auth_mod.h	2003-09-21 00:14:04.000000000 +0200
@@ -43,8 +43,6 @@
  */
 extern str secret;            /* secret phrase used to generate nonce */
 extern int nonce_expire;      /* nonce expire interval */
-extern str rpid_prefix;       /* Remote-Party-ID prefix */
-extern str rpid_suffix;       /* Remote-Party-ID suffix */
 
 
 /* Stateless reply function pointer */
diff -Naur /home/janakj/ser/stable/modules/auth/rpid.c /home/janakj/ser/stable.new/modules/auth/rpid.c
--- /home/janakj/ser/stable/modules/auth/rpid.c	2003-07-31 17:54:35.000000000 +0200
+++ /home/janakj/ser/stable.new/modules/auth/rpid.c	2003-09-21 00:17:03.000000000 +0200
@@ -113,7 +113,13 @@
 {
 	str rpid_hf;
 	char *at;
+	str rpid_prefix, rpid_suffix;
 
+	rpid_prefix.s = ((str*)_s1)->s;
+	rpid_prefix.len = ((str*)_s1)->len;
+	rpid_suffix.s = ((str*)_s2)->s;
+	rpid_suffix.len = ((str*)_s2)->len;
+	
 	     /* No remote party ID, just return */
 	if (!rpid.len) {
 		DBG("append_rpid_hf(): rpid is empty, nothing to append\n");


More information about the sr-users mailing list