root / lab4 / .minix-src / include / rpcsvc / yp_prot.h @ 13
History | View | Annotate | Download (11 KB)
1 |
/* $NetBSD: yp_prot.h,v 1.18 2013/01/23 17:27:35 mbalmer Exp $ */
|
---|---|
2 |
|
3 |
/*
|
4 |
* Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca>
|
5 |
* All rights reserved.
|
6 |
*
|
7 |
* Redistribution and use in source and binary forms, with or without
|
8 |
* modification, are permitted provided that the following conditions
|
9 |
* are met:
|
10 |
* 1. Redistributions of source code must retain the above copyright
|
11 |
* notice, this list of conditions and the following disclaimer.
|
12 |
* 2. Redistributions in binary form must reproduce the above copyright
|
13 |
* notice, this list of conditions and the following disclaimer in the
|
14 |
* documentation and/or other materials provided with the distribution.
|
15 |
*
|
16 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
17 |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
19 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
20 |
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
21 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
22 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
23 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
24 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
25 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
26 |
* SUCH DAMAGE.
|
27 |
*/
|
28 |
|
29 |
#ifndef _RPCSVC_YP_PROT_H_
|
30 |
#define _RPCSVC_YP_PROT_H_
|
31 |
|
32 |
/*
|
33 |
* YPSERV PROTOCOL:
|
34 |
*
|
35 |
* ypserv supports the following procedures:
|
36 |
*
|
37 |
* YPPROC_NULL takes (void), returns (void).
|
38 |
* called to check if server is alive.
|
39 |
* YPPROC_DOMAIN takes (char *), returns (bool_t).
|
40 |
* true if ypserv serves the named domain.
|
41 |
* YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t).
|
42 |
* true if ypserv serves the named domain.
|
43 |
* used for broadcasts, does not ack if ypserv
|
44 |
* doesn't handle named domain.
|
45 |
* YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val)
|
46 |
* does a lookup.
|
47 |
* YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val).
|
48 |
* gets the first key/datum from the map.
|
49 |
* YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val).
|
50 |
* gets the next key/datum from the map.
|
51 |
* YPPROC_XFR takes (struct ypreq_xfr), returns (void).
|
52 |
* tells ypserv to check if there is a new version of
|
53 |
* the map.
|
54 |
* YPPROC_CLEAR takes (void), returns (void).
|
55 |
* tells ypserv to flush its file cache, so that
|
56 |
* newly transferred files will get read.
|
57 |
* YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and
|
58 |
* struct ypresp_key_val).
|
59 |
* returns an array of data, with the bool_t being
|
60 |
* false on the last datum. read the source, it's
|
61 |
* convoluted.
|
62 |
* YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master).
|
63 |
* YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order).
|
64 |
* YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *).
|
65 |
*/
|
66 |
|
67 |
/* Program and version symbols, magic numbers */
|
68 |
#define YPPROG ((unsigned long)100004) |
69 |
#define YPVERS ((unsigned long)2) |
70 |
#define YPVERS_ORIG ((unsigned long)1) |
71 |
|
72 |
#define YPMAXRECORD 1024 |
73 |
#define YPMAXDOMAIN 64 |
74 |
#define YPMAXMAP 64 |
75 |
#define YPMAXPEER 256 |
76 |
|
77 |
/*
|
78 |
* I don't know if anything of sun's depends on this, or if they
|
79 |
* simply defined it so that their own code wouldn't try to send
|
80 |
* packets over the ethernet MTU. This YP code doesn't use it.
|
81 |
*/
|
82 |
#define YPMSGSZ 1600 |
83 |
|
84 |
#ifndef DATUM
|
85 |
typedef struct { |
86 |
const char *dptr; |
87 |
int dsize;
|
88 |
} datum; |
89 |
#define DATUM
|
90 |
#endif
|
91 |
|
92 |
struct ypmap_parms {
|
93 |
const char *domain; |
94 |
const char *map; |
95 |
unsigned int ordernum; |
96 |
char *owner;
|
97 |
}; |
98 |
|
99 |
struct ypreq_key {
|
100 |
const char *domain; |
101 |
const char *map; |
102 |
datum keydat; |
103 |
}; |
104 |
|
105 |
struct ypreq_nokey {
|
106 |
const char *domain; |
107 |
const char *map; |
108 |
}; |
109 |
|
110 |
struct ypreq_xfr {
|
111 |
struct ypmap_parms map_parms;
|
112 |
unsigned int transid; |
113 |
unsigned int proto; |
114 |
unsigned int port; |
115 |
}; |
116 |
#define ypxfr_domain map_parms.domain
|
117 |
#define ypxfr_map map_parms.map
|
118 |
#define ypxfr_ordernum map_parms.ordernum
|
119 |
#define ypxfr_owner map_parms.owner
|
120 |
|
121 |
struct ypresp_val {
|
122 |
unsigned int status; |
123 |
datum valdat; |
124 |
}; |
125 |
|
126 |
struct ypresp_key_val {
|
127 |
unsigned int status; |
128 |
datum keydat; |
129 |
datum valdat; |
130 |
}; |
131 |
|
132 |
struct ypresp_master {
|
133 |
unsigned int status; |
134 |
char *master;
|
135 |
}; |
136 |
|
137 |
struct ypresp_order {
|
138 |
unsigned int status; |
139 |
unsigned int ordernum; |
140 |
}; |
141 |
|
142 |
struct ypmaplist {
|
143 |
char ypml_name[YPMAXMAP + 1]; |
144 |
struct ypmaplist *ypml_next;
|
145 |
}; |
146 |
|
147 |
struct ypresp_maplist {
|
148 |
unsigned int status; |
149 |
struct ypmaplist *list;
|
150 |
}; |
151 |
|
152 |
/* ypserv procedure numbers */
|
153 |
#define YPPROC_NULL ((unsigned long)0) |
154 |
#define YPPROC_DOMAIN ((unsigned long)1) |
155 |
#define YPPROC_DOMAIN_NONACK ((unsigned long)2) |
156 |
#define YPPROC_MATCH ((unsigned long)3) |
157 |
#define YPPROC_FIRST ((unsigned long)4) |
158 |
#define YPPROC_NEXT ((unsigned long)5) |
159 |
#define YPPROC_XFR ((unsigned long)6) |
160 |
#define YPPROC_CLEAR ((unsigned long)7) |
161 |
#define YPPROC_ALL ((unsigned long)8) |
162 |
#define YPPROC_MASTER ((unsigned long)9) |
163 |
#define YPPROC_ORDER ((unsigned long)10) |
164 |
#define YPPROC_MAPLIST ((unsigned long)11) |
165 |
|
166 |
/* ypserv procedure return status values */
|
167 |
#define YP_TRUE ((unsigned int)1) /* general purpose success code */ |
168 |
#define YP_NOMORE ((unsigned int)2) /* no more entries in map */ |
169 |
#define YP_FALSE ((unsigned int)0) /* general purpose failure code */ |
170 |
#define YP_NOMAP ((unsigned int)-1) /* no such map in domain */ |
171 |
#define YP_NODOM ((unsigned int)-2) /* domain not supported */ |
172 |
#define YP_NOKEY ((unsigned int)-3) /* no such key in map */ |
173 |
#define YP_BADOP ((unsigned int)-4) /* invalid operation */ |
174 |
#define YP_BADDB ((unsigned int)-5) /* server data base is bad */ |
175 |
#define YP_YPERR ((unsigned int)-6) /* YP server error */ |
176 |
#define YP_BADARGS ((unsigned int)-7) /* request arguments bad */ |
177 |
#define YP_VERS ((unsigned int)-8) /* YP server version mismatch */ |
178 |
|
179 |
/*
|
180 |
* Sun's header file says:
|
181 |
* "Domain binding data structure, used by ypclnt package and ypserv modules.
|
182 |
* Users of the ypclnt package (or of this protocol) don't HAVE to know about
|
183 |
* it, but it must be available to users because _yp_dobind is a public
|
184 |
* interface."
|
185 |
*
|
186 |
* This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
|
187 |
* a public interface, and I don't know any reason anyone would want to call
|
188 |
* it. But, just in case anyone does actually expect it to be available..
|
189 |
* we provide this.. exactly as Sun wants it.
|
190 |
*/
|
191 |
struct dom_binding {
|
192 |
struct dom_binding *dom_pnext;
|
193 |
char dom_domain[YPMAXDOMAIN + 1]; |
194 |
struct sockaddr_in dom_server_addr;
|
195 |
u_short dom_server_port; |
196 |
int dom_socket;
|
197 |
CLIENT *dom_client; |
198 |
u_short dom_local_port; |
199 |
long dom_vers;
|
200 |
}; |
201 |
|
202 |
/*
|
203 |
* YPBIND PROTOCOL:
|
204 |
*
|
205 |
* ypbind supports the following procedures:
|
206 |
*
|
207 |
* YPBINDPROC_NULL takes (void), returns (void).
|
208 |
* to check if ypbind is running.
|
209 |
* YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp).
|
210 |
* requests that ypbind start to serve the
|
211 |
* named domain (if it doesn't already)
|
212 |
* YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void).
|
213 |
* used by ypset.
|
214 |
*/
|
215 |
|
216 |
#define YPBINDPROG ((unsigned long)100007) |
217 |
#define YPBINDVERS ((unsigned long)2) |
218 |
#define YPBINDVERS_ORIG ((unsigned long)1) |
219 |
|
220 |
/* ypbind procedure numbers */
|
221 |
#define YPBINDPROC_NULL ((unsigned long)0) |
222 |
#define YPBINDPROC_DOMAIN ((unsigned long)1) |
223 |
#define YPBINDPROC_SETDOM ((unsigned long)2) |
224 |
|
225 |
/* error code in ypbind_resp.ypbind_status */
|
226 |
enum ypbind_resptype {
|
227 |
YPBIND_SUCC_VAL = 1,
|
228 |
YPBIND_FAIL_VAL = 2
|
229 |
}; |
230 |
|
231 |
/* network order, of course */
|
232 |
struct ypbind_binding {
|
233 |
struct in_addr ypbind_binding_addr;
|
234 |
uint16_t ypbind_binding_port; |
235 |
}; |
236 |
|
237 |
struct ypbind_resp {
|
238 |
enum ypbind_resptype ypbind_status;
|
239 |
union {
|
240 |
unsigned int ypbind_error; |
241 |
struct ypbind_binding ypbind_bindinfo;
|
242 |
} ypbind_respbody; |
243 |
}; |
244 |
|
245 |
/* error code in ypbind_resp.ypbind_respbody.ypbind_error */
|
246 |
#define YPBIND_ERR_ERR 1 /* internal error */ |
247 |
#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ |
248 |
#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ |
249 |
|
250 |
/*
|
251 |
* Request data structure for ypbind "Set domain" procedure.
|
252 |
*/
|
253 |
struct ypbind_setdom {
|
254 |
char ypsetdom_domain[YPMAXDOMAIN + 1]; |
255 |
struct ypbind_binding ypsetdom_binding;
|
256 |
unsigned int ypsetdom_vers; |
257 |
}; |
258 |
#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
|
259 |
#define ypsetdom_port ypsetdom_binding.ypbind_binding_port
|
260 |
|
261 |
/*
|
262 |
* YPPUSH PROTOCOL:
|
263 |
*
|
264 |
* Sun says:
|
265 |
* "Protocol between clients (ypxfr, only) and yppush
|
266 |
* yppush speaks a protocol in the transient range, which
|
267 |
* is supplied to ypxfr as a command-line parameter when it
|
268 |
* is activated by ypserv."
|
269 |
*
|
270 |
* This protocol is not implimented, naturally, because this YP
|
271 |
* implimentation only does the client side.
|
272 |
*/
|
273 |
#define YPPUSHVERS ((unsigned long)1) |
274 |
#define YPPUSHVERS_ORIG ((unsigned long)1) |
275 |
|
276 |
/* yppush procedure numbers */
|
277 |
#define YPPUSHPROC_NULL ((unsigned long)0) |
278 |
#define YPPUSHPROC_XFRRESP ((unsigned long)1) |
279 |
|
280 |
struct yppushresp_xfr {
|
281 |
unsigned int transid; |
282 |
unsigned int status; |
283 |
}; |
284 |
|
285 |
/* yppush status value in yppushresp_xfr.status */
|
286 |
#define YPPUSH_SUCC ((unsigned int)1) /* Success */ |
287 |
#define YPPUSH_AGE ((unsigned int)2) /* Master's version not newer */ |
288 |
#define YPPUSH_NOMAP ((unsigned int)-1) /* Can't find server for map */ |
289 |
#define YPPUSH_NODOM ((unsigned int)-2) /* Domain not supported */ |
290 |
#define YPPUSH_RSRC ((unsigned int)-3) /* Local resource alloc failure */ |
291 |
#define YPPUSH_RPC ((unsigned int)-4) /* RPC failure talking to server */ |
292 |
#define YPPUSH_MADDR ((unsigned int)-5) /* Can't get master address */ |
293 |
#define YPPUSH_YPERR ((unsigned int)-6) /* YP server/map db error */ |
294 |
#define YPPUSH_BADARGS ((unsigned int)-7) /* Request arguments bad */ |
295 |
#define YPPUSH_DBM ((unsigned int)-8) /* Local dbm operation failed */ |
296 |
#define YPPUSH_FILE ((unsigned int)-9) /* Local file I/O operation failed */ |
297 |
#define YPPUSH_SKEW ((unsigned int)-10) /* Map version skew during transfer */ |
298 |
#define YPPUSH_CLEAR ((unsigned int)-11) /* Can't send "Clear" req to local ypserv */ |
299 |
#define YPPUSH_FORCE ((unsigned int)-12) /* No local order number in map - use -f */ |
300 |
#define YPPUSH_XFRERR ((unsigned int)-13) /* ypxfr error */ |
301 |
#define YPPUSH_REFUSED ((unsigned int)-14) /* Transfer request refused by ypserv */ |
302 |
|
303 |
struct ypall_callback;
|
304 |
|
305 |
__BEGIN_DECLS |
306 |
bool_t xdr_domainname(XDR *, char *); /* obsolete */ |
307 |
bool_t xdr_peername(XDR *, char *); /* obsolete */ |
308 |
bool_t xdr_mapname(XDR *, char *); /* obsolete */ |
309 |
bool_t xdr_datum(XDR *, datum *); |
310 |
bool_t xdr_ypdomain_wrap_string(XDR *, char **);
|
311 |
bool_t xdr_ypmap_wrap_string(XDR *, char **);
|
312 |
bool_t xdr_ypreq_key(XDR *, struct ypreq_key *);
|
313 |
bool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
|
314 |
bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *);
|
315 |
bool_t xdr_ypresp_val(XDR *, struct ypresp_val *);
|
316 |
bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
|
317 |
bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *);
|
318 |
bool_t xdr_ypowner_wrap_string(XDR *, char **);
|
319 |
bool_t xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *);
|
320 |
bool_t xdr_ypresp_order(XDR *, struct ypresp_order *);
|
321 |
bool_t xdr_ypresp_master(XDR *, struct ypresp_master *);
|
322 |
bool_t xdr_ypall(XDR *, struct ypall_callback *);
|
323 |
bool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *);
|
324 |
bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *);
|
325 |
bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *);
|
326 |
bool_t xdr_ypmaplist(XDR *, struct ypmaplist *);
|
327 |
bool_t xdr_yp_inaddr(XDR *, struct in_addr *);
|
328 |
__END_DECLS |
329 |
|
330 |
#endif /* _RPCSVC_YP_PROT_H_ */ |