Commit 018dd426 authored by Pekka Pessi's avatar Pekka Pessi

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

darcs-hash:20090108183805-db55f-d99c8e2f4b4ef846cd71745b2243dd20dd26410e.gz
parent 25dd4347
This diff is collapsed.
......@@ -219,14 +219,14 @@ int nta_check_session_content(nta_incoming_t *irq,
if (sip->sip_payload == NULL)
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;
char const *c_type;
if (c)
c_type = c->c_type;
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 */
c_type = application_sdp;
else
......@@ -234,7 +234,7 @@ int nta_check_session_content(nta_incoming_t *irq,
ab = NULL, c_type = NULL;
for (; ab; ab = ab->ac_next) {
if (strcasecmp(c_type, ab->ac_type) == 0)
if (su_casematch(c_type, ab->ac_type))
break;
}
......@@ -311,7 +311,7 @@ int nta_check_accept(nta_incoming_t *irq,
method == sip_method_prack ||
method == sip_method_update)) {
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;
return 0;
}
......@@ -322,7 +322,7 @@ int nta_check_accept(nta_incoming_t *irq,
continue;
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;
return 0;
}
......
......@@ -237,8 +237,8 @@ void sl_payload_log(su_log_t *log, int level,
log = su_log_default;
while (s < end && *s != '\0') {
size_t n = strncspn(s, end - s, "\r\n");
size_t crlf = strnspn(s + n, end - s - n, "\r\n");
size_t n = su_strncspn(s, end - s, "\r\n");
size_t crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (n < 70) {
memcpy(line, s, n);
line[n] = '\0';
......
......@@ -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;
while (s < end && *s != '\0') {
n = strncspn(s, end - s, "\r\n");
crlf = strnspn(s + n, end - s - n, "\r\n");
n = su_strncspn(s, end - s, "\r\n");
crlf = su_strnspn(s + n, end - s - n, "\r\n");
if (prefix)
fputs(prefix, stream), total += strlen(prefix);
fwrite(s, 1, n + crlf, stream);
......
......@@ -38,7 +38,7 @@
#include <stdio.h>
#ifndef STRING0_H
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#endif
#ifndef SIP_H
......
......@@ -62,7 +62,7 @@ typedef struct client_t client_t;
#include <sofia-sip/hostdomain.h>
#include <sofia-sip/tport.h>
#include <sofia-sip/string0.h>
#include <sofia-sip/su_string.h>
#include <stddef.h>
#include <stdlib.h>
......@@ -564,7 +564,7 @@ int test_init(agent_t *ag, char const *resolv_conf)
TEST_1(ag->ag_mclass);
#if SU_HAVE_IN6
if (str0cmp(getenv("ipv6"), "true") == 0) {
if (su_strmatch(getenv("ipv6"), "true")) {
contact = "sip:[::]:*;comp=sigcomp";
af = AF_INET6, sulen0 = sizeof (struct sockaddr_in6);
}
......@@ -1075,22 +1075,22 @@ int test_tports(agent_t *ag)
TEST_1(v = nta_agent_via(ag->ag_agent));
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)
v_udp_only = v;
udp = 1;
if (udp_comp == NULL)
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;
if (tcp_comp == NULL)
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;
}
else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0) {
else if (su_casematch(v->v_protocol, sip_transport_tls)) {
tls = 1;
}
}
......@@ -1454,7 +1454,7 @@ int test_tports(agent_t *ag)
TEST_P(ag->ag_latest_leg, ag->ag_default_leg);
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;
}
......@@ -1787,13 +1787,13 @@ int test_resolv(agent_t *ag, char const *resolv_conf)
TEST_1(v = nta_agent_via(ag->ag_agent));
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;
else if (strcasecmp(v->v_protocol, sip_transport_tcp) == 0)
else if (su_casematch(v->v_protocol, sip_transport_tcp))
tcp = 1;
else if (strcasecmp(v->v_protocol, sip_transport_sctp) == 0)
else if (su_casematch(v->v_protocol, sip_transport_sctp))
sctp = 1;
else if (strcasecmp(v->v_protocol, sip_transport_tls) == 0)
else if (su_casematch(v->v_protocol, sip_transport_tls))
tls = 1;
}
......
......@@ -59,6 +59,7 @@ typedef struct agent_t agent_t;
#include <sofia-sip/msg_mclass.h>
#include <sofia-sip/sofia_features.h>
#include <sofia-sip/hostdomain.h>
#include <sofia-sip/su_string.h>
#include <stddef.h>
#include <stdlib.h>
......@@ -67,7 +68,6 @@ typedef struct agent_t agent_t;
#include <stdio.h>
#include <assert.h>
#include <time.h>
#include "sofia-sip/string0.h"
extern su_log_t nta_log[];
extern su_log_t tport_log[];
......@@ -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(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_S(m->m_url->url_params, "transport=tcp");
TEST_1(nta_agent_add_tport(agent, (url_string_t *)url,
TPTAG_SERVER(0), TAG_END()) == 0);
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(m = nta_agent_contact(agent));
TEST_S(m->m_url->url_params, "transport=tcp");
......@@ -778,14 +778,14 @@ int api_test_tport(agent_t *ag)
url->url_params = "transport=udp";
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(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_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(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_S(m->m_url->url_params, "transport=udp");
TEST_VOID(nta_agent_destroy(agent));
......@@ -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(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
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(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->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent));
......@@ -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(nta_agent_add_tport(agent, (url_string_t *)url, TAG_END()) == 0);
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(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->m_url->url_params);
TEST_VOID(nta_agent_destroy(agent));
......@@ -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
filled in automaticaly */
filled in automatically */
int api_test_user_via_fillin(agent_t *ag)
{
su_home_t home[1];
......@@ -879,7 +879,7 @@ int api_test_user_via_fillin(agent_t *ag)
sip_via_t *via0, *via1;
sip_via_t via[1];
static char *via_params[] = { "param1=value1", "param2=value2" };
int i;
size_t i;
BEGIN();
......@@ -912,30 +912,30 @@ int api_test_user_via_fillin(agent_t *ag)
/* 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 */
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());
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);
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_S(via1->v_params[i], via_params[i]);
TEST_VOID(nta_outgoing_destroy(orq0));
TEST_VOID(nta_outgoing_destroy(orq1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment