]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
merge latest darcs changes from sofia-sip.
authorMichael Jerris <mike@jerris.com>
Tue, 17 Apr 2007 13:43:45 +0000 (13:43 +0000)
committerMichael Jerris <mike@jerris.com>
Tue, 17 Apr 2007 13:43:45 +0000 (13:43 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4963 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/sofia-sip/libsofia-sip-ua/nta/run_test_nta_api
libs/sofia-sip/libsofia-sip-ua/nua/test_cancel_bye.c
libs/sofia-sip/libsofia-sip-ua/nua/test_ops.c
libs/sofia-sip/libsofia-sip-ua/sdp/torture_sdp.c
libs/sofia-sip/libsofia-sip-ua/sip/run_test_sip_msg
libs/sofia-sip/libsofia-sip-ua/sip/sip_pref_util.c
libs/sofia-sip/libsofia-sip-ua/sip/sofia-sip/sip_util.h
libs/sofia-sip/libsofia-sip-ua/sip/torture_sip.c
libs/sofia-sip/libsofia-sip-ua/sresolv/run_test_sresolv
libs/sofia-sip/libsofia-sip-ua/su/run_test_su
libs/sofia-sip/libsofia-sip-ua/su/run_test_su_osx

index e0416fb66c7e9970f398b51c053183e3c42ba004..73369c73d7eff066b7eab1a574328388235db3a1 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # Run test_nta_api
 #
index 87fc11867c882c13e900db173d37d8b953615f38..c0bc8e8b80616aab17c32e3077b2610858f310c8 100644 (file)
@@ -1135,7 +1135,7 @@ int test_bye_after_receiving_401(struct context *ctx)
   INVITE(b, b_call, b_call->nh, 
         SIPTAG_SUBJECT_STR("NUA-6.3 re-INVITE"),
         TAG_END());
-  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response);
 
   TEST_1(nua_handle_has_active_call(a_call->nh));
   TEST_1(nua_handle_has_active_call(b_call->nh));
@@ -1210,7 +1210,7 @@ int test_bye_after_sending_401(struct context *ctx)
   INVITE(b, b_call, b_call->nh, 
         SIPTAG_SUBJECT_STR("NUA-6.4.1 re-INVITE"),
         TAG_END());
-  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response);
 
   TEST_1(nua_handle_has_active_call(a_call->nh));
   TEST_1(nua_handle_has_active_call(b_call->nh));
@@ -1286,7 +1286,7 @@ int test_bye_after_receiving_401_to_update(struct context *ctx)
         SIPTAG_SUBJECT_STR("NUA-6.4.2 UPDATE"),
         TAG_END());
   BYE(b, b_call, b_call->nh, TAG_END()); /* Queued until nua_authenticate */
-  run_ab_until(ctx, -1, reject_reinvite_401, -1, until_final_response);
+  run_ab_until(ctx, -1, reject_reinvite_401, -1, save_until_final_response);
 
   TEST_1(nua_handle_has_active_call(a_call->nh));
   TEST_1(nua_handle_has_active_call(b_call->nh));
