浏览代码

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 18 年之前
父节点
当前提交
face488efe
共有 5 个文件被更改,包括 23 次插入4 次删除
  1. 5 1
      cfg.lex
  2. 7 1
      cfg.y
  3. 1 0
      globals.h
  4. 2 0
      main.c
  5. 8 2
      parser/parse_uri.c

+ 5 - 1
cfg.lex

@@ -69,7 +69,9 @@
  *              RT_TIMER2_POLICY (andrei)
  *  2007-06-16  added DNS_SRV_LB, DNS_TRY_NAPTR (andrei)
  *  2007-06-18  added DNS_{UDP,TCP,TLS}_PREF (andrei)
- */
+ *  2007-09-10  introduced phone2tel option which allows NOT to consider
+ *              user=phone URIs as TEL URIs (jiri)
+*/
 
 
 %{
@@ -264,6 +266,7 @@ STAT	statistics
 MAXBUFFER maxbuffer
 CHILDREN children
 CHECK_VIA	check_via
+PHONE2TEL	phone2tel
 SYN_BRANCH syn_branch
 MEMLOG		"memlog"|"mem_log"
 MEMDBG		"memdbg"|"mem_dbg"
@@ -513,6 +516,7 @@ EAT_ABLE	[\ \t\b\r]
 <INITIAL>{MAXBUFFER}	{ count(); yylval.strval=yytext; return MAXBUFFER; }
 <INITIAL>{CHILDREN}	{ count(); yylval.strval=yytext; return CHILDREN; }
 <INITIAL>{CHECK_VIA}	{ count(); yylval.strval=yytext; return CHECK_VIA; }
+<INITIAL>{PHONE2TEL}	{ count(); yylval.strval=yytext; return PHONE2TEL; }
 <INITIAL>{SYN_BRANCH}	{ count(); yylval.strval=yytext; return SYN_BRANCH; }
 <INITIAL>{MEMLOG}	{ count(); yylval.strval=yytext; return MEMLOG; }
 <INITIAL>{MEMDBG}	{ count(); yylval.strval=yytext; return MEMDBG; }

+ 7 - 1
cfg.y

@@ -82,7 +82,9 @@
  *              RT_POLICY, RT_TIMER1_PRIO, RT_TIMER1_POLICY, RT_TIMER2_PRIO,
  *              RT_TIMER2_POLICY (andrei)
  * 2007-06-16  added DDNS_SRV_LB, DNS_TRY_NAPTR (andrei)
- */
+ * 2007-09-10  introduced phone2tel option which allows NOT to consider
+ *             user=phone URIs as TEL URIs (jiri)
+*/
 
 %{
 
@@ -301,6 +303,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token STAT
 %token CHILDREN
 %token CHECK_VIA
+%token PHONE2TEL
 %token SYN_BRANCH
 %token MEMLOG
 %token MEMDBG
@@ -380,6 +383,7 @@ static struct socket_id* mk_listen_id(char*, int, int);
 %token STUN_ALLOW_STUN
 %token STUN_ALLOW_FP
 
+
 /* operators */
 %nonassoc EQUAL
 %nonassoc EQUAL_T
@@ -642,6 +646,8 @@ assign_stm:
 	| CHILDREN EQUAL error { yyerror("number expected"); }
 	| CHECK_VIA EQUAL NUMBER { check_via=$3; }
 	| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
+	| PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
+	| PHONE2TEL EQUAL error { yyerror("boolean value expected"); }
 	| SYN_BRANCH EQUAL NUMBER { syn_branch=$3; }
 	| SYN_BRANCH EQUAL error { yyerror("boolean value expected"); }
 	| MEMLOG EQUAL NUMBER { memlog=$3; }

+ 1 - 0
globals.h

@@ -93,6 +93,7 @@ extern unsigned short tls_port_no;
 extern int dont_fork;
 extern int dont_daemonize;
 extern int check_via;
+extern int phone2tel;
 extern int received_dns;
 extern int syn_branch;
 /* extern int process_no; */

+ 2 - 0
main.c

@@ -296,6 +296,8 @@ int log_facility = LOG_DAEMON;
 int config_check = 0;
 /* check if reply first via host==us */
 int check_via =  0;
+/* translate user=phone URIs to TEL URIs */
+int phone2tel = 1;
 /* shall use stateful synonym branches? faster but not reboot-safe */
 int syn_branch = 1;
 /* debugging level for memory stats */

+ 8 - 2
parser/parse_uri.c

@@ -36,9 +36,13 @@
  * 2005-02-25  preliminary tel uri support (andrei)
  * 2005-03-03  more tel uri fixes (andrei)
  * 2006-04-20  comp uri param. support (rfc3486) if defined USE_COMP  (andrei)
+ * 2007-09-10  introduced phone2tel option which allows NOT to consider
+ *             user=phone URIs as TEL URIs
+ *
  */
 
 
+#include "../globals.h"
 #include "parse_uri.h"
 #include <string.h>
 #include "../dprint.h"
@@ -1098,8 +1102,10 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
 	switch(uri->type){
 		case SIPS_URI_T:
 		case SIP_URI_T:
-			if ((uri->user_param_val.len == 5) &&
-				(strncmp(uri->user_param_val.s, "phone", 5) == 0)) {
+			if ((phone2tel) &&
+			     (uri->user_param_val.len == 5) &&
+				 (strncmp(uri->user_param_val.s, "phone", 5) == 0)
+				) {
 				uri->type = TEL_URI_T;
 				uri->flags |= URI_SIP_USER_PHONE;
 				/* move params from user into uri->params */