mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 12:40:17 +00:00
Tue Mar 3 12:15:01 CST 2009 Pekka Pessi <first.last@nokia.com>
* nua: check_nua now uses s2base.h and s2sip.h git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12398 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
76f57d02bb
commit
522b3c4858
@ -1 +1 @@
|
||||
Tue Mar 3 15:59:49 CST 2009
|
||||
Tue Mar 3 16:00:35 CST 2009
|
||||
|
@ -55,8 +55,6 @@ check_nua_SOURCES = check_nua.c check_nua.h \
|
||||
check_nua_LDADD = $(nua_libs) ${top_builddir}/s2check/libs2.a \
|
||||
@CHECK_LIBS@
|
||||
|
||||
check_nua_CFLAGS = $(CFLAGS) -I$(top_srcdir)/s2check
|
||||
|
||||
nua_libs = libnua.la \
|
||||
../iptsec/libiptsec.la \
|
||||
../ipt/libipt.la \
|
||||
@ -84,6 +82,6 @@ EXTRA_DIST = nua.docs $(BUILT_SOURCES)
|
||||
|
||||
include $(top_srcdir)/rules/sofia.am
|
||||
|
||||
INCLUDES = ${INTERNAL_INCLUDES}
|
||||
INCLUDES = ${INTERNAL_INCLUDES} -I$(top_srcdir)/s2check
|
||||
|
||||
TAG_DLL_FLAGS = LIST=nua_tag_list
|
||||
|
@ -71,7 +71,7 @@ static void etsi_setup(void)
|
||||
NUTAG_OUTBOUND("no-options-keepalive, no-validate"),
|
||||
TAG_END());
|
||||
|
||||
soa = soa_create(NULL, s2->root, NULL);
|
||||
soa = soa_create(NULL, s2base->root, NULL);
|
||||
|
||||
fail_if(!soa);
|
||||
|
||||
@ -148,7 +148,7 @@ respond_with_sdp(struct message *request,
|
||||
fail_if(soa_get_local_sdp(soa, NULL, &body, &bodylen) != 1);
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
s2_respond_to(request, dialog, status, phrase,
|
||||
s2_sip_respond_to(request, dialog, status, phrase,
|
||||
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
|
||||
SIPTAG_PAYLOAD_STR(body),
|
||||
SIPTAG_CONTENT_DISPOSITION_STR("session"),
|
||||
@ -168,7 +168,7 @@ invite_sent_by_nua(nua_handle_t *nh,
|
||||
|
||||
fail_unless(s2_check_callstate(nua_callstate_calling));
|
||||
|
||||
return s2_wait_for_request(SIP_METHOD_INVITE);
|
||||
return s2_sip_wait_for_request(SIP_METHOD_INVITE);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -182,10 +182,10 @@ bye_by_nua(struct dialog *dialog, nua_handle_t *nh,
|
||||
nua_bye(nh, ta_tags(ta));
|
||||
ta_end(ta);
|
||||
|
||||
bye = s2_wait_for_request(SIP_METHOD_BYE);
|
||||
bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
|
||||
fail_if(!bye);
|
||||
s2_respond_to(bye, dialog, SIP_200_OK, TAG_END());
|
||||
s2_free_message(bye);
|
||||
s2_sip_respond_to(bye, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_free_message(bye);
|
||||
fail_unless(s2_check_event(nua_r_bye, 200));
|
||||
fail_unless(s2_check_callstate(nua_callstate_terminated));
|
||||
}
|
||||
@ -208,7 +208,7 @@ START_TEST(SIP_CC_OE_CE_V_019)
|
||||
"sends an ACK request with a To header identical to the "
|
||||
"received one for each received Success (200 OK) responses.");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
|
||||
invite = invite_sent_by_nua(nh, TAG_END());
|
||||
|
||||
@ -218,17 +218,17 @@ START_TEST(SIP_CC_OE_CE_V_019)
|
||||
|
||||
fail_unless(s2_check_event(nua_r_invite, 200));
|
||||
fail_unless(s2_check_callstate(nua_callstate_ready));
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
respond_with_sdp(invite, d2, SIP_200_OK, TAG_END());
|
||||
s2_free_message(invite);
|
||||
s2_sip_free_message(invite);
|
||||
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
bye = s2_wait_for_request(SIP_METHOD_BYE);
|
||||
bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
|
||||
fail_if(!bye);
|
||||
s2_respond_to(bye, d2, SIP_200_OK, TAG_END());
|
||||
s2_free_message(bye);
|
||||
s2_sip_respond_to(bye, d2, SIP_200_OK, TAG_END());
|
||||
s2_sip_free_message(bye);
|
||||
|
||||
bye_by_nua(d1, nh, TAG_END());
|
||||
|
||||
@ -248,39 +248,39 @@ START_TEST(SIP_CC_OE_CE_TI_008)
|
||||
"that matches the transaction, still answer with an "
|
||||
"ACK request until timer D set to at least 32 second expires.");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
|
||||
invite = invite_sent_by_nua(nh, TAG_END());
|
||||
|
||||
s2_respond_to(invite, d1, 404, "First not found", TAG_END());
|
||||
s2_sip_respond_to(invite, d1, 404, "First not found", TAG_END());
|
||||
fail_unless(s2_check_event(nua_r_invite, 404));
|
||||
fail_unless(s2_check_callstate(nua_callstate_terminated));
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
|
||||
s2_respond_to(invite, d1, 404, "Not found after 5 seconds", TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
s2_sip_respond_to(invite, d1, 404, "Not found after 5 seconds", TAG_END());
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
|
||||
s2_respond_to(invite, d1, 404, "Not found after 10 seconds", TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
s2_sip_respond_to(invite, d1, 404, "Not found after 10 seconds", TAG_END());
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(21, s2->root);
|
||||
s2_nua_fast_forward(21, s2base->root);
|
||||
|
||||
s2_respond_to(invite, d1, 404, "Not found after 31 seconds", TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
s2_sip_respond_to(invite, d1, 404, "Not found after 31 seconds", TAG_END());
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
|
||||
/* Wake up nua thread and let it time out INVITE transaction */
|
||||
nua_set_params(s2->nua, TAG_END());
|
||||
s2_check_event(nua_r_set_params, 0);
|
||||
|
||||
s2_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END());
|
||||
s2_free_message(invite);
|
||||
fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500));
|
||||
s2_sip_respond_to(invite, d1, 404, "Not found after 32 seconds", TAG_END());
|
||||
s2_sip_free_message(invite);
|
||||
fail_if(s2_sip_check_request_timeout(SIP_METHOD_ACK, 3));
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
@ -299,7 +299,7 @@ START_TEST(SIP_CC_OE_CE_TI_011_012)
|
||||
"on receipt of a retransmitted Success (200 OK) "
|
||||
"responses does not send an ACK request.");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
|
||||
invite = invite_sent_by_nua(nh, TAG_END());
|
||||
|
||||
@ -309,29 +309,29 @@ START_TEST(SIP_CC_OE_CE_TI_011_012)
|
||||
|
||||
fail_unless(s2_check_event(nua_r_invite, 200));
|
||||
fail_unless(s2_check_callstate(nua_callstate_ready));
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(21, s2->root);
|
||||
s2_nua_fast_forward(20, s2base->root);
|
||||
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
|
||||
fail_unless(s2_check_request(SIP_METHOD_ACK));
|
||||
fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
/* Stack times out the INVITE transaction */
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
|
||||
/* Wake up nua thread and let it time out INVITE transaction */
|
||||
nua_set_params(s2->nua, TAG_END());
|
||||
s2_check_event(nua_r_set_params, 0);
|
||||
|
||||
respond_with_sdp(invite, d1, SIP_200_OK, TAG_END());
|
||||
s2_free_message(invite);
|
||||
fail_if(s2_check_request_timeout(SIP_METHOD_ACK, 500));
|
||||
respond_with_sdp(invite, d1, SIP_200_OK,
|
||||
SIPTAG_SUBJECT_STR("Stray 200 OK"),
|
||||
TAG_END());
|
||||
s2_sip_free_message(invite);
|
||||
mark_point();
|
||||
fail_if(s2_sip_check_request_timeout(SIP_METHOD_ACK, 3));
|
||||
|
||||
bye_by_nua(d1, nh, TAG_END());
|
||||
|
||||
|
@ -33,6 +33,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "test_s2.h"
|
||||
#include "check_nua.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
@ -43,8 +44,6 @@
|
||||
#include <fnmatch.h>
|
||||
#endif
|
||||
|
||||
#include "test_s2.h"
|
||||
|
||||
static void usage(int exitcode)
|
||||
{
|
||||
fprintf(exitcode ? stderr : stdout,
|
||||
@ -62,6 +61,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
s2_tester = "check_nua";
|
||||
|
||||
s2_suite("N2");
|
||||
|
||||
if (getenv("CHECK_NUA_VERBOSE"))
|
||||
s2_start_stop = strtoul(getenv("CHECK_NUA_VERBOSE"), NULL, 10);
|
||||
|
||||
|
@ -75,7 +75,7 @@ static void pingpong_setup(void)
|
||||
TPTAG_PINGPONG(20000),
|
||||
TPTAG_KEEPALIVE(10000),
|
||||
TAG_END());
|
||||
tport_set_params(s2->tcp.tport, TPTAG_PONG2PING(1), TAG_END());
|
||||
tport_set_params(s2sip->tcp.tport, TPTAG_PONG2PING(1), TAG_END());
|
||||
}
|
||||
|
||||
static void pingpong_thread_setup(void)
|
||||
@ -121,12 +121,12 @@ START_TEST(register_1_0_1)
|
||||
|
||||
nua_register(nh, TAG_END());
|
||||
|
||||
fail_unless((m = s2_wait_for_request(SIP_METHOD_REGISTER)) != NULL, NULL);
|
||||
fail_unless((m = s2_sip_wait_for_request(SIP_METHOD_REGISTER)) != NULL, NULL);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_403_FORBIDDEN,
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
|
||||
@ -156,38 +156,38 @@ START_TEST(register_1_1_2)
|
||||
|
||||
nua_register(nh, TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_respond_to(m, NULL,
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_407_PROXY_AUTH_REQUIRED,
|
||||
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
s2_check_event(nua_r_register, 407);
|
||||
|
||||
nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_respond_to(m, NULL,
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_401_UNAUTHORIZED,
|
||||
SIPTAG_WWW_AUTHENTICATE_STR(s2_auth2_digest_str),
|
||||
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
s2_check_event(nua_r_register, 401);
|
||||
|
||||
nua_authenticate(nh, NUTAG_AUTH(s2_auth2_credentials), TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_authorization);
|
||||
fail_if(!m->sip->sip_proxy_authorization);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
assert(s2->registration->contact != NULL);
|
||||
s2_check_event(nua_r_register, 200);
|
||||
@ -237,32 +237,32 @@ START_TEST(register_1_2_1) {
|
||||
|
||||
nua_register(nh, TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
assert(s2->registration->contact != NULL);
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
fail_unless(s2->registration->contact != NULL);
|
||||
fail_if(s2->registration->contact->m_next != NULL);
|
||||
@ -286,19 +286,19 @@ static nua_handle_t *make_auth_natted_register(
|
||||
nua_register(nh, ta_tags(ta));
|
||||
ta_end(ta);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_respond_to(m, NULL,
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_401_UNAUTHORIZED,
|
||||
SIPTAG_WWW_AUTHENTICATE_STR(s2_auth_digest_str),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 401);
|
||||
|
||||
nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_authorization);
|
||||
/* should not unregister the previous contact
|
||||
@ -307,12 +307,12 @@ static nua_handle_t *make_auth_natted_register(
|
||||
fail_if(m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
assert(s2->registration->contact != NULL);
|
||||
s2_check_event(nua_r_register, 200);
|
||||
@ -350,61 +350,61 @@ START_TEST(register_1_2_2_2)
|
||||
|
||||
mark_point();
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
fail_if(!m);
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_407_PROXY_AUTH_REQUIRED,
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
mark_point();
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
fail_if(!m); fail_if(!m->sip->sip_proxy_authorization);
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
su_root_step(s2->root, 20); su_root_step(s2->root, 20);
|
||||
s2_fast_forward(120, s2->root); /* Default keepalive interval */
|
||||
su_root_step(s2base->root, 20); su_root_step(s2base->root, 20);
|
||||
s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */
|
||||
mark_point();
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
s2_respond_to(m, NULL,
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
su_root_step(s2->root, 20); su_root_step(s2->root, 20);
|
||||
s2_fast_forward(120, s2->root); /* Default keepalive interval */
|
||||
su_root_step(s2base->root, 20); su_root_step(s2base->root, 20);
|
||||
s2_nua_fast_forward(120, s2base->root); /* Default keepalive interval */
|
||||
mark_point();
|
||||
|
||||
receive_natted = "received=4.255.255.10";
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
s2_respond_to(m, NULL,
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_OPTIONS);
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_i_outbound, 0);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 200);
|
||||
|
||||
@ -434,33 +434,33 @@ START_TEST(register_1_2_2_3)
|
||||
|
||||
receive_natted = "received=4.255.255.10";
|
||||
|
||||
s2_fast_forward(3600, s2->root);
|
||||
s2_nua_fast_forward(3600, s2base->root);
|
||||
mark_point();
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
fail_unless(s2->registration->contact != NULL);
|
||||
fail_if(s2->registration->contact->m_next != NULL);
|
||||
@ -484,28 +484,28 @@ START_TEST(register_1_2_3) {
|
||||
|
||||
mark_point();
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
400, "Bad Contact",
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
fail_unless(s2->registration->contact != NULL);
|
||||
fail_if(s2->registration->contact->m_next != NULL);
|
||||
@ -530,34 +530,34 @@ START_TEST(register_1_3_1)
|
||||
|
||||
nh = nua_handle(nua, NULL, TAG_END());
|
||||
|
||||
nua_register(nh, NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END());
|
||||
nua_register(nh, NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END());
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_contact || m->sip->sip_contact->m_next);
|
||||
fail_if(!tport_is_tcp(m->tport));
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
assert(s2->registration->contact != NULL);
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
fail_unless(s2->registration->contact != NULL);
|
||||
fail_if(s2->registration->contact->m_next != NULL);
|
||||
@ -581,7 +581,7 @@ START_TEST(register_1_3_2_1)
|
||||
|
||||
mark_point();
|
||||
s2->registration->nh = nh;
|
||||
make_auth_natted_register(nh, NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END());
|
||||
make_auth_natted_register(nh, NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END());
|
||||
fail_if(!tport_is_tcp(s2->registration->tport));
|
||||
s2_register_teardown();
|
||||
}
|
||||
@ -604,38 +604,38 @@ START_TEST(register_1_3_2_2)
|
||||
mark_point();
|
||||
s2->registration->nh = nh;
|
||||
make_auth_natted_register(
|
||||
nh, NUTAG_PROXY(s2->tcp.contact->m_url),
|
||||
nh, NUTAG_PROXY(s2sip->tcp.contact->m_url),
|
||||
NUTAG_OUTBOUND("no-options-keepalive, no-validate"),
|
||||
TAG_END());
|
||||
fail_if(!tport_is_tcp(s2->registration->tport));
|
||||
tport_shutdown(s2->registration->tport, 2);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
/* The "NAT binding" changed when new TCP connection is established */
|
||||
/* => NUA re-REGISTERs with newly detected contact */
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 200);
|
||||
|
||||
@ -667,22 +667,22 @@ START_TEST(register_1_3_3_1)
|
||||
|
||||
/* NTA tries with UDP, we drop them */
|
||||
for (;;) {
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); fail_if(!m);
|
||||
if (!tport_is_udp(m->tport)) /* Drop UDP */
|
||||
break;
|
||||
s2_free_message(m);
|
||||
s2_fast_forward(4, s2->root);
|
||||
s2_sip_free_message(m);
|
||||
s2_nua_fast_forward(4, s2base->root);
|
||||
}
|
||||
|
||||
tcp = tport_ref(m->tport);
|
||||
|
||||
/* Respond to request over TCP */
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_401_UNAUTHORIZED,
|
||||
SIPTAG_WWW_AUTHENTICATE_STR(s2_auth_digest_str),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
s2_check_event(nua_r_register, 401);
|
||||
nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END());
|
||||
|
||||
@ -690,32 +690,32 @@ START_TEST(register_1_3_3_1)
|
||||
tport_set_params(tcp, TPTAG_PONG2PING(0), TAG_END());
|
||||
|
||||
/* Now request over UDP ... registering TCP contact! */
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
s2_save_register(m);
|
||||
fail_unless(
|
||||
url_has_param(s2->registration->contact->m_url, "transport=tcp"));
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
/* NUA detects oops... re-registers UDP */
|
||||
s2_check_event(nua_r_register, 100);
|
||||
|
||||
m = s2_wait_for_request(SIP_METHOD_REGISTER);
|
||||
m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
|
||||
fail_if(!m); fail_if(!m->sip->sip_authorization);
|
||||
fail_if(!m->sip->sip_contact || !m->sip->sip_contact->m_next);
|
||||
s2_save_register(m);
|
||||
|
||||
s2_respond_to(m, NULL,
|
||||
s2_sip_respond_to(m, NULL,
|
||||
SIP_200_OK,
|
||||
SIPTAG_CONTACT(s2->registration->contact),
|
||||
SIPTAG_VIA(natted_via(m)),
|
||||
TAG_END());
|
||||
s2_free_message(m);
|
||||
s2_sip_free_message(m);
|
||||
|
||||
s2_check_event(nua_r_register, 200);
|
||||
|
||||
@ -726,10 +726,10 @@ START_TEST(register_1_3_3_1)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 5; i++) {
|
||||
su_root_step(s2->root, 5);
|
||||
su_root_step(s2->root, 5);
|
||||
su_root_step(s2->root, 5);
|
||||
s2_fast_forward(5, s2->root);
|
||||
su_root_step(s2base->root, 5);
|
||||
su_root_step(s2base->root, 5);
|
||||
su_root_step(s2base->root, 5);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
}
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -56,7 +56,6 @@
|
||||
/* ====================================================================== */
|
||||
|
||||
static nua_t *nua;
|
||||
static soa_session_t *soa = NULL;
|
||||
static struct dialog *dialog = NULL;
|
||||
|
||||
#define CRLF "\r\n"
|
||||
@ -138,7 +137,7 @@ respond_to_subscribe(struct message *subscribe,
|
||||
ta_list ta;
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
s2_respond_to(subscribe, dialog, status, phrase,
|
||||
s2_sip_respond_to(subscribe, dialog, status, phrase,
|
||||
ta_tags(ta));
|
||||
ta_end(ta);
|
||||
|
||||
@ -156,15 +155,15 @@ notify_to_nua(enum nua_substate expect_substate,
|
||||
ta_list ta;
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
SIPTAG_CONTENT_TYPE_STR(event_mime_type),
|
||||
SIPTAG_PAYLOAD_STR(event_state),
|
||||
ta_tags(ta)));
|
||||
ta_end(ta);
|
||||
|
||||
response = s2_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
fail_if(!response);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, expect_substate));
|
||||
@ -186,7 +185,7 @@ subscription_by_nua(nua_handle_t *nh,
|
||||
char const *substate_str = subscription_state;
|
||||
char const *expires = "600";
|
||||
|
||||
subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
if (event_type)
|
||||
fail_if(!subscribe->sip->sip_event ||
|
||||
strcmp(event_type, subscribe->sip->sip_event->o_type));
|
||||
@ -200,7 +199,7 @@ subscription_by_nua(nua_handle_t *nh,
|
||||
ta_start(ta, tag, value);
|
||||
|
||||
if (send_notify_before_response) {
|
||||
s2_save_uas_dialog(dialog, subscribe->sip);
|
||||
s2_sip_save_uas_dialog(dialog, subscribe->sip);
|
||||
notify = notify_to_nua(substate,
|
||||
SIPTAG_EVENT(subscribe->sip->sip_event),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR(substate_str),
|
||||
@ -223,7 +222,7 @@ subscription_by_nua(nua_handle_t *nh,
|
||||
ta_tags(ta));
|
||||
}
|
||||
|
||||
s2_free_message(subscribe);
|
||||
s2_sip_free_message(subscribe);
|
||||
|
||||
return notify;
|
||||
}
|
||||
@ -235,15 +234,15 @@ unsubscribe_by_nua(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
|
||||
struct event *event;
|
||||
|
||||
nua_unsubscribe(nh, TAG_END());
|
||||
subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
|
||||
s2_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
s2_sip_respond_to(subscribe, dialog, SIP_200_OK, SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
|
||||
event = s2_wait_for_event(nua_r_unsubscribe, 200); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_active));
|
||||
s2_free_event(event);
|
||||
|
||||
fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
SIPTAG_EVENT(subscribe->sip->sip_event),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=tiemout"),
|
||||
SIPTAG_CONTENT_TYPE_STR(event_mime_type),
|
||||
@ -254,9 +253,9 @@ unsubscribe_by_nua(nua_handle_t *nh, tag_type_t tag, tag_value_t value, ...)
|
||||
fail_unless(s2_check_substate(event, nua_substate_terminated));
|
||||
s2_free_event(event);
|
||||
|
||||
response = s2_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
fail_if(!response);
|
||||
s2_free_message(response); s2_free_message(subscribe);
|
||||
s2_sip_free_message(response); s2_sip_free_message(subscribe);
|
||||
}
|
||||
|
||||
/* ====================================================================== */
|
||||
@ -269,7 +268,7 @@ START_TEST(subscribe_6_1_1)
|
||||
s2_case("6.1.1", "Basic subscription",
|
||||
"NUA sends SUBSCRIBE, waits for NOTIFY, sends un-SUBSCRIBE");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_free_event(notify);
|
||||
@ -291,15 +290,15 @@ START_TEST(subscribe_6_1_2)
|
||||
|
||||
send_notify_before_response = 1;
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_free_event(notify);
|
||||
|
||||
/* Wait for refresh */
|
||||
s2_fast_forward(600, s2->root);
|
||||
subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
s2_respond_to(subscribe, dialog, SIP_200_OK,
|
||||
s2_nua_fast_forward(600, s2base->root);
|
||||
subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_respond_to(subscribe, dialog, SIP_200_OK,
|
||||
SIPTAG_EXPIRES_STR("600"),
|
||||
TAG_END());
|
||||
|
||||
@ -307,7 +306,7 @@ START_TEST(subscribe_6_1_2)
|
||||
fail_unless(s2_check_substate(event, nua_substate_active));
|
||||
s2_free_event(event);
|
||||
|
||||
fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
SIPTAG_EVENT(subscribe->sip->sip_event),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=600"),
|
||||
SIPTAG_CONTENT_TYPE_STR(event_mime_type),
|
||||
@ -316,9 +315,9 @@ START_TEST(subscribe_6_1_2)
|
||||
event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_active));
|
||||
s2_free_event(event);
|
||||
response = s2_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
fail_if(!response);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
unsubscribe_by_nua(nh, TAG_END());
|
||||
|
||||
@ -336,21 +335,21 @@ START_TEST(subscribe_6_1_3)
|
||||
"NUA sends SUBSCRIBE, waits for NOTIFY, "
|
||||
"gets NOTIFY terminating the subscription,");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_free_event(notify);
|
||||
|
||||
fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
SIPTAG_EVENT_STR(event_type),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
|
||||
TAG_END()));
|
||||
event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_terminated));
|
||||
s2_free_event(event);
|
||||
response = s2_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
fail_if(!response);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
}
|
||||
@ -366,25 +365,25 @@ START_TEST(subscribe_6_1_4)
|
||||
"NUA sends SUBSCRIBE, waits for NOTIFY, "
|
||||
"gets NOTIFY terminating the subscription,");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_free_event(notify);
|
||||
|
||||
fail_if(s2_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
fail_if(s2_sip_request_to(dialog, SIP_METHOD_NOTIFY, NULL,
|
||||
SIPTAG_EVENT_STR(event_type),
|
||||
SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=deactivated"),
|
||||
TAG_END()));
|
||||
event = s2_wait_for_event(nua_i_notify, 200); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_embryonic));
|
||||
s2_free_event(event);
|
||||
response = s2_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
response = s2_sip_wait_for_response(200, SIP_METHOD_NOTIFY);
|
||||
fail_if(!response);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
su_home_unref((void *)dialog), dialog = su_home_new(sizeof *dialog); fail_if(!dialog);
|
||||
|
||||
s2_fast_forward(5, s2->root);
|
||||
s2_nua_fast_forward(5, s2base->root);
|
||||
/* nua re-establishes the subscription */
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_free_event(notify);
|
||||
@ -423,7 +422,7 @@ START_TEST(fetch_6_2_1)
|
||||
s2_case("6.2.1", "Event fetch - NOTIFY after 202",
|
||||
"NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_check_substate(notify, nua_substate_terminated);
|
||||
@ -442,7 +441,7 @@ START_TEST(fetch_6_2_2)
|
||||
|
||||
send_notify_before_response = 1;
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
notify = subscription_by_nua(nh, nua_substate_embryonic, TAG_END());
|
||||
s2_check_substate(notify, nua_substate_terminated);
|
||||
@ -460,18 +459,18 @@ START_TEST(fetch_6_2_3)
|
||||
s2_case("6.2.3", "Event fetch - no NOTIFY",
|
||||
"NUA sends SUBSCRIBE with Expires 0, waits for NOTIFY, times out");
|
||||
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
|
||||
nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
|
||||
nua_subscribe(nh, SIPTAG_EVENT_STR(event_type), SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
subscribe = s2_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
s2_respond_to(subscribe, dialog, SIP_202_ACCEPTED,
|
||||
subscribe = s2_sip_wait_for_request(SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_respond_to(subscribe, dialog, SIP_202_ACCEPTED,
|
||||
SIPTAG_EXPIRES_STR("0"), TAG_END());
|
||||
s2_free_message(subscribe);
|
||||
s2_sip_free_message(subscribe);
|
||||
|
||||
event = s2_wait_for_event(nua_r_subscribe, 202); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_embryonic));
|
||||
s2_free_event(event);
|
||||
|
||||
s2_fast_forward(600, s2->root);
|
||||
s2_nua_fast_forward(600, s2base->root);
|
||||
|
||||
event = s2_wait_for_event(nua_i_notify, 408); fail_if(!event);
|
||||
fail_unless(s2_check_substate(event, nua_substate_terminated));
|
||||
@ -513,7 +512,7 @@ subscribe_to_nua(char const *event,
|
||||
s2_check_event(nua_r_set_params, 200);
|
||||
|
||||
ta_start(ta, tag, value);
|
||||
s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR(event),
|
||||
ta_tags(ta));
|
||||
ta_end(ta);
|
||||
@ -525,10 +524,10 @@ subscribe_to_nua(char const *event,
|
||||
TAG_END());
|
||||
s2_free_event(subscribe);
|
||||
|
||||
response = s2_wait_for_response(202, SIP_METHOD_SUBSCRIBE);
|
||||
s2_update_dialog(dialog, response);
|
||||
response = s2_sip_wait_for_response(202, SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_update_dialog(dialog, response);
|
||||
fail_unless(response->sip->sip_expires != NULL);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
return nh;
|
||||
}
|
||||
@ -544,24 +543,24 @@ START_TEST(notify_6_3_1)
|
||||
"NUA receives SUBSCRIBE, sends 202 and NOTIFY. "
|
||||
"First NOTIFY terminates subscription. ");
|
||||
|
||||
s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR("presence"),
|
||||
TAG_END());
|
||||
s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR("presence"),
|
||||
TAG_END());
|
||||
/* 489 Bad Event by default */
|
||||
s2_check_response(489, SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE);
|
||||
|
||||
nua_set_params(nua, NUTAG_APPL_METHOD("SUBSCRIBE"), TAG_END());
|
||||
s2_check_event(nua_r_set_params, 200);
|
||||
|
||||
s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR("presence"),
|
||||
TAG_END());
|
||||
s2_check_response(489, SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_check_response(489, SIP_METHOD_SUBSCRIBE);
|
||||
|
||||
nua_set_params(nua, SIPTAG_ALLOW_EVENTS_STR("presence"), TAG_END());
|
||||
s2_check_event(nua_r_set_params, 200);
|
||||
|
||||
s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR("presence"),
|
||||
TAG_END());
|
||||
subscribe = s2_wait_for_event(nua_i_subscribe, 100);
|
||||
@ -571,11 +570,11 @@ START_TEST(notify_6_3_1)
|
||||
TAG_END());
|
||||
s2_free_event(subscribe);
|
||||
|
||||
s2_check_response(403, SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_check_response(403, SIP_METHOD_SUBSCRIBE);
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
|
||||
s2_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
s2_sip_request_to(dialog, SIP_METHOD_SUBSCRIBE, NULL,
|
||||
SIPTAG_EVENT_STR("presence"),
|
||||
TAG_END());
|
||||
subscribe = s2_wait_for_event(nua_i_subscribe, 100);
|
||||
@ -585,22 +584,22 @@ START_TEST(notify_6_3_1)
|
||||
TAG_END());
|
||||
s2_free_event(subscribe);
|
||||
|
||||
response = s2_wait_for_response(202, SIP_METHOD_SUBSCRIBE);
|
||||
s2_update_dialog(dialog, response);
|
||||
response = s2_sip_wait_for_response(202, SIP_METHOD_SUBSCRIBE);
|
||||
s2_sip_update_dialog(dialog, response);
|
||||
fail_unless(response->sip->sip_expires != NULL);
|
||||
s2_free_message(response);
|
||||
s2_sip_free_message(response);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_SUBSTATE(nua_substate_terminated),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"terminated"));
|
||||
s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
|
||||
s2_check_event(nua_r_notify, 200);
|
||||
nua_handle_destroy(nh);
|
||||
@ -610,8 +609,7 @@ END_TEST
|
||||
START_TEST(notify_6_3_2)
|
||||
{
|
||||
nua_handle_t *nh;
|
||||
struct event *subscribe;
|
||||
struct message *notify, *response;
|
||||
struct message *notify;
|
||||
sip_t *sip;
|
||||
|
||||
s2_case("6.3.2", "NOTIFY server - automatic subscription termination",
|
||||
@ -624,24 +622,24 @@ START_TEST(notify_6_3_2)
|
||||
NUTAG_SUBSTATE(nua_substate_active),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"active"));
|
||||
s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_check_event(nua_r_notify, 200);
|
||||
|
||||
s2_fast_forward(300, s2->root);
|
||||
s2_nua_fast_forward(300, s2base->root);
|
||||
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"terminated"));
|
||||
s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_check_event(nua_r_notify, 200);
|
||||
|
||||
nua_handle_destroy(nh);
|
||||
@ -677,26 +675,26 @@ START_TEST(notify_6_3_3)
|
||||
NUTAG_SUBSTATE(nua_substate_active),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"active"));
|
||||
s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_check_event(nua_r_notify, 200);
|
||||
|
||||
nua_notify(nh,
|
||||
NUTAG_SUBSTATE(nua_substate_active),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"active"));
|
||||
s2_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END());
|
||||
response = s2_wait_for_event(nua_r_notify, 481);
|
||||
fail_unless(s2_event_substate(response) == nua_substate_terminated);
|
||||
|
||||
@ -723,13 +721,13 @@ START_TEST(notify_6_3_4)
|
||||
NUTAG_SUBSTATE(nua_substate_active),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"active"));
|
||||
s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
|
||||
s2_check_event(nua_r_notify, 200);
|
||||
|
||||
nua_notify(nh,
|
||||
@ -740,13 +738,13 @@ START_TEST(notify_6_3_4)
|
||||
NUTAG_SUBSTATE(nua_substate_active),
|
||||
SIPTAG_PAYLOAD_STR(presence_closed),
|
||||
TAG_END());
|
||||
notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
|
||||
fail_unless(notify != NULL);
|
||||
sip = notify->sip;
|
||||
fail_unless(sip->sip_subscription_state != NULL);
|
||||
fail_unless(su_strmatch(sip->sip_subscription_state->ss_substate,
|
||||
"active"));
|
||||
s2_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END());
|
||||
s2_sip_respond_to(notify, dialog, SIP_481_NO_TRANSACTION, TAG_END());
|
||||
response = s2_wait_for_event(nua_r_notify, 481);
|
||||
fail_unless(s2_event_substate(response) == nua_substate_terminated);
|
||||
response = s2_wait_for_event(nua_r_notify, 481);
|
||||
@ -783,10 +781,10 @@ START_TEST(empty)
|
||||
s2_case("0.0.0", "Empty test case",
|
||||
"Detailed explanation for empty test case.");
|
||||
|
||||
tport_set_params(s2->master, TPTAG_LOG(1), TAG_END());
|
||||
tport_set_params(s2sip->master, TPTAG_LOG(1), TAG_END());
|
||||
s2_setup_logs(7);
|
||||
s2_setup_logs(0);
|
||||
tport_set_params(s2->master, TPTAG_LOG(0), TAG_END());
|
||||
tport_set_params(s2sip->master, TPTAG_LOG(0), TAG_END());
|
||||
}
|
||||
|
||||
END_TEST
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -24,42 +24,20 @@
|
||||
#ifndef S2TESTER_H
|
||||
#define S2TESTER_H
|
||||
|
||||
#define TP_STACK_T struct tester
|
||||
#define SU_ROOT_MAGIC_T struct tester
|
||||
|
||||
#include <sofia-sip/su_wait.h>
|
||||
#include <sofia-sip/sip.h>
|
||||
#include <sofia-sip/tport.h>
|
||||
#include <sofia-sip/nua.h>
|
||||
#include <sofia-sip/su_string.h>
|
||||
|
||||
#include "s2base.h"
|
||||
#include "s2util.h"
|
||||
#include "s2sip.h"
|
||||
|
||||
struct tester
|
||||
struct s2nua
|
||||
{
|
||||
su_home_t home[1];
|
||||
|
||||
su_root_t *root;
|
||||
msg_mclass_t const *mclass;
|
||||
int flags;
|
||||
|
||||
char const *hostname;
|
||||
tport_t *master;
|
||||
|
||||
sip_to_t *local;
|
||||
sip_contact_t *contact;
|
||||
struct {
|
||||
sip_contact_t *contact;
|
||||
tport_t *tport;
|
||||
} udp, tcp, tls;
|
||||
|
||||
struct message {
|
||||
struct message *next, **prev;
|
||||
msg_t *msg;
|
||||
sip_t *sip;
|
||||
tport_t *tport;
|
||||
su_time_t when;
|
||||
} *received;
|
||||
|
||||
nua_t *nua;
|
||||
|
||||
struct event {
|
||||
@ -76,33 +54,8 @@ struct tester
|
||||
sip_contact_t *contact;
|
||||
tport_t *tport;
|
||||
} registration[1];
|
||||
|
||||
unsigned long tid;
|
||||
|
||||
/* Settings */
|
||||
int server_uses_rport;
|
||||
};
|
||||
|
||||
struct dialog
|
||||
{
|
||||
su_home_t home[1];
|
||||
sip_from_t *local;
|
||||
sip_to_t *remote;
|
||||
sip_call_id_t *call_id;
|
||||
uint32_t lseq, rseq;
|
||||
sip_contact_t *target;
|
||||
sip_route_t *route;
|
||||
sip_contact_t *contact;
|
||||
|
||||
tport_t *tport;
|
||||
msg_t *invite; /* latest invite sent */
|
||||
};
|
||||
|
||||
extern char const *s2_tester;
|
||||
extern int s2_start_stop;
|
||||
extern struct tester *s2;
|
||||
extern tp_stack_class_t const s2_stack[1];
|
||||
|
||||
extern unsigned s2_default_registration_duration;
|
||||
extern char const s2_auth_digest_str[];
|
||||
extern char const s2_auth_credentials[];
|
||||
@ -115,9 +68,7 @@ extern char const s2_auth3_credentials[];
|
||||
|
||||
extern int s2_nua_thread;
|
||||
|
||||
void s2_case(char const *tag,
|
||||
char const *title,
|
||||
char const *description);
|
||||
extern struct s2nua *s2;
|
||||
|
||||
struct event *s2_remove_event(struct event *);
|
||||
void s2_free_event(struct event *);
|
||||
@ -127,54 +78,23 @@ struct event *s2_next_event(void);
|
||||
struct event *s2_wait_for_event(nua_event_t event, int status);
|
||||
int s2_check_event(nua_event_t event, int status);
|
||||
int s2_check_callstate(enum nua_callstate state);
|
||||
|
||||
struct message *s2_remove_message(struct message *m);
|
||||
void s2_free_message(struct message *m);
|
||||
void s2_flush_messages(void);
|
||||
|
||||
struct message *s2_next_response(void);
|
||||
struct message *s2_wait_for_response(int status, sip_method_t , char const *);
|
||||
int s2_check_response(int status, sip_method_t method, char const *name);
|
||||
|
||||
struct message *s2_next_request(void);
|
||||
struct message *s2_wait_for_request(sip_method_t method, char const *name);
|
||||
struct message *s2_wait_for_request_timeout(sip_method_t, char const *,
|
||||
int timeout);
|
||||
int s2_check_request(sip_method_t method, char const *name);
|
||||
int s2_check_request_timeout(sip_method_t method, char const *, int timeout);
|
||||
|
||||
int s2_check_substate(struct event *e, enum nua_substate state);
|
||||
|
||||
#define SIP_METHOD_UNKNOWN sip_method_unknown, NULL
|
||||
|
||||
void s2_save_uas_dialog(struct dialog *d, sip_t *sip);
|
||||
|
||||
struct message *s2_respond_to(struct message *m, struct dialog *d,
|
||||
int status, char const *phrase,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
int s2_request_to(struct dialog *d,
|
||||
sip_method_t method, char const *name,
|
||||
tport_t *tport,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
int s2_update_dialog(struct dialog *d, struct message *response);
|
||||
|
||||
int s2_save_register(struct message *m);
|
||||
|
||||
void s2_flush_all(void);
|
||||
|
||||
void s2_setup_base(char const *label, char const *hostname);
|
||||
void s2_setup_logs(int level);
|
||||
void s2_setup_tport(char const * const *protocols,
|
||||
tag_type_t tag, tag_value_t value, ...);
|
||||
void s2_teardown(void);
|
||||
|
||||
nua_t *s2_nua_setup(char const *label, tag_type_t tag, tag_value_t value, ...);
|
||||
|
||||
void s2_teardown_started(char const *label);
|
||||
void s2_nua_teardown(void);
|
||||
|
||||
void s2_nua_fast_forward(unsigned long seconds,
|
||||
su_root_t *steproot);
|
||||
|
||||
int s2_save_register(struct message *m);
|
||||
|
||||
void s2_register_setup(void);
|
||||
void s2_register_teardown(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user