]> sjero.net Git - wget/blob - src/host.h
aa8d59cb35fe05f759ac295498d35ffa8615907d
[wget] / src / host.h
1 /* Declarations for host.c
2    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3    2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4
5 This file is part of GNU Wget.
6
7 GNU Wget is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11
12 GNU Wget is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Wget.  If not, see <http://www.gnu.org/licenses/>.
19
20 Additional permission under GNU GPL version 3 section 7
21
22 If you modify this program, or any covered work, by linking or
23 combining it with the OpenSSL project's OpenSSL library (or a
24 modified version of that library), containing parts covered by the
25 terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
26 grants you additional permission to convey the resulting work.
27 Corresponding Source for a non-source form of such a combination
28 shall include the source code for the parts of OpenSSL used as well
29 as that of the covered work.  */
30
31 #ifndef HOST_H
32 #define HOST_H
33
34 #ifdef WINDOWS
35 # include <winsock2.h>
36 #else
37 # ifdef __VMS
38 #  include "vms_ip.h"
39 # else /* def __VMS */
40 #  include <netdb.h>
41 # endif /* def __VMS [else] */
42 # include <sys/socket.h>
43 # include <netinet/in.h>
44 #ifndef __BEOS__
45 # include <arpa/inet.h>
46 #endif
47 #endif
48
49 struct url;
50 struct address_list;
51
52 /* This struct defines an IP address, tagged with family type.  */
53
54 typedef struct {
55   /* Address family, one of AF_INET or AF_INET6. */
56   int family;
57
58   /* The actual data, in the form of struct in_addr or in6_addr: */
59   union {
60     struct in_addr d4;          /* IPv4 address */
61 #ifdef ENABLE_IPV6
62     struct in6_addr d6;         /* IPv6 address */
63 #endif
64   } data;
65
66   /* Under IPv6 getaddrinfo also returns scope_id.  Since it's
67      IPv6-specific it strictly belongs in the above union, but we put
68      it here for simplicity.  */
69 #if defined ENABLE_IPV6 && defined HAVE_SOCKADDR_IN6_SCOPE_ID
70   int ipv6_scope;
71 #endif
72 } ip_address;
73
74 /* IP_INADDR_DATA macro returns a void pointer that can be interpreted
75    as a pointer to struct in_addr in IPv4 context or a pointer to
76    struct in6_addr in IPv4 context.  This pointer can be passed to
77    functions that work on either, such as inet_ntop.  */
78 #define IP_INADDR_DATA(x) ((void *) &(x)->data)
79
80 enum {
81   LH_SILENT  = 1,
82   LH_BIND    = 2,
83   LH_REFRESH = 4
84 };
85 struct address_list *lookup_host (const char *, int);
86
87 void address_list_get_bounds (const struct address_list *, int *, int *);
88 const ip_address *address_list_address_at (const struct address_list *, int);
89 bool address_list_contains (const struct address_list *, const ip_address *);
90 void address_list_set_faulty (struct address_list *, int);
91 void address_list_set_connected (struct address_list *);
92 bool address_list_connected_p (const struct address_list *);
93 void address_list_release (struct address_list *);
94
95 const char *print_address (const ip_address *);
96 #ifdef ENABLE_IPV6
97 bool is_valid_ipv6_address (const char *, const char *);
98 #endif
99
100 bool accept_domain (struct url *);
101 bool sufmatch (const char **, const char *);
102
103 void host_cleanup (void);
104
105 #endif /* HOST_H */