[Freeswitch-svn] [commit] r10826 - in freeswitch/trunk/libs/sofia-sip: . libsofia-sip-ua/nta
FreeSWITCH SVN
mikej at freeswitch.org
Tue Dec 16 12:34:00 PST 2008
Author: mikej
Date: Tue Dec 16 15:34:00 2008
New Revision: 10826
Log:
Mon Dec 15 08:31:45 CST 2008 Stas Maximov <smaximov at ieee.org>
* nta: NULL host and port in user Via are filled automaticaly
NULL host or port in user-supplied Via header will be filled
automaticaly by NTA, just like branch and rport params.
Added related test case to test_nta_api.c.
Modified:
freeswitch/trunk/libs/sofia-sip/.update
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
Modified: freeswitch/trunk/libs/sofia-sip/.update
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/.update (original)
+++ freeswitch/trunk/libs/sofia-sip/.update Tue Dec 16 15:34:00 2008
@@ -1 +1 @@
-Tue Dec 16 14:28:36 CST 2008
+Tue Dec 16 14:33:26 CST 2008
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/nta.c Tue Dec 16 15:34:00 2008
@@ -2550,12 +2550,12 @@
clear = 1, v->v_protocol = via->v_protocol;
/* XXX - should we do this? */
- if (!user_via &&
+ if ((!user_via || !v->v_host) &&
via->v_host != v->v_host &&
str0cmp(via->v_host, v->v_host))
clear = 1, v->v_host = via->v_host;
- if ((!user_via ||
+ if ((!user_via || !v->v_port ||
/* Replace port in user Via only if we use udp and no rport */
(v->v_protocol == sip_transport_udp && !v->v_rport &&
!orq->orq_stateless)) &&
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/nta/test_nta_api.c Tue Dec 16 15:34:00 2008
@@ -865,6 +865,90 @@
}
+/* Test that NULL host and/or port fields of user supplied Via header are
+ filled in automaticaly */
+int api_test_user_via_fillin(agent_t *ag)
+{
+ su_home_t home[1];
+ su_root_t *root;
+ nta_agent_t *nta;
+ nta_leg_t *leg;
+ nta_outgoing_t *orq0, *orq1;
+ msg_t *msg0, *msg1;
+ sip_t *sip0, *sip1;
+ sip_via_t *via0, *via1;
+ sip_via_t via[1];
+ static char *via_params[] = { "param1=value1", "param2=value2" };
+ int i;
+
+ BEGIN();
+
+ memset(home, 0, sizeof home);
+ su_home_init(home);
+
+ TEST_1(root = su_root_create(NULL));
+
+ TEST_1(nta = nta_agent_create(root,
+ (url_string_t *)"sip:*:*",
+ NULL,
+ NULL,
+ TAG_END()));
+ TEST_1(leg = nta_leg_tcreate(nta, NULL, NULL,
+ NTATAG_NO_DIALOG(1),
+ TAG_END()));
+
+ /* This creates a delayed response message */
+ orq0 = nta_outgoing_tcreate(leg, outgoing_callback, ag, NULL,
+ SIP_METHOD_MESSAGE,
+ URL_STRING_MAKE("sip:foo.bar;transport=none"),
+ SIPTAG_FROM_STR("<sip:bar.foo>"),
+ SIPTAG_TO_STR("<sip:foo.bar>"),
+ TAG_END());
+ TEST_1(orq0);
+ TEST_1(msg0 = nta_outgoing_getrequest(orq0));
+ TEST_1(sip0 = sip_object(msg0));
+ TEST_1(via0 = sip0->sip_via);
+
+ /* create user Via template to be filled in by NTA */
+ sip_via_init(via);
+ via->v_protocol = "*";
+ for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++)
+ sip_via_add_param(home,via,via_params[i]); /* add param to the template */
+
+ /* This creates a delayed response message */
+ orq1 = nta_outgoing_tcreate(leg, outgoing_callback, ag, NULL,
+ SIP_METHOD_MESSAGE,
+ URL_STRING_MAKE("sip:foo.bar;transport=none"),
+ SIPTAG_FROM_STR("<sip:bar.foo>"),
+ SIPTAG_TO_STR("<sip:foo.bar>"),
+ NTATAG_USER_VIA(1),
+ SIPTAG_VIA(via),
+ TAG_END());
+ TEST_1(orq1);
+ TEST_1(msg1 = nta_outgoing_getrequest(orq1));
+ TEST_1(sip1 = sip_object(msg1));
+ TEST_1(via1 = sip1->sip_via);
+
+ /* check that template has been filled correctly */
+ TEST_S(via0->v_protocol,via1->v_protocol);
+ TEST_S(via0->v_host,via1->v_host);
+ TEST_S(via0->v_port,via1->v_port);
+ /* check that the parameter has been preserved */
+ for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++)
+ TEST_S(via1->v_params[i],via_params[i]);
+
+ TEST_VOID(nta_outgoing_destroy(orq0));
+ TEST_VOID(nta_outgoing_destroy(orq1));
+ TEST_VOID(nta_leg_destroy(leg));
+ TEST_VOID(nta_agent_destroy(nta));
+
+ TEST_VOID(su_root_destroy(root));
+ TEST_VOID(su_home_deinit(home));
+
+ END();
+}
+
+
int outgoing_default(agent_t *ag,
nta_outgoing_t *orq,
sip_t const *sip)
@@ -1426,6 +1510,7 @@
retval |= api_test_tport(ag); SINGLE_FAILURE_CHECK();
retval |= api_test_dialogs(ag); SINGLE_FAILURE_CHECK();
retval |= api_test_default(ag); SINGLE_FAILURE_CHECK();
+ retval |= api_test_user_via_fillin(ag); SINGLE_FAILURE_CHECK();
}
retval |= api_test_deinit(ag); fflush(stdout);
More information about the Freeswitch-svn
mailing list