xref: /illumos-gate/usr/src/cmd/ypcmd/yp_b.h (revision 7c478bd9)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate /*
31*7c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
32*7c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
33*7c478bd9Sstevel@tonic-gate  */
34*7c478bd9Sstevel@tonic-gate 
35*7c478bd9Sstevel@tonic-gate #ident	"%Z%%M%	%I%	%E% SMI"
36*7c478bd9Sstevel@tonic-gate 
37*7c478bd9Sstevel@tonic-gate #include <rpc/types.h>
38*7c478bd9Sstevel@tonic-gate #include "netconfig.h"
39*7c478bd9Sstevel@tonic-gate #include <stdio.h>
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate extern bool_t xdr_netconfig();
42*7c478bd9Sstevel@tonic-gate 
43*7c478bd9Sstevel@tonic-gate #define BINDING "/var/yp/binding"
44*7c478bd9Sstevel@tonic-gate 
45*7c478bd9Sstevel@tonic-gate #define YPSETNONE 0
46*7c478bd9Sstevel@tonic-gate #define	YPSETLOCAL 3
47*7c478bd9Sstevel@tonic-gate #define YPSETALL 5
48*7c478bd9Sstevel@tonic-gate 
49*7c478bd9Sstevel@tonic-gate /*
50*7c478bd9Sstevel@tonic-gate  * This structure is used only in the ypxfr protocol and has
51*7c478bd9Sstevel@tonic-gate  * nothing to do with ypbind.
52*7c478bd9Sstevel@tonic-gate  */
53*7c478bd9Sstevel@tonic-gate 
54*7c478bd9Sstevel@tonic-gate struct dom_binding {
55*7c478bd9Sstevel@tonic-gate 	struct dom_binding *dom_pnext;
56*7c478bd9Sstevel@tonic-gate 	char *dom_domain;
57*7c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
58*7c478bd9Sstevel@tonic-gate 	CLIENT *dom_client;
59*7c478bd9Sstevel@tonic-gate };
60*7c478bd9Sstevel@tonic-gate 
61*7c478bd9Sstevel@tonic-gate /* Following structure is used only by ypbind */
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate struct domain {
64*7c478bd9Sstevel@tonic-gate 	struct domain *dom_pnext;
65*7c478bd9Sstevel@tonic-gate 	char	*dom_name;
66*7c478bd9Sstevel@tonic-gate 	bool_t dom_boundp;
67*7c478bd9Sstevel@tonic-gate 	unsigned short dom_vers;	/* only YPVERS */
68*7c478bd9Sstevel@tonic-gate 	unsigned long	dom_error;
69*7c478bd9Sstevel@tonic-gate 	CLIENT * ping_clnt;
70*7c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
71*7c478bd9Sstevel@tonic-gate 	int	dom_report_success;	/* Controls msg to /dev/console*/
72*7c478bd9Sstevel@tonic-gate 	int	dom_broadcaster_pid;
73*7c478bd9Sstevel@tonic-gate 	int	bindfile;		/* File with binding info in it */
74*7c478bd9Sstevel@tonic-gate 	int 	broadcaster_fd;
75*7c478bd9Sstevel@tonic-gate 	FILE    *broadcaster_pipe;	/* to get answer from locater */
76*7c478bd9Sstevel@tonic-gate 	XDR	broadcaster_xdr;	/* xdr for pipe */
77*7c478bd9Sstevel@tonic-gate 	struct timeval lastping;	/* info to avoid a ping storm */
78*7c478bd9Sstevel@tonic-gate 	FILE	*cache_fp;		/* file pointer opened on cache_file */
79*7c478bd9Sstevel@tonic-gate 	char	*cache_file;		/* cached version of server info */
80*7c478bd9Sstevel@tonic-gate };
81*7c478bd9Sstevel@tonic-gate 
82*7c478bd9Sstevel@tonic-gate enum ypbind_resptype {
83*7c478bd9Sstevel@tonic-gate 	YPBIND_SUCC_VAL = 1,
84*7c478bd9Sstevel@tonic-gate 	YPBIND_FAIL_VAL = 2
85*7c478bd9Sstevel@tonic-gate };
86*7c478bd9Sstevel@tonic-gate typedef enum ypbind_resptype ypbind_resptype;
87*7c478bd9Sstevel@tonic-gate bool_t xdr_ypbind_resptype();
88*7c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_ERR 1		/* Internal error */
89*7c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
90*7c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_RESC 3		/* System resource allocation failure */
91*7c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NODOMAIN 4		/* Domain doesn't exist */
92*7c478bd9Sstevel@tonic-gate 
93*7c478bd9Sstevel@tonic-gate /* Following struct is used only by ypwhich and yppoll */
94*7c478bd9Sstevel@tonic-gate 
95*7c478bd9Sstevel@tonic-gate struct ypbind_domain {
96*7c478bd9Sstevel@tonic-gate 	char *ypbind_domainname;
97*7c478bd9Sstevel@tonic-gate 	long ypbind_vers;
98*7c478bd9Sstevel@tonic-gate };
99*7c478bd9Sstevel@tonic-gate typedef struct ypbind_domain ypbind_domain;
100*7c478bd9Sstevel@tonic-gate bool_t xdr_ypbind_domain();
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate /*
103*7c478bd9Sstevel@tonic-gate  * This structure is used to store information about the server
104*7c478bd9Sstevel@tonic-gate  * Returned by ypbind to the libnsl/yp clients to contact ypserv.
105*7c478bd9Sstevel@tonic-gate  * Also used by ypxfr.
106*7c478bd9Sstevel@tonic-gate  */
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate struct ypbind_binding {
109*7c478bd9Sstevel@tonic-gate 	struct netconfig *ypbind_nconf;
110*7c478bd9Sstevel@tonic-gate 	struct netbuf *ypbind_svcaddr;
111*7c478bd9Sstevel@tonic-gate 	char *ypbind_servername;
112*7c478bd9Sstevel@tonic-gate 	long ypbind_hi_vers;
113*7c478bd9Sstevel@tonic-gate 	long ypbind_lo_vers;
114*7c478bd9Sstevel@tonic-gate };
115*7c478bd9Sstevel@tonic-gate typedef struct ypbind_binding ypbind_binding;
116*7c478bd9Sstevel@tonic-gate bool_t xdr_ypbind_binding();
117*7c478bd9Sstevel@tonic-gate 
118*7c478bd9Sstevel@tonic-gate struct ypbind_resp {
119*7c478bd9Sstevel@tonic-gate 	ypbind_resptype ypbind_status;
120*7c478bd9Sstevel@tonic-gate 	union {
121*7c478bd9Sstevel@tonic-gate 		u_long ypbind_error;
122*7c478bd9Sstevel@tonic-gate 		struct ypbind_binding *ypbind_bindinfo;
123*7c478bd9Sstevel@tonic-gate 	} ypbind_resp_u;
124*7c478bd9Sstevel@tonic-gate };
125*7c478bd9Sstevel@tonic-gate typedef struct ypbind_resp ypbind_resp;
126*7c478bd9Sstevel@tonic-gate bool_t xdr_ypbind_resp();
127*7c478bd9Sstevel@tonic-gate 
128*7c478bd9Sstevel@tonic-gate struct ypbind_setdom {
129*7c478bd9Sstevel@tonic-gate 	char *ypsetdom_domain;
130*7c478bd9Sstevel@tonic-gate 	struct ypbind_binding *ypsetdom_bindinfo;
131*7c478bd9Sstevel@tonic-gate };
132*7c478bd9Sstevel@tonic-gate typedef struct ypbind_setdom ypbind_setdom;
133*7c478bd9Sstevel@tonic-gate bool_t xdr_ypbind_setdom();
134*7c478bd9Sstevel@tonic-gate 
135*7c478bd9Sstevel@tonic-gate #define	YPBINDPROG ((u_long)100007)
136*7c478bd9Sstevel@tonic-gate #define	YPBINDVERS ((u_long)3)
137*7c478bd9Sstevel@tonic-gate #define	YPBINDPROC_NULL ((u_long)0)
138*7c478bd9Sstevel@tonic-gate extern void *ypbindproc_null_3();
139*7c478bd9Sstevel@tonic-gate #define	YPBINDPROC_DOMAIN ((u_long)1)
140*7c478bd9Sstevel@tonic-gate extern ypbind_resp *ypbindproc_domain_3();
141*7c478bd9Sstevel@tonic-gate #define	YPBINDPROC_SETDOM ((u_long)2)
142*7c478bd9Sstevel@tonic-gate extern void *ypbindproc_setdom_3();
143*7c478bd9Sstevel@tonic-gate 
144*7c478bd9Sstevel@tonic-gate 
145*7c478bd9Sstevel@tonic-gate /*
146*7c478bd9Sstevel@tonic-gate  * XXX - compiled and edited from yp.x
147*7c478bd9Sstevel@tonic-gate  * These structures are added here to
148*7c478bd9Sstevel@tonic-gate  * support binary compatibility with static
149*7c478bd9Sstevel@tonic-gate  * apps that use the old ypbind protocol.
150*7c478bd9Sstevel@tonic-gate  * These structures are lifted from
151*7c478bd9Sstevel@tonic-gate  * 4.x source lib/libc/yp/yp_prot.h
152*7c478bd9Sstevel@tonic-gate  * and rename with a suffix _2 to avoid
153*7c478bd9Sstevel@tonic-gate  * conflicts with similar structs for
154*7c478bd9Sstevel@tonic-gate  * native ypbind protocol, as above.
155*7c478bd9Sstevel@tonic-gate  */
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate typedef char *domainname_2;
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate struct ypbind_binding_2 {
160*7c478bd9Sstevel@tonic-gate 	struct in_addr ypbind_binding_addr; /* In network order */
161*7c478bd9Sstevel@tonic-gate 	unsigned short int ypbind_binding_port; /* In network order */
162*7c478bd9Sstevel@tonic-gate };
163*7c478bd9Sstevel@tonic-gate typedef struct ypbind_binding_2 ypbind_binding_2;
164*7c478bd9Sstevel@tonic-gate 
165*7c478bd9Sstevel@tonic-gate struct ypbind_resp_2 {
166*7c478bd9Sstevel@tonic-gate 	ypbind_resptype ypbind_status;
167*7c478bd9Sstevel@tonic-gate 	union {
168*7c478bd9Sstevel@tonic-gate 		unsigned long ypbind_error;
169*7c478bd9Sstevel@tonic-gate 		ypbind_binding_2 ypbind_bindinfo;
170*7c478bd9Sstevel@tonic-gate 	} ypbind_respbody_2;
171*7c478bd9Sstevel@tonic-gate };
172*7c478bd9Sstevel@tonic-gate typedef struct ypbind_resp_2 ypbind_resp_2;
173*7c478bd9Sstevel@tonic-gate 
174*7c478bd9Sstevel@tonic-gate struct ypbind_setdom_2 {
175*7c478bd9Sstevel@tonic-gate 	char ypsetdom_domain[YPMAXDOMAIN + 1];
176*7c478bd9Sstevel@tonic-gate 	ypbind_binding_2 ypsetdom_binding;
177*7c478bd9Sstevel@tonic-gate 	unsigned short ypsetdom_vers;
178*7c478bd9Sstevel@tonic-gate };
179*7c478bd9Sstevel@tonic-gate typedef struct ypbind_setdom_2 ypbind_setdom_2;
180*7c478bd9Sstevel@tonic-gate 
181*7c478bd9Sstevel@tonic-gate /*
182*7c478bd9Sstevel@tonic-gate  * ypbind V2 and ypbind V1 differ only in the "set domain"
183*7c478bd9Sstevel@tonic-gate  * procedure, which we don't support.
184*7c478bd9Sstevel@tonic-gate  */
185*7c478bd9Sstevel@tonic-gate #define	YPBINDVERS_2 ((unsigned long)(2))
186*7c478bd9Sstevel@tonic-gate #define	YPBINDVERS_1 ((unsigned long)(1))
187*7c478bd9Sstevel@tonic-gate extern  ypbind_resp_2 * ypbindproc_domain_2();
188*7c478bd9Sstevel@tonic-gate extern int ypbindprog_2_freeresult();
189*7c478bd9Sstevel@tonic-gate 
190*7c478bd9Sstevel@tonic-gate /* the xdr functions */
191*7c478bd9Sstevel@tonic-gate extern bool_t xdr_ypbind_binding_2();
192*7c478bd9Sstevel@tonic-gate extern bool_t xdr_ypbind_resp_2();
193