[svn-commits] dvossel: trunk r246249 - in /trunk/channels/sip: ./ include/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Feb 10 17:13:53 CST 2010


Author: dvossel
Date: Wed Feb 10 17:13:49 2010
New Revision: 246249

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=246249
Log:
additional parse_uri test and documentation

Modified:
    trunk/channels/sip/include/reqresp_parser.h
    trunk/channels/sip/reqresp_parser.c

Modified: trunk/channels/sip/include/reqresp_parser.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/include/reqresp_parser.h?view=diff&rev=246249&r1=246248&r2=246249
==============================================================================
--- trunk/channels/sip/include/reqresp_parser.h (original)
+++ trunk/channels/sip/include/reqresp_parser.h Wed Feb 10 17:13:49 2010
@@ -31,6 +31,8 @@
  *   that if we don't have domain, we cannot split name:pass and domain:port.
  * - It is safe to call with ret_name, pass, domain, port pointing all to
  *   the same place.
+ * - If no secret parameter is provided, ret_name will return with both parts, user:secret
+ * - If no port parameter is provided, domain will return with both parts, domain:port
  * - This function overwrites the the uri string.
  * 
  * \retval 0 on success

Modified: trunk/channels/sip/reqresp_parser.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/reqresp_parser.c?view=diff&rev=246249&r1=246248&r2=246249
==============================================================================
--- trunk/channels/sip/reqresp_parser.c (original)
+++ trunk/channels/sip/reqresp_parser.c Wed Feb 10 17:13:49 2010
@@ -123,6 +123,10 @@
 	char uri2[] = "sip:name at host;transport=tcp";
 	char uri3[] = "sip:name:secret at host;transport=tcp";
 	char uri4[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+	/* test 5 is for NULL input */
+	char uri6[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+	char uri7[] = "sip:name:secret at host:port;transport=tcp?headers=%40%40testblah&headers2=blah%20blah";
+
 	switch (cmd) {
 	case TEST_INIT:
 		info->name = "sip_uri_parse_test";
@@ -193,11 +197,20 @@
 
 	/* Test 6, verify parse_uri does not crash when given a NULL output parameters */
 	name = pass = domain = port = transport = NULL;
-	if (parse_uri(uri4, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
+	if (parse_uri(uri6, "sip:,sips:", NULL, NULL, NULL, NULL, NULL)) {
 		ast_test_status_update(test, "Test 6: passing NULL output parameters failed.\n");
 		res = AST_TEST_FAIL;
 	}
 
+	/* Test 7, verify parse_uri returns user:secret and domain:port when no port or secret output parameters are supplied. */
+	name = pass = domain = port = transport = NULL;
+	if (parse_uri(uri7, "sip:,sips:", &name, NULL, &domain, NULL, NULL) ||
+			strcmp(name, "name:secret")        ||
+			strcmp(domain, "host:port")) {
+
+		ast_test_status_update(test, "Test 7: providing no port and secret output parameters failed.\n");
+		res = AST_TEST_FAIL;
+	}
 	return res;
 }
 




More information about the svn-commits mailing list