From d2cefc140a601c3028c16b23dae2d47cd95ac3c8 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Fri, 14 Jul 2006 10:30:44 +0000 Subject: [PATCH] Change the ai_addrlen type of struct addrinfo from size_t to socklen_t, per RFC 3493. --- ares/ares_ipv6.h | 14 +++++++------- lib/connect.c | 2 +- lib/hostip.h | 14 +++++++------- lib/hostip4.c | 50 +++++++++++++++++++++++++++--------------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/ares/ares_ipv6.h b/ares/ares_ipv6.h index a6d980fe7..afc98320b 100644 --- a/ares/ares_ipv6.h +++ b/ares/ares_ipv6.h @@ -40,14 +40,14 @@ struct sockaddr_in6 #endif #ifndef HAVE_STRUCT_ADDRINFO -struct addrinfo +struct addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - char *ai_cannonname; + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */ + char *ai_canonname; struct sockaddr *ai_addr; struct addrinfo *ai_next; }; diff --git a/lib/connect.c b/lib/connect.c index 0b404aed7..b12cf8b84 100644 --- a/lib/connect.c +++ b/lib/connect.c @@ -713,7 +713,7 @@ singleipconnect(struct connectdata *conn, /* Connect TCP sockets, bind UDP */ if(conn->socktype == SOCK_STREAM) - rc = connect(sockfd, ai->ai_addr, (socklen_t)ai->ai_addrlen); + rc = connect(sockfd, ai->ai_addr, ai->ai_addrlen); else rc = 0; diff --git a/lib/hostip.h b/lib/hostip.h index ade5efa28..2205aac08 100644 --- a/lib/hostip.h +++ b/lib/hostip.h @@ -94,13 +94,13 @@ typedef struct addrinfo Curl_addrinfo; /* OK, so some ipv4-only include tree probably have the addrinfo struct, but to work even on those that don't, we provide our own look-alike! */ struct Curl_addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; + int ai_flags; + int ai_family; + int ai_socktype; + int ai_protocol; + socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */ + char *ai_canonname; + struct sockaddr *ai_addr; struct Curl_addrinfo *ai_next; }; typedef struct Curl_addrinfo Curl_addrinfo; diff --git a/lib/hostip4.c b/lib/hostip4.c index 51eca67fe..bba9fb1dc 100644 --- a/lib/hostip4.c +++ b/lib/hostip4.c @@ -370,28 +370,34 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn, * Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct. * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6 * stacks, but for all hosts and environments. - -struct Curl_addrinfo { - int ai_flags; - int ai_family; - int ai_socktype; - int ai_protocol; - size_t ai_addrlen; - struct sockaddr *ai_addr; - char *ai_canonname; - struct addrinfo *ai_next; -}; - -struct hostent { - char *h_name; * official name of host * - char **h_aliases; * alias list * - int h_addrtype; * host address type * - int h_length; * length of address * - char **h_addr_list; * list of addresses * -} -#define h_addr h_addr_list[0] * for backward compatibility * - -*/ + * + * Curl_addrinfo defined in "lib/hostip.h" + * + * struct Curl_addrinfo { + * int ai_flags; + * int ai_family; + * int ai_socktype; + * int ai_protocol; + * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo * + * char *ai_canonname; + * struct sockaddr *ai_addr; + * struct Curl_addrinfo *ai_next; + * }; + * + * hostent defined in + * + * struct hostent { + * char *h_name; + * char **h_aliases; + * int h_addrtype; + * int h_length; + * char **h_addr_list; + * }; + * + * for backward compatibility: + * + * #define h_addr h_addr_list[0] + */ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port) {