提交 eeff4df0 authored 作者: Michael Jerris's avatar Michael Jerris

Thu Jan 8 12:38:05 CST 2009 Pekka Pessi <first.last@nokia.com>

  * nta: use <sofia-sip/su_string.h> functions



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11794 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 56288457
Wed Feb 11 10:46:12 CST 2009 Wed Feb 11 10:46:42 CST 2009
...@@ -219,14 +219,14 @@ int nta_check_session_content(nta_incoming_t *irq, ...@@ -219,14 +219,14 @@ int nta_check_session_content(nta_incoming_t *irq,
if (sip->sip_payload == NULL) if (sip->sip_payload == NULL)
return 0; return 0;
if (cd == NULL || strcasecmp(cd->cd_type, "session") == 0) { if (cd == NULL || su_casematch(cd->cd_type, "session")) {
sip_accept_t const *ab = session_accepts; sip_accept_t const *ab = session_accepts;
char const *c_type; char const *c_type;
if (c) if (c)
c_type = c->c_type; c_type = c->c_type;
else if (sip->sip_payload->pl_len > 3 && else if (sip->sip_payload->pl_len > 3 &&
strncasecmp(sip->sip_payload->pl_data, "v=0", 3) == 0) su_casenmatch(sip->sip_payload->pl_data, "v=0", 3))
/* Missing Content-Type, but it looks like SDP */ /* Missing Content-Type, but it looks like SDP */
c_type = application_sdp; c_type = application_sdp;
else else
...@@ -234,7 +234,7 @@ int nta_check_session_content(nta_incoming_t *irq, ...@@ -234,7 +234,7 @@ int nta_check_session_content(nta_incoming_t *irq,
ab = NULL, c_type = NULL; ab = NULL, c_type = NULL;
for (; ab; ab = ab->ac_next) { for (; ab; ab = ab->ac_next) {
if (strcasecmp(c_type, ab->ac_type) == 0) if (su_casematch(c_type, ab->ac_type))
break; break;
} }
...@@ -311,7 +311,7 @@ int nta_check_accept(nta_incoming_t *irq, ...@@ -311,7 +311,7 @@ int nta_check_accept(nta_incoming_t *irq,
method == sip_method_prack || method == sip_method_prack ||
method == sip_method_update)) { method == sip_method_update)) {
for (ab = acceptable; ab; ab = ab->ac_next) for (ab = acceptable; ab; ab = ab->ac_next)
if (strcasecmp(application_sdp, ab->ac_type) == 0) { if (su_casematch(application_sdp, ab->ac_type)) {
if (return_acceptable) *return_acceptable = ab; if (return_acceptable) *return_acceptable = ab;
return 0; return 0;
} }
...@@ -322,7 +322,7 @@ int nta_check_accept(nta_incoming_t *irq, ...@@ -322,7 +322,7 @@ int nta_check_accept(nta_incoming_t *irq,
continue; continue;
for (ab = acceptable; ab; ab = ab->ac_next) for (ab = acceptable; ab; ab = ab->ac_next)
if (strcasecmp(ac->ac_type, ab->ac_type) == 0) { if (su_casematch(ac->ac_type, ab->ac_type)) {
if (return_acceptable) *return_acceptable = ab; if (return_acceptable) *return_acceptable = ab;
return 0; return 0;
} }
......
...@@ -237,8 +237,8 @@ void sl_payload_log(su_log_t *log, int level, ...@@ -237,8 +237,8 @@ void sl_payload_log(su_log_t *log, int level,
log = su_log_default; log = su_log_default;
while (s < end && *s != '\0') { while (s < end && *s != '\0') {
size_t n = strncspn(s, end - s, "\r\n"); size_t n = su_strncspn(s, end - s, "\r\n");
size_t crlf = strnspn(s + n, end - s - n, "\r\n"); size_t crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (n < 70) { if (n < 70) {
memcpy(line, s, n); memcpy(line, s, n);
line[n] = '\0'; line[n] = '\0';
......
...@@ -214,8 +214,8 @@ issize_t sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const ...@@ -214,8 +214,8 @@ issize_t sl_payload_print(FILE *stream, char const *prefix, sip_payload_t const
size_t n, total = 0, crlf = 1, actual; size_t n, total = 0, crlf = 1, actual;
while (s < end && *s != '\0') { while (s < end && *s != '\0') {
n = strncspn(s, end - s, "\r\n"); n = su_strncspn(s, end - s, "\r\n");
crlf = strnspn(s + n, end - s - n, "\r\n"); crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (prefix) if (prefix)
fputs(prefix, stream), total += strlen(prefix); fputs(prefix, stream), total += strlen(prefix);
actual = fwrite(s, 1, n + crlf, stream) ; actual = fwrite(s, 1, n + crlf, stream) ;
......
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <stdio.h> #include <stdio.h>
#ifndef STRING0_H #ifndef STRING0_H
#include <sofia-sip/string0.h> #include <sofia-sip/su_string.h>
#endif #endif
#ifndef SIP_H #ifndef SIP_H
......
...@@ -62,7 +62,7 @@ typedef struct client_t client_t; ...@@ -62,7 +62,7 @@ typedef struct client_t client_t;
#include <sofia-sip/hostdomain.h> #include <sofia-sip/hostdomain.h>
#include <sofia-sip/tport.h> #include <sofia-sip/tport.h>
#include <sofia-sip/string0.h> #include <sofia-sip/su_string.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -564,7 +564,7 @@ int test_init(agent_t *ag, char const *resolv_conf) ...@@ -564,7 +564,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
TEST_1(ag->ag_mclass); TEST_1(ag->ag_mclass);
#if SU_HAVE_IN6 #if SU_HAVE_IN6
if (str0cmp(getenv("ipv6"), "true") == 0) { if (su_strmatch(getenv("ipv6"), "true")) {
contact = "sip:[::]:*;comp=sigcomp"; contact = "sip:[::]:*;comp=sigcomp";
af = AF_INET6, sulen0 = sizeof (struct sockaddr_in6); af = AF_INET6, sulen0 = sizeof (struct sockaddr_in6);
} }
...@@ -1075,22 +1075,22 @@ int test_tports(agent_t *ag) ...@@ -1075,22 +1075,22 @@ int test_tports(agent_t *ag)
TEST_1(v = nta_agent_via(ag->ag_agent)); TEST_1(v = nta_agent_via(ag->ag_agent));
for (; v; v = v->v_next) { for (; v; v = v->v_next) {
if (strcasecmp(v->v_protocol, sip_transport_udp) == 0) { if (su_casematch(v->v_protocol, sip_transport_udp)) {
if (udp) if (udp)
v_udp_only = v; v_udp_only = v;
udp = 1; udp = 1;
if (udp_comp == NULL) if (udp_comp == NULL)
udp_comp = v->v_comp; udp_comp = v->v_comp;
} }
else if (strcasecmp(v->v_protocol, sip_transport_tcp) == 0) { else if (su_casematch(v->v_protocol, sip_transport_tcp)) {
tcp = 1; tcp = 1;
if (tcp_comp == NULL) if (tcp_comp == NULL)
tcp_comp = v->v_comp; tcp_comp = v->v_comp;
} }
else if (strcasecmp(v->v_protocol, sip_transport_sctp) == 0) { else if (su_casematch(v->v_protocol, sip_transport_sctp)) {
sctp = 1; sctp = 1;
} }
else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0) { else if (su_casematch(v->v_protocol, sip_transport_tls)) {
tls = 1; tls = 1;
} }
} }
...@@ -1454,7 +1454,7 @@ int test_tports(agent_t *ag) ...@@ -1454,7 +1454,7 @@ int test_tports(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_default_leg); TEST_P(ag->ag_latest_leg, ag->ag_default_leg);
TEST_1(ag->ag_in_via); TEST_1(ag->ag_in_via);
TEST_1(strcasecmp(ag->ag_in_via->v_protocol, "SIP/2.0/UDP") == 0); TEST_1(su_casematch(ag->ag_in_via->v_protocol, "SIP/2.0/UDP"));
su_free(ag->ag_home, ag->ag_in_via), ag->ag_in_via = NULL; su_free(ag->ag_home, ag->ag_in_via), ag->ag_in_via = NULL;
} }
...@@ -1787,13 +1787,13 @@ int test_resolv(agent_t *ag, char const *resolv_conf) ...@@ -1787,13 +1787,13 @@ int test_resolv(agent_t *ag, char const *resolv_conf)
TEST_1(v = nta_agent_via(ag->ag_agent)); TEST_1(v = nta_agent_via(ag->ag_agent));
for (; v; v = v->v_next) { for (; v; v = v->v_next) {
if (strcasecmp(v->v_protocol, sip_transport_udp) == 0) if (su_casematch(v->v_protocol, sip_transport_udp))
udp = 1; udp = 1;
else if (strcasecmp(v->v_protocol, sip_transport_tcp) == 0) else if (su_casematch(v->v_protocol, sip_transport_tcp))
tcp = 1; tcp = 1;
else if (strcasecmp(v->v_protocol, sip_transport_sctp) == 0) else if (su_casematch(v->v_protocol, sip_transport_sctp))
sctp = 1; sctp = 1;
else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0) else if (su_casematch(v->v_protocol, sip_transport_tls))
tls = 1; tls = 1;
} }
......
...@@ -59,6 +59,7 @@ typedef struct agent_t agent_t; ...@@ -59,6 +59,7 @@ typedef struct agent_t agent_t;
#include <sofia-sip/msg_mclass.h> #include <sofia-sip/msg_mclass.h>
#include <sofia-sip/sofia_features.h> #include <sofia-sip/sofia_features.h>
#include <sofia-sip/hostdomain.h> #include <sofia-sip/hostdomain.h>
#include <sofia-sip/su_string.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
...@@ -67,7 +68,6 @@ typedef struct agent_t agent_t; ...@@ -67,7 +68,6 @@ typedef struct agent_t agent_t;
#include <stdio.h> #include <stdio.h>
#include <assert.h> #include <assert.h>
#include <time.h> #include <time.h>
#include "sofia-sip/string0.h"
extern su_log_t nta_log[]; extern su_log_t nta_log[];
extern su_log_t tport_log[]; extern su_log_t tport_log[];
...@@ -763,14 +763,14 @@ int api_test_tport(agent_t *ag) ...@@ -763,14 +763,14 @@ int api_test_tport(agent_t *ag)
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0); TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next); TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(m = nta_agent_contact(agent)); TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=tcp"); TEST_S(m->m_url->url_params, "transport=tcp");
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TEST_1(nta_agent_add_tport(agent, (url_string_t *)url,
TPTAG_SERVER(0), TAG_END()) == 0); TPTAG_SERVER(0), TAG_END()) == 0);
TEST_1(v = nta_agent_public_via(agent)); TEST_1(!v->v_next); TEST_1(v = nta_agent_public_via(agent)); TEST_1(!v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(host_has_domain_invalid(v->v_host)); TEST_1(host_has_domain_invalid(v->v_host));
TEST_1(m = nta_agent_contact(agent)); TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=tcp"); TEST_S(m->m_url->url_params, "transport=tcp");
...@@ -778,14 +778,14 @@ int api_test_tport(agent_t *ag) ...@@ -778,14 +778,14 @@ int api_test_tport(agent_t *ag)
url->url_params = "transport=udp"; url->url_params = "transport=udp";
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0); TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(v = v->v_next); TEST_1(v = nta_agent_via(agent)); TEST_1(v = v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_VOID(nta_agent_destroy(agent)); TEST_VOID(nta_agent_destroy(agent));
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END())); TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0); TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next); TEST_1(v = nta_agent_via(agent)); TEST_1(!v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(m = nta_agent_contact(agent)); TEST_1(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=udp"); TEST_S(m->m_url->url_params, "transport=udp");
TEST_VOID(nta_agent_destroy(agent)); TEST_VOID(nta_agent_destroy(agent));
...@@ -795,9 +795,9 @@ int api_test_tport(agent_t *ag) ...@@ -795,9 +795,9 @@ int api_test_tport(agent_t *ag)
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END())); TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0); TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(v = nta_agent_via(agent));
TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(v = v->v_next); TEST_1(v = v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(m = nta_agent_contact(agent)); TEST_1(m = nta_agent_contact(agent));
TEST_1(!m->m_url->url_params); TEST_1(!m->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent)); TEST_VOID(nta_agent_destroy(agent));
...@@ -807,9 +807,9 @@ int api_test_tport(agent_t *ag) ...@@ -807,9 +807,9 @@ int api_test_tport(agent_t *ag)
TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END())); TEST_1(agent = nta_agent_create(ag->ag_root, NONE, NULL, NULL, TAG_END()));
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0); TEST_1(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
TEST_1(v = nta_agent_via(agent)); TEST_1(v = nta_agent_via(agent));
TEST(strcasecmp(v->v_protocol, sip_transport_udp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_udp), 0);
TEST_1(v = v->v_next); TEST_1(v = v->v_next);
TEST(strcasecmp(v->v_protocol, sip_transport_tcp), 0); TEST(!su_casematch(v->v_protocol, sip_transport_tcp), 0);
TEST_1(m = nta_agent_contact(agent)); TEST_1(m = nta_agent_contact(agent));
TEST_1(!m->m_url->url_params); TEST_1(!m->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent)); TEST_VOID(nta_agent_destroy(agent));
...@@ -866,7 +866,7 @@ static int api_test_dialogs(agent_t *ag) ...@@ -866,7 +866,7 @@ static int api_test_dialogs(agent_t *ag)
/* Test that NULL host and/or port fields of user supplied Via header are /* Test that NULL host and/or port fields of user supplied Via header are
filled in automaticaly */ filled in automatically */
int api_test_user_via_fillin(agent_t *ag) int api_test_user_via_fillin(agent_t *ag)
{ {
su_home_t home[1]; su_home_t home[1];
...@@ -879,7 +879,7 @@ int api_test_user_via_fillin(agent_t *ag) ...@@ -879,7 +879,7 @@ int api_test_user_via_fillin(agent_t *ag)
sip_via_t *via0, *via1; sip_via_t *via0, *via1;
sip_via_t via[1]; sip_via_t via[1];
static char *via_params[] = { "param1=value1", "param2=value2" }; static char *via_params[] = { "param1=value1", "param2=value2" };
int i; size_t i;
BEGIN(); BEGIN();
...@@ -912,30 +912,30 @@ int api_test_user_via_fillin(agent_t *ag) ...@@ -912,30 +912,30 @@ int api_test_user_via_fillin(agent_t *ag)
/* create user Via template to be filled in by NTA */ /* create user Via template to be filled in by NTA */
sip_via_init(via); sip_via_init(via);
via->v_protocol = "*"; via->v_protocol = "*";
for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++) 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 */ sip_via_add_param(home, via, via_params[i]); /* add param to the template */
/* This creates a delayed response message */ /* This creates a delayed response message */
orq1 = nta_outgoing_tcreate(leg, outgoing_callback, ag, NULL, orq1 = nta_outgoing_tcreate(leg, outgoing_callback, ag, NULL,
SIP_METHOD_MESSAGE, SIP_METHOD_MESSAGE,
URL_STRING_MAKE("sip:foo.bar;transport=none"), URL_STRING_MAKE("sip:foo.bar;transport=none"),
SIPTAG_FROM_STR("<sip:bar.foo>"), SIPTAG_FROM_STR("<sip:bar.foo>"),
SIPTAG_TO_STR("<sip:foo.bar>"), SIPTAG_TO_STR("<sip:foo.bar>"),
NTATAG_USER_VIA(1), NTATAG_USER_VIA(1),
SIPTAG_VIA(via), SIPTAG_VIA(via),
TAG_END()); TAG_END());
TEST_1(orq1); TEST_1(orq1);
TEST_1(msg1 = nta_outgoing_getrequest(orq1)); TEST_1(msg1 = nta_outgoing_getrequest(orq1));
TEST_1(sip1 = sip_object(msg1)); TEST_1(sip1 = sip_object(msg1));
TEST_1(via1 = sip1->sip_via); TEST_1(via1 = sip1->sip_via);
/* check that template has been filled correctly */ /* check that template has been filled correctly */
TEST_S(via0->v_protocol,via1->v_protocol); TEST_S(via0->v_protocol, via1->v_protocol);
TEST_S(via0->v_host,via1->v_host); TEST_S(via0->v_host, via1->v_host);
TEST_S(via0->v_port,via1->v_port); TEST_S(via0->v_port, via1->v_port);
/* check that the parameter has been preserved */ /* check that the parameter has been preserved */
for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++) for (i = 0; i < sizeof(via_params)/sizeof(via_params[0]); i++)
TEST_S(via1->v_params[i],via_params[i]); TEST_S(via1->v_params[i], via_params[i]);
TEST_VOID(nta_outgoing_destroy(orq0)); TEST_VOID(nta_outgoing_destroy(orq0));
TEST_VOID(nta_outgoing_destroy(orq1)); TEST_VOID(nta_outgoing_destroy(orq1));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论