Browse Source

- tels uri support and sip/sips user=phone support patch from Juha Heinanen,
sligthly modified

Andrei Pelinescu-Onciul 20 years ago
parent
commit
f924ae07e7
2 changed files with 23 additions and 6 deletions
  1. 1 1
      parser/msg_parser.h
  2. 22 5
      parser/parse_uri.c

+ 1 - 1
parser/msg_parser.h

@@ -122,7 +122,7 @@ struct sip_uri {
 };
 #endif
 
-enum _uri_type{ERROR_URI_T=0, SIP_URI_T, SIPS_URI_T, TEL_URI_T};
+enum _uri_type{ERROR_URI_T=0, SIP_URI_T, SIPS_URI_T, TEL_URI_T, TELS_URI_T};
 typedef enum _uri_type uri_type;
 
 struct sip_uri {

+ 22 - 5
parser/parse_uri.c

@@ -951,11 +951,28 @@ int parse_uri(char* buf, int len, struct sip_uri* uri)
 		default:
 			goto error_bug;
 	}
-	if (uri->type==TEL_URI_T){
-		/* fix tel uris, move the number in uri and empty the host */
-		uri->user=uri->host;
-		uri->host.s="";
-		uri->host.len=0;
+	switch(uri->type){
+		case SIP_URI_T:
+			if ((uri->user_param_val.len == 5) &&
+				(strncmp(uri->user_param_val.s, "phone", 5) == 0)) {
+				uri->type = TEL_URI_T;
+			}
+			break;
+		case SIPS_URI_T:
+			if ((uri->user_param_val.len == 5) &&
+				(strncmp(uri->user_param_val.s, "phone", 5) == 0)) {
+				uri->type = TELS_URI_T;
+			}
+			break;
+		case TEL_URI_T:
+		case TELS_URI_T:
+			/* fix tel uris, move the number in uri and empty the host */
+			uri->user=uri->host;
+			uri->host.s="";
+			uri->host.len=0;
+			break;
+		case ERROR_URI_T:
+			break; /* do nothing, avoids a compilation warning */
 	}
 #ifdef EXTRA_DEBUG
 	/* do stuff */