merge latest darcs changes from sofia-sip.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4963 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2007-04-17 13:43:45 +00:00
parent cf3c9b8889
commit 4ad763132d
11 changed files with 152 additions and 20 deletions

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
#
# Run test_nta_api
#

View 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));

View 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.

View 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);

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
#
# Run the parser tests
#

View 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)

View 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;
};

View 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\"",

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
#
# Run sresolv_test using our own name server
#

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
rc=0

View File

@ -1,4 +1,4 @@
#! /bin/bash
#! /bin/sh
rc=0