Change the ai_addrlen type of struct addrinfo from size_t to socklen_t, per RFC 3493.

This commit is contained in:
Yang Tse 2006-07-14 10:30:44 +00:00
parent ccfce89423
commit d2cefc140a
4 changed files with 43 additions and 37 deletions

View File

@ -40,14 +40,14 @@ struct sockaddr_in6
#endif #endif
#ifndef HAVE_STRUCT_ADDRINFO #ifndef HAVE_STRUCT_ADDRINFO
struct addrinfo struct addrinfo
{ {
int ai_flags; int ai_flags;
int ai_family; int ai_family;
int ai_socktype; int ai_socktype;
int ai_protocol; int ai_protocol;
size_t ai_addrlen; socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
char *ai_cannonname; char *ai_canonname;
struct sockaddr *ai_addr; struct sockaddr *ai_addr;
struct addrinfo *ai_next; struct addrinfo *ai_next;
}; };

View File

@ -713,7 +713,7 @@ singleipconnect(struct connectdata *conn,
/* Connect TCP sockets, bind UDP */ /* Connect TCP sockets, bind UDP */
if(conn->socktype == SOCK_STREAM) 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 else
rc = 0; rc = 0;

View File

@ -94,13 +94,13 @@ typedef struct addrinfo Curl_addrinfo;
/* OK, so some ipv4-only include tree probably have the addrinfo struct, but /* 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! */ to work even on those that don't, we provide our own look-alike! */
struct Curl_addrinfo { struct Curl_addrinfo {
int ai_flags; int ai_flags;
int ai_family; int ai_family;
int ai_socktype; int ai_socktype;
int ai_protocol; int ai_protocol;
size_t ai_addrlen; socklen_t ai_addrlen; /* Follow rfc3493 struct addrinfo */
struct sockaddr *ai_addr; char *ai_canonname;
char *ai_canonname; struct sockaddr *ai_addr;
struct Curl_addrinfo *ai_next; struct Curl_addrinfo *ai_next;
}; };
typedef struct Curl_addrinfo Curl_addrinfo; typedef struct Curl_addrinfo Curl_addrinfo;

View File

@ -370,28 +370,34 @@ Curl_addrinfo *Curl_getaddrinfo(struct connectdata *conn,
* Curl_he2ai() translates from a hostent struct to a Curl_addrinfo struct. * 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 * The Curl_addrinfo is meant to work like the addrinfo struct does for IPv6
* stacks, but for all hosts and environments. * stacks, but for all hosts and environments.
*
struct Curl_addrinfo { * Curl_addrinfo defined in "lib/hostip.h"
int ai_flags; *
int ai_family; * struct Curl_addrinfo {
int ai_socktype; * int ai_flags;
int ai_protocol; * int ai_family;
size_t ai_addrlen; * int ai_socktype;
struct sockaddr *ai_addr; * int ai_protocol;
char *ai_canonname; * socklen_t ai_addrlen; * Follow rfc3493 struct addrinfo *
struct addrinfo *ai_next; * char *ai_canonname;
}; * struct sockaddr *ai_addr;
* struct Curl_addrinfo *ai_next;
struct hostent { * };
char *h_name; * official name of host * *
char **h_aliases; * alias list * * hostent defined in <netdb.h>
int h_addrtype; * host address type * *
int h_length; * length of address * * struct hostent {
char **h_addr_list; * list of addresses * * char *h_name;
} * char **h_aliases;
#define h_addr h_addr_list[0] * for backward compatibility * * 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) Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
{ {