Commit 4725a433 authored by Pekka Pessi's avatar Pekka Pessi

su module: use socklen_t where appropriate.

su.h, su_localinfo.h (li_addrlen), su_addrinfo.c, su_localinfo.c.

darcs-hash:20060906190747-65a35-849f2c5e03b719a798c4968aa1869cafbd4ff6d1.gz
parent f4ae0662
......@@ -338,13 +338,13 @@ SOFIAPUBFUN const char *inet_ntop(int af, void const *src,
/**@HI Calculate correct size of su_sockaddr_t structure. */
#if SU_HAVE_IN6
#define SU_SOCKADDR_SIZE(su) \
((su)->su_family == AF_INET ? sizeof((su)->su_sin) \
: ((su)->su_family == AF_INET6 ? sizeof((su)->su_sin6) \
: sizeof(*su)))
((socklen_t)((su)->su_family == AF_INET ? sizeof((su)->su_sin) \
: ((su)->su_family == AF_INET6 ? sizeof((su)->su_sin6) \
: sizeof(*su))))
#else
#define SU_SOCKADDR_SIZE(su) \
((su)->su_family == AF_INET ? sizeof((su)->su_sin) \
: sizeof(*su))
((socklen_t)((su)->su_family == AF_INET ? sizeof((su)->su_sin) \
: sizeof(*su)))
#endif
#define su_sockaddr_size SU_SOCKADDR_SIZE
......
......@@ -50,7 +50,7 @@ struct su_localinfo_s {
int li_family; /**< Address family. */
int li_index; /**< Network interface index. */
int li_scope; /**< Address scope. */
int li_addrlen; /**< Length of li_addr. */
socklen_t li_addrlen; /**< Length of li_addr. */
su_sockaddr_t *li_addr; /**< Binary address. */
char *li_canonname; /**< Canonical name for address. */
su_localinfo_t *li_next; /**< Next structure in linked list. */
......
......@@ -935,15 +935,22 @@ char const *su_gai_strerror(int errcode)
return gai_strerror(errcode);
}
/** Resolve socket address into hostname and service name */
/** Resolve socket address into hostname and service name.
*
* @note
* This function uses now @RFC2133 prototype. The @RFC3493 redefines the
* prototype as well as ai_addrlen to use socklen_t instead of size_t.
* If your application allocates more than 2 gigabytes for resolving the
* hostname, you probably lose.
*/
int
su_getnameinfo(const su_sockaddr_t *su, size_t sulen,
char *return_host, size_t hostlen,
char *return_serv, size_t servlen,
int flags)
{
return getnameinfo(&su->su_sa, sulen,
return_host, hostlen,
return_serv, servlen,
return getnameinfo(&su->su_sa, (socklen_t)sulen,
return_host, (socklen_t)hostlen,
return_serv, (socklen_t)servlen,
flags);
}
......@@ -427,7 +427,7 @@ int localinfo4(su_localinfo_t const *hints, su_localinfo_t **rresult)
#if defined(__APPLE_CC__)
{
su_sockaddr_t *sa;
unsigned int salen = sizeof(*sa);
socklen_t salen = sizeof(*sa);
int scope = 0, gni_flags = 0;
li = calloc(1, sizeof(su_localinfo_t));
......@@ -697,11 +697,11 @@ int localinfo4(su_localinfo_t const *hints, su_localinfo_t **rresult)
su_localinfo_t *li = NULL, **lli = &tbf;
su_sockaddr_t *su;
#if SU_HAVE_IN6
int su_sockaddr_size =
socklen_t su_sockaddr_size =
(hints->li_flags & LI_V4MAPPED) ? sizeof(*su) : sizeof(struct sockaddr_in);
flags = hints->li_flags & (LI_V4MAPPED|LI_CANONNAME|LI_NUMERIC|LI_IFNAME);
#else
int su_sockaddr_size = sizeof(struct sockaddr_in);
socklen_t su_sockaddr_size = sizeof(struct sockaddr_in);
flags = hints->li_flags & (LI_CANONNAME|LI_NUMERIC|LI_IFNAME);
#endif
......
......@@ -400,7 +400,7 @@ su_port_t *su_port_create(void)
#else
{
struct sockaddr_in sin = { sizeof(struct sockaddr_in), 0 };
size_t sinsize = sizeof sin;
socklen_t sinsize = sizeof sin;
struct sockaddr *sa = (struct sockaddr *)&sin;
af = PF_INET;
......
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