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