xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_b.h (revision 1da57d55)
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 /*
24  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
25  * Use is subject to license terms.
26  */
27 
28 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
29 /*	  All Rights Reserved  	*/
30 
31 /*
32  * Portions of this source code were derived from Berkeley 4.3 BSD
33  * under license from the Regents of the University of California.
34  */
35 
36 #ifndef _YP_B_H
37 #define	_YP_B_H
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include <rpc/types.h>
44 #include <netconfig.h>
45 #include <stdio.h>
46 #include <synch.h>
47 #include <netdb.h>
48 
49 extern bool_t xdr_netconfig(XDR *, struct netconfig *);
50 
51 #define	BINDING "/var/yp/binding"
52 #define	YPSETLOCAL 3
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 	int cache_bad;
60 	int fd;		/* fd in dom_client */
61 	dev_t rdev;	/* device id of fd */
62 	int ref_count;	/* number of threads using this structure */
63 	int need_free;	/* if true, this structure needs to be freed */
64 	mutex_t server_name_lock;    /* protects server name in dom_binding */
65 };
66 
67 /* Following structure is used only by ypbind */
68 
69 struct domain {
70 	struct domain *dom_pnext;
71 	char	*dom_name;
72 	bool_t dom_boundp;
73 	unsigned short dom_vers;	/* only YPVERS */
74 	unsigned int	dom_error;
75 	CLIENT * ping_clnt;
76 	struct ypbind_binding *dom_binding;
77 	int	dom_report_success;	/* Controls msg to /dev/console */
78 	int	dom_broadcaster_pid;
79 	int	bindfile;		/* File with binding info in it */
80 	int 	broadcaster_fd;
81 	FILE    *broadcaster_pipe;	/* to get answer from locater */
82 	XDR	broadcaster_xdr;	/* xdr for pipe */
83 	struct timeval lastping;	/* info to avoid a ping storm */
84 };
85 
86 enum ypbind_resptype {
87 	YPBIND_SUCC_VAL = 1,
88 	YPBIND_FAIL_VAL = 2
89 };
90 typedef enum ypbind_resptype ypbind_resptype;
91 extern bool_t xdr_ypbind_resptype(XDR *, ypbind_resptype *);
92 #define	YPBIND_ERR_ERR 1		/* Internal error */
93 #define	YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
94 #define	YPBIND_ERR_RESC 3		/* System resource allocation failure */
95 #define	YPBIND_ERR_NODOMAIN 4		/* Domain doesn't exist */
96 
97 /* Following struct is used only by ypwhich and yppoll */
98 
99 struct ypbind_domain {
100 	char *ypbind_domainname;
101 	rpcvers_t ypbind_vers;
102 };
103 typedef struct ypbind_domain ypbind_domain;
104 extern bool_t xdr_ypbind_domain(XDR *, ypbind_domain *);
105 
106 /*
107  * This structure is used to store information about the server
108  * Returned by ypbind to the libnsl/yp clients to contact ypserv.
109  * Also used by ypxfr.
110  */
111 
112 struct ypbind_binding {
113 	struct netconfig *ypbind_nconf;
114 	struct netbuf *ypbind_svcaddr;
115 	char *ypbind_servername;
116 	rpcvers_t ypbind_hi_vers;
117 	rpcvers_t ypbind_lo_vers;
118 };
119 typedef struct ypbind_binding ypbind_binding;
120 extern bool_t xdr_ypbind_binding(XDR *, ypbind_binding *);
121 
122 struct ypbind_resp {
123 	ypbind_resptype ypbind_status;
124 	union {
125 		uint_t ypbind_error;
126 		struct ypbind_binding *ypbind_bindinfo;
127 	} ypbind_resp_u;
128 };
129 typedef struct ypbind_resp ypbind_resp;
130 extern bool_t xdr_ypbind_resp(XDR *, ypbind_resp *);
131 
132 struct ypbind_setdom {
133 	char *ypsetdom_domain;
134 	struct ypbind_binding *ypsetdom_bindinfo;
135 };
136 typedef struct ypbind_setdom ypbind_setdom;
137 extern bool_t xdr_ypbind_setdom(XDR *, ypbind_setdom *);
138 
139 #define	YPBINDPROG ((rpcprog_t)100007)
140 #define	YPBINDVERS ((rpcvers_t)3)
141 #define	YPBINDPROC_NULL ((rpcproc_t)0)
142 extern void *ypbindproc_null_3();
143 #define	YPBINDPROC_DOMAIN ((rpcproc_t)1)
144 extern ypbind_resp *ypbindproc_domain_3();
145 #define	YPBINDPROC_SETDOM ((rpcproc_t)2)
146 extern void *ypbindproc_setdom_3();
147 
148 extern struct timeval _ypserv_timeout;
149 extern unsigned int _ypsleeptime;
150 
151 extern int __yp_dobind(char *, struct dom_binding **);
152 extern int __yp_dobind_rsvdport(char *, struct dom_binding **);
153 extern void free_dom_binding(struct dom_binding *);
154 extern CLIENT *__yp_clnt_create_rsvdport(const char *, rpcprog_t,
155     rpcvers_t, const char *, const uint_t, const uint_t);
156 extern void __yp_rel_binding(struct dom_binding *);
157 extern CLIENT *__clnt_create_loopback(rpcprog_t, rpcvers_t, int *);
158 
159 #ifdef __cplusplus
160 }
161 #endif
162 
163 #endif /* _YP_B_H */
164