8158 Want named threads API
[unleashed.git] / usr / src / head / netdir.h
blob123aeeea109b2a8d1140aca4552d94cccf0b17db
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright (c) 2016 by Delphix. All rights reserved.
26 /* Copyright (c) 1992 Sun Microsystems, Inc. */
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 * netdir.h
33 * This is the include file that defines various structures and
34 * constants used by the netdir routines.
37 #ifndef _NETDIR_H
38 #define _NETDIR_H
41 * This files uses struct netconfig, and netconfig.h must be included
42 * before this to avoid warnings.
45 #include <netconfig.h>
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
51 struct nd_addrlist {
52 int n_cnt; /* number of netbufs */
53 struct netbuf *n_addrs; /* the netbufs */
56 struct nd_hostservlist {
57 int h_cnt; /* number of nd_hostservs */
58 struct nd_hostserv *h_hostservs; /* the entries */
61 struct nd_hostserv {
62 char *h_host; /* the host name */
63 char *h_serv; /* the service name */
66 struct nd_mergearg {
67 char *s_uaddr; /* servers universal address */
68 char *c_uaddr; /* clients universal address */
69 char *m_uaddr; /* merged universal address */
73 * _nderror is a private variable to the netdir system.
75 #ifdef _REENTRANT
76 extern int *__nderror();
77 #define _nderror (*(__nderror()))
78 #else
79 extern int _nderror;
80 #endif /* _REENTRANT */
83 int netdir_options(struct netconfig *, int option, int fd, char *par);
84 int netdir_getbyname(struct netconfig *, struct nd_hostserv *,
85 struct nd_addrlist **);
86 int netdir_getbyaddr(struct netconfig *, struct nd_hostservlist **,
87 struct netbuf *);
88 int __netdir_getbyaddr_nosrv(struct netconfig *, struct nd_hostservlist **,
89 struct netbuf *);
90 int netdir_mergeaddr(struct netconfig *, char **muaddr, char *uaddr,
91 char *ruaddr);
92 void netdir_free(void *, int);
93 struct netbuf *uaddr2taddr(struct netconfig *, char *);
94 char *taddr2uaddr(struct netconfig *, struct netbuf *);
95 void netdir_perror(char *);
96 char *netdir_sperror();
97 struct nd_addrlist *_netdir_getbyname(struct netconfig *, struct nd_hostserv *);
98 struct nd_hostservlist *_netdir_getbyaddr(struct netconfig *, struct netbuf *);
99 struct netbuf *_uaddr2taddr(struct netconfig *, char *);
100 char *_taddr2uaddr(struct netconfig *, struct netbuf *);
101 char *_netdir_mergeaddr(struct netconfig *, char *uaddr, char *ruaddr);
104 * These are all objects that can be freed by netdir_free
106 #define ND_HOSTSERV 0
107 #define ND_HOSTSERVLIST 1
108 #define ND_ADDR 2
109 #define ND_ADDRLIST 3
112 * These are the various errors that can be encountered while attempting
113 * to translate names to addresses. Note that none of them (except maybe
114 * no memory) are truely fatal unless the ntoa deamon is on its last attempt
115 * to translate the name. First four errors are to failitate return values
116 * from DNS, that are used by mail and others.
118 * Negative errors terminate the search resolution process, positive errors
119 * are treated as warnings.
122 #define ND_TRY_AGAIN -5 /* Non-Authoritive Host not found, or */
123 /* SERVERFAIL */
124 #define ND_NO_RECOVERY -4 /* Non recoverable errors, FORMERR, REFUSED, */
125 /* NOTIMP */
126 #define ND_NO_DATA -3 /* Valid name, no data record of requested */
127 /* type */
128 #define ND_NO_ADDRESS ND_NO_DATA /* no address, look for MX record */
129 #define ND_BADARG -2 /* Bad arguments passed */
130 #define ND_NOMEM -1 /* No virtual memory left */
131 #define ND_OK 0 /* Translation successful */
132 #define ND_NOHOST 1 /* Hostname was not resolvable */
133 #define ND_NOSERV 2 /* Service was unknown */
134 #define ND_NOSYM 3 /* Couldn't resolve symbol */
135 #define ND_OPEN 4 /* File couldn't be opened */
136 #define ND_ACCESS 5 /* File is not accessable */
137 #define ND_UKNWN 6 /* Unknown object to be freed */
138 #define ND_NOCTRL 7 /* Unknown option passed to netdir_options */
139 #define ND_FAILCTRL 8 /* Option failed in netdir_options */
140 #define ND_SYSTEM 9 /* Other System error */
143 * The following netdir_options commands can be given to the fd. These is
144 * a way of providing for any transport specific action which the caller
145 * may want to initiate on its transport. It is up to the trasport provider
146 * to support the netdir_options it wants to support.
149 #define ND_SET_BROADCAST 1 /* Do t_optmgmt to support broadcast */
150 #define ND_SET_RESERVEDPORT 2 /* bind it to reserve address */
151 #define ND_CHECK_RESERVEDPORT 3 /* check if address is reserved */
152 #define ND_MERGEADDR 4 /* Merge universal address */
155 * The following special case host names are used to give the underlying
156 * transport provides a clue as to the intent of the request.
159 #define HOST_SELF "\\1"
160 #define HOST_ANY "\\2"
161 #define HOST_BROADCAST "\\3"
162 #define HOST_SELF_BIND HOST_SELF
163 #define HOST_SELF_CONNECT "\\4"
165 #ifdef __cplusplus
167 #endif
169 #endif /* _NETDIR_H */