Browse code

on behalf of Jiri, patch adopted from 2.0 branch

* 2007-09-10 introduced phone2uri option which allows NOT to consider
* user=phone URIs as TEL URIs

Michal Matyska authored on 10/09/2007 22:26:59
Showing 5 changed files
... ...
@@ -69,7 +69,9 @@
69 69
  *              RT_TIMER2_POLICY (andrei)
70 70
  *  2007-06-16  added DNS_SRV_LB, DNS_TRY_NAPTR (andrei)
71 71
  *  2007-06-18  added DNS_{UDP,TCP,TLS}_PREF (andrei)
72
- */
72
+ *  2007-09-10  introduced phone2tel option which allows NOT to consider
73
+ *              user=phone URIs as TEL URIs (jiri)
74
+*/
73 75
 
74 76
 
75 77
 %{
... ...
@@ -264,6 +266,7 @@ STAT	statistics
264 264
 MAXBUFFER maxbuffer
265 265
 CHILDREN children
266 266
 CHECK_VIA	check_via
267
+PHONE2TEL	phone2tel
267 268
 SYN_BRANCH syn_branch
268 269
 MEMLOG		"memlog"|"mem_log"
269 270
 MEMDBG		"memdbg"|"mem_dbg"
... ...
@@ -513,6 +516,7 @@ EAT_ABLE	[\ \t\b\r]
513 513
 <INITIAL>{MAXBUFFER}	{ count(); yylval.strval=yytext; return MAXBUFFER; }
514 514
 <INITIAL>{CHILDREN}	{ count(); yylval.strval=yytext; return CHILDREN; }
515 515
 <INITIAL>{CHECK_VIA}	{ count(); yylval.strval=yytext; return CHECK_VIA; }
516
+<INITIAL>{PHONE2TEL}	{ count(); yylval.strval=yytext; return PHONE2TEL; }
516 517
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
517 518
 <INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
518 519
 <INITIAL>{MEMDBG}	{ count(); yylval.strval=yytext; return MEMDBG; }
... ...
@@ -82,7 +82,9 @@
82 82
  *              RT_POLICY, RT_TIMER1_PRIO, RT_TIMER1_POLICY, RT_TIMER2_PRIO,
83 83
  *              RT_TIMER2_POLICY (andrei)
84 84
  * 2007-06-16  added DDNS_SRV_LB, DNS_TRY_NAPTR (andrei)
85
- */
85
+ * 2007-09-10  introduced phone2tel option which allows NOT to consider
86
+ *             user=phone URIs as TEL URIs (jiri)
87
+*/
86 88
 
87 89
 %{
88 90
 
... ...
@@ -301,6 +303,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
301 301
 %token STAT
302 302
 %token CHILDREN
303 303
 %token CHECK_VIA
304
+%token PHONE2TEL
304 305
 %token SYN_BRANCH
305 306
 %token MEMLOG
306 307
 %token MEMDBG
... ...
@@ -380,6 +383,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
380 380
 %token STUN_ALLOW_STUN
381 381
 %token STUN_ALLOW_FP
382 382
 
383
+
383 384
 /* operators */
384 385
 %nonassoc EQUAL
385 386
 %nonassoc EQUAL_T
... ...
@@ -642,6 +646,8 @@ assign_stm:
642 642
 	| CHILDREN EQUAL error { yyerror("number expected"); }
643 643
 	| CHECK_VIA EQUAL NUMBER { check_via=$3; }
644 644
 	| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
645
+	| PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
646
+	| PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
645 647
 	| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
646 648
 	| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
647 649
 	| MEMLOG EQUAL NUMBER { memlog=$3; }
... ...
@@ -93,6 +93,7 @@ extern unsigned short tls_port_no;
93 93
 extern int dont_fork;
94 94
 extern int dont_daemonize;
95 95
 extern int check_via;
96
+extern int phone2tel;
96 97
 extern int received_dns;
97 98
 extern int syn_branch;
98 99
 /* extern int process_no; */
... ...
@@ -296,6 +296,8 @@ int log_facility = LOG_DAEMON;
296 296
 int config_check = 0;
297 297
 /* check if reply first via host==us */
298 298
 int check_via =  0;
299
+/* translate user=phone URIs to TEL URIs */
300
+int phone2tel = 1;
299 301
 /* shall use stateful synonym branches? faster but not reboot-safe */
300 302
 int syn_branch = 1;
301 303
 /* debugging level for memory stats */
... ...
@@ -36,9 +36,13 @@
36 36
  * 2005-02-25  preliminary tel uri support (andrei)
37 37
  * 2005-03-03  more tel uri fixes (andrei)
38 38
  * 2006-04-20  comp uri param. support (rfc3486) if defined USE_COMP  (andrei)
39
+ * 2007-09-10  introduced phone2tel option which allows NOT to consider
40
+ *             user=phone URIs as TEL URIs
41
+ *
39 42
  */
40 43
 
41 44
 
45
+#include "../globals.h"
42 46
 #include "parse_uri.h"
43 47
 #include <string.h>
44 48
 #include "../dprint.h"
... ...
@@ -1098,8 +1102,10 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
1098 1098
 	switch(uri->type){
1099 1099
 		case SIPS_URI_T:
1100 1100
 		case SIP_URI_T:
1101
-			if ((uri->user_param_val.len == 5) &&
1102
-				(strncmp(uri->user_param_val.s, "phone", 5) == 0)) {
1101
+			if ((phone2tel) &&
1102
+			     (uri->user_param_val.len == 5) &&
1103
+				 (strncmp(uri->user_param_val.s, "phone", 5) == 0)
1104
+				) {
1103 1105
 				uri->type = TEL_URI_T;
1104 1106
 				uri->flags |= URI_SIP_USER_PHONE;
1105 1107
 				/* move params from user into uri->params */