summaryrefslogtreecommitdiffstats
path: root/gl/getaddrinfo.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/getaddrinfo.c')
-rw-r--r--gl/getaddrinfo.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/gl/getaddrinfo.c b/gl/getaddrinfo.c
index 04f0ac2e..f09cf9ee 100644
--- a/gl/getaddrinfo.c
+++ b/gl/getaddrinfo.c
@@ -1,5 +1,5 @@
1/* Get address information (partial implementation). 1/* Get address information (partial implementation).
2 Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007 Free Software 2 Copyright (C) 1997, 2001, 2002, 2004, 2005, 2006, 2007, 2008 Free Software
3 Foundation, Inc. 3 Foundation, Inc.
4 Contributed by Simon Josefsson <simon@josefsson.org>. 4 Contributed by Simon Josefsson <simon@josefsson.org>.
5 5
@@ -19,12 +19,15 @@
19 19
20#include <config.h> 20#include <config.h>
21 21
22#include "getaddrinfo.h" 22#include <netdb.h>
23 23
24#if HAVE_NETINET_IN_H 24#if HAVE_NETINET_IN_H
25# include <netinet/in.h> 25# include <netinet/in.h>
26#endif 26#endif
27 27
28/* Get inet_ntop. */
29#include <arpa/inet.h>
30
28/* Get calloc. */ 31/* Get calloc. */
29#include <stdlib.h> 32#include <stdlib.h>
30 33
@@ -40,8 +43,6 @@
40#define _(String) gettext (String) 43#define _(String) gettext (String)
41#define N_(String) String 44#define N_(String) String
42 45
43#include "inet_ntop.h"
44
45/* BeOS has AF_INET, but not PF_INET. */ 46/* BeOS has AF_INET, but not PF_INET. */
46#ifndef PF_INET 47#ifndef PF_INET
47# define PF_INET AF_INET 48# define PF_INET AF_INET
@@ -300,6 +301,22 @@ getaddrinfo (const char *restrict nodename,
300 tmp->ai_addr->sa_family = he->h_addrtype; 301 tmp->ai_addr->sa_family = he->h_addrtype;
301 tmp->ai_family = he->h_addrtype; 302 tmp->ai_family = he->h_addrtype;
302 303
304#ifdef HAVE_STRUCT_SOCKADDR_SA_LEN
305 switch (he->h_addrtype)
306 {
307#if HAVE_IPV4
308 case AF_INET:
309 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in);
310 break;
311#endif
312#if HAVE_IPV6
313 case AF_INET6:
314 tmp->ai_addr->sa_len = sizeof (struct sockaddr_in6);
315 break;
316#endif
317 }
318#endif
319
303 /* FIXME: If more than one address, create linked list of addrinfo's. */ 320 /* FIXME: If more than one address, create linked list of addrinfo's. */
304 321
305 *res = tmp; 322 *res = tmp;
@@ -326,7 +343,7 @@ freeaddrinfo (struct addrinfo *ai)
326 cur = ai; 343 cur = ai;
327 ai = ai->ai_next; 344 ai = ai->ai_next;
328 345
329 if (cur->ai_canonname) free (cur->ai_canonname); 346 free (cur->ai_canonname);
330 free (cur); 347 free (cur);
331 } 348 }
332} 349}