index ec7700975c82f1cb10c25fb677dd82fee14e01b7..80d3f30c4113af36572a874f972d03532e0afd5d 100644 (file)
@@ -55,7 +55,9 @@ int until_final_response(CONDITION_PARAMS)
 int save_until_final_response(CONDITION_PARAMS)
 {
   save_event_in_list(ctx, event, ep, call);
-  return event >= nua_r_set_params && status >= 200;
+  return
+    nua_r_set_params <= event && event < nua_i_network_changed
+    && status >= 200;
 }
 
 /** Save events.
index 7fdb2dfa0f54c573938dd5986ab446a02478c123..53bec31325b4eeea8014f9c80d6856c4083f401b 100644 (file)
@@ -460,7 +460,7 @@ static int test_sanity(void)
 
   su_home_check(home); TEST_1(home);
 
-  TEST_1((parser = sdp_parse(home, s3_msg, sizeof(s1_msg), 0)));
+  TEST_1((parser = sdp_parse(home, s3_msg, sizeof(s3_msg) - 1, 0)));
   
   TEST_1(sdp_sanity_check(parser) == 0);
 
@@ -469,6 +469,52 @@ static int test_sanity(void)
   END();
 }
 
+static char const pint_msg[] = 
+  "v=0\r\n"
+  "o=- 2353687640 2353687640 IN IP4 128.3.4.5\r\n"
+  "s=marketing\r\n"
+  "e=john.jones.3@chinet.net\r\n"
+  "c= TN RFC2543  +1-201-406-4090\r\n"
+  "t=2353687640 0\r\n"
+  "m=audio 1 voice -\r\n"
+  ;
+
+static char const pint_torture_msg[] = 
+  "v=0\r\n"
+  "o=- 2353687640 2353687640 IN IP4 128.3.4.5\r\n"
+  "s=marketing\r\n"
+
+  "c= TN RFC2543 123\r\n"
+  "a=phone-context:+97252\r\n"
+  "t=2353687640 0\r\n"
+  "m= text 1  fax plain\r\n"
+  "a=fmtp:plain  spr:fi6MeoclEjaF3EDfYHlkqx1zn8A1lMoiJFUHpQ5Xo\r\n"
+  ;
+
+static int test_pint(void)
+{
+  su_home_t *home = su_home_create();
+  sdp_parser_t *parser;
+  sdp_session_t *sdp;
+
+  BEGIN();
+
+  su_home_check(home); TEST_1(home);
+
+  TEST_1((parser = sdp_parse(home, pint_msg, sizeof(pint_msg) - 1, sdp_f_anynet)));
+  TEST_1((sdp = sdp_session(parser)));
+
+  TEST_1((parser = sdp_parse(home, pint_torture_msg, sizeof(pint_torture_msg) - 1,
+                            sdp_f_anynet)));
+  TEST_1((sdp = sdp_session(parser)));
+  
+  su_home_check(home);
+  su_home_unref(home);
+
+  END();
+}
+
+
 static sdp_list_t const l0[1] = {{ sizeof(l0), NULL, "foo" }};
 static sdp_list_t const l1[1] = {{ sizeof(l1), (sdp_list_t *)l0, "bar" }};
 
@@ -873,6 +919,7 @@ int main(int argc, char *argv[])
   retval |= test_error(); fflush(stdout);
   retval |= test_session(); fflush(stdout);
   retval |= test_session2(); fflush(stdout);
+  retval |= test_pint(); fflush(stdout);
   retval |= test_sanity(); fflush(stdout);
   retval |= test_list(); fflush(stdout);
   retval |= test_rtpmap(); fflush(stdout);
index 4fa928283642d721bfc12ba945df5234db59cb9c..7a5aeb78de55d80c0544eb57dbf216b0be5afd1f 100755 (executable)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # Run the parser tests
 #
index 43a52d4354a1a82a8dd13a0acb7ca547302ce58a..e36ae345427d044ed5a2995fc194a8a4f38bd53d 100644 (file)
@@ -44,6 +44,8 @@
 #include <sofia-sip/sip_util.h>
 #include <sofia-sip/sip_status.h>
 
+static double parse_number(char const *str, char **return_end);
+
 /** Parse a single preference */
 int sip_prefs_parse(union sip_pref *sp, 
                    char const **in_out_s, 
@@ -107,16 +109,16 @@ int sip_prefs_parse(union sip_pref *sp,
     s0 = s[0];
 
     if (s0 == '=')
-      sp->sp_type = sp_range, n1 = n2 = strtod(s = s + 1, &e);
+      sp->sp_type = sp_range, n1 = n2 = parse_number(s = s + 1, &e);
     else if (s0 == '<' && s[1] == '=')
-      sp->sp_type = sp_range, n1 = DBL_MIN, n2 = strtod(s = s + 2, &e);
+      sp->sp_type = sp_range, n1 = -DBL_MAX, n2 = parse_number(s = s + 2, &e);
     else if (s0 == '>' && s[1] == '=')
-      sp->sp_type = sp_range, n1 = strtod(s = s + 2, &e), n2 = DBL_MAX;
-    else if (((n1 = strtod(s, &e)) != 0.0 || s != e) && e[0] == ':')
-      sp->sp_type = sp_range, n2 = strtod(s = e + 1, &e);
+      sp->sp_type = sp_range, n1 = parse_number(s = s + 2, &e), n2 = DBL_MAX;
+    else if (((n1 = parse_number(s, &e)) != 0.0 || s != e) && e[0] == ':')
+      sp->sp_type = sp_range, n2 = parse_number(s = e + 1, &e);
     else
       /* Error in conversion */
-      sp->sp_type = sp_error, n1 = DBL_MAX, n2 = DBL_MIN;
+      sp->sp_type = sp_error, n1 = DBL_MAX, n2 = -DBL_MAX;
 
     if (s == e && (n1 == 0.0 || n2 == 0.0))
       sp->sp_type = sp_error;      /* Error in conversion */
@@ -155,6 +157,46 @@ int sip_prefs_parse(union sip_pref *sp,
   return sp->sp_type != sp_error;
 }
 
+/** Parse number:
+ * number          =  [ "+" / "-" ] 1*DIGIT ["." 0*DIGIT]
+ */
+static double parse_number(char const *str, char **return_end)
+{
+  double value = 0.0;
+  double decimal = 0.1;
+  char d, sign = '+';
+
+  if (return_end)
+    *return_end = (char *)str;
+
+  d = *str;
+
+  if (d == '+' || d == '-')
+    sign = d, d = *++str;
+
+  if (!('0' <= d && d <= '9'))
+    return value;
+
+  for (; '0' <= d && d <= '9'; d = *++str)
+    value = value * 10 + (d - '0');
+
+  if (d == '.') for (d = *++str; '0' <= d && d <= '9'; d = *++str) {
+    value += (d - '0') * decimal; decimal *= 0.1;
+  }
+
+  if (value > DBL_MAX)
+    value = DBL_MAX;
+
+  if (sign == '-')
+    value = -value;
+
+  if (return_end)
+    *return_end = (char *)str;
+
+  return value;
+}
+
+
 /** Return true if preferences match */
 int sip_prefs_match(union sip_pref const *a, 
                    union sip_pref const *b)
index ccdd72fc4d0a8198bd792360975b5d0791c7ad36..f43c9f49a149ee623e4ac6eb2a527819ecb6e42b 100644 (file)
@@ -149,8 +149,8 @@ union sip_pref
    */
   struct sp_range {
     enum sp_type spr_type;
-    double spr_lower;
-    double spr_upper;
+    double spr_lower;          /**< Lower limit. Lowest value is -DBL_MAX. */
+    double spr_upper;          /**< Upper limit. Highest value is DBL_MAX. */
   } sp_range;
 };
 
index 6c8c568c0a5f3b234468cb6b73affa6bacde25e1..a173c11d12016f20288b8b03a4edaa3a48ab23ed 100644 (file)
@@ -2535,6 +2535,7 @@ int test_request_disposition(void)
 }
 
 #include <float.h>
