1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of
5 * the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15 * MA 02111-1307 USA
16 */
17/***************************************************************************
18 * LPRng - An Extended Print Spooler System
19 *
20 * Copyright 1988-2003, Patrick Powell, San Diego, CA
21 *     papowell@lprng.com
22 * See LICENSE for conditions of use.
23 * $Id: gethostinfo.h,v 1.1.1.1 2008/10/15 03:28:27 james26_jang Exp $
24 ***************************************************************************/
25
26
27
28#ifndef _GETHOSTINFO_H_
29#define _GETHOSTINFO_H_ 1
30
31/*****************************************************************
32 * Get Fully Qualified Domain Name (FQDN) host name
33 * The 'domain' information is appended to the host name only in
34 * desperation cases and only if it is non-null.
35 * If the FQDN cannot be found,  then you fall back on the host name.
36 *****************************************************************/
37
38
39/*****************************************************************
40 * Host name and address information
41 *  The gethostbyname function returns a pointer to a structure
42 *  which contains all the host information.  But this
43 *  value disappears or is modified on the next call.  We save
44 *  the information  using this structure.  Also,  we look
45 *  forward to the IPV6 structure,  where we need a structure
46 *  for an address.
47 *****************************************************************/
48
49struct host_information{
50	char *shorthost;
51	char *fqdn;
52	struct line_list host_names;	/* official name of host is first */
53	int h_addrtype;		/* address type */
54	int h_length;		/* address length */
55	struct line_list h_addr_list;	/* address list */
56};
57
58EXTERN struct host_information Localhost_IP;	/* IP from localhost lookup */
59EXTERN struct host_information Host_IP;	/* current host ip */
60EXTERN struct host_information RemoteHost_IP;	/* IP from localhost lookup */
61EXTERN struct host_information LookupHost_IP;	/* for lookup */
62EXTERN struct host_information PermHost_IP;		/* for permission lookup */
63
64/* PROTOTYPES */
65void Clear_host_information( struct host_information *info );
66void Clear_all_host_information(void);
67void Check_for_dns_hack( struct hostent *h_ent );
68char *Find_fqdn( struct host_information *info, const char *shorthost );
69char *Fixup_fqdn( const char *shorthost, struct host_information *info,
70	struct hostent *host_ent );
71void Get_local_host( void );
72char *Get_hostinfo_byaddr( struct host_information *info,
73	struct sockaddr *sinaddr, int addr_only );
74char *Get_remote_hostbyaddr( struct host_information *info,
75	struct sockaddr *sinaddr, int force_ip_addr_use );
76int Same_host( struct host_information *host,
77	struct host_information *remote );
78void Dump_host_information( char *title,  struct host_information *info );
79void form_addr_and_mask(char *v, char *addr,char *mask,
80	int addrlen, int family );
81int cmp_ip_addr( char *h, char *a, char *m, int len );
82int Match_ipaddr_value( struct line_list *list, struct host_information *host );
83
84#endif
85