Commit 08287d39 authored by Pekka Pessi's avatar Pekka Pessi

tport.c: cleared whitespace

darcs-hash:20081126183839-db55f-8bc76861b38b4cdd6423e5fcaf645bcad55f24b8.gz
parent 7fe6cb69
......@@ -108,7 +108,7 @@ su_inline int tp_cmp(tport_t const *a, tport_t const *b)
{
if (a == b)
return 0;
if (a->tp_addrlen != b->tp_addrlen)
return (int)(a->tp_addrlen - b->tp_addrlen);
......@@ -122,7 +122,7 @@ su_inline int tprb_is_inserted(tport_t const *a)
RBTREE_PROTOS(su_inline, tprb, tport_t);
RBTREE_BODIES(su_inline, tprb, tport_t,
RBTREE_BODIES(su_inline, tprb, tport_t,
TP_LEFT, TP_RIGHT, TP_PARENT,
TP_IS_RED, TP_SET_RED, TP_IS_BLACK, TP_SET_BLACK, TP_COPY_COLOR,
tp_cmp, TP_INSERT, TP_REMOVE);
......@@ -171,25 +171,25 @@ struct tport_pending_s {
/** Return true if transport is master. */
int tport_is_master(tport_t const *self)
{
return
self &&
return
self &&
self->tp_master->mr_master == self;
}
/** Return true if transport is primary. */
int tport_is_primary(tport_t const *self)
{
return
self &&
return
self &&
self->tp_pri->pri_primary == self;
}
/** Return true if transport is secondary. */
int tport_is_secondary(tport_t const *self)
{
return
self &&
self->tp_master->mr_master != self &&
return
self &&
self->tp_master->mr_master != self &&
self->tp_pri->pri_primary != self;
}
......@@ -204,33 +204,33 @@ int tport_is_stream(tport_t const *self)
{
return self && self->tp_addrinfo->ai_socktype == SOCK_STREAM;
}
/** Test if transport is dgram. */
int tport_is_dgram(tport_t const *self)
{
return self && self->tp_addrinfo->ai_socktype == SOCK_DGRAM;
}
/** Test if transport is udp. */
int tport_is_udp(tport_t const *self)
{
return self && self->tp_addrinfo->ai_protocol == IPPROTO_UDP;
}
/** Test if transport is tcp. */
int tport_is_tcp(tport_t const *self)
{
return self && self->tp_addrinfo->ai_protocol == IPPROTO_TCP;
}
/** Return 1 if transport is reliable, 0 otherwise.
*
* (Note that this is part of external API).
*/
int tport_is_reliable(tport_t const *self)
{
return self != NULL &&
(self->tp_addrinfo->ai_socktype == SOCK_STREAM ||
return self != NULL &&
(self->tp_addrinfo->ai_socktype == SOCK_STREAM ||
self->tp_addrinfo->ai_socktype == SOCK_SEQPACKET);
}
......@@ -248,8 +248,8 @@ int tport_is_public(tport_t const *self)
/** Return true if transport supports IPv4 */
int tport_has_ip4(tport_t const *self)
{
return self &&
(self->tp_addrinfo->ai_family == 0 ||
return self &&
(self->tp_addrinfo->ai_family == 0 ||
self->tp_addrinfo->ai_family == AF_INET);
}
......@@ -258,8 +258,8 @@ int tport_has_ip4(tport_t const *self)
/** Return true if transport supports IPv6 */
int tport_has_ip6(tport_t const *self)
{
return self &&
(self->tp_addrinfo->ai_family == 0 ||
return self &&
(self->tp_addrinfo->ai_family == 0 ||
self->tp_addrinfo->ai_family == AF_INET6);
}
#endif
......@@ -277,7 +277,7 @@ int tport_is_updating(tport_t const *self)
tport_primary_t *pri;
if (tport_is_master(self)) {
for (pri = self->tp_master->mr_primaries; pri; pri = pri->pri_next)
for (pri = self->tp_master->mr_primaries; pri; pri = pri->pri_next)
if (pri->pri_updating)
return 1;
}
......@@ -322,8 +322,8 @@ int tport_is_connected(tport_t const *self)
int tport_is_clear_to_send(tport_t const *self)
{
return
tport_is_master(self) ||
tport_is_primary(self) ||
tport_is_master(self) ||
tport_is_primary(self) ||
(tport_is_secondary(self) &&
tport_is_registered(self) &&
self->tp_reusable &&
......@@ -352,16 +352,16 @@ int tport_has_sigcomp(tport_t const *self)
/** Set IP TOS for socket */
void tport_set_tos(su_socket_t socket, su_addrinfo_t *ai, int tos)
{
if (tos >= 0 &&
ai->ai_family == AF_INET &&
if (tos >= 0 &&
ai->ai_family == AF_INET &&
setsockopt(socket, IPPROTO_IP, IP_TOS, (const void*)&tos, sizeof(tos)) < 0) {
SU_DEBUG_3(("tport: setsockopt(IP_TOS): %s\n",
su_strerror(su_errno())));
}
}
static
tport_t *tport_connect(tport_primary_t *pri, su_addrinfo_t *ai,
static
tport_t *tport_connect(tport_primary_t *pri, su_addrinfo_t *ai,
tp_name_t const *tpn);
static int bind6only_check(tport_master_t *mr);
......@@ -370,13 +370,13 @@ static
int tport_server_addrinfo(tport_master_t *mr,
char const *canon,
int family,
char const *host,
char const *host,
char const *service,
char const *protocol,
char const * const transports[],
su_addrinfo_t **res);
static int tport_get_local_addrinfo(tport_master_t *mr,
static int tport_get_local_addrinfo(tport_master_t *mr,
char const *port,
su_addrinfo_t const *hints,
su_addrinfo_t **return_ai);
......@@ -427,7 +427,7 @@ static void tport_parse(tport_t *self, int complete, su_time_t now);
static tport_primary_t *tport_alloc_primary(tport_master_t *mr,
tport_vtable_t const *vtable,
tp_name_t tpn[1],
su_addrinfo_t *ai,
su_addrinfo_t *ai,
tagi_t const *tags,
char const **return_culprit);
......@@ -445,21 +445,21 @@ static int getprotohints(su_addrinfo_t *hints,
/* Stack class used when transports are being destroyed */
static
void tport_destroy_recv(tp_stack_t *stack, tport_t *tp,
msg_t *msg, tp_magic_t *magic,
void tport_destroy_recv(tp_stack_t *stack, tport_t *tp,
msg_t *msg, tp_magic_t *magic,
su_time_t received)
{
msg_destroy(msg);
}
static
void tport_destroy_error(tp_stack_t *stack, tport_t *tp,
void tport_destroy_error(tp_stack_t *stack, tport_t *tp,
int errcode, char const *remote)
{
}
static
msg_t *tport_destroy_alloc(tp_stack_t *stack, int flags,
msg_t *tport_destroy_alloc(tp_stack_t *stack, int flags,
char const data[], usize_t len,
tport_t const *tp,
tp_client_t *tpc)
......@@ -473,7 +473,7 @@ static char const tpn_any[] = "*";
/** Create the master transport.
*
* Master transport object is used to bind the protocol using transport with
* actual transport objects corresponding to TCP, UDP, etc.
* actual transport objects corresponding to TCP, UDP, etc.
*
* @sa tport_tbind()
*
......@@ -483,7 +483,7 @@ static char const tpn_any[] = "*";
*/
tport_t *tport_tcreate(tp_stack_t *stack,
tp_stack_class_t const *tpac,
su_root_t *root,
su_root_t *root,
tag_type_t tag, tag_value_t value, ...)
{
tport_master_t *mr;
......@@ -547,7 +547,7 @@ void tport_destroy(tport_t *self)
{
tport_master_t *mr;
static tp_stack_class_t tport_destroy_tpac[1] =
static tp_stack_class_t tport_destroy_tpac[1] =
{{
sizeof tport_destroy_tpac,
/* tpac_recv */ tport_destroy_recv,
......@@ -560,7 +560,7 @@ void tport_destroy(tport_t *self)
if (self == NULL)
return;
assert(tport_is_master(self));
if (!tport_is_master(self))
return;
......@@ -586,7 +586,7 @@ void tport_destroy(tport_t *self)
/** Allocate a primary transport */
static
static
tport_primary_t *tport_alloc_primary(tport_master_t *mr,
tport_vtable_t const *vtable,
tp_name_t tpn[1],
......@@ -600,7 +600,7 @@ tport_primary_t *tport_alloc_primary(tport_master_t *mr,
for (next = &mr->mr_primaries; *next; next = &(*next)->pri_next)
;
assert(vtable->vtp_pri_size >= sizeof *pri);
if ((pri = su_home_clone(mr->mr_home, vtable->vtp_pri_size))) {
......@@ -625,9 +625,9 @@ tport_primary_t *tport_alloc_primary(tport_master_t *mr,
(void *)pri));
}
*next = pri;
*next = pri;
tp = pri->pri_primary;
if (!tp)
*return_culprit = "alloc";
else if (tport_set_params(tp, TAG_NEXT(tags)) < 0)
......@@ -635,9 +635,9 @@ tport_primary_t *tport_alloc_primary(tport_master_t *mr,
else if (vtable->vtp_init_primary &&
vtable->vtp_init_primary(pri, tpn, ai, tags, return_culprit) < 0)
;
else if (tport_setname(tp, vtable->vtp_name, ai, tpn->tpn_canon) == -1)
else if (tport_setname(tp, vtable->vtp_name, ai, tpn->tpn_canon) == -1)
*return_culprit = "tport_setname";
else if (tpn->tpn_ident &&
else if (tpn->tpn_ident &&
!(tp->tp_name->tpn_ident = su_strdup(tp->tp_home, tpn->tpn_ident)))
*return_culprit = "alloc ident";
else
......@@ -652,7 +652,7 @@ tport_primary_t *tport_alloc_primary(tport_master_t *mr,
/** Destroy a primary transport and its secondary transports. @internal */
static
static
void tport_zap_primary(tport_primary_t *pri)
{
tport_primary_t **prip;
......@@ -695,7 +695,7 @@ static
tport_primary_t *tport_listen(tport_master_t *mr,
tport_vtable_t const *vtable,
tp_name_t tpn[1],
su_addrinfo_t *ai,
su_addrinfo_t *ai,
tagi_t *tags)
{
tport_primary_t *pri = NULL;
......@@ -739,7 +739,7 @@ tport_primary_t *tport_listen(tport_master_t *mr,
return TPORT_LISTEN_ERROR(su_errno(), "su_wait_create");
/* Register receiving or accepting function with events specified above */
index = su_root_register(mr->mr_root, wait, tport_wakeup_pri, tp, 0);
index = su_root_register(mr->mr_root, wait, tport_wakeup_pri, tp, 0);
if (index == -1) {
su_wait_destroy(wait);
return TPORT_LISTEN_ERROR(su_errno(), "su_root_register");
......@@ -750,7 +750,7 @@ tport_primary_t *tport_listen(tport_master_t *mr,
pri->pri_primary->tp_has_connection = 0;
SU_DEBUG_5(("%s(%p): %s " TPN_FORMAT "\n",
SU_DEBUG_5(("%s(%p): %s " TPN_FORMAT "\n",
__func__, (void *)pri, "listening at",
TPN_ARGS(pri->pri_primary->tp_name)));
......@@ -780,13 +780,13 @@ int tport_bind_socket(int socket,
(IN6_IS_ADDR_V4MAPPED(&su->su_sin6.sin6_addr) ||
IN6_IS_ADDR_V4COMPAT(&su->su_sin6.sin6_addr))) {
su_sockaddr_t su0[1];
memcpy(su0, su, sizeof su0);
memset(su, 0, ai->ai_addrlen = sizeof su->su_sin);
su->su_family = ai->ai_family = AF_INET;
su->su_port = su0->su_port;
#ifndef IN6_V4MAPPED_TO_INADDR
#define IN6_V4MAPPED_TO_INADDR(in6, in4) \
memcpy((in4), 12 + (uint8_t *)(in6), sizeof(struct in_addr))
......@@ -823,17 +823,17 @@ int tport_set_events(tport_t *self, int set, int clear)
if (self->tp_pri->pri_vtable->vtp_set_events)
return self->tp_pri->pri_vtable->vtp_set_events(self);
SU_DEBUG_7(("tport_set_events(%p): events%s%s%s\n", (void *)self,
(events & SU_WAIT_IN) ? " IN" : "",
(events & SU_WAIT_OUT) ? " OUT" : "",
SU_WAIT_CONNECT != SU_WAIT_OUT &&
(events & SU_WAIT_CONNECT) ? " CONNECT" : ""));
return
su_root_eventmask(self->tp_master->mr_root,
self->tp_index,
self->tp_socket,
return
su_root_eventmask(self->tp_master->mr_root,
self->tp_index,
self->tp_socket,
self->tp_events = events);
}
......@@ -851,7 +851,7 @@ int tport_set_events(tport_t *self, int set, int clear)
*
* @note The socket is always closed upon error.
*/
tport_t *tport_alloc_secondary(tport_primary_t *pri,
tport_t *tport_alloc_secondary(tport_primary_t *pri,
int socket,
int accepted,
char const **return_reason)
......@@ -862,7 +862,7 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri,
self = su_home_clone(mr->mr_home, pri->pri_vtable->vtp_secondary_size);
if (self) {
SU_DEBUG_7(("%s(%p): new secondary tport %p\n",
SU_DEBUG_7(("%s(%p): new secondary tport %p\n",
__func__, (void *)pri, (void *)self));
self->tp_refs = -1; /* Freshly allocated */
......@@ -915,7 +915,7 @@ tport_t *tport_alloc_secondary(tport_primary_t *pri,
* @param tpn canonical name of node
*/
static
tport_t *tport_connect(tport_primary_t *pri,
tport_t *tport_connect(tport_primary_t *pri,
su_addrinfo_t *ai,
tp_name_t const *tpn)
{
......@@ -996,20 +996,20 @@ tport_t *tport_base_connect(tport_primary_t *pri,
/* Bind this socket to same IP address as the primary server socket */
if (getsockname(server_socket, &susa.su_sa, &susalen) < 0) {
SU_DEBUG_3(("%s(%p): getsockname(): %s\n",
SU_DEBUG_3(("%s(%p): getsockname(): %s\n",
__func__, (void *)self, su_strerror(su_errno())));
}
else {
susa.su_port = 0;
if (bind(s, &susa.su_sa, susalen) < 0) {
SU_DEBUG_3(("%s(%p): bind(local-ip): %s\n",
SU_DEBUG_3(("%s(%p): bind(local-ip): %s\n",
__func__, (void *)self, su_strerror(su_errno())));
}
}
}
/* Set sockname for the tport */
if (tport_setname(self, tpn->tpn_proto, real_ai, tpn->tpn_canon) == -1)
if (tport_setname(self, tpn->tpn_proto, real_ai, tpn->tpn_canon) == -1)
TPORT_CONNECT_ERROR(su_errno(), tport_setname);
/* Try to have a non-blocking connect().
......@@ -1039,7 +1039,7 @@ tport_t *tport_base_connect(tport_primary_t *pri,
self->tp_index = index;
if (ai == real_ai) {
SU_DEBUG_5(("%s(%p): %s to " TPN_FORMAT "\n",
SU_DEBUG_5(("%s(%p): %s to " TPN_FORMAT "\n",
__func__, (void *)self, what, TPN_ARGS(self->tp_name)));
}
else {
......@@ -1078,7 +1078,7 @@ void tport_zap_secondary(tport_t *self)
if (self->tp_msg) {
msg_destroy(self->tp_msg), self->tp_msg = NULL;
SU_DEBUG_3(("%s(%p): zapped partially received message\n",
SU_DEBUG_3(("%s(%p): zapped partially received message\n",
__func__, (void *)self));
}
......@@ -1088,7 +1088,7 @@ void tport_zap_secondary(tport_t *self)
msg_destroy(self->tp_queue[i]), self->tp_queue[i] = NULL;
n++;
}
SU_DEBUG_3(("%s(%p): zapped %lu queued messages\n",
SU_DEBUG_3(("%s(%p): zapped %lu queued messages\n",
__func__, (void *)self, (LU)n));
}
......@@ -1132,7 +1132,7 @@ void tport_unref(tport_t *tp)
return;
if (--tp->tp_refs > 0)
return;
if (!tport_is_secondary(tp))
return;
......@@ -1186,7 +1186,7 @@ int tport_get_params(tport_t const *self,
tpp = self->tp_params;
ta_start(ta, tag, value);
connect = tpp->tpp_conn_orient
connect = tpp->tpp_conn_orient
/* Only dgram primary is *not* connection-oriented */
|| !tport_is_primary(self) || !tport_is_dgram(self);
......@@ -1235,7 +1235,7 @@ int tport_set_params(tport_t *self,
ta_list ta;
int n, m = 0;
tport_params_t tpp[1], *tpp0;
usize_t mtu;
int connect, sdwn_error, reusable, stun_server, pong2ping;
......@@ -1296,8 +1296,8 @@ int tport_set_params(tport_t *self,
if (mtu > UINT_MAX)
mtu = UINT_MAX;
tpp->tpp_mtu = (unsigned)mtu;
/* Currently only primary UDP transport can *not* be connection oriented */
tpp->tpp_conn_orient = connect;
/* Currently only primary UDP transport can *not* be connection oriented */
tpp->tpp_conn_orient = connect;
tpp->tpp_sdwn_error = sdwn_error;
self->tp_reusable = reusable;
tpp->tpp_stun_server = stun_server;
......@@ -1306,7 +1306,7 @@ int tport_set_params(tport_t *self,
if (memcmp(tpp0, tpp, sizeof tpp) == 0)
return n;
if (tport_is_secondary(self) &&
if (tport_is_secondary(self) &&
self->tp_params == self->tp_pri->pri_primary->tp_params) {
tpp0 = su_zalloc(self->tp_home, sizeof *tpp0); if (!tpp0) return -1;
self->tp_params = tpp0;
......@@ -1376,7 +1376,7 @@ int tport_register_type(tport_vtable_t const *vtp)
/**Get a vtable for given protocol */
tport_vtable_t const *tport_vtable_by_name(char const *protoname,
enum tport_via public)
enum tport_via public)
{
int i;
......@@ -1392,7 +1392,7 @@ tport_vtable_t const *tport_vtable_by_name(char const *protoname,
assert(vtable->vtp_pri_size >= sizeof (tport_primary_t));
assert(vtable->vtp_secondary_size >= sizeof (tport_t));
return vtable;
}
......@@ -1400,7 +1400,7 @@ tport_vtable_t const *tport_vtable_by_name(char const *protoname,
}
#if 0
tport_set_f const *tport_set_methods[TPORT_NUMBER_OF_TYPES + 1] =
tport_set_f const *tport_set_methods[TPORT_NUMBER_OF_TYPES + 1] =
{
tport_server_bind_set,
tport_client_bind_set,
......@@ -1414,7 +1414,7 @@ tport_set_f const *tport_set_methods[TPORT_NUMBER_OF_TYPES + 1] =
NULL
};
int tport_bind_set(tport_master_t *mr,
int tport_bind_set(tport_master_t *mr,
tp_name_t const *tpn,
char const * const transports[],
tagi_t const *taglist,
......@@ -1461,7 +1461,7 @@ int tport_tbind(tport_t *self,
tp_name_t mytpn[1];
tport_master_t *mr;
char const *http_connect = NULL;
if (self == NULL || tport_is_secondary(self) ||
tpn == NULL || transports == NULL) {
su_seterrno(EINVAL);
......@@ -1486,7 +1486,7 @@ int tport_tbind(tport_t *self,
if (http_connect && public == 0)
public = tport_type_connect;
if (public && public != tport_type_stun)
server = 0;
......@@ -1519,7 +1519,7 @@ int tport_bind_client(tport_master_t *mr,
if (public == tport_type_local)
public = tport_type_client;
SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n",
__func__, (void *)mr, TPN_ARGS(tpn)));
......@@ -1531,8 +1531,8 @@ int tport_bind_client(tport_master_t *mr,
for (i = 0; transports[i]; i++) {
su_addrinfo_t hints[1];
char const *proto = transports[i];
if (strcmp(proto, tpn->tpn_proto) != 0 &&
if (strcmp(proto, tpn->tpn_proto) != 0 &&
strcmp(tpn->tpn_proto, tpn_any) != 0)
continue;
......@@ -1582,7 +1582,7 @@ int tport_bind_server(tport_master_t *mr,
bind6only_check(mr);
(void)hostname;
SU_DEBUG_5(("%s(%p) to " TPN_FORMAT "\n",
__func__, (void *)mr, TPN_ARGS(tpn)));
......@@ -1603,7 +1603,7 @@ int tport_bind_server(tport_master_t *mr,
if (tpn->tpn_port != NULL && strlen(tpn->tpn_port) > 0 &&
strcmp(tpn->tpn_port, tpn_any) != 0)
service = tpn->tpn_port;
else
else
service = "";
if (host && (strcmp(host, "0.0.0.0") == 0 || strcmp(host, "0") == 0))
......@@ -1617,7 +1617,7 @@ int tport_bind_server(tport_master_t *mr,
(host || tpn->tpn_canon != tpn->tpn_host))
canon = tpn->tpn_canon;
if (tport_server_addrinfo(mr, canon, family,
if (tport_server_addrinfo(mr, canon, family,
host, service, tpn->tpn_proto,
transports, &res) < 0)
return -1;
......@@ -1628,9 +1628,9 @@ int tport_bind_server(tport_master_t *mr,
port = port0 = port1 = ntohs(((su_sockaddr_t *)res->ai_addr)->su_port);
error = EPROTONOSUPPORT;
/*
* Loop until we can bind all the transports requested
* by the transport user to the same port.
/*
* Loop until we can bind all the transports requested
* by the transport user to the same port.
*/
for (;;) {
for (ai = res; ai; ai = ai->ai_next) {
......@@ -1651,7 +1651,7 @@ int tport_bind_server(tport_master_t *mr,
tpname->tpn_canon = canon;
tpname->tpn_host = host;
SU_DEBUG_9(("%s(%p): calling tport_listen for %s\n",
SU_DEBUG_9(("%s(%p): calling tport_listen for %s\n",
__func__, (void *)mr, ai->ai_canonname));
pri = tport_listen(mr, vtable, tpname, ainfo, tags);
......@@ -1698,7 +1698,7 @@ int tport_bind_server(tport_master_t *mr,
if (port == port1) /* All ports in use! */
break;
SU_DEBUG_3(("%s(%p): cannot bind all transports to port %u, trying %u\n",
SU_DEBUG_3(("%s(%p): cannot bind all transports to port %u, trying %u\n",
__func__, (void *)mr, old, port));
}
......@@ -1728,20 +1728,20 @@ int bind6only_check(tport_master_t *mr)
s4 = su_socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
s6 = su_socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
memset(su, 0, sizeof *su);
su->su_len = sulen = (sizeof su->su_sin6);
su->su_family = AF_INET6;
memset(su4, 0, sizeof *su4);
su4->su_len = su4len = (sizeof su->su_sin);
su4->su_family = AF_INET;
if (bind(s6, &su->su_sa, sulen) < 0)
;
else if (getsockname(s6, &su->su_sa, &sulen) < 0)
;
else if ((su4->su_port = su->su_port) != 0 &&
else if ((su4->su_port = su->su_port) != 0 &&
bind(s4, &su4->su_sa, su4len) == 0)
retval = 1;
......@@ -1757,14 +1757,14 @@ int bind6only_check(tport_master_t *mr)
/* Number of supported transports */
#define TPORT_N (8)
/** Return list of addrinfo structures matching to
/** Return list of addrinfo structures matching to
* canon/host/service/protocol
*/
static
int tport_server_addrinfo(tport_master_t *mr,
char const *canon,
int family,
char const *host,
char const *host,
char const *service,
char const *protocol,
char const * const transports[],
......@@ -1775,13 +1775,13 @@ int tport_server_addrinfo(tport_master_t *mr,
*return_addrinfo = NULL;
/*
/*
* Resolve all the transports requested by the protocol
*/
for (i = 0, N = 0; transports[i] && N < TPORT_N; i++) {
su_addrinfo_t *ai = &hints[N];
if (strcasecmp(transports[i], protocol) != 0 &&
if (strcasecmp(transports[i], protocol) != 0 &&
strcmp(protocol, tpn_any) != 0)
continue;
......@@ -1795,7 +1795,7 @@ int tport_server_addrinfo(tport_master_t *mr,
if (N == 0)
return su_seterrno(EPROTONOSUPPORT);
if (transports[i] /* Too many protocols */)
if (transports[i] /* Too many protocols */)
return su_seterrno(ENOMEM);
hints[N - 1].ai_next = NULL;
......@@ -1803,7 +1803,7 @@ int tport_server_addrinfo(tport_master_t *mr,
if (host) {
int error = tport_getaddrinfo(host, service, hints, return_addrinfo);
if (error || !*return_addrinfo) {
SU_DEBUG_3(("%s(%p): su_getaddrinfo(%s, %s) for %s: %s\n",
SU_DEBUG_3(("%s(%p): su_getaddrinfo(%s, %s) for %s: %s\n",
__func__, (void *)mr,
host ? host : "\"\"", service, protocol,
su_gai_strerror(error)));
......@@ -1818,7 +1818,7 @@ int tport_server_addrinfo(tport_master_t *mr,
/** Convert localinfo into addrinfo */
static
int
tport_get_local_addrinfo(tport_master_t *mr,
tport_get_local_addrinfo(tport_master_t *mr,
char const *port,
su_addrinfo_t const *hints,
su_addrinfo_t **return_ai)
......@@ -1855,14 +1855,14 @@ tport_get_local_addrinfo(tport_master_t *mr,
error = su_getlocalinfo(lihints, &li_result);
if (error) {
#if SU_HAVE_IN6
SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n",
__func__, (void *)mr,
family == AF_INET6 ? "ip6"
SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n",
__func__, (void *)mr,
family == AF_INET6 ? "ip6"
: family == AF_INET ? "ip4" : "ip",
su_gli_strerror(error)));
#else
SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n",
__func__, (void *)mr,
SU_DEBUG_3(("%s(%p): su_getlocalinfo() for %s address: %s\n",
__func__, (void *)mr,
family == AF_INET ? "ip4" : "ip",
su_gli_strerror(error)));
#endif
......@@ -1878,7 +1878,7 @@ tport_get_local_addrinfo(tport_master_t *mr,
ai = calloc(1, sizeof *ai + li->li_addrlen);
if (ai == NULL)
break;
*prev = ai, prev = &ai->ai_next;
ai->ai_flags = AI_PASSIVE | TP_AI_ANY;
......@@ -1886,7 +1886,7 @@ tport_get_local_addrinfo(tport_master_t *mr,
ai->ai_socktype = h->ai_socktype;
ai->ai_protocol = h->ai_protocol;
ai->ai_canonname = h->ai_canonname;
ai->ai_addr = memcpy(ai + 1, li->li_addr,
ai->ai_addr = memcpy(ai + 1, li->li_addr,
ai->ai_addrlen = li->li_addrlen);
su = (void *)ai->ai_addr;
su->su_port = htons(lport);
......@@ -1924,7 +1924,7 @@ int tport_getaddrinfo(char const *node, char const *service,
int error = EAI_SOCKTYPE;
int i, N;
su_addrinfo_t *all[TPORT_N + 1]; /* Lists for all supported transports */
su_addrinfo_t *results[TPORT_N + 1];
su_addrinfo_t *results[TPORT_N + 1];
void *addr;
int addrlen;
......@@ -1938,7 +1938,7 @@ int tport_getaddrinfo(char const *node, char const *service,
error = su_getaddrinfo(node, service, h, &all[N]);
results[N] = all[N];
if (error == EAI_SOCKTYPE) {
SU_DEBUG_7(("%s(): su_getaddrinfo(%s, %s) for %s: %s\n",
SU_DEBUG_7(("%s(): su_getaddrinfo(%s, %s) for %s: %s\n",
__func__, node ? node : "\"\"", service,
h0->ai_canonname, su_gai_strerror(error)));
continue;
......@@ -1979,22 +1979,22 @@ int tport_getaddrinfo(char const *node, char const *service,
if (memcmp(addr, a, addrlen)) /* Different address */
break;
results[i] = ai0->ai_next;
ai = calloc(1, sizeof *ai + ai0->ai_addrlen);
if (ai == NULL)
if (ai == NULL)
goto error;
*prev = memcpy(ai, ai0, sizeof *ai); prev = &ai->ai_next; *prev = NULL;
ai->ai_addr = memcpy(ai + 1, ai0->ai_addr, ai0->ai_addrlen);
ai->ai_canonname = h0->ai_canonname;
}
}