+#include <math.h>
 
 int test_caller_prefs(void)
 {
@@ -2650,7 +2651,7 @@ int test_caller_prefs(void)
     
   TEST_1(sip_prefs_parse(sp, &s, &negate));
   TEST(sp->sp_type, sp_range);
-  TEST_D(sp->sp_range.spr_lower, DBL_MIN);
+  TEST_D(sp->sp_range.spr_lower, -DBL_MAX);
   TEST_D(sp->sp_range.spr_upper, 3.0);
   TEST_1(sip_prefs_match(sp, sp));
   TEST_1(!negate);
@@ -2668,7 +2669,7 @@ int test_caller_prefs(void)
 
   TEST_1(sip_prefs_parse(sp, &s, &negate));
   TEST(sp->sp_type, sp_range);
-  TEST_D(sp->sp_range.spr_lower, DBL_MIN);
+  TEST_D(sp->sp_range.spr_lower, -DBL_MAX);
   TEST_D(sp->sp_range.spr_upper, 6.0);
   TEST_1(sip_prefs_match(sp, sp));
   TEST_1(negate);
@@ -2687,6 +2688,46 @@ int test_caller_prefs(void)
   TEST_1(!sip_prefs_parse(sp, &s, &negate));
   TEST(sp->sp_type, sp_init);
 
+  /* Numeric */
+  s = "\" !#="
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111."
+
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111"
+    "1111111111111111111111111111111111111111,"
+    " #<=-16"
+    "\"";
+
+  negate = 0; memset(sp, 0, sizeof sp);
+
+  TEST_1(sip_prefs_parse(sp, &s, &negate));
+  TEST(sp->sp_type, sp_range);
+  TEST_D(sp->sp_range.spr_lower, DBL_MAX);
+  TEST_D(sp->sp_range.spr_upper, DBL_MAX);
+  TEST_1(sip_prefs_match(sp, sp));
+  TEST_1(negate);
+
+  TEST_1(sip_prefs_parse(sp, &s, &negate));
+  TEST(sp->sp_type, sp_range);
+  TEST_D(sp->sp_range.spr_lower, -DBL_MAX);
+  TEST_D(sp->sp_range.spr_upper, -16.0);
+  TEST_1(sip_prefs_match(sp, sp));
+  TEST_1(!negate);
+
   error = 12;
 
   TEST_1(sip_prefs_matching("\"INVITE,MESSAGE,SUBSCRIBE\"", 
index 26a1832aa0a830636795e5ae7130a5149a527d6e..88f7b0480cfbc21909ed78392693c7c497a8538e 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 #
 # Run sresolv_test using our own name server
 #
index f5b05de0c95cd6cd517e6d1031bff6a31ed1fe5d..35cb458b4249bdb2a02a7bd6d8b144d422b7d406 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 
 rc=0
 
index be0d8b59e3c7ad3064544bfba1b438a99703266a..3fa41f5da32a8632728cbbf86504dd89de9f6db7 100644 (file)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /bin/sh
 
 rc=0