]>
Commit | Line | Data |
---|---|---|
6259ec0d UD |
1 | /* |
2 | * Sun RPC is a product of Sun Microsystems, Inc. and is provided for | |
3 | * unrestricted use provided that this legend is included on all tape | |
4 | * media and as a part of the software program in whole or part. Users | |
5 | * may copy or modify Sun RPC without charge, but are not authorized | |
6 | * to license or distribute it to anyone else except as part of a product or | |
7 | * program developed by the user. | |
0c6cee5d | 8 | * |
6259ec0d UD |
9 | * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE |
10 | * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR | |
11 | * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. | |
0c6cee5d | 12 | * |
6259ec0d UD |
13 | * Sun RPC is provided with no support and without any obligation on the |
14 | * part of Sun Microsystems, Inc. to assist in its use, correction, | |
15 | * modification or enhancement. | |
0c6cee5d | 16 | * |
6259ec0d UD |
17 | * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE |
18 | * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC | |
19 | * OR ANY PART THEREOF. | |
0c6cee5d | 20 | * |
6259ec0d UD |
21 | * In no event will Sun Microsystems, Inc. be liable for any lost revenue |
22 | * or profits or other special, indirect and consequential damages, even if | |
23 | * Sun has been advised of the possibility of such damages. | |
0c6cee5d | 24 | * |
6259ec0d UD |
25 | * Sun Microsystems, Inc. |
26 | * 2550 Garcia Avenue | |
27 | * Mountain View, California 94043 | |
28 | */ | |
29 | ||
30 | #include <rpcsvc/yp.h> | |
56ad7b2c | 31 | #include <rpcsvc/ypclnt.h> |
6259ec0d UD |
32 | |
33 | bool_t | |
34 | xdr_ypstat (XDR *xdrs, ypstat *objp) | |
35 | { | |
0c6cee5d UD |
36 | if (!xdr_enum (xdrs, (enum_t *) objp)) |
37 | return FALSE; | |
38 | return TRUE; | |
6259ec0d UD |
39 | } |
40 | ||
41 | bool_t | |
0c6cee5d | 42 | xdr_ypxfrstat (XDR *xdrs, ypxfrstat *objp) |
6259ec0d | 43 | { |
0c6cee5d UD |
44 | if (!xdr_enum (xdrs, (enum_t *) objp)) |
45 | return FALSE; | |
46 | return TRUE; | |
6259ec0d UD |
47 | } |
48 | ||
49 | bool_t | |
0c6cee5d | 50 | xdr_domainname (XDR *xdrs, domainname *objp) |
6259ec0d | 51 | { |
0c6cee5d UD |
52 | if (!xdr_string (xdrs, objp, ~0)) |
53 | return FALSE; | |
54 | return TRUE; | |
6259ec0d UD |
55 | } |
56 | ||
57 | bool_t | |
0c6cee5d | 58 | xdr_mapname (XDR *xdrs, mapname *objp) |
6259ec0d | 59 | { |
0c6cee5d UD |
60 | if (!xdr_string (xdrs, objp, ~0)) |
61 | return FALSE; | |
62 | return TRUE; | |
6259ec0d UD |
63 | } |
64 | ||
65 | bool_t | |
0c6cee5d | 66 | xdr_peername (XDR *xdrs, peername *objp) |
6259ec0d | 67 | { |
0c6cee5d UD |
68 | if (!xdr_string (xdrs, objp, ~0)) |
69 | return FALSE; | |
70 | return TRUE; | |
6259ec0d UD |
71 | } |
72 | ||
73 | bool_t | |
0c6cee5d | 74 | xdr_keydat (XDR *xdrs, keydat *objp) |
6259ec0d | 75 | { |
0c6cee5d UD |
76 | if (!xdr_bytes (xdrs, (char **) &objp->keydat_val, |
77 | (u_int *) &objp->keydat_len, ~0)) | |
78 | return FALSE; | |
79 | return TRUE; | |
6259ec0d UD |
80 | } |
81 | ||
82 | bool_t | |
0c6cee5d | 83 | xdr_valdat (XDR *xdrs, valdat *objp) |
6259ec0d | 84 | { |
0c6cee5d UD |
85 | if (!xdr_bytes (xdrs, (char **) &objp->valdat_val, |
86 | (u_int *) &objp->valdat_len, ~0)) | |
87 | return FALSE; | |
88 | return TRUE; | |
6259ec0d UD |
89 | } |
90 | ||
91 | bool_t | |
0c6cee5d | 92 | xdr_ypmap_parms (XDR *xdrs, ypmap_parms *objp) |
6259ec0d | 93 | { |
0c6cee5d UD |
94 | if (!xdr_domainname (xdrs, &objp->domain)) |
95 | return FALSE; | |
96 | if (!xdr_mapname (xdrs, &objp->map)) | |
97 | return FALSE; | |
98 | if (!xdr_u_int (xdrs, &objp->ordernum)) | |
99 | return FALSE; | |
100 | if (!xdr_peername (xdrs, &objp->peer)) | |
101 | return FALSE; | |
102 | return TRUE; | |
6259ec0d UD |
103 | } |
104 | ||
105 | bool_t | |
0c6cee5d | 106 | xdr_ypreq_key (XDR *xdrs, ypreq_key *objp) |
6259ec0d | 107 | { |
0c6cee5d UD |
108 | if (!xdr_domainname (xdrs, &objp->domain)) |
109 | return FALSE; | |
110 | if (!xdr_mapname (xdrs, &objp->map)) | |
111 | return FALSE; | |
112 | if (!xdr_keydat (xdrs, &objp->key)) | |
113 | return FALSE; | |
114 | return TRUE; | |
6259ec0d UD |
115 | } |
116 | ||
117 | bool_t | |
0c6cee5d | 118 | xdr_ypreq_nokey (XDR *xdrs, ypreq_nokey *objp) |
6259ec0d | 119 | { |
0c6cee5d UD |
120 | if (!xdr_domainname (xdrs, &objp->domain)) |
121 | return FALSE; | |
122 | if (!xdr_mapname (xdrs, &objp->map)) | |
123 | return FALSE; | |
124 | return TRUE; | |
6259ec0d UD |
125 | } |
126 | ||
127 | bool_t | |
0c6cee5d | 128 | xdr_ypreq_xfr (XDR *xdrs, ypreq_xfr *objp) |
6259ec0d | 129 | { |
0c6cee5d UD |
130 | if (!xdr_ypmap_parms (xdrs, &objp->map_parms)) |
131 | return FALSE; | |
132 | if (!xdr_u_int (xdrs, &objp->transid)) | |
133 | return FALSE; | |
134 | if (!xdr_u_int (xdrs, &objp->prog)) | |
135 | return FALSE; | |
136 | if (!xdr_u_int (xdrs, &objp->port)) | |
137 | return FALSE; | |
138 | return TRUE; | |
6259ec0d UD |
139 | } |
140 | ||
141 | bool_t | |
0c6cee5d | 142 | xdr_ypresp_val (XDR *xdrs, ypresp_val *objp) |
6259ec0d | 143 | { |
0c6cee5d UD |
144 | if (!xdr_ypstat (xdrs, &objp->stat)) |
145 | return FALSE; | |
146 | if (!xdr_valdat (xdrs, &objp->val)) | |
147 | return FALSE; | |
148 | return TRUE; | |
6259ec0d UD |
149 | } |
150 | ||
151 | bool_t | |
0c6cee5d | 152 | xdr_ypresp_key_val (XDR *xdrs, ypresp_key_val *objp) |
6259ec0d | 153 | { |
0c6cee5d UD |
154 | if (!xdr_ypstat (xdrs, &objp->stat)) |
155 | return FALSE; | |
156 | if (!xdr_valdat (xdrs, &objp->val)) | |
157 | return FALSE; | |
158 | if (!xdr_keydat (xdrs, &objp->key)) | |
159 | return FALSE; | |
160 | return TRUE; | |
6259ec0d UD |
161 | } |
162 | ||
163 | bool_t | |
0c6cee5d | 164 | xdr_ypresp_master (XDR *xdrs, ypresp_master *objp) |
6259ec0d | 165 | { |
0c6cee5d UD |
166 | if (!xdr_ypstat (xdrs, &objp->stat)) |
167 | return FALSE; | |
168 | if (!xdr_peername (xdrs, &objp->peer)) | |
169 | return FALSE; | |
170 | return TRUE; | |
6259ec0d UD |
171 | } |
172 | ||
173 | bool_t | |
0c6cee5d | 174 | xdr_ypresp_order (XDR *xdrs, ypresp_order *objp) |
6259ec0d | 175 | { |
0c6cee5d UD |
176 | if (!xdr_ypstat (xdrs, &objp->stat)) |
177 | return FALSE; | |
178 | if (!xdr_u_int (xdrs, &objp->ordernum)) | |
179 | return FALSE; | |
180 | return TRUE; | |
6259ec0d UD |
181 | } |
182 | ||
183 | bool_t | |
0c6cee5d | 184 | xdr_ypresp_all (XDR *xdrs, ypresp_all *objp) |
6259ec0d | 185 | { |
0c6cee5d UD |
186 | if (!xdr_bool (xdrs, &objp->more)) |
187 | return FALSE; | |
188 | switch (objp->more) | |
189 | { | |
190 | case TRUE: | |
191 | if (!xdr_ypresp_key_val (xdrs, &objp->ypresp_all_u.val)) | |
192 | return FALSE; | |
193 | break; | |
194 | case FALSE: | |
195 | break; | |
196 | default: | |
197 | return FALSE; | |
6259ec0d | 198 | } |
0c6cee5d | 199 | return TRUE; |
6259ec0d UD |
200 | } |
201 | ||
202 | bool_t | |
0c6cee5d | 203 | xdr_ypresp_xfr (XDR *xdrs, ypresp_xfr *objp) |
6259ec0d | 204 | { |
0c6cee5d UD |
205 | if (!xdr_u_int (xdrs, &objp->transid)) |
206 | return FALSE; | |
207 | if (!xdr_ypxfrstat (xdrs, &objp->xfrstat)) | |
208 | return FALSE; | |
209 | return TRUE; | |
6259ec0d UD |
210 | } |
211 | ||
212 | bool_t | |
0c6cee5d | 213 | xdr_ypmaplist (XDR *xdrs, ypmaplist *objp) |
6259ec0d | 214 | { |
0c6cee5d UD |
215 | if (!xdr_mapname (xdrs, &objp->map)) |
216 | return FALSE; | |
217 | if (!xdr_pointer (xdrs, (char **) &objp->next, sizeof (ypmaplist), | |
218 | (xdrproc_t) xdr_ypmaplist)) | |
219 | return FALSE; | |
220 | return TRUE; | |
6259ec0d UD |
221 | } |
222 | ||
223 | bool_t | |
0c6cee5d | 224 | xdr_ypresp_maplist (XDR *xdrs, ypresp_maplist *objp) |
6259ec0d | 225 | { |
0c6cee5d UD |
226 | if (!xdr_ypstat (xdrs, &objp->stat)) |
227 | return FALSE; | |
228 | if (!xdr_pointer (xdrs, (char **) &objp->maps, sizeof (ypmaplist), | |
229 | (xdrproc_t) xdr_ypmaplist)) | |
230 | return FALSE; | |
231 | return TRUE; | |
6259ec0d UD |
232 | } |
233 | ||
234 | bool_t | |
0c6cee5d | 235 | xdr_yppush_status (XDR *xdrs, yppush_status *objp) |
6259ec0d | 236 | { |
0c6cee5d UD |
237 | if (!xdr_enum (xdrs, (enum_t *) objp)) |
238 | return FALSE; | |
239 | return TRUE; | |
6259ec0d UD |
240 | } |
241 | ||
242 | bool_t | |
0c6cee5d | 243 | xdr_yppushresp_xfr (XDR *xdrs, yppushresp_xfr *objp) |
6259ec0d | 244 | { |
0c6cee5d UD |
245 | if (!xdr_u_int (xdrs, &objp->transid)) |
246 | return FALSE; | |
247 | if (!xdr_yppush_status (xdrs, &objp->status)) | |
248 | return FALSE; | |
249 | return TRUE; | |
6259ec0d UD |
250 | } |
251 | ||
252 | bool_t | |
0c6cee5d | 253 | xdr_ypbind_resptype (XDR *xdrs, ypbind_resptype *objp) |
6259ec0d | 254 | { |
0c6cee5d UD |
255 | if (!xdr_enum (xdrs, (enum_t *) objp)) |
256 | return FALSE; | |
257 | return TRUE; | |
6259ec0d UD |
258 | } |
259 | ||
260 | bool_t | |
0c6cee5d | 261 | xdr_ypbind_binding (XDR *xdrs, ypbind_binding *objp) |
6259ec0d | 262 | { |
0c6cee5d UD |
263 | if (!xdr_opaque (xdrs, objp->ypbind_binding_addr, 4)) |
264 | return FALSE; | |
265 | if (!xdr_opaque (xdrs, objp->ypbind_binding_port, 2)) | |
266 | return FALSE; | |
267 | return TRUE; | |
6259ec0d UD |
268 | } |
269 | ||
270 | bool_t | |
0c6cee5d | 271 | xdr_ypbind_resp (XDR *xdrs, ypbind_resp *objp) |
6259ec0d | 272 | { |
0c6cee5d UD |
273 | if (!xdr_ypbind_resptype (xdrs, &objp->ypbind_status)) |
274 | return FALSE; | |
275 | switch (objp->ypbind_status) | |
276 | { | |
277 | case YPBIND_FAIL_VAL: | |
278 | if (!xdr_u_int (xdrs, &objp->ypbind_resp_u.ypbind_error)) | |
279 | return FALSE; | |
280 | break; | |
281 | case YPBIND_SUCC_VAL: | |
282 | if (!xdr_ypbind_binding (xdrs, &objp->ypbind_resp_u.ypbind_bindinfo)) | |
283 | return FALSE; | |
284 | break; | |
285 | default: | |
286 | return FALSE; | |
6259ec0d | 287 | } |
0c6cee5d | 288 | return TRUE; |
6259ec0d UD |
289 | } |
290 | ||
291 | bool_t | |
0c6cee5d | 292 | xdr_ypbind_setdom (XDR *xdrs, ypbind_setdom *objp) |
6259ec0d | 293 | { |
0c6cee5d UD |
294 | if (!xdr_domainname (xdrs, &objp->ypsetdom_domain)) |
295 | return FALSE; | |
296 | if (!xdr_ypbind_binding (xdrs, &objp->ypsetdom_binding)) | |
297 | return FALSE; | |
298 | if (!xdr_u_int (xdrs, &objp->ypsetdom_vers)) | |
299 | return FALSE; | |
300 | return TRUE; | |
6259ec0d | 301 | } |
56ad7b2c UD |
302 | |
303 | bool_t | |
304 | xdr_ypall(XDR *xdrs, struct ypall_callback *incallback) | |
305 | { | |
306 | struct ypresp_key_val out; | |
307 | char key[YPMAXRECORD], val[YPMAXRECORD]; | |
308 | ||
309 | /* | |
310 | * Set up key/val struct to be used during the transaction. | |
311 | */ | |
312 | memset(&out, 0, sizeof out); | |
313 | out.key.keydat_val = key; | |
314 | out.key.keydat_len = sizeof(key); | |
315 | out.val.valdat_val = val; | |
316 | out.val.valdat_len = sizeof(val); | |
317 | ||
318 | for (;;) { | |
319 | bool_t more, status; | |
320 | ||
321 | /* Values pending? */ | |
322 | if (!xdr_bool(xdrs, &more)) | |
323 | return FALSE; /* can't tell! */ | |
324 | if (!more) | |
325 | return TRUE; /* no more */ | |
326 | ||
327 | /* Transfer key/value pair. */ | |
328 | status = xdr_ypresp_key_val(xdrs, &out); | |
329 | ||
330 | /* | |
331 | * If we succeeded, call the callback function. | |
332 | * The callback will return TRUE when it wants | |
333 | * no more values. If we fail, indicate the | |
334 | * error. | |
335 | */ | |
336 | if (status) { | |
337 | if ((*incallback->foreach)(out.stat, | |
338 | (char *)out.key.keydat_val, out.key.keydat_len, | |
339 | (char *)out.val.valdat_val, out.val.valdat_len, | |
340 | incallback->data)) | |
341 | return TRUE; | |
342 | } else | |
343 | return FALSE; | |
344 | } | |
345 | } |