]> sjero.net Git - wget/blob - src/host.h
[svn] Add the necessary includes for compilation under FreeBSD.
[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 #ifndef HOST_H
21 #define HOST_H
22
23 #include <netdb.h>
24 #include <netinet/in.h>
25 #include <sys/socket.h>
26
27 #undef INET6
28
29 struct url;
30 struct address_list;
31
32 /* wget_sockaddr is used instead of sockaddr where an IPV6 address
33    must fit.  */
34
35 typedef union {
36         struct sockaddr     sa;   /* Generic but too small */
37         struct sockaddr_in  sin;  /* IPv4 socket address */
38 #ifdef INET6
39         struct sockaddr_in6 sin6; /* IPv6 socket address */
40 #endif
41 } wget_sockaddr;
42
43 typedef struct {
44   unsigned char bytes[4];
45 } ip4_address;
46
47 /* If compiled with IPv6 support, we internally represent all IP
48    addresses as IPv6 addresses.  IPv4 addresses are dynamically mapped
49    to IPv6, i.e. stored in the format ::ffff:<Ipv4>.  */
50
51 #ifdef INET6
52 # define MAX_IP_ADDRESS_SIZE 16
53 #else
54 # define MAX_IP_ADDRESS_SIZE 4
55 #endif
56
57 typedef struct {
58   unsigned char bytes[MAX_IP_ADDRESS_SIZE];
59 } ip_address;
60
61 /* Function declarations */
62 struct address_list *lookup_host PARAMS ((const char *, int));
63 char *herrmsg PARAMS ((int));
64
65 void address_list_get_bounds PARAMS ((struct address_list *, int *, int *));
66 void address_list_copy_one PARAMS ((struct address_list *, int,
67                                     ip_address *));
68 int address_list_match_all PARAMS ((struct address_list *,
69                                     struct address_list *));
70 void address_list_set_faulty PARAMS ((struct address_list *, int));
71 void address_list_release PARAMS ((struct address_list *));
72
73 char *pretty_print_address PARAMS ((ip_address *));
74
75 int accept_domain PARAMS ((struct url *));
76 int sufmatch PARAMS ((const char **, const char *));
77
78 void host_cleanup PARAMS ((void));
79
80 void wget_sockaddr_set_address PARAMS((wget_sockaddr *, int, 
81                                        unsigned short, ip_address *));
82 void wget_sockaddr_set_port PARAMS((wget_sockaddr *, unsigned short));
83 void *wget_sockaddr_get_addr PARAMS((wget_sockaddr *));
84 unsigned short wget_sockaddr_get_port PARAMS((const wget_sockaddr *));
85 int sockaddr_len PARAMS(());
86 void map_ipv4_to_ip PARAMS((ip4_address *, ip_address *));
87 int  map_ip_to_ipv4 PARAMS((ip_address *, ip4_address *));
88  
89 extern  int     ip_default_family;      /* defined in host.c */
90
91
92 #endif /* HOST_H */