]> sjero.net Git - wget/blob - src/host.h
[svn] Look for and use socklen_t.
[wget] / src / host.h
1 /* Declarations for host.c
2    Copyright (C) 1995, 1996, 1997, 2001 Free Software Foundation, Inc.
3
4 This file is part of GNU Wget.
5
6 GNU Wget is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 GNU Wget is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Wget; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 In addition, as a special exception, the Free Software Foundation
21 gives permission to link the code of its release of Wget with the
22 OpenSSL project's "OpenSSL" library (or with modified versions of it
23 that use the same license as the "OpenSSL" library), and distribute
24 the linked executables.  You must obey the GNU General Public License
25 in all respects for all of the code used other than "OpenSSL".  If you
26 modify this file, you may extend this exception to your version of the
27 file, but you are not obligated to do so.  If you do not wish to do
28 so, delete this exception statement from your version.  */
29
30 #ifndef HOST_H
31 #define HOST_H
32
33 #ifdef WINDOWS
34 # include <winsock.h>
35 #else
36 # include <netdb.h>
37 # include <sys/socket.h>
38 # include <netinet/in.h>
39 #ifndef __BEOS__
40 # include <arpa/inet.h>
41 #endif
42 #endif
43
44 struct url;
45 struct address_list;
46
47 /* wget_sockaddr is used instead of sockaddr where an IPV6 address
48    must fit.  */
49
50 typedef union {
51         struct sockaddr     sa;   /* Generic but too small */
52         struct sockaddr_in  sin;  /* IPv4 socket address */
53 #ifdef ENABLE_IPV6
54         struct sockaddr_in6 sin6; /* IPv6 socket address */
55 #endif
56 } wget_sockaddr;
57
58 typedef struct {
59   unsigned char bytes[4];
60 } ip4_address;
61
62 /* If compiled with IPv6 support, we internally represent all IP
63    addresses as IPv6 addresses.  IPv4 addresses are dynamically mapped
64    to IPv6, i.e. stored in the format ::ffff:<Ipv4>.  */
65
66 #ifdef ENABLE_IPV6
67 # define MAX_IP_ADDRESS_SIZE 16
68 #else
69 # define MAX_IP_ADDRESS_SIZE 4
70 #endif
71
72 typedef struct {
73   unsigned char bytes[MAX_IP_ADDRESS_SIZE];
74 } ip_address;
75
76 /* Function declarations */
77 struct address_list *lookup_host PARAMS ((const char *, int));
78 char *herrmsg PARAMS ((int));
79
80 void address_list_get_bounds PARAMS ((struct address_list *, int *, int *));
81 void address_list_copy_one PARAMS ((struct address_list *, int,
82                                     ip_address *));
83 int address_list_match_all PARAMS ((struct address_list *,
84                                     struct address_list *));
85 void address_list_set_faulty PARAMS ((struct address_list *, int));
86 void address_list_release PARAMS ((struct address_list *));
87
88 char *pretty_print_address PARAMS ((ip_address *));
89
90 int accept_domain PARAMS ((struct url *));
91 int sufmatch PARAMS ((const char **, const char *));
92
93 void host_cleanup PARAMS ((void));
94
95 void wget_sockaddr_set_address PARAMS((wget_sockaddr *, int, 
96                                        unsigned short, ip_address *));
97 void wget_sockaddr_set_port PARAMS((wget_sockaddr *, unsigned short));
98 void *wget_sockaddr_get_addr PARAMS((wget_sockaddr *));
99 unsigned short wget_sockaddr_get_port PARAMS((const wget_sockaddr *));
100 socklen_t sockaddr_len PARAMS(());
101 void map_ipv4_to_ip PARAMS((ip4_address *, ip_address *));
102 int  map_ip_to_ipv4 PARAMS((ip_address *, ip4_address *));
103  
104 extern  int     ip_default_family;      /* defined in host.c */
105
106
107 #endif /* HOST_H */