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.
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.
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.
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.
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.
25 * Sun Microsystems, Inc.
27 * Mountain View, California 94043
30 #include <rpcsvc/yp.h>
31 #include <rpcsvc/ypclnt.h>
34 xdr_ypstat (XDR
*xdrs
, ypstat
*objp
)
36 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
42 xdr_ypxfrstat (XDR
*xdrs
, ypxfrstat
*objp
)
44 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
50 xdr_domainname (XDR
*xdrs
, domainname
*objp
)
52 if (!xdr_string (xdrs
, objp
, ~0))
58 xdr_mapname (XDR
*xdrs
, mapname
*objp
)
60 if (!xdr_string (xdrs
, objp
, ~0))
66 xdr_peername (XDR
*xdrs
, peername
*objp
)
68 if (!xdr_string (xdrs
, objp
, ~0))
74 xdr_keydat (XDR
*xdrs
, keydat
*objp
)
76 if (!xdr_bytes (xdrs
, (char **) &objp
->keydat_val
,
77 (u_int
*) &objp
->keydat_len
, ~0))
83 xdr_valdat (XDR
*xdrs
, valdat
*objp
)
85 if (!xdr_bytes (xdrs
, (char **) &objp
->valdat_val
,
86 (u_int
*) &objp
->valdat_len
, ~0))
92 xdr_ypmap_parms (XDR
*xdrs
, ypmap_parms
*objp
)
94 if (!xdr_domainname (xdrs
, &objp
->domain
))
96 if (!xdr_mapname (xdrs
, &objp
->map
))
98 if (!xdr_u_int (xdrs
, &objp
->ordernum
))
100 if (!xdr_peername (xdrs
, &objp
->peer
))
106 xdr_ypreq_key (XDR
*xdrs
, ypreq_key
*objp
)
108 if (!xdr_domainname (xdrs
, &objp
->domain
))
110 if (!xdr_mapname (xdrs
, &objp
->map
))
112 if (!xdr_keydat (xdrs
, &objp
->key
))
118 xdr_ypreq_nokey (XDR
*xdrs
, ypreq_nokey
*objp
)
120 if (!xdr_domainname (xdrs
, &objp
->domain
))
122 if (!xdr_mapname (xdrs
, &objp
->map
))
128 xdr_ypreq_xfr (XDR
*xdrs
, ypreq_xfr
*objp
)
130 if (!xdr_ypmap_parms (xdrs
, &objp
->map_parms
))
132 if (!xdr_u_int (xdrs
, &objp
->transid
))
134 if (!xdr_u_int (xdrs
, &objp
->prog
))
136 if (!xdr_u_int (xdrs
, &objp
->port
))
142 xdr_ypresp_val (XDR
*xdrs
, ypresp_val
*objp
)
144 if (!xdr_ypstat (xdrs
, &objp
->stat
))
146 if (!xdr_valdat (xdrs
, &objp
->val
))
152 xdr_ypresp_key_val (XDR
*xdrs
, ypresp_key_val
*objp
)
154 if (!xdr_ypstat (xdrs
, &objp
->stat
))
156 if (!xdr_valdat (xdrs
, &objp
->val
))
158 if (!xdr_keydat (xdrs
, &objp
->key
))
164 xdr_ypresp_master (XDR
*xdrs
, ypresp_master
*objp
)
166 if (!xdr_ypstat (xdrs
, &objp
->stat
))
168 if (!xdr_peername (xdrs
, &objp
->peer
))
174 xdr_ypresp_order (XDR
*xdrs
, ypresp_order
*objp
)
176 if (!xdr_ypstat (xdrs
, &objp
->stat
))
178 if (!xdr_u_int (xdrs
, &objp
->ordernum
))
184 xdr_ypresp_all (XDR
*xdrs
, ypresp_all
*objp
)
186 if (!xdr_bool (xdrs
, &objp
->more
))
191 if (!xdr_ypresp_key_val (xdrs
, &objp
->ypresp_all_u
.val
))
203 xdr_ypresp_xfr (XDR
*xdrs
, ypresp_xfr
*objp
)
205 if (!xdr_u_int (xdrs
, &objp
->transid
))
207 if (!xdr_ypxfrstat (xdrs
, &objp
->xfrstat
))
213 xdr_ypmaplist (XDR
*xdrs
, ypmaplist
*objp
)
215 if (!xdr_mapname (xdrs
, &objp
->map
))
217 if (!xdr_pointer (xdrs
, (char **) &objp
->next
, sizeof (ypmaplist
),
218 (xdrproc_t
) xdr_ypmaplist
))
224 xdr_ypresp_maplist (XDR
*xdrs
, ypresp_maplist
*objp
)
226 if (!xdr_ypstat (xdrs
, &objp
->stat
))
228 if (!xdr_pointer (xdrs
, (char **) &objp
->maps
, sizeof (ypmaplist
),
229 (xdrproc_t
) xdr_ypmaplist
))
235 xdr_yppush_status (XDR
*xdrs
, yppush_status
*objp
)
237 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
243 xdr_yppushresp_xfr (XDR
*xdrs
, yppushresp_xfr
*objp
)
245 if (!xdr_u_int (xdrs
, &objp
->transid
))
247 if (!xdr_yppush_status (xdrs
, &objp
->status
))
253 xdr_ypbind_resptype (XDR
*xdrs
, ypbind_resptype
*objp
)
255 if (!xdr_enum (xdrs
, (enum_t
*) objp
))
261 xdr_ypbind_binding (XDR
*xdrs
, ypbind_binding
*objp
)
263 if (!xdr_opaque (xdrs
, objp
->ypbind_binding_addr
, 4))
265 if (!xdr_opaque (xdrs
, objp
->ypbind_binding_port
, 2))
271 xdr_ypbind_resp (XDR
*xdrs
, ypbind_resp
*objp
)
273 if (!xdr_ypbind_resptype (xdrs
, &objp
->ypbind_status
))
275 switch (objp
->ypbind_status
)
277 case YPBIND_FAIL_VAL
:
278 if (!xdr_u_int (xdrs
, &objp
->ypbind_resp_u
.ypbind_error
))
281 case YPBIND_SUCC_VAL
:
282 if (!xdr_ypbind_binding (xdrs
, &objp
->ypbind_resp_u
.ypbind_bindinfo
))
292 xdr_ypbind_setdom (XDR
*xdrs
, ypbind_setdom
*objp
)
294 if (!xdr_domainname (xdrs
, &objp
->ypsetdom_domain
))
296 if (!xdr_ypbind_binding (xdrs
, &objp
->ypsetdom_binding
))
298 if (!xdr_u_int (xdrs
, &objp
->ypsetdom_vers
))
304 xdr_ypall(XDR
*xdrs
, struct ypall_callback
*incallback
)
306 struct ypresp_key_val out
;
307 char key
[YPMAXRECORD
], val
[YPMAXRECORD
];
310 * Set up key/val struct to be used during the transaction.
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
);
321 /* Values pending? */
322 if (!xdr_bool(xdrs
, &more
))
323 return FALSE
; /* can't tell! */
325 return TRUE
; /* no more */
327 /* Transfer key/value pair. */
328 status
= xdr_ypresp_key_val(xdrs
, &out
);
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
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
,