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
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]
24 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
32 * Portions of this source code were derived from Berkeley
33 * under license from the Regents of the University of
37 #pragma ident "%Z%%M% %I% %E% SMI"
44 #include <rpcsvc/yp_prot.h>
45 #include <rpcsvc/ypclnt.h>
46 #include <sys/types.h>
49 static int doorder(char *, char *, struct dom_binding
*, struct timeval
,
54 * This checks parameters, and implements the outer "until binding success"
58 yp_order(char *domain
, char *map
, unsigned long *order
)
63 struct dom_binding
*pdomb
;
65 if ((map
== NULL
) || (domain
== NULL
))
66 return (YPERR_BADARGS
);
68 domlen
= strlen(domain
);
71 if ((domlen
== 0) || (domlen
> YPMAXDOMAIN
) ||
72 (maplen
== 0) || (maplen
> YPMAXMAP
) ||
74 return (YPERR_BADARGS
);
78 if (reason
= __yp_dobind(domain
, &pdomb
))
81 if (pdomb
->dom_binding
->ypbind_hi_vers
>= YPVERS
) {
83 reason
= doorder(domain
, map
, pdomb
, _ypserv_timeout
,
86 __yp_rel_binding(pdomb
);
87 if (reason
== YPERR_RPC
) {
89 (void) sleep(_ypsleeptime
);
94 __yp_rel_binding(pdomb
);
103 * This talks v3 to ypserv
106 doorder(char *domain
, char *map
, struct dom_binding
*pdomb
,
107 struct timeval timeout
, unsigned long *order
)
109 struct ypreq_nokey req
;
110 struct ypresp_order resp
;
111 unsigned int retval
= 0;
115 (void) memset((char *)&resp
, 0, sizeof (struct ypresp_order
));
118 * Do the get_order request. If the rpc call failed, return with
119 * status from this point.
122 if (clnt_call(pdomb
->dom_client
, YPPROC_ORDER
,
123 (xdrproc_t
)xdr_ypreq_nokey
,
124 (char *)&req
, (xdrproc_t
)xdr_ypresp_order
, (char *)&resp
,
125 timeout
) != RPC_SUCCESS
)
128 /* See if the request succeeded */
130 if (resp
.status
!= YP_TRUE
) {
131 retval
= ypprot_err(resp
.status
);
134 *order
= (unsigned long)resp
.ordernum
;
135 CLNT_FREERES(pdomb
->dom_client
,
136 (xdrproc_t
)xdr_ypresp_order
, (char *)&resp
);