[Freeswitch-svn] [commit] r12398 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nua
FreeSWITCH SVN
mikej at freeswitch.org
Tue Mar 3 14:00:57 PST 2009
Author: mikej
Date: Tue Mar 3 16:00:56 2009
New Revision: 12398
Log:
Tue Mar 3 12:15:01 CST 2009 Pekka Pessi <first.last at nokia.com>
* nua: check_nua now uses s2base.h and s2sip.h
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Tue Mar 3 16:00:56 2009
@@ -1 +1 @@
-Tue Mar 3 15:59:49 CST 2009
+Tue Mar 3 16:00:35 CST 2009
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/Makefile.am Tue Mar 3 16:00:56 2009
@@ -55,8 +55,6 @@
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 @@
include $(top_srcdir)/rules/sofia.am
-INCLUDES = ${INTERNAL_INCLUDES}
+INCLUDES = ${INTERNAL_INCLUDES} -I$(top_srcdir)/s2check
TAG_DLL_FLAGS = LIST=nua_tag_list
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_etsi.c Tue Mar 3 16:00:56 2009
@@ -71,7 +71,7 @@
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 @@
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 @@
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 @@
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 @@
"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 @@
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 @@
"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 @@
"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 @@
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());
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_nua.c Tue Mar 3 16:00:56 2009
@@ -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 @@
s2_tester = "check_nua";
+ s2_suite("N2");
+
if (getenv("CHECK_NUA_VERBOSE"))
s2_start_stop = strtoul(getenv("CHECK_NUA_VERBOSE"), NULL, 10);
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_register.c Tue Mar 3 16:00:56 2009
@@ -75,7 +75,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
/* 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 @@
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 @@
{
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);
}
}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_session.c Tue Mar 3 16:00:56 2009
@@ -68,7 +68,7 @@
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);
@@ -161,7 +161,7 @@
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"),
@@ -184,7 +184,7 @@
ta_start(ta, tag, value);
fail_if(
- s2_request_to(dialog, method, name, tport,
+ s2_sip_request_to(dialog, method, name, tport,
SIPTAG_CONTENT_TYPE_STR("application/sdp"),
SIPTAG_PAYLOAD_STR(body),
ta_tags(ta)));
@@ -203,7 +203,7 @@
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 uint32_t s2_rseq;
@@ -233,7 +233,7 @@
ta_tags(ta));
}
else {
- s2_respond_to(
+ s2_sip_respond_to(
invite, dialog, status, phrase,
SIPTAG_REQUIRE_STR("100rel"),
SIPTAG_RSEQ(rs),
@@ -243,7 +243,7 @@
fail_unless(s2_check_event(nua_r_invite, status));
- return s2_wait_for_request(SIP_METHOD_PRACK);
+ return s2_sip_wait_for_request(SIP_METHOD_PRACK);
}
static void
@@ -267,10 +267,10 @@
fail_unless(s2_check_callstate(nua_callstate_proceeding));
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
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));
}
static nua_handle_t *
@@ -295,7 +295,7 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
nua_respond(nh, SIP_180_RINGING,
@@ -303,23 +303,23 @@
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_early));
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
process_answer(response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_respond(nh, SIP_200_OK, TAG_END());
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
- s2_free_message(response);
+ s2_sip_update_dialog(dialog, response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_ack, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -338,10 +338,10 @@
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));
}
@@ -359,19 +359,19 @@
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_407_PROXY_AUTH_REQUIRED,
+ s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED,
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
TAG_END());
- s2_free_message(bye);
+ s2_sip_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END());
- 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));
fail_if(s2->events);
@@ -391,14 +391,14 @@
nua_cancel(nh, ta_tags(ta));
ta_end(ta);
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(cancel);
fail_unless(s2_check_event(nua_r_cancel, 200));
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_event(nua_r_invite, 487));
}
@@ -410,12 +410,12 @@
ta_list ta;
ta_start(ta, tag, value);
- fail_if(s2_request_to(dialog, SIP_METHOD_BYE, NULL, ta_tags(ta)));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, ta_tags(ta)));
ta_end(ta);
fail_unless(s2_check_event(nua_i_bye, 200));
fail_unless(s2_check_callstate(nua_callstate_terminated));
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
}
/* ====================================================================== */
@@ -430,7 +430,7 @@
s2_case("2.1.1", "Basic call",
"NUA sends INVITE, NUA sends BYE");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, TAG_END());
@@ -448,7 +448,7 @@
s2_case("2.1.2.1", "Basic call",
"NUA sends INVITE, NUA receives BYE");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, TAG_END());
@@ -465,11 +465,11 @@
s2_case("2.1.2.2", "Basic call over TCP",
"NUA sends INVITE, NUA receives BYE");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
TAG_END());
invite_by_nua(nh,
- NUTAG_PROXY(s2->tcp.contact->m_url),
+ NUTAG_PROXY(s2sip->tcp.contact->m_url),
TAG_END());
bye_to_nua(nh, TAG_END());
@@ -502,7 +502,7 @@
s2_case("2.1.3.2", "Incoming call over TCP",
"NUA receives INVITE and BYE");
- dialog->tport = s2->tcp.tport;
+ dialog->tport = s2sip->tcp.tport;
nh = invite_to_nua(TAG_END());
@@ -569,44 +569,44 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
nua_respond(nh, SIP_180_RINGING,
/* Dialog-specific proxy is saved */
- NUTAG_PROXY(s2->tcp.contact->m_url),
+ NUTAG_PROXY(s2sip->tcp.contact->m_url),
SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_early));
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
process_answer(response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_respond(nh, SIP_200_OK, TAG_END());
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
- s2_free_message(response);
+ s2_sip_update_dialog(dialog, response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_ack, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
nua_bye(nh, TAG_END());
- bye = s2_wait_for_request(SIP_METHOD_BYE);
+ bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
fail_if(!bye);
/* Check that NUA used dialog-specific proxy with BYE */
fail_unless(tport_is_tcp(bye->tport));
- 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));
@@ -623,7 +623,7 @@
s2_case("2.1.7", "Call lookup",
"Test dialog and call-id lookup");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, TAG_END());
@@ -656,11 +656,11 @@
s2_case("2.1.8", "Call using NUTAG_PROXY()",
"Test handle-specific NUTAG_PROXY().");
- 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, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
- NUTAG_PROXY(s2->tcp.contact->m_url), TAG_END());
+ NUTAG_PROXY(s2sip->tcp.contact->m_url), TAG_END());
process_offer(invite);
respond_with_sdp(
@@ -672,10 +672,10 @@
fail_unless(s2_check_callstate(nua_callstate_proceeding));
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_unless(ack && tport_is_tcp(ack->tport));
bye_by_nua(nh, TAG_END());
@@ -715,23 +715,23 @@
s2_case("2.2.1", "Cancel call",
"NUA is caller, NUA sends CANCEL immediately");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
nua_cancel(nh, TAG_END());
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- fail_if(s2->received != NULL);
- s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ fail_if(s2sip->received != NULL);
+ s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_event(nua_r_invite, 487));
fail_unless(s2_check_callstate(nua_callstate_terminated));
@@ -751,15 +751,15 @@
s2_case("2.2.2", "Canceled call",
"NUA is caller, NUA sends CANCEL after receiving 100");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
cancel_by_nua(nh, invite, dialog, TAG_END());
@@ -778,13 +778,13 @@
s2_case("2.2.3", "Canceled call",
"NUA is caller, NUA sends CANCEL after receiving 180");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
respond_with_sdp(
invite, dialog, SIP_180_RINGING,
@@ -810,13 +810,13 @@
"NUA is caller, NUA sends CANCEL after receiving 180 "
"but UAS already sent 200 OK.");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
respond_with_sdp(
invite, dialog, SIP_180_RINGING,
@@ -826,16 +826,16 @@
fail_unless(s2_check_callstate(nua_callstate_proceeding));
nua_cancel(nh, TAG_END());
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
+ s2_sip_free_message(cancel);
fail_unless(s2_check_event(nua_r_cancel, 481));
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -858,14 +858,14 @@
"but UAS already sent 200 OK.\n"
"Test case checks that NUA really sends BYE after nua_bye() is called\n");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
NUTAG_AUTOACK(0),
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
respond_with_sdp(
invite, dialog, SIP_180_RINGING,
@@ -875,23 +875,23 @@
fail_unless(s2_check_callstate(nua_callstate_proceeding));
nua_bye(nh, TAG_END());
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
+ s2_sip_free_message(cancel);
fail_unless(s2_check_event(nua_r_cancel, 481));
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_callstate(nua_callstate_terminating));
- 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));
@@ -919,7 +919,7 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
nua_respond(nh, SIP_180_RINGING,
@@ -927,22 +927,22 @@
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_early));
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
process_answer(response);
- s2_free_message(response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_cancel, 200));
fail_unless(s2_check_callstate(nua_callstate_terminated));
- response = s2_wait_for_response(200, SIP_METHOD_CANCEL);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
- response = s2_wait_for_response(487, SIP_METHOD_INVITE);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ response = s2_sip_wait_for_response(487, SIP_METHOD_INVITE);
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
@@ -974,7 +974,7 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
nua_respond(nh, SIP_180_RINGING,
@@ -982,22 +982,22 @@
TAG_END());
fail_unless(s2_check_callstate(nua_callstate_early));
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
process_answer(response);
- s2_free_message(response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_CANCEL, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_cancel, 200));
fail_unless(s2_check_callstate(nua_callstate_terminated));
- response = s2_wait_for_response(200, SIP_METHOD_CANCEL);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_CANCEL);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
- response = s2_wait_for_response(487, SIP_METHOD_INVITE);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ response = s2_sip_wait_for_response(487, SIP_METHOD_INVITE);
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
@@ -1082,7 +1082,7 @@
struct message *invite, *ack;
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
respond_with_sdp(
invite, dialog, SIP_200_OK,
@@ -1090,12 +1090,12 @@
SIPTAG_REQUIRE_STR("timer"),
SIPTAG_RECORD_ROUTE(rr),
TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
if (rr == NULL)
- s2_free_message(ack);
+ s2_sip_free_message(ack);
return ack;
}
@@ -1106,7 +1106,7 @@
struct message *ack;
sip_record_route_init(rr);
- *rr->r_url = *s2->contact->m_url;
+ *rr->r_url = *s2sip->contact->m_url;
rr->r_url->url_user = "record";
rr->r_url->url_params = "lr";
@@ -1121,11 +1121,11 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
ack = invite_timer_round(nh, "300;refresher=uac", rr);
fail_if(ack->sip->sip_route &&
su_strmatch(ack->sip->sip_route->r_url->url_user, "record"));
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
invite_timer_round(nh, "300;refresher=uac", NULL);
bye_by_nua(nh, TAG_END());
@@ -1149,9 +1149,9 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
invite_timer_round(nh, "300", NULL);
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
invite_timer_round(nh, "300", NULL);
bye_by_nua(nh, TAG_END());
@@ -1190,11 +1190,11 @@
"receives 200, send ACK.");
sip_record_route_init(rr);
- *rr->r_url = *s2->contact->m_url;
+ *rr->r_url = *s2sip->contact->m_url;
rr->r_url->url_user = "record";
rr->r_url->url_params = "lr";
- 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, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
@@ -1205,8 +1205,8 @@
SIP_183_SESSION_PROGRESS,
SIPTAG_RECORD_ROUTE(rr),
TAG_END());
- s2_respond_to(prack, dialog, SIP_200_OK, TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_callstate(nua_callstate_proceeding));
fail_unless(s2_check_event(nua_r_prack, 200));
@@ -1216,23 +1216,23 @@
fail_unless(prack->sip->sip_route != NULL);
fail_unless(su_strmatch(prack->sip->sip_route->r_url->url_user, "record"));
- s2_respond_to(prack, dialog, SIP_200_OK, TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_callstate(nua_callstate_proceeding));
fail_unless(s2_check_event(nua_r_prack, 200));
/* Change the record-route */
rr->r_url->url_user = "record2";
- s2_respond_to(invite, dialog, SIP_200_OK,
+ s2_sip_respond_to(invite, dialog, SIP_200_OK,
SIPTAG_RECORD_ROUTE(rr),
TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
fail_unless(su_strmatch(ack->sip->sip_route->r_url->url_user, "record2"));
- s2_free_message(ack);
+ s2_sip_free_message(ack);
bye_to_nua(nh, TAG_END());
@@ -1252,7 +1252,7 @@
"receives 180, sends PRACK, receives 200 for it, "
"receives 200, send ACK.");
- 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,
@@ -1269,24 +1269,24 @@
prack = respond_with_100rel(invite, dialog, with_sdp = 0,
SIP_183_SESSION_PROGRESS,
TAG_END());
- s2_respond_to(prack, dialog, SIP_200_OK, TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_callstate(nua_callstate_proceeding));
fail_unless(s2_check_event(nua_r_prack, 200));
prack = respond_with_100rel(invite, dialog, with_sdp = 0,
SIP_180_RINGING,
TAG_END());
- s2_respond_to(prack, dialog, SIP_200_OK, TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_callstate(nua_callstate_proceeding));
fail_unless(s2_check_event(nua_r_prack, 200));
- s2_respond_to(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(invite);
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));
bye_to_nua(nh, TAG_END());
@@ -1321,7 +1321,7 @@
"receives 180, sends PRACK, receives 200 for it, "
"receives 200, send ACK.");
- 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, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
@@ -1338,11 +1338,11 @@
prack, dialog, SIP_200_OK,
SIPTAG_REQUIRE_STR("100rel"),
TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_event(nua_r_prack, 200));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
- update = s2_wait_for_request(SIP_METHOD_UPDATE);
+ update = s2_sip_wait_for_request(SIP_METHOD_UPDATE);
/* UPDATE sent by stack, stack sends event for it */
fail_unless(s2_check_callstate(nua_callstate_proceeding));
@@ -1350,7 +1350,7 @@
respond_with_sdp(
update, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(update), update = NULL;
+ s2_sip_free_message(update), update = NULL;
fail_unless(s2_check_event(nua_r_update, 200));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
@@ -1358,16 +1358,16 @@
prack = respond_with_100rel(invite, dialog, with_sdp = 0,
SIP_180_RINGING,
TAG_END());
- s2_respond_to(prack, dialog, SIP_200_OK, TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_respond_to(prack, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_callstate(nua_callstate_proceeding));
fail_unless(s2_check_event(nua_r_prack, 200));
- s2_respond_to(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(invite);
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));
bye_to_nua(nh, TAG_END());
@@ -1391,7 +1391,7 @@
"sends UPDATE, "
"receives 200 to UPDATE.");
- 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,
@@ -1416,24 +1416,24 @@
rack->ra_method_name = invite->sip->sip_cseq->cs_method_name;
nua_prack(nh, SIPTAG_RACK(rack), TAG_END());
- prack = s2_wait_for_request(SIP_METHOD_PRACK);
+ prack = s2_sip_wait_for_request(SIP_METHOD_PRACK);
process_offer(prack);
- s2_respond_to(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_completing));
respond_with_sdp(
prack, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_event(nua_r_prack, 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));
- update = s2_wait_for_request(SIP_METHOD_UPDATE);
+ update = s2_sip_wait_for_request(SIP_METHOD_UPDATE);
/* UPDATE sent by stack, stack sends event for it */
fail_unless(s2_check_callstate(nua_callstate_calling));
@@ -1441,7 +1441,7 @@
respond_with_sdp(
update, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(update), update = NULL;
+ s2_sip_free_message(update), update = NULL;
fail_unless(s2_check_event(nua_r_update, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1467,7 +1467,7 @@
"receives 200 to UPDATE, "
"sends ACK.");
- 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,
@@ -1492,21 +1492,21 @@
rack->ra_method_name = invite->sip->sip_cseq->cs_method_name;
nua_prack(nh, SIPTAG_RACK(rack), TAG_END());
- prack = s2_wait_for_request(SIP_METHOD_PRACK);
+ prack = s2_sip_wait_for_request(SIP_METHOD_PRACK);
process_offer(prack);
respond_with_sdp(
prack, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(prack), prack = NULL;
+ s2_sip_free_message(prack), prack = NULL;
fail_unless(s2_check_event(nua_r_prack, 200));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
- update = s2_wait_for_request(SIP_METHOD_UPDATE);
+ update = s2_sip_wait_for_request(SIP_METHOD_UPDATE);
/* UPDATE sent by stack, stack sends event for it */
fail_unless(s2_check_callstate(nua_callstate_proceeding));
- s2_respond_to(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_completing));
@@ -1514,11 +1514,11 @@
respond_with_sdp(
update, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(update), update = NULL;
+ s2_sip_free_message(update), update = NULL;
fail_unless(s2_check_event(nua_r_update, 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));
bye_to_nua(nh, TAG_END());
@@ -1560,15 +1560,15 @@
for (i = 0; i < 2; i++) {
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
process_offer(invite);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1597,40 +1597,40 @@
soa_generate_offer(soa, 1, NULL);
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
respond_with_sdp(invite, dialog, SIP_500_INTERNAL_SERVER_ERROR,
SIPTAG_RETRY_AFTER_STR("8"),
TAG_END());
- s2_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ s2_sip_free_message(invite);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
- response = s2_wait_for_response(491, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(491, SIP_METHOD_INVITE);
fail_if(!response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
- s2_free_message(response);
+ s2_sip_free_message(response);
fail_if(soa_process_reject(soa, NULL) < 0);
/* We get nua_r_invite with 100 trying (and 500 in sip->sip_status) */
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(10, s2->root);
+ s2_nua_fast_forward(10, s2base->root);
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
process_offer(invite);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
bye_by_nua(nh, TAG_END());
@@ -1652,7 +1652,7 @@
nh = invite_to_nua(
TAG_END());
- s2_request_to(dialog, SIP_METHOD_INVITE, NULL,
+ s2_sip_request_to(dialog, SIP_METHOD_INVITE, NULL,
SIPTAG_USER_AGENT_STR("evil (evil) evil"),
TAG_END());
@@ -1660,24 +1660,24 @@
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
fail_if(!response->sip->sip_content_type);
- s2_free_message(response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_ack, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
- s2_fast_forward(10, s2->root);
+ s2_nua_fast_forward(10, s2base->root);
nua_set_hparams(nh, NUTAG_REFRESH_WITHOUT_SDP(1), TAG_END());
fail_unless(s2_check_event(nua_r_set_params, 200));
- s2_request_to(dialog, SIP_METHOD_INVITE, NULL,
+ s2_sip_request_to(dialog, SIP_METHOD_INVITE, NULL,
SIPTAG_USER_AGENT_STR("evil (evil) evil"),
TAG_END());
@@ -1685,14 +1685,14 @@
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
- s2_update_dialog(dialog, response);
+ s2_sip_update_dialog(dialog, response);
fail_if(response->sip->sip_content_type);
- s2_free_message(response);
+ s2_sip_free_message(response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL, TAG_END()));
fail_unless(s2_check_event(nua_i_ack, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1719,17 +1719,17 @@
nua_invite(nh, SIPTAG_PAYLOAD_STR(""), TAG_END());
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
fail_if(invite->sip->sip_content_type);
soa_generate_offer(soa, 1, NULL);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
process_answer(ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1764,7 +1764,7 @@
struct message *invite, *ack;
s2_case("3.1.1", "Call failure", "Call fails with 403 response");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
TAG_END());
nua_invite(nh, SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
@@ -1772,17 +1772,17 @@
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, NULL, SIP_403_FORBIDDEN,
+ s2_sip_respond_to(invite, NULL, SIP_403_FORBIDDEN,
SIPTAG_TO_STR("UAS Changed <sip:To at Header.field.invalid>"),
TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
fail_if(strcmp(ack->sip->sip_to->a_display, "UAS Changed"));
- s2_free_message(ack);
+ s2_sip_free_message(ack);
fail_unless(s2_check_event(nua_r_invite, 403));
fail_unless(s2_check_callstate(nua_callstate_terminated));
@@ -1800,7 +1800,7 @@
s2_case("3.1.2", "Call fails after too many retries",
"Call fails after 4 times 500 Retry-After");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
NUTAG_RETRY_COUNT(3),
TAG_END());
@@ -1809,17 +1809,17 @@
for (i = 0;; i++) {
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR,
+ s2_sip_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR,
SIPTAG_RETRY_AFTER_STR("5"),
TAG_END());
- s2_free_message(invite);
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ s2_sip_free_message(invite);
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
if (i == 3)
break;
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(5, s2->root);
+ s2_nua_fast_forward(5, s2base->root);
}
fail_unless(s2_check_event(nua_r_invite, 500));
@@ -1835,7 +1835,7 @@
struct message *invite;
s2_case("3.2.1", "Re-INVITE failure", "Re-INVITE fails with 403 response");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
TAG_END());
invite_by_nua(nh, TAG_END());
@@ -1844,12 +1844,12 @@
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, NULL, SIP_403_FORBIDDEN, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, NULL, SIP_403_FORBIDDEN, TAG_END());
+ s2_sip_free_message(invite);
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_event(nua_r_invite, 403));
/* Return to previous state */
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1868,7 +1868,7 @@
s2_case("3.2.2", "Re-INVITE fails after too many retries",
"Call fails after 4 times 500 Retry-After");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
NUTAG_RETRY_COUNT(3),
TAG_END());
@@ -1879,26 +1879,26 @@
for (i = 0;; i++) {
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR,
+ s2_sip_respond_to(invite, NULL, SIP_500_INTERNAL_SERVER_ERROR,
SIPTAG_RETRY_AFTER_STR("5"),
TAG_END());
- s2_free_message(invite);
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ s2_sip_free_message(invite);
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
if (i == 3)
break;
fail_unless(s2_check_event(nua_r_invite, 100));
- s2_fast_forward(5, s2->root);
+ s2_nua_fast_forward(5, s2base->root);
}
fail_unless(s2_check_event(nua_r_invite, 500));
/* Graceful termination */
fail_unless(s2_check_callstate(nua_callstate_terminating));
- 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));
@@ -1913,7 +1913,7 @@
struct message *invite;
s2_case("3.2.3", "Re-INVITE failure", "Re-INVITE fails with 491 response");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local),
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor),
TAG_END());
invite_by_nua(nh, TAG_END());
@@ -1922,11 +1922,11 @@
fail_unless(s2_check_callstate(nua_callstate_calling));
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, NULL, SIP_491_REQUEST_PENDING, TAG_END());
- s2_free_message(invite);
- fail_unless(s2_check_request(SIP_METHOD_ACK));
+ s2_sip_respond_to(invite, NULL, SIP_491_REQUEST_PENDING, TAG_END());
+ s2_sip_free_message(invite);
+ fail_unless(s2_sip_check_request(SIP_METHOD_ACK));
fail_unless(s2_check_event(nua_r_invite, 491));
/* Return to previous state */
fail_unless(s2_check_callstate(nua_callstate_ready));
@@ -1971,12 +1971,12 @@
nua_bye(nh, TAG_END());
- 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_407_PROXY_AUTH_REQUIRED,
+ s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED,
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
TAG_END());
- s2_free_message(bye);
+ s2_sip_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
soa_generate_offer(soa, 1, NULL);
@@ -1984,11 +1984,11 @@
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
do {
- r481 = s2_wait_for_response(0, SIP_METHOD_INVITE);
+ r481 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE);
}
while (r481->sip->sip_status->st_status < 200);
- s2_update_dialog(dialog, r481); /* send ACK */
+ s2_sip_update_dialog(dialog, r481); /* send ACK */
fail_unless(s2_check_callstate(nua_callstate_terminated));
@@ -2010,22 +2010,22 @@
s2_flush_events();
nua_bye(nh, TAG_END());
- bye = s2_wait_for_request(SIP_METHOD_BYE);
+ bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
fail_if(!bye);
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
do {
- r481 = s2_wait_for_response(0, SIP_METHOD_INVITE);
+ r481 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE);
}
while (r481->sip->sip_status->st_status < 200);
- s2_update_dialog(dialog, r481); /* send ACK */
+ s2_sip_update_dialog(dialog, r481); /* send ACK */
fail_unless(s2_check_callstate(nua_callstate_terminated));
- s2_respond_to(bye, dialog, SIP_200_OK,
+ s2_sip_respond_to(bye, dialog, SIP_200_OK,
TAG_END());
- s2_free_message(bye);
+ s2_sip_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 200));
nua_handle_destroy(nh);
@@ -2051,22 +2051,22 @@
s2_flush_events();
nua_bye(nh, TAG_END());
- bye = s2_wait_for_request(SIP_METHOD_BYE);
+ bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
fail_if(!bye);
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 100);
fail_if(!i_bye);
nua_respond(nh, 200, "OKOK", NUTAG_WITH(i_bye->data->e_msg), TAG_END());
- 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));
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
nua_handle_destroy(nh);
}
@@ -2089,23 +2089,23 @@
fail_unless(s2_check_event(nua_r_set_params, 200));
s2_flush_events();
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 100);
fail_if(!i_bye);
nua_bye(nh, TAG_END());
- 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));
nua_respond(nh, 200, "OKOK", NUTAG_WITH(i_bye->data->e_msg), TAG_END());
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
nua_handle_destroy(nh);
}
@@ -2128,23 +2128,23 @@
fail_unless(s2_check_event(nua_r_set_params, 200));
s2_flush_events();
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 100);
fail_if(!i_bye);
nua_bye(nh, TAG_END());
- 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));
nua_handle_destroy(nh);
- fail_unless(s2_check_response(500, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(500, SIP_METHOD_BYE));
}
END_TEST
@@ -2165,22 +2165,22 @@
s2_flush_events();
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
- fail_unless(s2_check_response(100, SIP_METHOD_INVITE));
+ fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE));
nua_bye(nh, TAG_END());
fail_unless(s2_check_event(nua_i_invite, 100));
fail_unless(s2_check_callstate(nua_callstate_received));
do {
- r486 = s2_wait_for_response(0, SIP_METHOD_INVITE);
+ r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE);
}
while (r486->sip->sip_status->st_status < 200);
- s2_update_dialog(dialog, r486); /* send ACK */
+ s2_sip_update_dialog(dialog, r486); /* send ACK */
fail_unless(r486->sip->sip_status->st_status == 486);
- 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);
nua_handle_destroy(nh);
}
@@ -2203,21 +2203,21 @@
s2_flush_events();
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
- fail_unless(s2_check_response(100, SIP_METHOD_INVITE));
+ fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE));
nua_bye(nh, TAG_END());
fail_unless(s2_check_event(nua_i_invite, 100));
fail_unless(s2_check_callstate(nua_callstate_received));
- 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);
do {
- r486 = s2_wait_for_response(0, SIP_METHOD_INVITE);
+ r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE);
}
while (r486->sip->sip_status->st_status < 200);
- s2_update_dialog(dialog, r486); /* send ACK */
+ s2_sip_update_dialog(dialog, r486); /* send ACK */
fail_unless(r486->sip->sip_status->st_status == 486);
nua_handle_destroy(nh);
@@ -2232,14 +2232,14 @@
s2_case("4.1.8", "BYE followed by response to INVITE",
"NUA receives INVITE, sends BYE at same time");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, NUTAG_AUTOANSWER(0), TAG_END());
s2_flush_events();
request_with_sdp(dialog, SIP_METHOD_INVITE, NULL, TAG_END());
- fail_unless(s2_check_response(100, SIP_METHOD_INVITE));
+ fail_unless(s2_sip_check_response(100, SIP_METHOD_INVITE));
nua_bye(nh, TAG_END());
fail_unless(s2_check_event(nua_i_invite, 100));
fail_unless(s2_check_callstate(nua_callstate_received));
@@ -2247,16 +2247,16 @@
nua_respond(nh, SIP_486_BUSY_HERE, TAG_END());
do {
- r486 = s2_wait_for_response(0, SIP_METHOD_INVITE);
+ r486 = s2_sip_wait_for_response(0, SIP_METHOD_INVITE);
}
while (r486->sip->sip_status->st_status < 200);
- s2_update_dialog(dialog, r486); /* send ACK */
+ s2_sip_update_dialog(dialog, r486); /* send ACK */
fail_unless(r486->sip->sip_status->st_status == 486);
- 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);
nua_handle_destroy(nh);
}
@@ -2279,29 +2279,29 @@
s2_flush_events();
nua_bye(nh, TAG_END());
- bye = s2_wait_for_request(SIP_METHOD_BYE);
+ bye = s2_sip_wait_for_request(SIP_METHOD_BYE);
fail_if(!bye);
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 200);
fail_if(!i_bye);
s2_free_event(i_bye), i_bye = NULL;
fail_unless(s2_check_callstate(nua_callstate_terminated));
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
nua_handle_destroy(nh);
mark_point();
- su_root_step(s2->root, 10);
- su_root_step(s2->root, 10);
- su_root_step(s2->root, 10);
+ su_root_step(s2base->root, 10);
+ su_root_step(s2base->root, 10);
+ su_root_step(s2base->root, 10);
mark_point();
- 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);
mark_point();
while (su_home_check_alloc((su_home_t *)nua, (void *)nh)) {
- su_root_step(s2->root, 10);
+ su_root_step(s2base->root, 10);
}
}
END_TEST
@@ -2323,37 +2323,37 @@
s2_flush_events();
nua_invite(nh, TAG_END());
- invite = s2_wait_for_request(SIP_METHOD_INVITE);
+ invite = s2_sip_wait_for_request(SIP_METHOD_INVITE);
fail_if(!invite);
- s2_respond_to(invite, dialog, SIP_501_NOT_IMPLEMENTED, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_501_NOT_IMPLEMENTED, TAG_END());
+ 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);
fail_unless(s2_check_callstate(nua_callstate_calling));
fail_unless(s2_check_event(nua_r_invite, 501));
fail_unless(s2_check_callstate(nua_callstate_terminating));
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 200);
fail_if(!i_bye);
s2_free_event(i_bye), i_bye = NULL;
fail_unless(s2_check_callstate(nua_callstate_terminated));
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
nua_handle_destroy(nh);
- su_root_step(s2->root, 10);
- su_root_step(s2->root, 10);
- su_root_step(s2->root, 10);
+ su_root_step(s2base->root, 10);
+ su_root_step(s2base->root, 10);
+ su_root_step(s2base->root, 10);
- 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);
while (su_home_check_alloc((su_home_t *)nua, (void *)nh)) {
- su_root_step(s2->root, 10);
+ su_root_step(s2base->root, 10);
}
}
END_TEST
@@ -2367,29 +2367,29 @@
s2_case("4.1.11", "Receive BYE in completing state",
"NUA sends INVITE, receives 200, receives BYE.");
- 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, NUTAG_AUTOACK(0), TAG_END());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
fail_unless(s2_check_event(nua_r_invite, 200));
fail_unless(s2_check_callstate(nua_callstate_completing));
- s2_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_BYE, NULL, TAG_END());
i_bye = s2_wait_for_event(nua_i_bye, 200);
fail_if(!i_bye);
s2_free_event(i_bye), i_bye = NULL;
fail_unless(s2_check_callstate(nua_callstate_terminated));
- fail_unless(s2_check_response(200, SIP_METHOD_BYE));
+ fail_unless(s2_sip_check_response(200, SIP_METHOD_BYE));
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
nua_handle_destroy(nh);
}
@@ -2411,26 +2411,26 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
invite_timer_round(nh, "300", NULL);
nua_bye(nh, TAG_END());
- 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_407_PROXY_AUTH_REQUIRED,
+ s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED,
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
TAG_END());
- s2_free_message(bye);
+ s2_sip_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
nua_authenticate(nh, NUTAG_AUTH("Digest:\"s2test\":abc:abc"), TAG_END());
- 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));
fail_if(s2->events);
@@ -2455,28 +2455,28 @@
SIPTAG_REQUIRE_STR("timer"),
TAG_END());
- s2_fast_forward(300, s2->root);
+ s2_nua_fast_forward(300, s2base->root);
invite_timer_round(nh, "300", NULL);
- s2_fast_forward(140, s2->root);
+ s2_nua_fast_forward(140, s2base->root);
nua_bye(nh, TAG_END());
- 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_407_PROXY_AUTH_REQUIRED,
+ s2_sip_respond_to(bye, dialog, SIP_407_PROXY_AUTH_REQUIRED,
SIPTAG_PROXY_AUTHENTICATE_STR(s2_auth_digest_str),
TAG_END());
- s2_free_message(bye);
+ s2_sip_free_message(bye);
fail_unless(s2_check_event(nua_r_bye, 407));
- s2_fast_forward(160, s2->root);
+ s2_nua_fast_forward(160, s2base->root);
nua_authenticate(nh, NUTAG_AUTH(s2_auth_credentials), TAG_END());
- 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));
fail_if(s2->events);
@@ -2518,22 +2518,22 @@
s2_case("4.3.1", "Destroy handle after INVITE sent",
"NUA sends INVITE, handle gets destroyed.");
- 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());
process_offer(invite);
nua_handle_destroy(nh);
- s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ s2_sip_free_message(invite);
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(cancel);
}
END_TEST
@@ -2546,23 +2546,23 @@
s2_case("4.3.2", "Destroy handle in calling state",
"NUA sends INVITE, receives 180, handle gets destroyed.");
- 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());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
nua_handle_destroy(nh);
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ s2_sip_free_message(invite);
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(cancel);
}
END_TEST
@@ -2574,11 +2574,11 @@
s2_case("4.3.3", "Destroy handle in completing state",
"NUA sends INVITE, receives 200, handle gets destroyed.");
- 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, NUTAG_AUTOACK(0), TAG_END());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
@@ -2588,16 +2588,16 @@
nua_handle_destroy(nh);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(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, 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);
- s2_free_message(invite);
+ s2_sip_free_message(invite);
}
END_TEST
@@ -2610,11 +2610,11 @@
s2_case("4.3.3", "Destroy handle in ready state ",
"NUA sends INVITE, receives 200, handle gets destroyed.");
- 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, NUTAG_AUTOACK(0), TAG_END());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
@@ -2623,20 +2623,20 @@
fail_unless(s2_check_callstate(nua_callstate_completing));
nua_ack(nh, TAG_END());
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(ack);
fail_unless(s2_check_callstate(nua_callstate_ready));
nua_handle_destroy(nh);
- 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);
- s2_free_message(invite);
+ s2_sip_free_message(invite);
}
END_TEST
@@ -2656,15 +2656,15 @@
nua_handle_destroy(nh);
- s2_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_100_TRYING, TAG_END());
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ s2_sip_free_message(invite);
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(cancel);
}
END_TEST
@@ -2681,19 +2681,19 @@
invite = invite_sent_by_nua(nh, TAG_END());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
nua_handle_destroy(nh);
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
- s2_free_message(invite);
+ s2_sip_respond_to(invite, dialog, SIP_487_REQUEST_CANCELLED, TAG_END());
+ s2_sip_free_message(invite);
- s2_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_200_OK, TAG_END());
+ s2_sip_free_message(cancel);
}
END_TEST
@@ -2710,7 +2710,7 @@
invite = invite_sent_by_nua(nh, NUTAG_AUTOACK(0), TAG_END());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
@@ -2720,16 +2720,16 @@
nua_handle_destroy(nh);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(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, 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);
- s2_free_message(invite);
+ s2_sip_free_message(invite);
}
END_TEST
@@ -2739,15 +2739,12 @@
nua_handle_t *nh;
struct message *invite, *ack, *bye;
- tport_set_params(s2->master, TPTAG_LOG(1), TAG_END());
- s2_setup_logs(7);
-
s2_case("4.3.8", "Destroy handle after INVITE sent",
"NUA sends INVITE, handle gets destroyed, "
"but remote end returns 200 OK. "
"Make sure nua tries to release call properly.");
- 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());
process_offer(invite);
@@ -2755,16 +2752,16 @@
nua_handle_destroy(nh);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(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, 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);
}
END_TEST
@@ -2774,40 +2771,37 @@
nua_handle_t *nh;
struct message *invite, *cancel, *ack, *bye;
- tport_set_params(s2->master, TPTAG_LOG(1), TAG_END());
- s2_setup_logs(7);
-
s2_case("4.3.9", "Destroy handle in calling state",
"NUA sends INVITE, receives 180, handle gets destroyed, "
"but remote end returns 200 OK. "
"Make sure nua tries to release call properly.");
- 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());
process_offer(invite);
- s2_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
+ s2_sip_respond_to(invite, dialog, SIP_180_RINGING, TAG_END());
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
nua_handle_destroy(nh);
- cancel = s2_wait_for_request(SIP_METHOD_CANCEL);
+ cancel = s2_sip_wait_for_request(SIP_METHOD_CANCEL);
fail_if(!cancel);
- s2_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
- s2_free_message(cancel);
+ s2_sip_respond_to(cancel, dialog, SIP_481_NO_TRANSACTION, TAG_END());
+ s2_sip_free_message(cancel);
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
- ack = s2_wait_for_request(SIP_METHOD_ACK);
+ ack = s2_sip_wait_for_request(SIP_METHOD_ACK);
fail_if(!ack);
- s2_free_message(ack);
+ s2_sip_free_message(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, 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);
}
END_TEST
@@ -2831,18 +2825,18 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_handle_destroy(nh);
- response = s2_wait_for_response(480, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(480, SIP_METHOD_INVITE);
fail_if(!response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
- s2_free_message(response);
+ s2_sip_free_message(response);
}
END_TEST
@@ -2866,24 +2860,24 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_respond(nh, SIP_180_RINGING, TAG_END());
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_handle_destroy(nh);
- response = s2_wait_for_response(480, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(480, SIP_METHOD_INVITE);
fail_if(!response);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
- s2_free_message(response);
+ s2_sip_free_message(response);
}
END_TEST
@@ -2907,37 +2901,37 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_respond(nh, SIP_180_RINGING,
SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
fail_unless(s2_check_callstate(nua_callstate_early));
nua_respond(nh, SIP_200_OK, TAG_END());
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
nua_handle_destroy(nh);
- fail_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
- s2_free_message(response);
+ s2_sip_free_message(response);
- 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);
}
END_TEST
@@ -2961,37 +2955,37 @@
s2_free_event(invite);
- response = s2_wait_for_response(100, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(100, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_respond(nh, SIP_180_RINGING,
SOATAG_USER_SDP_STR("m=audio 5004 RTP/AVP 0 8"),
TAG_END());
- response = s2_wait_for_response(180, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(180, SIP_METHOD_INVITE);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
fail_unless(s2_check_callstate(nua_callstate_early));
nua_respond(nh, SIP_200_OK, TAG_END());
fail_unless(s2_check_callstate(nua_callstate_completed));
- response = s2_wait_for_response(200, SIP_METHOD_INVITE);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_INVITE);
fail_if(!response);
nua_handle_destroy(nh);
- 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_if(s2_request_to(dialog, SIP_METHOD_ACK, NULL,
+ fail_if(s2_sip_request_to(dialog, SIP_METHOD_ACK, NULL,
SIPTAG_VIA(sip_object(dialog->invite)->sip_via),
TAG_END()));
- s2_free_message(response);
+ s2_sip_free_message(response);
}
END_TEST
@@ -3037,23 +3031,23 @@
s2_case("5.1.1", "Test nua_respond() API",
"Test nua_respond() API with OPTIONS.");
- s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
options = s2_wait_for_event(nua_i_options, 200);
fail_unless(options != NULL);
nh = options->nh; fail_if(!nh);
- response = s2_wait_for_response(200, SIP_METHOD_OPTIONS);
+ response = s2_sip_wait_for_response(200, SIP_METHOD_OPTIONS);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_handle_destroy(nh);
nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END());
fail_unless(s2_check_event(nua_r_set_params, 200));
- s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
options = s2_wait_for_event(nua_i_options, 100);
fail_unless(options != NULL);
@@ -3061,9 +3055,9 @@
nua_respond(nh, 202, "okok", NUTAG_WITH_SAVED(options->event), TAG_END());
- response = s2_wait_for_response(202, SIP_METHOD_OPTIONS);
+ response = s2_sip_wait_for_response(202, SIP_METHOD_OPTIONS);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_handle_destroy(nh);
}
@@ -3099,7 +3093,7 @@
nua_set_params(nua, NUTAG_APPL_METHOD("OPTIONS"), TAG_END());
fail_unless(s2_check_event(nua_r_set_params, 200));
- s2_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
+ s2_sip_request_to(dialog, SIP_METHOD_OPTIONS, NULL, TAG_END());
options = s2_wait_for_event(nua_i_options, 100);
fail_unless(options != NULL);
@@ -3109,9 +3103,9 @@
pthread_join(tid, &thread_return);
fail_unless(thread_return == (void *)options);
- response = s2_wait_for_response(202, SIP_METHOD_OPTIONS);
+ response = s2_sip_wait_for_response(202, SIP_METHOD_OPTIONS);
fail_if(!response);
- s2_free_message(response);
+ s2_sip_free_message(response);
nua_handle_destroy(nh);
}
@@ -3160,13 +3154,13 @@
s2_case("5.2.1", "Receive REFER",
"Make a call, receive REFER.");
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, TAG_END());
- *sip_refer_to_init(r)->r_url = *s2->local->a_url;
+ *sip_refer_to_init(r)->r_url = *s2sip->aor->a_url;
r->r_url->url_user = "bob2";
- s2_request_to(dialog, SIP_METHOD_REFER, NULL,
+ s2_sip_request_to(dialog, SIP_METHOD_REFER, NULL,
SIPTAG_REFER_TO(r),
TAG_END());
refer = s2_wait_for_event(nua_i_refer, 202);
@@ -3175,8 +3169,8 @@
nua_handle_destroy(nh);
- notify = s2_wait_for_request(SIP_METHOD_NOTIFY);
- s2_respond_to(notify, dialog, SIP_200_OK, TAG_END());
+ notify = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
+ s2_sip_respond_to(notify, dialog, SIP_200_OK, TAG_END());
}
END_TEST
@@ -3200,16 +3194,13 @@
dialog2 = su_home_new(sizeof *dialog2); fail_unless(dialog2 != NULL);
- nh = nua_handle(nua, NULL, SIPTAG_TO(s2->local), TAG_END());
+ nh = nua_handle(nua, NULL, SIPTAG_TO(s2sip->aor), TAG_END());
invite_by_nua(nh, TAG_END());
- *sip_refer_to_init(r)->r_url = *s2->local->a_url;
+ *sip_refer_to_init(r)->r_url = *s2sip->aor->a_url;
r->r_url->url_user = "bob2";
- tport_set_params(s2->master, TPTAG_LOG(1), TAG_END());
- s2_setup_logs(7);
-
- s2_request_to(dialog, SIP_METHOD_REFER, NULL,
+ s2_sip_request_to(dialog, SIP_METHOD_REFER, NULL,
SIPTAG_REFER_TO(r),
TAG_END());
refer = s2_wait_for_event(nua_i_refer, 202);
@@ -3233,10 +3224,10 @@
SIPTAG_PAYLOAD_STR("SIP/2.0 100 Trying\r\n"),
NUTAG_SUBSTATE(nua_substate_active),
TAG_END());
- notify0 = s2_wait_for_request(SIP_METHOD_NOTIFY);
+ notify0 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
fail_unless((ss = notify0->sip->sip_subscription_state) != NULL);
fail_unless(su_casematch("active", ss->ss_substate));
- s2_respond_to(notify0, dialog1, SIP_200_OK, TAG_END());
+ s2_sip_respond_to(notify0, dialog1, SIP_200_OK, TAG_END());
notified = s2_wait_for_event(nua_r_notify, 200);
nh2 = nua_handle(nua, NULL, NUTAG_URL(r->r_url), TAG_END());
@@ -3255,17 +3246,17 @@
fail_unless(s2_check_event(nua_r_invite, 180));
fail_unless(s2_check_callstate(nua_callstate_proceeding));
- notify1 = s2_wait_for_request(SIP_METHOD_NOTIFY);
- s2_respond_to(notify1, dialog1, SIP_200_OK, TAG_END());
+ notify1 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
+ s2_sip_respond_to(notify1, dialog1, SIP_200_OK, TAG_END());
respond_with_sdp(invite, dialog, SIP_200_OK, TAG_END());
- s2_free_message(invite);
+ s2_sip_free_message(invite);
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));
- notify2 = s2_wait_for_request(SIP_METHOD_NOTIFY);
- s2_respond_to(notify2, dialog1, SIP_200_OK, TAG_END());
+ notify2 = s2_sip_wait_for_request(SIP_METHOD_NOTIFY);
+ s2_sip_respond_to(notify2, dialog1, SIP_200_OK, TAG_END());
fail_unless((ss = notify2->sip->sip_subscription_state) != NULL);
fail_unless(su_casematch("terminated", ss->ss_substate));
@@ -3296,10 +3287,10 @@
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
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/check_simple.c Tue Mar 3 16:00:56 2009
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
ta_tags(ta));
}
- s2_free_message(subscribe);
+ s2_sip_free_message(subscribe);
return notify;
}
@@ -235,15 +234,15 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
"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 @@
"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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
"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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.c Tue Mar 3 16:00:56 2009
@@ -54,33 +54,11 @@
#include <limits.h>
#include <time.h>
-char const *s2_tester = "s2_tester";
-int s2_start_stop;
+/* -- Globals -------------------------------------------------------------- */
-/* -- Module types ------------------------------------------------------ */
+struct s2nua *s2;
-struct tp_magic_s
-{
- sip_via_t *via;
- sip_contact_t *contact;
-};
-
-/* -- Module prototypes ------------------------------------------------- */
-
-static msg_t *s2_msg(int flags);
-static int s2_complete_response(msg_t *response,
- int status, char const *phrase,
- msg_t *request);
-static char *s2_generate_tag(su_home_t *home);
-
-/* -- Module globals ---------------------------------------------------- */
-
-struct tester *s2;
-
-static char const *_s2case = "0.0";
-static unsigned s2_tag_generator = 0;
-
-/* -- Globals ----------------------------------------------------------- */
+int s2_nua_thread = 0;
unsigned s2_default_registration_duration = 3600;
@@ -108,8 +86,6 @@
char const s2_auth3_credentials[] = "Digest:\"s2test3\":abc:abc";
-int s2_nua_thread = 0;
-
/* -- NUA events -------------------------------------------------------- */
struct event *s2_remove_event(struct event *e)
@@ -148,7 +124,7 @@
if (s2->events)
return s2_remove_event(s2->events);
- su_root_step(s2->root, 100);
+ su_root_step(s2base->root, 100);
}
}
@@ -165,7 +141,7 @@
return s2_remove_event(e);
}
- su_root_step(s2->root, 100);
+ su_root_step(s2base->root, 100);
}
}
@@ -230,862 +206,6 @@
*prev = e, e->prev = prev;
}
-/* ---------------------------------------------------------------------- */
-/* SIP messages sent by nua */
-
-struct message *
-s2_remove_message(struct message *m)
-{
- if ((*m->prev = m->next))
- m->next->prev = m->prev;
-
- m->prev = NULL, m->next = NULL;
-
- return m;
-}
-
-void
-s2_free_message(struct message *m)
-{
- if (m) {
- if (m->prev) {
- if ((*m->prev = m->next))
- m->next->prev = m->prev;
- }
- msg_destroy(m->msg);
- tport_unref(m->tport);
- free(m);
- }
-}
-
-void s2_flush_messages(void)
-{
- while (s2->received) {
- s2_free_message(s2->received);
- }
-}
-
-struct message *
-s2_next_response(void)
-{
- struct message *m;
-
- for (;;) {
- for (m = s2->received; m; m = m->next) {
- if (m->sip->sip_status)
- return s2_remove_message(m);
- }
- su_root_step(s2->root, 100);
- }
-}
-
-struct message *
-s2_wait_for_response(int status, sip_method_t method, char const *name)
-{
- struct message *m;
-
- for (;;) {
- for (m = s2->received; m; m = m->next) {
- if (!m->sip->sip_status)
- continue;
-
- if (status != 0 && m->sip->sip_status->st_status != status)
- continue;
-
- if (method == sip_method_unknown && name == NULL)
- break;
-
- if (m->sip->sip_cseq == NULL)
- continue;
-
- if (m->sip->sip_cseq->cs_method != method)
- continue;
- if (name == NULL)
- break;
- if (strcmp(m->sip->sip_cseq->cs_method_name, name) == 0)
- break;
- }
-
- if (m)
- return s2_remove_message(m);
-
- su_root_step(s2->root, 100);
- }
-}
-
-int
-s2_check_response(int status, sip_method_t method, char const *name)
-{
- struct message *m = s2_wait_for_response(status, method, name);
- s2_free_message(m);
- return m != NULL;
-}
-
-
-struct message *
-s2_next_request(void)
-{
- struct message *m;
-
- for (;;) {
- for (m = s2->received; m; m = m->next) {
- if (m->sip->sip_request)
- return s2_remove_message(m);
- }
-
- su_root_step(s2->root, 100);
- }
-
- return NULL;
-}
-
-struct message *
-s2_wait_for_request(sip_method_t method, char const *name)
-{
- return s2_wait_for_request_timeout(method, name, -1);
-}
-
-struct message *
-s2_wait_for_request_timeout(sip_method_t method, char const *name, int timeout)
-{
- struct message *m;
- int t = timeout;
-
- for (;;) {
- for (m = s2->received; m; m = m->next) {
- if (m->sip->sip_request) {
- if (method == sip_method_unknown && name == NULL)
- return s2_remove_message(m);
-
- if (m->sip->sip_request->rq_method == method &&
- strcmp(m->sip->sip_request->rq_method_name, name) == 0)
- return s2_remove_message(m);
- }
- }
-
- su_root_step(s2->root, 100);
- if (timeout != -1 && ((t -= 100) <= 0))
- break;
- }
-
- return NULL;
-}
-
-int
-s2_check_request(sip_method_t method, char const *name)
-{
- struct message *m = s2_wait_for_request(method, name);
- s2_free_message(m);
- return m != NULL;
-}
-
-int
-s2_check_request_timeout(sip_method_t method, char const *name, int timeout)
-{
- struct message *m = s2_wait_for_request_timeout(method, name, timeout);
- s2_free_message(m);
- return m != NULL;
-}
-
-void
-s2_save_uas_dialog(struct dialog *d, sip_t *sip)
-{
- if (d && !d->local) {
- assert(sip->sip_request);
- d->local = sip_from_dup(d->home, sip->sip_to);
- if (d->local->a_tag == NULL)
- sip_from_tag(d->home, d->local, s2_generate_tag(d->home));
- d->remote = sip_to_dup(d->home, sip->sip_from);
- d->call_id = sip_call_id_dup(d->home, sip->sip_call_id);
- d->rseq = sip->sip_cseq->cs_seq;
- /* d->route = sip_route_dup(d->home, sip->sip_record_route); */
- d->target = sip_contact_dup(d->home, sip->sip_contact);
- }
-}
-
-struct message *
-s2_respond_to(struct message *m, struct dialog *d,
- int status, char const *phrase,
- tag_type_t tag, tag_value_t value, ...)
-{
- ta_list ta;
- msg_t *reply;
- sip_t *sip;
- su_home_t *home;
- tp_name_t tpn[1];
- char *rport;
-
- assert(m); assert(m->msg); assert(m->tport);
- assert(100 <= status && status < 700);
-
- s2_save_uas_dialog(d, m->sip);
-
- ta_start(ta, tag, value);
-
- reply = s2_msg(0); sip = sip_object(reply); home = msg_home(reply);
-
- assert(reply && home && sip);
-
- if (sip_add_tl(reply, sip, ta_tags(ta)) < 0) {
- abort();
- }
-
- s2_complete_response(reply, status, phrase, m->msg);
-
- if (sip->sip_status && sip->sip_status->st_status > 100 &&
- sip->sip_to && !sip->sip_to->a_tag &&
- sip->sip_cseq && sip->sip_cseq->cs_method != sip_method_cancel) {
- char const *ltag = NULL;
-
- if (d && d->local)
- ltag = d->local->a_tag;
-
- if (ltag == NULL)
- ltag = s2_generate_tag(home);
-
- if (sip_to_tag(msg_home(reply), sip->sip_to, ltag) < 0) {
- assert(!"add To tag");
- }
- }
-
- if (d && !d->contact) {
- d->contact = sip_contact_dup(d->home, sip->sip_contact);
- }
-
- *tpn = *tport_name(m->tport);
-
- rport = su_sprintf(home, "rport=%u",
- ntohs(((su_sockaddr_t *)
- msg_addrinfo(m->msg)->ai_addr)->su_port));
-
- if (s2->server_uses_rport &&
- sip->sip_via->v_rport &&
- sip->sip_via->v_rport[0] == '\0') {
- msg_header_add_param(home, sip->sip_via->v_common, rport);
- }
-
- tpn->tpn_port = rport + strlen("rport=");
-
- tport_tsend(m->tport, reply, tpn, TPTAG_MTU(INT_MAX), ta_tags(ta));
- msg_destroy(reply);
-
- ta_end(ta);
-
- return m;
-}
-
-/** Add headers from the request to the response message. */
-static int
-s2_complete_response(msg_t *response,
- int status, char const *phrase,
- msg_t *request)
-{
- su_home_t *home = msg_home(response);
- sip_t *response_sip = sip_object(response);
- sip_t const *request_sip = sip_object(request);
-
- int incomplete = 0;
-
- if (!response_sip || !request_sip || !request_sip->sip_request)
- return -1;
-
- if (!response_sip->sip_status)
- response_sip->sip_status = sip_status_create(home, status, phrase, NULL);
- if (!response_sip->sip_via)
- response_sip->sip_via = sip_via_dup(home, request_sip->sip_via);
- if (!response_sip->sip_from)
- response_sip->sip_from = sip_from_dup(home, request_sip->sip_from);
- if (!response_sip->sip_to)
- response_sip->sip_to = sip_to_dup(home, request_sip->sip_to);
- if (!response_sip->sip_call_id)
- response_sip->sip_call_id =
- sip_call_id_dup(home, request_sip->sip_call_id);
- if (!response_sip->sip_cseq)
- response_sip->sip_cseq = sip_cseq_dup(home, request_sip->sip_cseq);
-
- if (!response_sip->sip_record_route && request_sip->sip_record_route)
- sip_add_dup(response, response_sip, (void*)request_sip->sip_record_route);
-
- incomplete = sip_complete_message(response) < 0;
-
- msg_serialize(response, (msg_pub_t *)response_sip);
-
- if (incomplete ||
- !response_sip->sip_status ||
- !response_sip->sip_via ||
- !response_sip->sip_from ||
- !response_sip->sip_to ||
- !response_sip->sip_call_id ||
- !response_sip->sip_cseq ||
- !response_sip->sip_content_length ||
- !response_sip->sip_separator ||
- (request_sip->sip_record_route && !response_sip->sip_record_route))
- return -1;
-
- return 0;
-}
-
-/* Send request (updating dialog).
- *
- * Return zero upon success, nonzero upon failure.
- */
-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, ...)
-{
- ta_list ta;
- tagi_t const *tags;
-
- msg_t *msg = s2_msg(0);
- sip_t *sip = sip_object(msg);
- url_t const *target = NULL;
- sip_cseq_t cseq[1];
- sip_via_t via[1]; char const *v_params[8];
- sip_content_length_t l[1];
- tp_name_t tpn[1];
- tp_magic_t *magic;
- int user_via = 0;
-
- ta_start(ta, tag, value);
- tags = ta_args(ta);
-
- if (sip_add_tagis(msg, sip, &tags) < 0)
- goto error;
-
- if (sip->sip_request)
- target = sip->sip_request->rq_url;
- else if (d->target)
- target = d->target->m_url;
- else if (s2->registration->contact)
- target = s2->registration->contact->m_url;
- else
- target = NULL;
-
- if (target == NULL)
- goto error;
-
- if (!sip->sip_request) {
- sip_request_t *rq;
- rq = sip_request_create(msg_home(msg), method, name,
- (url_string_t *)target, NULL);
- sip_header_insert(msg, sip, (sip_header_t *)rq);
- }
-
- if (!d->local && sip->sip_from)
- d->local = sip_from_dup(d->home, sip->sip_from);
- if (!d->contact && sip->sip_contact)
- d->contact = sip_contact_dup(d->home, sip->sip_contact);
- if (!d->remote && sip->sip_to)
- d->remote = sip_to_dup(d->home, sip->sip_to);
- if (!d->target && sip->sip_request)
- d->target = sip_contact_create(d->home,
- (url_string_t *)sip->sip_request->rq_url,
- NULL);
- if (!d->call_id && sip->sip_call_id)
- d->call_id = sip_call_id_dup(d->home, sip->sip_call_id);
- if (!d->lseq && sip->sip_cseq)
- d->lseq = sip->sip_cseq->cs_seq;
-
- if (!d->local)
- d->local = sip_from_dup(d->home, s2->local);
- if (!d->contact)
- d->contact = sip_contact_dup(d->home, s2->contact);
- if (!d->remote)
- d->remote = sip_to_dup(d->home, s2->registration->aor);
- if (!d->call_id)
- d->call_id = sip_call_id_create(d->home, NULL);
- assert(d->local && d->contact);
- assert(d->remote && d->target);
- assert(d->call_id);
-
- if (tport == NULL)
- tport = d->tport;
-
- if (tport == NULL)
- tport = s2->registration->tport;
-
- if (tport == NULL && d->target->m_url->url_type == url_sips)
- tport = s2->tls.tport;
-
- if (tport == NULL)
- tport = s2->udp.tport;
- else if (tport == NULL)
- tport = s2->tcp.tport;
- else if (tport == NULL)
- tport = s2->tls.tport;
-
- assert(tport);
-
- *tpn = *tport_name(tport);
-
- if (tport_is_primary(tport)) {
- tpn->tpn_host = target->url_host;
- tpn->tpn_port = url_port(target);
- if (!tpn->tpn_port || !tpn->tpn_port[0])
- tpn->tpn_port = url_port_default(target->url_type);
- }
-
- magic = tport_magic(tport);
- assert(magic != NULL);
-
- sip_cseq_init(cseq);
- cseq->cs_method = method;
- cseq->cs_method_name = name;
-
- if (d->invite && (method == sip_method_ack || method == sip_method_cancel)) {
- cseq->cs_seq = sip_object(d->invite)->sip_cseq->cs_seq;
- }
- else {
- cseq->cs_seq = ++d->lseq;
- }
-
- if (sip->sip_via) {
- user_via = 1;
- }
- else if (d->invite && method == sip_method_cancel) {
- *via = *sip_object(d->invite)->sip_via;
- }
- else {
- *via = *magic->via;
- via->v_params = v_params;
- v_params[0] = su_sprintf(msg_home(msg), "branch=z9hG4bK%lx", ++s2->tid);
- v_params[1] = NULL;
- }
-
- sip_content_length_init(l);
- if (sip->sip_payload)
- l->l_length = sip->sip_payload->pl_len;
-
- if (d->local->a_tag == NULL) {
- char const *ltag = s2_generate_tag(d->home);
-
- if (sip_from_tag(d->home, d->local, ltag) < 0) {
- assert(!"add To tag");
- }
-
- if (sip->sip_from && sip->sip_from->a_tag == NULL) {
- if (sip_from_tag(msg_home(msg), sip->sip_from, ltag) < 0) {
- assert(!"add To tag");
- }
- }
- }
-
- sip_add_tl(msg, sip,
- TAG_IF(!sip->sip_from, SIPTAG_FROM(d->local)),
- TAG_IF(!sip->sip_contact, SIPTAG_CONTACT(d->contact)),
- TAG_IF(!sip->sip_to, SIPTAG_TO(d->remote)),
- TAG_IF(!sip->sip_call_id, SIPTAG_CALL_ID(d->call_id)),
- TAG_IF(!sip->sip_cseq, SIPTAG_CSEQ(cseq)),
- TAG_IF(!user_via, SIPTAG_VIA(via)),
- TAG_IF(!sip->sip_content_length, SIPTAG_CONTENT_LENGTH(l)),
- TAG_IF(!sip->sip_separator, SIPTAG_SEPARATOR_STR("\r\n")),
- TAG_END());
-
- msg_serialize(msg, NULL);
-
- if (method == sip_method_invite) {
- msg_destroy(d->invite);
- d->invite = msg_ref_create(msg);
- }
-
- tport = tport_tsend(tport, msg, tpn, ta_tags(ta));
- ta_end(ta);
-
- if (d->tport != tport) {
- tport_unref(d->tport);
- d->tport = tport_ref(tport);
- }
-
- return tport ? 0 : -1;
-
- error:
- ta_end(ta);
- return -1;
-}
-
-/** Save information from response.
- *
- * Send ACK for error messages to INVITE.
- */
-int s2_update_dialog(struct dialog *d, struct message *m)
-{
- int status = 0;
-
- if (m->sip->sip_status)
- status = m->sip->sip_status->st_status;
-
- if (100 < status && status < 300) {
- d->remote = sip_to_dup(d->home, m->sip->sip_to);
- if (m->sip->sip_contact)
- d->contact = sip_contact_dup(d->home, m->sip->sip_contact);
- }
-
- if (300 <= status && m->sip->sip_cseq &&
- m->sip->sip_cseq->cs_method == sip_method_invite &&
- d->invite) {
- msg_t *ack = s2_msg(0);
- sip_t *sip = sip_object(ack);
- sip_t *invite = sip_object(d->invite);
- sip_request_t rq[1];
- sip_cseq_t cseq[1];
- tp_name_t tpn[1];
-
- *rq = *invite->sip_request;
- rq->rq_method = sip_method_ack, rq->rq_method_name = "ACK";
- *cseq = *invite->sip_cseq;
- cseq->cs_method = sip_method_ack, cseq->cs_method_name = "ACK";
-
- sip_add_tl(ack, sip,
- SIPTAG_REQUEST(rq),
- SIPTAG_VIA(invite->sip_via),
- SIPTAG_FROM(invite->sip_from),
- SIPTAG_TO(invite->sip_to),
- SIPTAG_CALL_ID(invite->sip_call_id),
- SIPTAG_CSEQ(cseq),
- SIPTAG_CONTENT_LENGTH_STR("0"),
- SIPTAG_SEPARATOR_STR("\r\n"),
- TAG_END());
-
- *tpn = *tport_name(d->tport);
- if (!tport_is_secondary(d->tport) ||
- !tport_is_clear_to_send(d->tport)) {
- tpn->tpn_host = rq->rq_url->url_host;
- tpn->tpn_port = rq->rq_url->url_port;
- }
-
- msg_serialize(ack, NULL);
- tport_tsend(d->tport, ack, tpn, TAG_END());
- }
-
- return 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-int
-s2_save_register(struct message *rm)
-{
- sip_contact_t *contact, *m, **m_prev;
- sip_expires_t const *ex;
- sip_date_t const *date;
- sip_time_t now = rm->when.tv_sec, expires;
-
- msg_header_free_all(s2->home, (msg_header_t *)s2->registration->aor);
- msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact);
- tport_unref(s2->registration->tport);
-
- s2->registration->aor = NULL;
- s2->registration->contact = NULL;
- s2->registration->tport = NULL;
-
- if (rm == NULL)
- return 0;
-
- assert(rm && rm->sip && rm->sip->sip_request);
- assert(rm->sip->sip_request->rq_method == sip_method_register);
-
- ex = rm->sip->sip_expires;
- date = rm->sip->sip_date;
-
- contact = sip_contact_dup(s2->home, rm->sip->sip_contact);
-
- for (m_prev = &contact; *m_prev;) {
- m = *m_prev;
-
- expires = sip_contact_expires(m, ex, date,
- s2_default_registration_duration,
- now);
- if (expires) {
- char *p = su_sprintf(s2->home, "expires=%lu", (unsigned long)expires);
- msg_header_add_param(s2->home, m->m_common, p);
- m_prev = &m->m_next;
- }
- else {
- *m_prev = m->m_next;
- m->m_next = NULL;
- msg_header_free(s2->home, (msg_header_t *)m);
- }
- }
-
- if (contact == NULL)
- return 0;
-
- s2->registration->aor = sip_to_dup(s2->home, rm->sip->sip_to);
- s2->registration->contact = contact;
- s2->registration->tport = tport_ref(rm->tport);
-
- return 0;
-}
-
-/* ---------------------------------------------------------------------- */
-
-static char *
-s2_generate_tag(su_home_t *home)
-{
- s2_tag_generator += 1;
-
- return su_sprintf(home, "tag=N2-%s/%u", _s2case, s2_tag_generator);
-}
-
-void s2_case(char const *number,
- char const *title,
- char const *description)
-{
- _s2case = number;
-
- if (s2_start_stop)
- printf("%s - starting %s %s\n", s2_tester, number, title);
-}
-
-/* ---------------------------------------------------------------------- */
-/* tport interface */
-static void
-s2_stack_recv(struct tester *s2,
- tport_t *tp,
- msg_t *msg,
- tp_magic_t *magic,
- su_time_t now)
-{
- struct message *next = calloc(1, sizeof *next), **prev;
-
- next->msg = msg;
- next->sip = sip_object(msg);
- next->when = now;
- next->tport = tport_ref(tp);
-
-#if 0
- if (next->sip->sip_request)
- printf("nua sent: %s\n", next->sip->sip_request->rq_method_name);
- else
- printf("nua sent: SIP/2.0 %u %s\n",
- next->sip->sip_status->st_status,
- next->sip->sip_status->st_phrase);
-#endif
-
- for (prev = &s2->received; *prev; prev = &(*prev)->next)
- ;
-
- next->prev = prev, *prev = next;
-}
-
-static void
-s2_stack_error(struct tester *s2,
- tport_t *tp,
- int errcode,
- char const *remote)
-{
- fprintf(stderr, "%s(%p): error %d (%s) from %s\n",
- "nua_tester_error",
- (void *)tp, errcode, su_strerror(errcode),
- remote ? remote : "<unknown destination>");
-}
-
-static msg_t *
-s2_stack_alloc(struct tester *s2, int flags,
- char const data[], usize_t size,
- tport_t const *tport,
- tp_client_t *tpc)
-{
- return msg_create(s2->mclass, flags | s2->flags);
-}
-
-static msg_t *
-s2_msg(int flags)
-{
- return msg_create(s2->mclass, flags | s2->flags);
-}
-
-tp_stack_class_t const s2_stack[1] =
- {{
- /* tpac_size */ (sizeof s2_stack),
- /* tpac_recv */ s2_stack_recv,
- /* tpac_error */ s2_stack_error,
- /* tpac_alloc */ s2_stack_alloc,
- }};
-
-/** Basic setup for test cases */
-void s2_setup_base(char const *label, char const *hostname)
-{
- assert(s2 == NULL);
-
- if (s2_start_stop > 1) {
- printf("%s - setup %s test case\n", s2_tester, label ? label : "next");
- }
-
- su_init();
-
- s2 = su_home_new(sizeof *s2);
-
- assert(s2 != NULL);
-
- s2->root = su_root_create(s2);
-
- assert(s2->root != NULL);
-
- s2->local = sip_from_format(s2->home, "Bob <sip:bob@%s>",
- hostname ? hostname : "example.net");
-
- if (hostname == NULL)
- hostname = "127.0.0.1";
-
- s2->hostname = hostname;
- s2->tid = (unsigned long)time(NULL) * 510633671UL;
-
-}
-
-SOFIAPUBVAR su_log_t nua_log[];
-SOFIAPUBVAR su_log_t soa_log[];
-SOFIAPUBVAR su_log_t nea_log[];
-SOFIAPUBVAR su_log_t nta_log[];
-SOFIAPUBVAR su_log_t tport_log[];
-SOFIAPUBVAR su_log_t su_log_default[];
-
-void
-s2_setup_logs(int level)
-{
- assert(s2);
-
- su_log_soft_set_level(nua_log, level);
- su_log_soft_set_level(soa_log, level);
- su_log_soft_set_level(su_log_default, level);
- su_log_soft_set_level(nea_log, level);
- su_log_soft_set_level(nta_log, level);
- su_log_soft_set_level(tport_log, level);
-}
-
-static char const * default_protocols[] = { "udp", "tcp", NULL };
-
-void
-s2_setup_tport(char const * const *protocols,
- tag_type_t tag, tag_value_t value, ...)
-{
- ta_list ta;
- tp_name_t tpn[1];
- int bound;
- tport_t *tp;
-
- assert(s2 != NULL);
-
- ta_start(ta, tag, value);
-
- if (s2->master == NULL) {
- s2->master = tport_tcreate(s2, s2_stack, s2->root,
- TPTAG_LOG(getenv("S2_TPORT_LOG") != NULL),
- ta_tags(ta));
-
- if (s2->master == NULL) {
- assert(s2->master);
- }
- s2->mclass = sip_default_mclass();
- s2->flags = 0;
- }
-
- memset(tpn, 0, (sizeof tpn));
- tpn->tpn_proto = "*";
- tpn->tpn_host = s2->hostname;
- tpn->tpn_port = "*";
-
- if (protocols == NULL)
- protocols = default_protocols;
-
- bound = tport_tbind(s2->master, tpn, protocols,
- TPTAG_SERVER(1),
- ta_tags(ta));
- assert(bound != -1);
-
- tp = tport_primaries(s2->master);
-
- if (protocols == default_protocols && s2->contact == NULL) {
- *tpn = *tport_name(tp);
- s2->contact = sip_contact_format(s2->home, "<sip:%s:%s>",
- tpn->tpn_host,
- tpn->tpn_port);
- }
-
- for (;tp; tp = tport_next(tp)) {
- sip_via_t *v;
- sip_contact_t *m;
- tp_magic_t *magic;
-
- if (tport_magic(tp))
- continue;
-
- *tpn = *tport_name(tp);
-
- v = sip_via_format(s2->home, "SIP/2.0/%s %s:%s",
- tpn->tpn_proto,
- tpn->tpn_host,
- tpn->tpn_port);
- assert(v != NULL);
- if (!su_casenmatch(tpn->tpn_proto, "tls", 3)) {
- m = sip_contact_format(s2->home, "<sip:%s:%s;transport=%s>",
- tpn->tpn_host,
- tpn->tpn_port,
- tpn->tpn_proto);
- if (s2->udp.contact == NULL && su_casematch(tpn->tpn_proto, "udp")) {
- s2->udp.tport = tport_ref(tp);
- s2->udp.contact = m;
- }
- if (s2->tcp.contact == NULL && su_casematch(tpn->tpn_proto, "tcp")) {
- s2->tcp.tport = tport_ref(tp);
- s2->tcp.contact = m;
- }
- }
- else if (!su_casematch(tpn->tpn_proto, "tls")) {
- m = sip_contact_format(s2->home, "<sips:%s:%s;transport=%s>",
- tpn->tpn_host,
- tpn->tpn_port,
- tpn->tpn_proto);
- }
- else {
- m = sip_contact_format(s2->home, "<sips:%s:%s>",
- tpn->tpn_host,
- tpn->tpn_port);
- if (s2->tls.contact == NULL) {
- s2->tls.tport = tport_ref(tp);
- s2->tls.contact = m;
- }
- }
- assert(m != NULL);
-
- magic = su_zalloc(s2->home, (sizeof *magic));
- magic->via = v, magic->contact = m;
-
- if (s2->contact == NULL)
- s2->contact = m;
-
- tport_set_magic(tp, magic);
- }
-}
-
-static char const *s2_teardown_label = NULL;
-
-void
-s2_teardown_started(char const *label)
-{
- if (!s2_teardown_label) {
- s2_teardown_label = label;
- if (s2_start_stop > 1) {
- printf("%s - tearing down %s test case\n", s2_tester, label);
- }
- }
-}
-
-void
-s2_teardown(void)
-{
- s2 = NULL;
- su_deinit();
-
- if (s2_start_stop > 1) {
- printf("%s - %s test case tore down\n", s2_tester,
- s2_teardown_label ? s2_teardown_label : "previous");
- }
-
- s2_teardown_label = NULL;
-}
/* ====================================================================== */
@@ -1094,27 +214,31 @@
{
ta_list ta;
- s2_setup_base(label, NULL);
- s2_dns_setup(s2->root);
+ s2_setup(label);
+
+ s2 = su_home_new(sizeof *s2);
+
+ s2_dns_setup(s2base->root);
s2_setup_logs(0);
- s2_setup_tport(NULL, TAG_END());
- assert(s2->contact);
+ s2_sip_setup("example.org", NULL, TAG_END());
+ assert(s2sip->contact);
+
s2_dns_domain("example.org", 1,
- "s2", 1, s2->udp.contact->m_url,
- "s2", 1, s2->tcp.contact->m_url,
+ "s2", 1, s2sip->udp.contact->m_url,
+ "s2", 1, s2sip->tcp.contact->m_url,
NULL);
/* enable/disable multithreading */
- su_root_threading(s2->root, s2_nua_thread);
+ su_root_threading(s2base->root, s2_nua_thread);
ta_start(ta, tag, value);
s2->nua =
- nua_create(s2->root,
+ nua_create(s2base->root,
s2_nua_callback,
s2,
SIPTAG_FROM_STR("Alice <sip:alice at example.org>"),
- /* NUTAG_PROXY((url_string_t *)s2->contact->m_url), */
+ /* NUTAG_PROXY((url_string_t *)s2sip->contact->m_url), */
/* Use internal DNS server */
NUTAG_PROXY("sip:example.org"),
/* Force sresolv to use localhost and s2dns as DNS server */
@@ -1129,12 +253,33 @@
return s2->nua;
}
+void
+s2_nua_fast_forward(unsigned long seconds,
+ su_root_t *steproot)
+{
+ s2_fast_forward(seconds, NULL);
+
+ if (s2_nua_thread)
+ /* Wake up nua thread */
+ nua_handle_by_call_id(s2->nua, NULL);
+
+ if (steproot)
+ su_root_step(steproot, 0);
+}
+
void s2_nua_teardown(void)
{
- nua_destroy(s2->nua);
- s2->nua = NULL;
+ if (s2) {
+ struct s2nua *zap = s2;
+ nua_destroy(s2->nua), s2->nua = NULL;
+ s2 = NULL;
+ su_home_unref(zap->home);
+ }
+
s2_dns_teardown();
+ s2_sip_teardown();
s2_teardown();
+
}
/* ====================================================================== */
@@ -1160,15 +305,16 @@
nua_register(nh, TAG_END());
- m = s2_wait_for_request(SIP_METHOD_REGISTER);
+ m = s2_sip_wait_for_request(SIP_METHOD_REGISTER);
assert(m);
+
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);
@@ -1193,15 +339,15 @@
nua_unregister(nh, TAG_END());
- m = s2_wait_for_request(SIP_METHOD_REGISTER); assert(m);
+ m = s2_sip_wait_for_request(SIP_METHOD_REGISTER); assert(m);
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());
assert(s2->registration->contact == NULL);
- s2_free_message(m);
+ s2_sip_free_message(m);
s2_check_event(nua_r_unregister, 200);
@@ -1209,3 +355,62 @@
s2->registration->nh = NULL;
}
}
+
+int
+s2_save_register(struct message *rm)
+{
+ sip_contact_t *contact, *m, **m_prev;
+ sip_expires_t const *ex;
+ sip_date_t const *date;
+ sip_time_t now = rm->when.tv_sec, expires;
+
+ msg_header_free_all(s2->home, (msg_header_t *)s2->registration->aor);
+ msg_header_free_all(s2->home, (msg_header_t *)s2->registration->contact);
+ tport_unref(s2->registration->tport);
+
+ s2->registration->aor = NULL;
+ s2->registration->contact = NULL;
+ s2->registration->tport = NULL;
+
+ if (rm == NULL)
+ return 0;
+
+ assert(rm && rm->sip && rm->sip->sip_request);
+ assert(rm->sip->sip_request->rq_method == sip_method_register);
+
+ ex = rm->sip->sip_expires;
+ date = rm->sip->sip_date;
+
+ contact = sip_contact_dup(s2->home, rm->sip->sip_contact);
+
+ for (m_prev = &contact; *m_prev;) {
+ m = *m_prev;
+
+ expires = sip_contact_expires(m, ex, date,
+ s2_default_registration_duration,
+ now);
+ if (expires) {
+ char *p = su_sprintf(s2->home, "expires=%lu", (unsigned long)expires);
+ msg_header_add_param(s2->home, m->m_common, p);
+ m_prev = &m->m_next;
+ }
+ else {
+ *m_prev = m->m_next;
+ m->m_next = NULL;
+ msg_header_free(s2->home, (msg_header_t *)m);
+ }
+ }
+
+ if (contact == NULL)
+ return 0;
+
+ s2->registration->aor = sip_to_dup(s2->home, rm->sip->sip_to);
+ s2->registration->contact = contact;
+ s2->registration->tport = tport_ref(rm->tport);
+
+ s2sip->sut.aor = s2->registration->aor;
+ s2sip->sut.contact = s2->registration->contact;
+ s2sip->sut.tport = s2->registration->tport;
+
+ return 0;
+}
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nua/test_s2.h Tue Mar 3 16:00:56 2009
@@ -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 @@
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 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_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
+
More information about the Freeswitch-svn
mailing list