1/* Declarations for host.c 2 Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 3 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. 4 5This file is part of GNU Wget. 6 7GNU Wget is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 3 of the License, or 10 (at your option) any later version. 11 12GNU Wget is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with Wget. If not, see <http://www.gnu.org/licenses/>. 19 20Additional permission under GNU GPL version 3 section 7 21 22If you modify this program, or any covered work, by linking or 23combining it with the OpenSSL project's OpenSSL library (or a 24modified version of that library), containing parts covered by the 25terms of the OpenSSL or SSLeay licenses, the Free Software Foundation 26grants you additional permission to convey the resulting work. 27Corresponding Source for a non-source form of such a combination 28shall include the source code for the parts of OpenSSL used as well 29as that of the covered work. */ 30 31#ifndef HOST_H 32#define HOST_H 33 34#ifdef WINDOWS 35# include <winsock.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# ifdef HAVE_ARPA_INET_H 45# include <arpa/inet.h> 46# endif 47#endif 48 49struct url; 50struct address_list; 51 52/* This struct defines an IP address, tagged with family type. */ 53 54typedef 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 80enum { 81 LH_SILENT = 1, 82 LH_BIND = 2, 83 LH_REFRESH = 4 84}; 85struct address_list *lookup_host (const char *, int); 86 87void address_list_get_bounds (const struct address_list *, int *, int *); 88const ip_address *address_list_address_at (const struct address_list *, int); 89bool address_list_contains (const struct address_list *, const ip_address *); 90void address_list_set_faulty (struct address_list *, int); 91void address_list_set_connected (struct address_list *); 92bool address_list_connected_p (const struct address_list *); 93void address_list_release (struct address_list *); 94 95const char *print_address (const ip_address *); 96#ifdef ENABLE_IPV6 97bool is_valid_ipv6_address (const char *, const char *); 98#endif 99 100bool accept_domain (struct url *); 101bool sufmatch (const char **, const char *); 102 103void host_cleanup (void); 104 105#endif /* HOST_H */ 106