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