27 #ifdef HAVE_NETINET_IN_H 28 # include <netinet/in.h> 33 #ifdef HAVE_ARPA_INET_H 34 # include <arpa/inet.h> 45 #if defined(NETWARE) && defined(__NOVELL_LIBC__) 47 # define in_addr_t unsigned long 69 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER == 910) && \ 70 defined(__OPTIMIZE__) && defined(__unix__) && defined(__i386__) 72 # define vqualifier volatile 83 for(ca = cahead; ca != NULL; ca = canext) {
93 #ifdef HAVE_GETADDRINFO 109 Curl_getaddrinfo_ex(
const char *nodename,
110 const char *servname,
111 const struct addrinfo *hints,
114 const struct addrinfo *ai;
115 struct addrinfo *aihead;
124 error =
getaddrinfo(nodename, servname, hints, &aihead);
130 for(ai = aihead; ai != NULL; ai = ai->ai_next) {
134 if(ai->ai_family == AF_INET)
135 ss_size =
sizeof(
struct sockaddr_in);
137 else if(ai->ai_family == AF_INET6)
138 ss_size =
sizeof(
struct sockaddr_in6);
144 if((ai->ai_addr == NULL) || !(ai->ai_addrlen > 0))
148 if((
size_t)ai->ai_addrlen < ss_size)
177 if(ai->ai_canonname != NULL) {
200 freeaddrinfo(aihead);
275 struct sockaddr_in *addr;
277 struct sockaddr_in6 *addr6;
287 DEBUGASSERT((he->h_name != NULL) && (he->h_addr_list != NULL));
289 for(i = 0; (curr = he->h_addr_list[
i]) != NULL; i++) {
293 if(he->h_addrtype == AF_INET6)
294 ss_size =
sizeof(
struct sockaddr_in6);
297 ss_size =
sizeof(
struct sockaddr_in);
340 memcpy(&addr->sin_addr, curr,
sizeof(
struct in_addr));
341 addr->sin_family = (
unsigned short)(he->h_addrtype);
342 addr->sin_port = htons((
unsigned short)port);
349 memcpy(&addr6->sin6_addr, curr,
sizeof(
struct in6_addr));
350 addr6->sin6_family = (
unsigned short)(he->h_addrtype);
351 addr6->sin6_port = htons((
unsigned short)port);
373 struct in6_addr ina6;
394 #if defined(__VMS) && \ 395 defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64) 396 #pragma pointer_size save 397 #pragma pointer_size short 398 #pragma message disable PTRMISMATCH 413 hoststr =
strdup(hostname);
421 addrsize =
sizeof(
struct in_addr);
423 memcpy(addrentry, inaddr,
sizeof(
struct in_addr));
427 addrsize =
sizeof(
struct in6_addr);
428 addrentry = (
void *)&buf->
addrentry.ina6;
429 memcpy(addrentry, inaddr,
sizeof(
struct in6_addr));
441 h->h_addrtype = (short)af;
442 h->h_length = (short)addrsize;
445 h->h_addr_list[1] = NULL;
447 #if defined(__VMS) && \ 448 defined(__INITIAL_POINTER_SIZE) && (__INITIAL_POINTER_SIZE == 64) 449 #pragma pointer_size restore 450 #pragma message enable PTRMISMATCH 482 #ifdef USE_UNIX_SOCKETS 491 struct sockaddr_un *sa_un;
506 sa_un->sun_family = AF_UNIX;
509 path_len = strlen(
path) + 1;
510 if(path_len >
sizeof(sa_un->sun_path)) {
520 ((offsetof(
struct sockaddr_un, sun_path) + path_len) & 0x7FFFFFFF);
524 memcpy(sa_un->sun_path + 1,
path, path_len - 1);
532 #if defined(CURLDEBUG) && defined(HAVE_FREEADDRINFO) 542 curl_dofreeaddrinfo(
struct addrinfo *freethis,
543 int line,
const char *source)
546 lwip_freeaddrinfo(freethis);
548 (freeaddrinfo)(freethis);
550 curl_memlog(
"ADDR %s:%d freeaddrinfo(%p)\n",
551 source, line, (
void *)freethis);
556 #if defined(CURLDEBUG) && defined(HAVE_GETADDRINFO) 566 curl_dogetaddrinfo(
const char *
hostname,
568 const struct addrinfo *hints,
569 struct addrinfo **result,
570 int line,
const char *source)
573 int res = lwip_getaddrinfo(
hostname, service, hints, result);
579 curl_memlog(
"ADDR %s:%d getaddrinfo() = %p\n",
580 source, line, (
void *)*result);
582 curl_memlog(
"ADDR %s:%d getaddrinfo() failed\n",
588 #if defined(HAVE_GETADDRINFO) && defined(USE_RESOLVE_ON_IPS) 596 struct sockaddr_in *addr;
598 struct sockaddr_in6 *addr6;
600 for(ca = addrinfo; ca != NULL; ca = ca->
ai_next) {
604 addr->sin_port = htons((
unsigned short)
port);
610 addr6->sin6_port = htons((
unsigned short)
port);
union namebuff::@8 addrentry
Curl_addrinfo * Curl_ip2addr(int af, const void *inaddr, const char *hostname, int port)
void Curl_freeaddrinfo(Curl_addrinfo *cahead)
UNITTEST_START int result
struct sockaddr * ai_addr
memcpy(filename, filename1, strlen(filename1))
CURL_TYPEOF_CURL_SOCKLEN_T curl_socklen_t
int Curl_inet_pton(int af, const char *src, void *dst)
static unsigned short port
struct Curl_addrinfo * ai_next
Curl_addrinfo * Curl_str2addr(char *address, int port)
curl_socklen_t ai_addrlen
Curl_addrinfo * Curl_he2ai(const struct hostent *he, int port)
#define calloc(nbelem, size)