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