xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_b.h (revision 1da57d55)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
2261961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*
24*e8031f0aSraf  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
257c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
267c478bd9Sstevel@tonic-gate  */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
297c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /*
327c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
337c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
3661961e0fSrobinson #ifndef _YP_B_H
3761961e0fSrobinson #define	_YP_B_H
3861961e0fSrobinson 
3961961e0fSrobinson #ifdef __cplusplus
4061961e0fSrobinson extern "C" {
4161961e0fSrobinson #endif
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #include <rpc/types.h>
4461961e0fSrobinson #include <netconfig.h>
457c478bd9Sstevel@tonic-gate #include <stdio.h>
467c478bd9Sstevel@tonic-gate #include <synch.h>
477c478bd9Sstevel@tonic-gate #include <netdb.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate extern bool_t xdr_netconfig(XDR *, struct netconfig *);
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	BINDING "/var/yp/binding"
527c478bd9Sstevel@tonic-gate #define	YPSETLOCAL 3
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate struct dom_binding {
557c478bd9Sstevel@tonic-gate 	struct dom_binding *dom_pnext;
567c478bd9Sstevel@tonic-gate 	char *dom_domain;
577c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
587c478bd9Sstevel@tonic-gate 	CLIENT *dom_client;
597c478bd9Sstevel@tonic-gate 	int cache_bad;
607c478bd9Sstevel@tonic-gate 	int fd;		/* fd in dom_client */
617c478bd9Sstevel@tonic-gate 	dev_t rdev;	/* device id of fd */
627c478bd9Sstevel@tonic-gate 	int ref_count;	/* number of threads using this structure */
637c478bd9Sstevel@tonic-gate 	int need_free;	/* if true, this structure needs to be freed */
647c478bd9Sstevel@tonic-gate 	mutex_t server_name_lock;    /* protects server name in dom_binding */
657c478bd9Sstevel@tonic-gate };
667c478bd9Sstevel@tonic-gate 
677c478bd9Sstevel@tonic-gate /* Following structure is used only by ypbind */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate struct domain {
707c478bd9Sstevel@tonic-gate 	struct domain *dom_pnext;
717c478bd9Sstevel@tonic-gate 	char	*dom_name;
727c478bd9Sstevel@tonic-gate 	bool_t dom_boundp;
737c478bd9Sstevel@tonic-gate 	unsigned short dom_vers;	/* only YPVERS */
747c478bd9Sstevel@tonic-gate 	unsigned int	dom_error;
757c478bd9Sstevel@tonic-gate 	CLIENT * ping_clnt;
767c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
7761961e0fSrobinson 	int	dom_report_success;	/* Controls msg to /dev/console */
787c478bd9Sstevel@tonic-gate 	int	dom_broadcaster_pid;
797c478bd9Sstevel@tonic-gate 	int	bindfile;		/* File with binding info in it */
807c478bd9Sstevel@tonic-gate 	int 	broadcaster_fd;
817c478bd9Sstevel@tonic-gate 	FILE    *broadcaster_pipe;	/* to get answer from locater */
827c478bd9Sstevel@tonic-gate 	XDR	broadcaster_xdr;	/* xdr for pipe */
837c478bd9Sstevel@tonic-gate 	struct timeval lastping;	/* info to avoid a ping storm */
847c478bd9Sstevel@tonic-gate };
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate enum ypbind_resptype {
877c478bd9Sstevel@tonic-gate 	YPBIND_SUCC_VAL = 1,
887c478bd9Sstevel@tonic-gate 	YPBIND_FAIL_VAL = 2
897c478bd9Sstevel@tonic-gate };
907c478bd9Sstevel@tonic-gate typedef enum ypbind_resptype ypbind_resptype;
917c478bd9Sstevel@tonic-gate extern bool_t xdr_ypbind_resptype(XDR *, ypbind_resptype *);
927c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_ERR 1		/* Internal error */
937c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
947c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_RESC 3		/* System resource allocation failure */
957c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NODOMAIN 4		/* Domain doesn't exist */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /* Following struct is used only by ypwhich and yppoll */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate struct ypbind_domain {
1007c478bd9Sstevel@tonic-gate 	char *ypbind_domainname;
1017c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_vers;
1027c478bd9Sstevel@tonic-gate };
1037c478bd9Sstevel@tonic-gate typedef struct ypbind_domain ypbind_domain;
10461961e0fSrobinson extern bool_t xdr_ypbind_domain(XDR *, ypbind_domain *);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate /*
1077c478bd9Sstevel@tonic-gate  * This structure is used to store information about the server
1087c478bd9Sstevel@tonic-gate  * Returned by ypbind to the libnsl/yp clients to contact ypserv.
1097c478bd9Sstevel@tonic-gate  * Also used by ypxfr.
1107c478bd9Sstevel@tonic-gate  */
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate struct ypbind_binding {
1137c478bd9Sstevel@tonic-gate 	struct netconfig *ypbind_nconf;
1147c478bd9Sstevel@tonic-gate 	struct netbuf *ypbind_svcaddr;
1157c478bd9Sstevel@tonic-gate 	char *ypbind_servername;
1167c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_hi_vers;
1177c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_lo_vers;
1187c478bd9Sstevel@tonic-gate };
1197c478bd9Sstevel@tonic-gate typedef struct ypbind_binding ypbind_binding;
12061961e0fSrobinson extern bool_t xdr_ypbind_binding(XDR *, ypbind_binding *);
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate struct ypbind_resp {
1237c478bd9Sstevel@tonic-gate 	ypbind_resptype ypbind_status;
1247c478bd9Sstevel@tonic-gate 	union {
12561961e0fSrobinson 		uint_t ypbind_error;
1267c478bd9Sstevel@tonic-gate 		struct ypbind_binding *ypbind_bindinfo;
1277c478bd9Sstevel@tonic-gate 	} ypbind_resp_u;
1287c478bd9Sstevel@tonic-gate };
1297c478bd9Sstevel@tonic-gate typedef struct ypbind_resp ypbind_resp;
13061961e0fSrobinson extern bool_t xdr_ypbind_resp(XDR *, ypbind_resp *);
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate struct ypbind_setdom {
1337c478bd9Sstevel@tonic-gate 	char *ypsetdom_domain;
1347c478bd9Sstevel@tonic-gate 	struct ypbind_binding *ypsetdom_bindinfo;
1357c478bd9Sstevel@tonic-gate };
1367c478bd9Sstevel@tonic-gate typedef struct ypbind_setdom ypbind_setdom;
13761961e0fSrobinson extern bool_t xdr_ypbind_setdom(XDR *, ypbind_setdom *);
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #define	YPBINDPROG ((rpcprog_t)100007)
1407c478bd9Sstevel@tonic-gate #define	YPBINDVERS ((rpcvers_t)3)
1417c478bd9Sstevel@tonic-gate #define	YPBINDPROC_NULL ((rpcproc_t)0)
1427c478bd9Sstevel@tonic-gate extern void *ypbindproc_null_3();
1437c478bd9Sstevel@tonic-gate #define	YPBINDPROC_DOMAIN ((rpcproc_t)1)
1447c478bd9Sstevel@tonic-gate extern ypbind_resp *ypbindproc_domain_3();
1457c478bd9Sstevel@tonic-gate #define	YPBINDPROC_SETDOM ((rpcproc_t)2)
1467c478bd9Sstevel@tonic-gate extern void *ypbindproc_setdom_3();
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate extern struct timeval _ypserv_timeout;
1497c478bd9Sstevel@tonic-gate extern unsigned int _ypsleeptime;
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate extern int __yp_dobind(char *, struct dom_binding **);
1527c478bd9Sstevel@tonic-gate extern int __yp_dobind_rsvdport(char *, struct dom_binding **);
1537c478bd9Sstevel@tonic-gate extern void free_dom_binding(struct dom_binding *);
1547c478bd9Sstevel@tonic-gate extern CLIENT *__yp_clnt_create_rsvdport(const char *, rpcprog_t,
1557c478bd9Sstevel@tonic-gate     rpcvers_t, const char *, const uint_t, const uint_t);
1567c478bd9Sstevel@tonic-gate extern void __yp_rel_binding(struct dom_binding *);
1577c478bd9Sstevel@tonic-gate extern CLIENT *__clnt_create_loopback(rpcprog_t, rpcvers_t, int *);
1587c478bd9Sstevel@tonic-gate 
15961961e0fSrobinson #ifdef __cplusplus
16061961e0fSrobinson }
16161961e0fSrobinson #endif
16261961e0fSrobinson 
16361961e0fSrobinson #endif /* _YP_B_H */
164