This repository has been archived by the owner on Feb 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
set sdp laddr to SIP src address (#34)
* sipsess: use new sipsess_connect() interface with sipsess_desc_h * sipsess: check if answer handler was called and not offer handler
- Loading branch information
Showing
1 changed file
with
66 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,11 @@ struct test { | |
struct sipsess *b; | ||
bool estab_a; | ||
bool estab_b; | ||
bool answr_a; | ||
bool answr_b; | ||
bool offer_a; | ||
bool offer_b; | ||
struct mbuf *desc; | ||
bool blind_transfer; | ||
uint16_t altaddr_port; | ||
int err; | ||
|
@@ -46,20 +51,62 @@ static void exit_handler(void *arg) | |
} | ||
|
||
|
||
static int offer_handler(struct mbuf **descp, const struct sip_msg *msg, | ||
void *arg) | ||
static int desc_handler(struct mbuf **descp, const struct sa *src, | ||
const struct sa *dst, void *arg) | ||
{ | ||
struct test *test = arg; | ||
(void)src; | ||
(void)dst; | ||
|
||
test->desc = mbuf_alloc(1); | ||
if (!test->desc) | ||
return ENOMEM; | ||
|
||
*descp = test->desc; | ||
return 0; | ||
} | ||
|
||
|
||
static int offer_handler_a(struct mbuf **descp, const struct sip_msg *msg, | ||
void *arg) | ||
{ | ||
struct test *test = arg; | ||
(void)descp; | ||
(void)msg; | ||
(void)arg; | ||
|
||
test->offer_a = true; | ||
return 0; | ||
} | ||
|
||
|
||
static int answer_handler(const struct sip_msg *msg, void *arg) | ||
static int offer_handler_b(struct mbuf **descp, const struct sip_msg *msg, | ||
void *arg) | ||
{ | ||
struct test *test = arg; | ||
(void)descp; | ||
(void)msg; | ||
(void)arg; | ||
|
||
test->offer_b = true; | ||
return 0; | ||
} | ||
|
||
|
||
static int answer_handler_a(const struct sip_msg *msg, void *arg) | ||
{ | ||
struct test *test = arg; | ||
(void)msg; | ||
|
||
test->answr_a = true; | ||
return 0; | ||
} | ||
|
||
|
||
static int answer_handler_b(const struct sip_msg *msg, void *arg) | ||
{ | ||
struct test *test = arg; | ||
(void)msg; | ||
|
||
test->answr_b = true; | ||
return 0; | ||
} | ||
|
||
|
@@ -111,7 +158,8 @@ static void conn_handler(const struct sip_msg *msg, void *arg) | |
|
||
err = sipsess_accept(&test->b, test->sock, msg, 200, "OK", | ||
"b", "application/sdp", NULL, NULL, NULL, false, | ||
offer_handler, answer_handler, estab_handler_b, | ||
offer_handler_b, answer_handler_b, | ||
estab_handler_b, | ||
NULL, NULL, close_handler, test, NULL); | ||
if (err) { | ||
abort_test(test, err); | ||
|
@@ -196,9 +244,9 @@ int test_sipsess(void) | |
(void)re_snprintf(to_uri, sizeof(to_uri), "sip:[email protected]:%u", port); | ||
err = sipsess_connect(&test.a, test.sock, to_uri, NULL, | ||
"sip:[email protected]", "a", NULL, 0, | ||
"application/sdp", NULL, NULL, NULL, false, | ||
callid, | ||
offer_handler, answer_handler, NULL, | ||
"application/sdp", NULL, NULL, false, | ||
callid, desc_handler, | ||
offer_handler_a, answer_handler_a, NULL, | ||
estab_handler_a, NULL, NULL, | ||
close_handler, &test, NULL); | ||
mem_deref(callid); | ||
|
@@ -217,6 +265,9 @@ int test_sipsess(void) | |
/* okay here -- verify */ | ||
TEST_ASSERT(test.estab_a); | ||
TEST_ASSERT(test.estab_b); | ||
TEST_ASSERT(test.desc); | ||
TEST_ASSERT(test.answr_a); | ||
TEST_ASSERT(!test.offer_b); | ||
|
||
out: | ||
test.a = mem_deref(test.a); | ||
|
@@ -282,9 +333,9 @@ int test_sipsess_blind_transfer(void) | |
(void)re_snprintf(to_uri, sizeof(to_uri), "sip:[email protected]:%u", port); | ||
err = sipsess_connect(&test.a, test.sock, to_uri, NULL, | ||
"sip:[email protected]", "a", NULL, 0, | ||
"application/sdp", NULL, NULL, NULL, false, | ||
callid, | ||
offer_handler, answer_handler, NULL, | ||
"application/sdp", NULL, NULL, false, | ||
callid, desc_handler, | ||
offer_handler_a, answer_handler_a, NULL, | ||
estab_handler_a, NULL, NULL, | ||
close_handler, &test, NULL); | ||
mem_deref(callid); | ||
|
@@ -305,6 +356,9 @@ int test_sipsess_blind_transfer(void) | |
TEST_ASSERT(test.blind_transfer); | ||
TEST_ASSERT(test.estab_a); | ||
TEST_ASSERT(test.estab_b); | ||
TEST_ASSERT(test.desc); | ||
TEST_ASSERT(test.answr_a); | ||
TEST_ASSERT(!test.offer_b); | ||
|
||
out: | ||
test.a = mem_deref(test.a); | ||
|