Commit a37287d8 authored by Pekka Pessi's avatar Pekka Pessi

tport: updated internal interfaces to use ssize_t/size_t.

darcs-hash:20060920152906-65a35-0b099206786428ea2d7876c7895b40245e9149b3.gz
parent e70ded57
......@@ -156,10 +156,10 @@ struct tport_comp_vtable_s {
su_sockaddr_t *from,
socklen_t fromlen);
int (*vsc_send_comp)(tport_t const *self,
ssize_t (*vsc_send_comp)(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
int iovused,
size_t iovused,
struct sigcomp_compartment *cc,
tport_compressor_t *sc);
......
......@@ -336,7 +336,7 @@ static int
tport_connected(su_root_magic_t *m, su_wait_t *w, tport_t *self),
tport_resolve(tport_t *self, msg_t *msg, tp_name_t const *tpn),
tport_vsend(tport_t *self, msg_t *msg, tp_name_t const *tpn,
msg_iovec_t iov[], int iovused,
msg_iovec_t iov[], size_t iovused,
struct sigcomp_compartment *cc),
tport_send_error(tport_t *, msg_t *, tp_name_t const *),
tport_queue(tport_t *self, msg_t *msg),
......@@ -482,6 +482,7 @@ void tport_destroy(tport_t *self)
/* tpac_recv */ tport_destroy_recv,
/* tpac_error */ tport_destroy_error,
/* tpac_alloc */ tport_destroy_alloc,
/* tpac_address */ NULL
}};
SU_DEBUG_7(("%s(%p)\n", __func__, self));
......@@ -1997,7 +1998,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
tport_primary_t *dad;
tport_t *tp, *tp_next;
su_time_t now = su_now();
int ts = su_time_ms(now);
int ts = (int)su_time_ms(now);
/* Go through all primary transports */
for (dad = mr->mr_primaries; dad; dad = dad->pri_next) {
......@@ -2022,7 +2023,7 @@ void tport_tick(su_root_magic_t *magic, su_timer_t *t, tport_master_t *mr)
int closed;
if (msg &&
tp->tp_params->tpp_timeout != UINT_MAX &&
tp->tp_params->tpp_timeout < INT_MAX &&
tp->tp_params->tpp_timeout < ts - (int)tp->tp_time &&
!msg_is_streaming(msg)) {
SU_DEBUG_5(("tport_tick(%p): incomplete message idle for %d ms\n",
......@@ -3155,7 +3156,7 @@ int tport_send_msg(tport_t *self, msg_t *msg,
self->tp_time = su_time_ms(now = su_now());
n = tport_vsend(self, msg, tpn, iov, (int)iovused, cc);
n = tport_vsend(self, msg, tpn, iov, iovused, cc);
SU_DEBUG_9(("tport_vsend returned %d\n", n));
if (n < 0)
......@@ -3173,7 +3174,7 @@ int tport_send_msg(tport_t *self, msg_t *msg,
if (tport_is_connection_oriented(self)) {
iov[i].mv_len -= n - total;
iov[i].mv_base = (char *)iov[i].mv_base + (n - total);
if (tport_queue_rest(self, msg, &iov[i], (int)(iovused - i)) >= 0)
if (tport_queue_rest(self, msg, &iov[i], iovused - i) >= 0)
return n;
}
else {
......@@ -3211,10 +3212,10 @@ int tport_vsend(tport_t *self,
msg_t *msg,
tp_name_t const *tpn,
msg_iovec_t iov[],
int iovused,
size_t iovused,
struct sigcomp_compartment *cc)
{
int n;
ssize_t n;
su_addrinfo_t *ai = msg_addrinfo(msg);
if (cc) {
......@@ -3237,8 +3238,8 @@ int tport_vsend(tport_t *self,
tport_dump_iovec(self, msg, n, iov, iovused, "sent", "to");
if (tport_log->log_level >= 7) {
int i;
size_t m = 0;
size_t i, m = 0;
for (i = 0; i < iovused; i++)
m += iov[i].mv_len;
......@@ -3318,9 +3319,9 @@ static
int tport_queue_rest(tport_t *self,
msg_t *msg,
msg_iovec_t iov[],
int iovused)
ssize_t iovused)
{
usize_t iovlen = self->tp_iovlen;
size_t iovlen = self->tp_iovlen;
assert(tport_is_connection_oriented(self));
assert(self->tp_queue == NULL ||
......@@ -3570,8 +3571,7 @@ void tport_send_event(tport_t *self)
static
void tport_send_queue(tport_t *self)
{
int i;
size_t n, total;
size_t i, n, total;
msg_t *msg;
msg_iovec_t *iov;
int iovused;
......@@ -4106,6 +4106,9 @@ tport_t *tport_by_name(tport_t const *self, tp_name_t const *tpn)
{
tport_t const *sub, *next;
char const *canon, *host, *port, *comp;
#if SU_HAVE_IN6
char *end, ipaddr[TPORT_HOSTPORTSIZE];
#endif
assert(self); assert(tpn);
......@@ -4130,18 +4133,16 @@ tport_t *tport_by_name(tport_t const *self, tp_name_t const *tpn)
memset(su, 0, sizeof su);
#if SU_HAVE_IN6
if (strchr(host, ':')) {
char *end, ipaddr[TPORT_HOSTPORTSIZE];
if (host[0] == '[') {
/* Remove [] around IPv6 address */
host = strncpy(ipaddr, host + 1, sizeof(ipaddr) - 1);
ipaddr[sizeof(ipaddr) - 1] = '\0';
if ((end = strchr(host, ']')))
*end = 0;
}
if (host_is_ip6_reference(host)) {
/* Remove [] around IPv6 address */
host = strncpy(ipaddr, host + 1, sizeof(ipaddr) - 1);
ipaddr[sizeof(ipaddr) - 1] = '\0';
if ((end = strchr(host, ']')))
*end = 0;
su->su_len = sulen = (socklen_t) sizeof (struct sockaddr_in6);
su->su_family = AF_INET6;
}
else if (host_is_ip_address(host)) {
su->su_len = sulen = (socklen_t) sizeof (struct sockaddr_in6);
su->su_family = AF_INET6;
}
......@@ -4206,7 +4207,7 @@ tport_t *tport_by_name(tport_t const *self, tp_name_t const *tpn)
continue;
if (resolved) {
if (sub->tp_addrlen != (size_t)sulen ||
if ((socklen_t)sub->tp_addrlen != sulen ||
memcmp(sub->tp_addr, su, sulen)) {
SU_DEBUG_7(("tport(%p): not found by name " TPN_FORMAT "\n",
self, TPN_ARGS(tpn)));
......
......@@ -191,10 +191,10 @@ struct tport_s {
unsigned short tp_qhead; /**< Head of queue */
msg_iovec_t *tp_unsent; /**< Pointer to first unsent iovec */
unsigned tp_unsentlen; /**< Number of unsent iovecs */
size_t tp_unsentlen; /**< Number of unsent iovecs */
msg_iovec_t *tp_iov; /**< Iovecs allocated for sending */
usize_t tp_iovlen; /**< Number of allocated iovecs */
size_t tp_iovlen; /**< Number of allocated iovecs */
/* ==== Extensions ===================================================== */
......@@ -211,7 +211,7 @@ struct tport_s {
/** Primary structure */
struct tport_primary {
tport_t pri_primary[1]; /**< Transport part */
#if DOX
#if DOXYGEN_ONLY
su_home_t pri_home[1];
#else
#define pri_home pri_primary->tp_home
......@@ -244,7 +244,7 @@ struct tport_primary {
/** Master structure */
struct tport_master {
tport_t mr_master[1];
#if DOX
#if DOXYGEN_ONLY
su_home_t mr_home[1];
#else
#define mr_home mr_master->tp_home
......@@ -304,7 +304,7 @@ struct tport_master {
#endif
};
/** Virtual funtion table */
/** Virtual funtion table for transports */
struct tport_vtable
{
char const *vtp_name;
......@@ -329,8 +329,8 @@ struct tport_vtable
int (*vtp_set_events)(tport_t const *self);
int (*vtp_wakeup)(tport_t *self, int events);
int (*vtp_recv)(tport_t *self);
int (*vtp_send)(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], int iovused);
ssize_t (*vtp_send)(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], size_t iovused);
void (*vtp_deliver)(tport_t *self, msg_t *msg, su_time_t now);
int (*vtp_prepare)(tport_t *self, msg_t *msg,
tp_name_t const *tpn,
......@@ -422,7 +422,7 @@ void tport_open_log(tport_master_t *mr, tagi_t *tags);
void tport_log_msg(tport_t *tp, msg_t *msg, char const *what,
char const *via, su_time_t now);
void tport_dump_iovec(tport_t const *self, msg_t *msg,
isize_t n, su_iovec_t const iov[], isize_t iovused,
size_t n, su_iovec_t const iov[], size_t iovused,
char const *what, char const *how);
extern tport_vtable_t const tport_udp_vtable;
......@@ -435,8 +435,8 @@ int tport_udp_init_primary(tport_primary_t *,
char const **return_culprit);
void tport_udp_deinit_primary(tport_primary_t *);
int tport_recv_dgram(tport_t *self);
int tport_send_dgram(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], int iovused);
ssize_t tport_send_dgram(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], size_t iovused);
int tport_udp_error(tport_t const *self, su_sockaddr_t name[1]);
extern tport_vtable_t const tport_tcp_vtable;
......@@ -453,8 +453,8 @@ int tport_tcp_init_client(tport_primary_t *,
int tport_tcp_init_secondary(tport_t *self, int socket, int accepted,
char const **return_reason);
int tport_recv_stream(tport_t *self);
int tport_send_stream(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], int iovused);
ssize_t tport_send_stream(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], size_t iovused);
extern tport_vtable_t const tport_sctp_vtable;
extern tport_vtable_t const tport_sctp_client_vtable;
......@@ -512,10 +512,10 @@ int tport_recv_comp_dgram(tport_t const *self,
su_sockaddr_t *from,
socklen_t fromlen);
int tport_send_comp(tport_t const *self,
ssize_t tport_send_comp(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
int iovused,
size_t iovused,
struct sigcomp_compartment *cc,
tport_compressor_t *sc);
......
......@@ -115,7 +115,7 @@ void tport_open_log(tport_master_t *mr, tagi_t *tags)
/** Create log stamp */
void tport_stamp(tport_t const *self, msg_t *msg,
char stamp[128], char const *what,
isize_t n, char const *via,
size_t n, char const *via,
su_time_t now)
{
char label[24] = "";
......@@ -149,7 +149,7 @@ void tport_stamp(tport_t const *self, msg_t *msg,
/** Dump the data from the iovec */
void tport_dump_iovec(tport_t const *self, msg_t *msg,
isize_t n, su_iovec_t const iov[], isize_t iovused,
size_t n, su_iovec_t const iov[], size_t iovused,
char const *what, char const *how)
{
tport_master_t *mr = self->tp_master;
......
......@@ -273,12 +273,12 @@ int tport_recv_comp_dgram(tport_t const *self,
}
int tport_send_comp(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
int iovused,
struct sigcomp_compartment *cc,
tport_compressor_t *comp)
ssize_t tport_send_comp(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
size_t iovused,
struct sigcomp_compartment *cc,
tport_compressor_t *comp)
{
tport_comp_vtable_t const *vsc = tport_comp_vtable;
......
......@@ -32,6 +32,8 @@
*
*/
#include "config.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
......@@ -74,12 +76,12 @@ struct tls_s {
/* Receiving */
int read_events;
void *read_buffer;
int read_buffer_len;
size_t read_buffer_len;
/* Sending */
int write_events;
void *write_buffer;
int write_buffer_len;
size_t write_buffer_len;
/* Host names */
char *hosts[TLS_MAX_HOSTS + 1];
......@@ -599,9 +601,9 @@ int tls_error(tls_t *tls, int ret, char const *who, char const *operation,
return -1;
}
int tls_read(tls_t *tls)
ssize_t tls_read(tls_t *tls)
{
int ret;
ssize_t ret;
if (tls == NULL) {
errno = EINVAL;
......@@ -614,7 +616,7 @@ int tls_read(tls_t *tls)
tls->read_events);
if (tls->read_buffer_len)
return tls->read_buffer_len;
return (ssize_t)tls->read_buffer_len;
tls->read_events = POLLIN;
......@@ -635,10 +637,10 @@ int tls_read(tls_t *tls)
}
}
return tls->read_buffer_len = ret;
return (ssize_t)(tls->read_buffer_len = ret);
}
void *tls_read_buffer(tls_t *tls, int N)
void *tls_read_buffer(tls_t *tls, size_t N)
{
assert(N == tls->read_buffer_len);
tls->read_buffer_len = 0;
......@@ -666,12 +668,13 @@ int tls_want_read(tls_t *tls, int events)
return 0;
}
int tls_write(tls_t *tls, void *buf, int size)
ssize_t tls_write(tls_t *tls, void *buf, size_t size)
{
int ret;
ssize_t ret;
if (0)
fprintf(stderr, "tls_write(%p) called on %s\n", tls,
fprintf(stderr, "tls_write(%p, %p, "MOD_ZU") called on %s\n",
tls, buf, size,
tls && tls->type == tls_slave ? "server" : "client");
if (tls == NULL || buf == NULL) {
......
......@@ -33,8 +33,8 @@
* Copyright 2001, 2002 Nokia Research Center. All rights reserved.
*/
#ifndef SU_CONFIG_H
#include <sofia-sip/su_config.h>
#ifndef SU_TYPES_H
#include <sofia-sip/su_types.h>
#endif
SOFIA_BEGIN_DECLS
......@@ -65,12 +65,12 @@ tls_t *tls_init_slave(tls_t *tls_master, int sock);
tls_t *tls_init_client(tls_t *tls_master, int sock);
void tls_free(tls_t *tls);
int tls_get_socket(tls_t *tls);
int tls_read(tls_t *tls);
void *tls_read_buffer(tls_t *tls, int N);
ssize_t tls_read(tls_t *tls);
void *tls_read_buffer(tls_t *tls, size_t N);
int tls_want_read(tls_t *tls, int events);
int tls_pending(tls_t const *tls);
int tls_write(tls_t *tls, void *buf, int size);
ssize_t tls_write(tls_t *tls, void *buf, size_t size);
int tls_want_write(tls_t *tls, int events);
int tls_check_hosts(tls_t *tls, char const *hosts[TLS_MAX_HOSTS]);
......
......@@ -256,11 +256,11 @@ int tport_recv_stream(tport_t *self)
return 1;
}
int tport_send_stream(tport_t const *self, msg_t *msg,
msg_iovec_t iov[],
int iovused)
ssize_t tport_send_stream(tport_t const *self, msg_t *msg,
msg_iovec_t iov[],
size_t iovused)
{
#if __sun__ /* XXX - there must be better way... */
#if __sun__ /* XXX - there must be a better way... */
if (iovused > 16)
iovused = 16;
#endif
......
......@@ -71,9 +71,9 @@ static void tport_tls_deinit_secondary(tport_t *self);
static void tport_tls_shutdown(tport_t *self, int how);
static int tport_tls_set_events(tport_t const *self);
static int tport_tls_events(tport_t *self, int events);
static int tport_tls_recv(tport_t *self);
static int tport_tls_send(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], int iovused);
static ssize_t tport_tls_recv(tport_t *self);
static ssize_t tport_tls_send(tport_t const *self, msg_t *msg,
msg_iovec_t iov[], size_t iovused);
typedef struct
{
......@@ -400,15 +400,16 @@ int tport_tls_recv(tport_t *self)
}
static
int tport_tls_send(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
int iovlen)
ssize_t tport_tls_send(tport_t const *self,
msg_t *msg,
msg_iovec_t iov[],
size_t iovlen)
{
tport_tls_primary_t *tlspri = (tport_tls_primary_t *)self->tp_pri;
tport_tls_t *tlstp = (tport_tls_t *)self;
enum { TLSBUFSIZE = 2048 };
int i, j, n, m, size = 0;
size_t i, j, m, size = 0;
ssize_t n;
int oldmask, mask;
if (tlstp->tlstp_context == NULL) {
......
......@@ -281,9 +281,9 @@ int tport_recv_dgram(tport_t *self)
}
/** Send using su_vsend(). Map IPv4 addresses as IPv6 addresses, if needed. */
int tport_send_dgram(tport_t const *self, msg_t *msg,
msg_iovec_t iov[],
int iovused)
ssize_t tport_send_dgram(tport_t const *self, msg_t *msg,
msg_iovec_t iov[],
size_t iovused)
{
su_sockaddr_t su[1];
socklen_t sulen = sizeof su;
......
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