xref: /titanic_50/usr/src/head/netdir.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24  */
25 /*	Copyright (c) 1992 Sun Microsystems, Inc.	*/
26 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 /*
30  * netdir.h
31  *
32  * This is the include file that defines various structures and
33  * constants used by the netdir routines.
34  */
35 
36 #ifndef _NETDIR_H
37 #define	_NETDIR_H
38 
39 /*
40  * This files uses struct netconfig, and netconfig.h must be included
41  * before this to avoid warnings.
42  */
43 
44 #include <netconfig.h>
45 
46 #ifdef	__cplusplus
47 extern "C" {
48 #endif
49 
50 struct nd_addrlist {
51 	int 		n_cnt;		/* number of netbufs */
52 	struct netbuf 	*n_addrs;	/* the netbufs */
53 };
54 
55 struct nd_hostservlist {
56 	int			h_cnt;		/* number of nd_hostservs */
57 	struct nd_hostserv	*h_hostservs;	/* the entries */
58 };
59 
60 struct nd_hostserv {
61 	char		*h_host;	/* the host name */
62 	char		*h_serv;	/* the service name */
63 };
64 
65 struct nd_mergearg {
66 	char		*s_uaddr;	/* servers universal address */
67 	char		*c_uaddr;	/* clients universal address */
68 	char		*m_uaddr;	/* merged universal address */
69 };
70 
71 /*
72  * _nderror is a private variable to the netdir system.
73  */
74 #ifdef _REENTRANT
75 extern int	*__nderror();
76 #define	_nderror	(*(__nderror()))
77 #else
78 extern int _nderror;
79 #endif  /* _REENTRANT */
80 
81 
82 int netdir_options(struct netconfig *, int option, int fd, char *par);
83 int netdir_getbyname(struct netconfig *, struct nd_hostserv *,
84     struct nd_addrlist **);
85 int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **,
86     struct netbuf *);
87 int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **,
88     struct netbuf *);
89 int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr,
90     char *ruaddr);
91 void netdir_free(void *, int);
92 struct netbuf *uaddr2taddr(struct netconfig *, char *);
93 char *taddr2uaddr(struct netconfig *, struct netbuf *);
94 void netdir_perror(char *);
95 char *netdir_sperror();
96 struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *);
97 struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *);
98 struct netbuf *_uaddr2taddr(struct netconfig *, char *);
99 char *_taddr2uaddr(struct netconfig *, struct netbuf *);
100 char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr);
101 
102 /*
103  * These are all objects that can be freed by netdir_free
104  */
105 #define	ND_HOSTSERV	0
106 #define	ND_HOSTSERVLIST	1
107 #define	ND_ADDR		2
108 #define	ND_ADDRLIST	3
109 
110 /*
111  * These are the various errors that can be encountered while attempting
112  * to translate names to addresses. Note that none of them (except maybe
113  * no memory) are truely fatal unless the ntoa deamon is on its last attempt
114  * to translate the name. First four errors are to failitate return values
115  * from DNS, that are used by mail and others.
116  *
117  * Negative errors terminate the search resolution process, positive errors
118  * are treated as warnings.
119  */
120 
121 #define	ND_TRY_AGAIN	-5	/* Non-Authoritive Host not found, or */
122 				/* SERVERFAIL */
123 #define	ND_NO_RECOVERY	-4	/* Non recoverable errors, FORMERR, REFUSED, */
124 				/* NOTIMP */
125 #define	ND_NO_DATA	-3	/* Valid name, no data record of requested */
126 				/* type */
127 #define	ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */
128 #define	ND_BADARG	-2	/* Bad arguments passed 	*/
129 #define	ND_NOMEM 	-1	/* No virtual memory left	*/
130 #define	ND_OK		0	/* Translation successful	*/
131 #define	ND_NOHOST	1	/* Hostname was not resolvable	*/
132 #define	ND_NOSERV	2	/* Service was unknown		*/
133 #define	ND_NOSYM	3	/* Couldn't resolve symbol	*/
134 #define	ND_OPEN		4	/* File couldn't be opened	*/
135 #define	ND_ACCESS	5	/* File is not accessable	*/
136 #define	ND_UKNWN	6	/* Unknown object to be freed	*/
137 #define	ND_NOCTRL	7	/* Unknown option passed to netdir_options */
138 #define	ND_FAILCTRL	8	/* Option failed in netdir_options */
139 #define	ND_SYSTEM	9	/* Other System error		*/
140 
141 /*
142  * The following netdir_options commands can be given to the fd. These is
143  * a way of providing for any transport specific action which the caller
144  * may want to initiate on his transport. It is up to the trasport provider
145  * to support the netdir_options he wants to support.
146  */
147 
148 #define	ND_SET_BROADCAST	1	/* Do t_optmgmt to support broadcast */
149 #define	ND_SET_RESERVEDPORT	2	/* bind it to reserve address */
150 #define	ND_CHECK_RESERVEDPORT	3	/* check if address is reserved */
151 #define	ND_MERGEADDR		4	/* Merge universal address */
152 
153 /*
154  *	The following special case host names are used to give the underlying
155  *	transport provides a clue as to the intent of the request.
156  */
157 
158 #define	HOST_SELF	"\\1"
159 #define	HOST_ANY	"\\2"
160 #define	HOST_BROADCAST	"\\3"
161 #define	HOST_SELF_BIND	HOST_SELF
162 #define	HOST_SELF_CONNECT	"\\4"
163 
164 #ifdef	__cplusplus
165 }
166 #endif
167 
168 #endif	/* _NETDIR_H */
169