Commit 4b335796 authored by Pekka Pessi's avatar Pekka Pessi

Using su_inet_ntop and su_inet_pton

darcs-hash:20080605142318-db55f-1c7c5d21fed5f16f494ab5f8e2f32e92af76232c.gz
parent 54169942
......@@ -636,16 +636,16 @@ int test_init(agent_t *ag, char const *resolv_conf)
*m->m_url = *ag->ag_contact->m_url;
if (host_is_ip4_address(m->m_url->url_host)) {
inet_pton(su->su_family = AF_INET,
m->m_url->url_host,
&su->su_sin.sin_addr);
su_inet_pton(su->su_family = AF_INET,
m->m_url->url_host,
&su->su_sin.sin_addr);
ag->ag_su_nta_len = (sizeof su->su_sin);
}
else {
TEST_1(host_is_ip_address(m->m_url->url_host));
inet_pton(su->su_family = AF_INET6,
m->m_url->url_host,
&su->su_sin6.sin6_addr);
su_inet_pton(su->su_family = AF_INET6,
m->m_url->url_host,
&su->su_sin6.sin6_addr);
ag->ag_su_nta_len = (sizeof su->su_sin6);
}
......
......@@ -185,7 +185,7 @@ static int init_test(tester_t *t)
t->t_addr->su_len = (sizeof t->t_addr->su_sin);
s = su_socket(t->t_addr->su_family = AF_INET, SOCK_STREAM, 0);
TEST_1(s != INVALID_SOCKET);
TEST_1(inet_pton(AF_INET, "127.0.0.1", &t->t_addr->su_sin.sin_addr) >= 0);
TEST_1(su_inet_pton(AF_INET, "127.0.0.1", &t->t_addr->su_sin.sin_addr) >= 0);
TEST_1(bind(s, &t->t_addr->su_sa,
t->t_addrlen = (sizeof t->t_addr->su_sin)) != -1);
TEST_1(getsockname(s, &t->t_addr->su_sa, &t->t_addrlen) != -1);
......
......@@ -1365,7 +1365,7 @@ void s2_dns_domain(char const *domain, int use_naptr,
assert(s2->dns.reg != 0);
inet_pton(AF_INET, "127.0.0.1", &localhost);
su_inet_pton(AF_INET, "127.0.0.1", &localhost);
va_start(va0, use_naptr);
......
......@@ -221,7 +221,7 @@ void answer_to_a_query(sres_context_t *sr, sres_query_t *q,
if (a->a_record->r_status)
continue; /* There was an error */
inet_ntop(AF_INET, &a->a_addr, addr, sizeof(addr));
su_inet_ntop(AF_INET, &a->a_addr, addr, sizeof(addr));
printf("%s@%s:%u\n", sr->sr_tport, addr, sr->sr_port);
sr->sr_exitcode = 0;
}
......
......@@ -184,6 +184,11 @@ struct sockaddr_storage {
#endif
#endif
#endif
SOFIAPUBFUN int su_inet_pton(int af, char const *src, void *dst);
SOFIAPUBFUN const char *su_inet_ntop(int af, void const *src,
char *dst, size_t size);
#else
#define sres_send(s,b,len,flags) send((s),(b),(len),(flags))
......@@ -195,6 +200,10 @@ struct sockaddr_storage {
#define SOCKET_ERROR (-1)
#define INVALID_SOCKET ((sres_socket_t)-1)
#define sres_socket(x,y,z) socket((x),(y),(z))
#define su_inet_pton inet_pton
#define su_inet_ntop inet_ntop
#endif
#if 1
......@@ -264,8 +273,8 @@ int test_socket(sres_context_t *ctx)
a1len = a2len = a3len = a4len = sizeof (struct sockaddr_in6);
if (af == AF_INET) {
TEST_1(inet_pton(af, "127.0.0.1", &sin3->sin_addr) > 0);
TEST_1(inet_pton(af, "127.0.0.1", &sin4->sin_addr) > 0);
TEST_1(su_inet_pton(af, "127.0.0.1", &sin3->sin_addr) > 0);
TEST_1(su_inet_pton(af, "127.0.0.1", &sin4->sin_addr) > 0);
} else {
}
......@@ -734,7 +743,7 @@ int test_a6(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 0);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
"3ffe:1200:3012:c000:210:a4ff:fe8d:6a46");
TEST_P(rr_a6->a6_prename, NULL);
......@@ -748,7 +757,7 @@ int test_a6(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 0);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
"3ffe:1200:3012:c000:210:a4ff:fe8d:6a46");
TEST_P(rr_a6->a6_prename, NULL);
......@@ -778,7 +787,7 @@ int test_a6_prefix(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 64);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
"::a08:20ff:fe7d:e7ac");
TEST_S(rr_a6->a6_prename, "mynet.example.com.");
......@@ -795,7 +804,7 @@ int test_a6_prefix(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_class, sres_class_in);
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 0);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
"3ff0:12:3012:c006:a08:20ff:fe7d:e7ac");
TEST_P(rr_a6->a6_prename, NULL);
......@@ -811,7 +820,7 @@ int test_a6_prefix(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_class, sres_class_in);
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 128);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)), "::");
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)), "::");
TEST_S(rr_a6->a6_prename, "a6.example.com.");
sres_free_answers(res, ctx->result), ctx->result = NULL;
......@@ -824,7 +833,7 @@ int test_a6_prefix(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 64);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)),
"::a08:20ff:fe7d:e7ac");
TEST_S(rr_a6->a6_prename, "mynet.example.com.");
......@@ -853,7 +862,7 @@ int test_aaaa(sres_context_t *ctx)
TEST(rr_aaaa->aaaa_record->r_class, sres_class_in);
TEST(rr_aaaa->aaaa_record->r_ttl, 60);
TEST_S(inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
"3ffe:1200:3012:c000:206:5bff:fe55:4630");
sres_free_answers(res, ctx->result), ctx->result = NULL;
......@@ -865,7 +874,7 @@ int test_aaaa(sres_context_t *ctx)
TEST(rr_aaaa->aaaa_record->r_class, sres_class_in);
TEST(rr_aaaa->aaaa_record->r_ttl, 60);
TEST_S(inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
"3ffe:1200:3012:c000:206:5bff:fe55:4630");
sres_free_answers(res, result), result = NULL;
......@@ -1027,7 +1036,7 @@ int test_ptr_ipv4_sockaddr(sres_context_t *ctx)
const sres_ptr_record_t *rr;
struct sockaddr_in sin = {0};
inet_pton(AF_INET, "127.0.0.1", &sin.sin_addr);
su_inet_pton(AF_INET, "127.0.0.1", &sin.sin_addr);
sin.sin_family = AF_INET;
BEGIN();
......@@ -1089,8 +1098,8 @@ int test_ptr_ipv6_sockaddr(sres_context_t *ctx)
BEGIN();
inet_pton(AF_INET6, "3ffe:1200:3012:c000:0a08:20ff:fe7d:e7ac",
&sin6.sin6_addr);
su_inet_pton(AF_INET6, "3ffe:1200:3012:c000:0a08:20ff:fe7d:e7ac",
&sin6.sin6_addr);
sin6.sin6_family = AF_INET6;
......@@ -1154,9 +1163,9 @@ int test_cache(sres_context_t *ctx)
sres_query(res, test_answer_multi, ctx,
sres_type_aaaa, "mgw02.example.com");
inet_pton(AF_INET6,
"3ffe:1200:3012:c000:0a08:20ff:fe7d:e7ac",
&sin6.sin6_addr);
su_inet_pton(AF_INET6,
"3ffe:1200:3012:c000:0a08:20ff:fe7d:e7ac",
&sin6.sin6_addr);
sin6.sin6_family = AF_INET6;
......@@ -1361,7 +1370,7 @@ int test_cache(sres_context_t *ctx)
TEST(rr_a6->a6_record->r_ttl, 60);
TEST(rr_a6->a6_prelen, 0);
TEST_S(inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)), "3ff0::");
TEST_S(su_inet_ntop(AF_INET6, &rr_a6->a6_suffix, buf, sizeof(buf)), "3ff0::");
TEST_P(rr_a6->a6_prename, NULL);
......@@ -1373,7 +1382,7 @@ int test_cache(sres_context_t *ctx)
TEST(rr_aaaa->aaaa_record->r_type, sres_type_aaaa);
TEST(rr_aaaa->aaaa_record->r_class, sres_class_in);
TEST(rr_aaaa->aaaa_record->r_ttl, 60);
TEST_S(inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
"3ffe:1200:3012:c000:206:5bff:fe55:462f");
sres_free_answers(res, result);
......@@ -1416,7 +1425,7 @@ int test_query_one_type(sres_context_t *ctx)
TEST(rr_aaaa->aaaa_record->r_type, sres_type_aaaa);
TEST(rr_aaaa->aaaa_record->r_class, sres_class_in);
TEST(rr_aaaa->aaaa_record->r_ttl, 60);
TEST_S(inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
TEST_S(su_inet_ntop(AF_INET6, &rr_aaaa->aaaa_addr, buf, sizeof(buf)),
"3ffe:1200:3012:c000:206:5bff:fe55:462f");
TEST_P(result[1], NULL);
......
......@@ -276,8 +276,8 @@ void stunc_bind_cb(stunc_t *stunc,
}
SU_DEBUG_0(("%s: local address NATed as %s:%u\n", __func__,
inet_ntop(sa->su_family, SU_ADDR(sa),
ipaddr, sizeof(ipaddr)),
su_inet_ntop(sa->su_family, SU_ADDR(sa),
ipaddr, sizeof(ipaddr)),
(unsigned) ntohs(sa->su_port)));
break;
......@@ -428,8 +428,8 @@ int main(int argc, char *argv[])
err = bind(s, (struct sockaddr *)&sockaddr, socklen);
if (err < 0) {
SU_DEBUG_1(("%s: Error %d binding to %s:%u\n", __func__, err,
inet_ntop(sockaddr.su_family, SU_ADDR(&sockaddr),
ipaddr, sizeof(ipaddr)),
su_inet_ntop(sockaddr.su_family, SU_ADDR(&sockaddr),
ipaddr, sizeof(ipaddr)),
(unsigned) ntohs(sockaddr.su_port)));
return -1;
}
......
......@@ -143,7 +143,7 @@ int main(int argc, char *argv[])
#endif
port = ntohs(su->su_port);
inet_ntop(ai->ai_family, SU_ADDR(su), buffer, sizeof(buffer));
su_inet_ntop(ai->ai_family, SU_ADDR(su), buffer, sizeof(buffer));
printf("%d@[%s]:%u", ai->ai_protocol, buffer, port);
if (ai->ai_flags & AI_CANONNAME)
......
......@@ -167,8 +167,8 @@ int main(int argc, char *argv[])
fputs(li->li_canonname, stdout);
}
else {
inet_ntop(li->li_family, SU_ADDR(li->li_addr),
buffer, sizeof(buffer));
su_inet_ntop(li->li_family, SU_ADDR(li->li_addr),
buffer, sizeof(buffer));
printf("%s maddr=[%s]", li->li_canonname, buffer);
}
if (li->li_scope & LI_SCOPE_GLOBAL)
......
......@@ -223,7 +223,7 @@ getaddrinfo(hostname, servname, hints, res)
/* translator hack */
{
char *q = getenv("GAI");
if (q && inet_pton(AF_INET6, q, &faith_prefix) == 1)
if (q && su_inet_pton(AF_INET6, q, &faith_prefix) == 1)
translate = YES;
}
firsttime = 0;
......@@ -411,7 +411,7 @@ getaddrinfo(hostname, servname, hints, res)
/* hostname as numeric name */
for (i = 0; gai_afdl[i].a_af; i++) {
if (inet_pton(gai_afdl[i].a_af, hostname, pton)) {
if (su_inet_pton(gai_afdl[i].a_af, hostname, pton)) {
u_long v4a;
u_char pfx;
......@@ -752,7 +752,7 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
if (host == NULL || hostlen == 0) {
/* what should we do? */
} else if (flags & NI_NUMERICHOST) {
if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr))
if (su_inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr))
== NULL)
return ENI_SYSTEM;
if (strlen(numaddr) > hostlen)
......@@ -784,7 +784,8 @@ getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
} else {
if (flags & NI_NAMEREQD)
return ENI_NOHOSTNAME;
if (inet_ntop(gni_afd->a_af, addr, numaddr, sizeof(numaddr))
if (su_inet_ntop(gni_afd->a_af, addr,
numaddr, sizeof(numaddr))
== NULL)
return ENI_NOHOSTNAME;
if (strlen(numaddr) > hostlen)
......
......@@ -1047,7 +1047,7 @@ int localinfo6(su_localinfo_t const *hints, su_localinfo_t **rresult)
sa = calloc(1, sizeof(su_sockaddr_t));
sa->su_family = AF_INET6;
if (inet_pton(AF_INET6, addr, &sa->su_sin6.sin6_addr) <= 0)
if (su_inet_pton(AF_INET6, addr, &sa->su_sin6.sin6_addr) <= 0)
goto err;
s = su_socket(AF_INET6, SOCK_DGRAM, 0);
......@@ -1105,7 +1105,7 @@ int localinfo6(su_localinfo_t const *hints, su_localinfo_t **rresult)
li->li_addrlen = sizeof(*su);
li->li_addr = su = (su_sockaddr_t *)(li + 1);
su->su_family = li->li_family = AF_INET6;
if (inet_pton(AF_INET6, addr, &su->su_sin6.sin6_addr) <= 0)
if (su_inet_pton(AF_INET6, addr, &su->su_sin6.sin6_addr) <= 0)
goto err;
if (li->li_flags & LI_IFNAME)
li->li_ifname = ifname;
......
......@@ -373,7 +373,7 @@ int forwarder_accept(proxy_t *pr, su_wait_t *w, forwarder_t *f0)
char buf[SU_ADDRSIZE];
SU_DEBUG_3(("accept: connection from %s:%u\n",
inet_ntop(su->su_family, SU_ADDR(su), buf, sizeof(buf)),
su_inet_ntop(su->su_family, SU_ADDR(su), buf, sizeof(buf)),
ntohs(su->su_port)));
if (!su_wait_create(f->f_wait, f->f_socket, SU_WAIT_IN) &&
......@@ -628,7 +628,7 @@ int forwarder_shutdown(forwarder_t *f)
char buf[SU_ADDRSIZE];
SU_DEBUG_3(("forwarder_shutdown: shutdown from %s:%u\n",
inet_ntop(su->su_family, SU_ADDR(su), buf, sizeof(buf)),
su_inet_ntop(su->su_family, SU_ADDR(su), buf, sizeof(buf)),
ntohs(su->su_port)));
if (su_root_unregister(f->f_pr->pr_root, f->f_wait, forwarder_recv, f) < 0) {
......@@ -663,9 +663,9 @@ void forwarder_close(forwarder_t *f)
su2 = f->f_dest, su1 = f->f_peer->f_dest, d2 = "up", d1 = "down";
SU_DEBUG_3(("forwarder_close: connection from %s:%u to %s:%d\n",
inet_ntop(su1->su_family, SU_ADDR(su1), buf1, sizeof(buf1)),
su_inet_ntop(su1->su_family, SU_ADDR(su1), buf1, sizeof(buf1)),
ntohs(su1->su_port),
inet_ntop(su2->su_family, SU_ADDR(su2), buf2, sizeof(buf2)),
su_inet_ntop(su2->su_family, SU_ADDR(su2), buf2, sizeof(buf2)),
ntohs(su2->su_port)));
forwarder_destroy(f);
......
......@@ -116,7 +116,7 @@ static su_socket_t udpsocket(void)
if (opt_verbatim)
printf("udpsocket: using address [%s]:%u\n",
inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port));
return s;
......@@ -183,7 +183,7 @@ do_rtt(struct pinger *p, su_wait_t *w, void *p0)
if (opt_verbatim)
printf("do_rtt: %d bytes from [%s]:%u: \"%s\", rtt = %lg ms\n",
n, inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
n, su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port), buf, rtt / 1000);
do_ping(p, p->t, NULL);
......@@ -237,7 +237,7 @@ do_recv(struct pinger *p, su_wait_t *w, void *p0)
if (opt_verbatim)
printf("do_recv: %d bytes from [%s]:%u: \"%s\" at %s\n",
n, inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
n, su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port), buf, snow(now));
fflush(stdout);
......
......@@ -127,7 +127,7 @@ static su_socket_t udpsocket(void)
if (opt_verbatim)
printf("udpsocket: using address [%s]:%u\n",
inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port));
return s;
......@@ -202,7 +202,7 @@ do_rtt(struct pinger *p, su_wait_t *w, void *p0)
if (opt_verbatim)
printf("do_rtt: %d bytes from [%s]:%u: \"%s\", rtt = %lg ms\n",
n, inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
n, su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port), buf, rtt / 1000);
do_ping(p, p->t, NULL);
......@@ -260,7 +260,7 @@ do_recv(struct pinger *p, su_wait_t *w, void *p0)
if (opt_verbatim)
printf("do_recv: %d bytes from [%s]:%u: \"%s\" at %s\n",
n, inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
n, su_inet_ntop(su.su_family, SU_ADDR(&su), nbuf, sizeof(nbuf)),
ntohs(su.su_sin.sin_port), buf, snow(now));
fflush(stdout);
......
......@@ -177,7 +177,7 @@ int test_sendrecv(void)
memset(&su, 0, sulen);
su.su_len = sulen;
su.su_family = AF_INET;
TEST(inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(su_inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(bind(s, &su.su_sa, sulen), 0);
TEST(getsockname(s, &su.su_sa, &sulen), 0);
......@@ -197,7 +197,7 @@ int test_sendrecv(void)
memset(&su, 0, sulen);
su.su_len = sulen;
su.su_family = AF_INET;
TEST(inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(su_inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(bind(l, &su.su_sa, sulen), 0);
TEST(bind(s, &su.su_sa, sulen), 0);
......@@ -304,7 +304,7 @@ int test_select(void)
memset(&su, 0, sulen);
su.su_len = sulen;
su.su_family = AF_INET;
TEST(inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(su_inet_pton(AF_INET, "127.0.0.1", &su.su_sin.sin_addr), 1);
TEST(bind(s, &su.su_sa, sulen), 0);
TEST(getsockname(s, &su.su_sa, &sulen), 0);
......
......@@ -239,9 +239,9 @@ int init_test(root_test_t *rt,
TEST_1(su_wait_create(ep->wait, ep->s, SU_WAIT_IN|SU_WAIT_ERR) != -1);
TEST_1(getsockname(ep->s, &ep->addr->su_sa, &ep->addrlen) != -1);
if (SU_HAS_INADDR_ANY(ep->addr)) {
inet_pton(su->su_family,
su->su_family == AF_INET ? "127.0.0.1" : "::1",
SU_ADDR(ep->addr));
su_inet_pton(su->su_family,
su->su_family == AF_INET ? "127.0.0.1" : "::1",
SU_ADDR(ep->addr));
}
}
......
......@@ -108,9 +108,9 @@ int init_test(root_test_t *rt)
TEST_1(su_wait_create(ep->wait, ep->s, SU_WAIT_IN|SU_WAIT_ERR) != -1);
TEST_1(getsockname(ep->s, &ep->addr->su_sa, &ep->addrlen) != -1);
if (SU_HAS_INADDR_ANY(ep->addr)) {
inet_pton(su->su_family,
su->su_family == AF_INET ? "127.0.0.1" : "::1",
SU_ADDR(ep->addr));
su_inet_pton(su->su_family,
su->su_family == AF_INET ? "127.0.0.1" : "::1",
SU_ADDR(ep->addr));
}
}
......
......@@ -3958,7 +3958,7 @@ tport_resolve(tport_t *self, msg_t *msg, tp_name_t const *tpn)
#else
SU_DEBUG_9(("tport_resolve addrinfo = %s%s%s:%d\n",
"",
inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr)),
su_inet_ntop(su->su_family, SU_ADDR(su), ipaddr, sizeof(ipaddr)),
"",
htons(su->su_port)));
#endif
......
......@@ -197,7 +197,8 @@ void tport_stun_bind_done(tport_primary_t *pri,
SU_DEBUG_5(("%s: stun_bind() ok: local address NATed as %s:%u\n",
__func__,
inet_ntop(su->su_family, SU_ADDR(su), ipname, sizeof(ipname)),
su_inet_ntop(su->su_family, SU_ADDR(su),
ipname, sizeof(ipname)),
(unsigned) ntohs(su->su_port)));
}
......
......@@ -144,7 +144,7 @@ int tport_udp_init_primary(tport_primary_t *pri,
imr->imr_multiaddr = su->su_sin.sin_addr;
if (host_is_ip4_address(tpn->tpn_canon) &&
inet_pton(AF_INET, tpn->tpn_canon, &iface) > 0) {
su_inet_pton(AF_INET, tpn->tpn_canon, &iface) > 0) {
imr->imr_interface = iface;
}
......@@ -506,8 +506,8 @@ int tport_udp_error(tport_t const *self, su_sockaddr_t name[1])
origin, info));
if (from->su_family != AF_UNSPEC)
SU_DEBUG_3(("\treported by [%s]:%u\n",
inet_ntop(from->su_family, SU_ADDR(from),
info, sizeof(info)),
su_inet_ntop(from->su_family, SU_ADDR(from),
info, sizeof(info)),
ntohs(from->su_port)));
if (msg->msg_namelen == 0)
......
......@@ -217,7 +217,7 @@ int test_nua_init(struct context *ctx,
else if (su->su_family == AF_INET6) {
a_uri = (void *)
su_sprintf(ctx->home, "sip:[%s]:%u",
inet_ntop(su->su_family, SU_ADDR(su), b, sizeof b),
su_inet_ntop(su->su_family, SU_ADDR(su), b, sizeof b),
ntohs(su->su_port));
a_bind = "sip:[::]:*";
}
......@@ -225,7 +225,7 @@ int test_nua_init(struct context *ctx,
else if (su->su_family == AF_INET) {
a_uri = (void *)
su_sprintf(ctx->home, "sip:%s:%u",
inet_ntop(su->su_family, SU_ADDR(su), b, sizeof b),
su_inet_ntop(su->su_family, SU_ADDR(su), b, sizeof b),
ntohs(su->su_port));
}
......@@ -234,15 +234,15 @@ int test_nua_init(struct context *ctx,
su->su_len = sulen = (sizeof su->su_sin6), su->su_family = AF_INET6;
len = strcspn(p_uri->url_host + 1, "]"); assert(len < sizeof b);
memcpy(b, p_uri->url_host + 1, len); b[len] = '\0';
inet_pton(su->su_family, b, SU_ADDR(su));
su_inet_pton(su->su_family, b, SU_ADDR(su));
}
else {
su->su_len = sulen = (sizeof su->su_sin), su->su_family = AF_INET;
inet_pton(su->su_family, p_uri->url_host, SU_ADDR(su));
su_inet_pton(su->su_family, p_uri->url_host, SU_ADDR(su));
}
#else
su->su_len = sulen = (sizeof su->su_sin), su->su_family = AF_INET;
inet_pton(su->su_family, p_uri->url_host, SU_ADDR(su));
su_inet_pton(su->su_family, p_uri->url_host, SU_ADDR(su));
#endif
su->su_port = htons(strtoul(url_port(p_uri), NULL, 10));
......
......@@ -531,13 +531,13 @@ static int binding_init(struct binding *b,
}
getpeername(b->in_socket, (void *)addr, &addrlen);
inet_ntop(addr->su_family, SU_ADDR(addr), ipname, sizeof ipname);
su_inet_ntop(addr->su_family, SU_ADDR(addr), ipname, sizeof ipname);
snprintf(b->in_name, sizeof b->in_name,
addr->su_family == AF_INET6 ? "[%s]:%u" : "%s:%u",
ipname, ntohs(addr->su_port));
getsockname(out_socket, (void *)addr, &addrlen);
inet_ntop(addr->su_family, SU_ADDR(addr), ipname, sizeof ipname);
su_inet_ntop(addr->su_family, SU_ADDR(addr), ipname, sizeof ipname);
snprintf(b->out_name, sizeof b->out_name,
addr->su_family == AF_INET6 ? "[%s]:%u" : "%s:%u",
ipname, ntohs(addr->su_port));
......@@ -617,7 +617,7 @@ static struct binding *nat_binding_find(struct nat *nat,
size_t namelen;
struct binding *b;
inet_ntop(from->su_family, SU_ADDR(from), ipname, sizeof ipname);
su_inet_ntop(from->su_family, SU_ADDR(from), ipname, sizeof ipname);
snprintf(name, sizeof name,
from->su_family == AF_INET6 ? "[%s]:%u" : "%s:%u",
ipname, ntohs(from->su_port));
......@@ -915,7 +915,7 @@ static int invalidate_binding(struct binding *b)
b->out_register = out_register;
getsockname(out, (void *)addr, &addrlen);
inet_ntop(addr->su_family, SU_ADDR(addr), name, sizeof name);
su_inet_ntop(addr->su_family, SU_ADDR(addr), name, sizeof name);
snprintf(b->out_name, sizeof b->out_name,
addr->su_family == AF_INET6 ? "[%s]:%u" : "%s:%u",
name, ntohs(addr->su_port));
......
......@@ -134,13 +134,6 @@
#include "config.h"
#if !defined(HAVE_WIN32)
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
#include "sofia-sip/su.h"
#include "sofia-resolv/sres.h"
......@@ -803,7 +796,7 @@ print_addr_results(struct transport const *tports,
if (answers[i]->sr_record->r_status != 0)
continue;
inet_ntop(af, &answers[i]->sr_a->a_addr, addr, sizeof addr);
su_inet_ntop(af, &answers[i]->sr_a->a_addr, addr, sizeof addr);
for (j = 0; tports[j].name; j++) {
if (strcasecmp(tport, tports[j].name) == 0)
......
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