xref: /illumos-gate/usr/src/lib/libnsl/yp/yp_b.h (revision e8031f0a)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
4061961e0fSrobinson 
4161961e0fSrobinson #ifdef __cplusplus
4261961e0fSrobinson extern "C" {
4361961e0fSrobinson #endif
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #include <rpc/types.h>
4661961e0fSrobinson #include <netconfig.h>
477c478bd9Sstevel@tonic-gate #include <stdio.h>
487c478bd9Sstevel@tonic-gate #include <synch.h>
497c478bd9Sstevel@tonic-gate #include <netdb.h>
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate extern bool_t xdr_netconfig(XDR *, struct netconfig *);
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #define	BINDING "/var/yp/binding"
547c478bd9Sstevel@tonic-gate #define	YPSETLOCAL 3
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate struct dom_binding {
577c478bd9Sstevel@tonic-gate 	struct dom_binding *dom_pnext;
587c478bd9Sstevel@tonic-gate 	char *dom_domain;
597c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
607c478bd9Sstevel@tonic-gate 	CLIENT *dom_client;
617c478bd9Sstevel@tonic-gate 	int cache_bad;
627c478bd9Sstevel@tonic-gate 	int fd;		/* fd in dom_client */
637c478bd9Sstevel@tonic-gate 	dev_t rdev;	/* device id of fd */
647c478bd9Sstevel@tonic-gate 	int ref_count;	/* number of threads using this structure */
657c478bd9Sstevel@tonic-gate 	int need_free;	/* if true, this structure needs to be freed */
667c478bd9Sstevel@tonic-gate 	mutex_t server_name_lock;    /* protects server name in dom_binding */
677c478bd9Sstevel@tonic-gate };
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /* Following structure is used only by ypbind */
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate struct domain {
727c478bd9Sstevel@tonic-gate 	struct domain *dom_pnext;
737c478bd9Sstevel@tonic-gate 	char	*dom_name;
747c478bd9Sstevel@tonic-gate 	bool_t dom_boundp;
757c478bd9Sstevel@tonic-gate 	unsigned short dom_vers;	/* only YPVERS */
767c478bd9Sstevel@tonic-gate 	unsigned int	dom_error;
777c478bd9Sstevel@tonic-gate 	CLIENT * ping_clnt;
787c478bd9Sstevel@tonic-gate 	struct ypbind_binding *dom_binding;
7961961e0fSrobinson 	int	dom_report_success;	/* Controls msg to /dev/console */
807c478bd9Sstevel@tonic-gate 	int	dom_broadcaster_pid;
817c478bd9Sstevel@tonic-gate 	int	bindfile;		/* File with binding info in it */
827c478bd9Sstevel@tonic-gate 	int 	broadcaster_fd;
837c478bd9Sstevel@tonic-gate 	FILE    *broadcaster_pipe;	/* to get answer from locater */
847c478bd9Sstevel@tonic-gate 	XDR	broadcaster_xdr;	/* xdr for pipe */
857c478bd9Sstevel@tonic-gate 	struct timeval lastping;	/* info to avoid a ping storm */
867c478bd9Sstevel@tonic-gate };
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate enum ypbind_resptype {
897c478bd9Sstevel@tonic-gate 	YPBIND_SUCC_VAL = 1,
907c478bd9Sstevel@tonic-gate 	YPBIND_FAIL_VAL = 2
917c478bd9Sstevel@tonic-gate };
927c478bd9Sstevel@tonic-gate typedef enum ypbind_resptype ypbind_resptype;
937c478bd9Sstevel@tonic-gate extern bool_t xdr_ypbind_resptype(XDR *, ypbind_resptype *);
947c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_ERR 1		/* Internal error */
957c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NOSERV 2		/* No bound server for passed domain */
967c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_RESC 3		/* System resource allocation failure */
977c478bd9Sstevel@tonic-gate #define	YPBIND_ERR_NODOMAIN 4		/* Domain doesn't exist */
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate /* Following struct is used only by ypwhich and yppoll */
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate struct ypbind_domain {
1027c478bd9Sstevel@tonic-gate 	char *ypbind_domainname;
1037c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_vers;
1047c478bd9Sstevel@tonic-gate };
1057c478bd9Sstevel@tonic-gate typedef struct ypbind_domain ypbind_domain;
10661961e0fSrobinson extern bool_t xdr_ypbind_domain(XDR *, ypbind_domain *);
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate /*
1097c478bd9Sstevel@tonic-gate  * This structure is used to store information about the server
1107c478bd9Sstevel@tonic-gate  * Returned by ypbind to the libnsl/yp clients to contact ypserv.
1117c478bd9Sstevel@tonic-gate  * Also used by ypxfr.
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate 
1147c478bd9Sstevel@tonic-gate struct ypbind_binding {
1157c478bd9Sstevel@tonic-gate 	struct netconfig *ypbind_nconf;
1167c478bd9Sstevel@tonic-gate 	struct netbuf *ypbind_svcaddr;
1177c478bd9Sstevel@tonic-gate 	char *ypbind_servername;
1187c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_hi_vers;
1197c478bd9Sstevel@tonic-gate 	rpcvers_t ypbind_lo_vers;
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate typedef struct ypbind_binding ypbind_binding;
12261961e0fSrobinson extern bool_t xdr_ypbind_binding(XDR *, ypbind_binding *);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate struct ypbind_resp {
1257c478bd9Sstevel@tonic-gate 	ypbind_resptype ypbind_status;
1267c478bd9Sstevel@tonic-gate 	union {
12761961e0fSrobinson 		uint_t ypbind_error;
1287c478bd9Sstevel@tonic-gate 		struct ypbind_binding *ypbind_bindinfo;
1297c478bd9Sstevel@tonic-gate 	} ypbind_resp_u;
1307c478bd9Sstevel@tonic-gate };
1317c478bd9Sstevel@tonic-gate typedef struct ypbind_resp ypbind_resp;
13261961e0fSrobinson extern bool_t xdr_ypbind_resp(XDR *, ypbind_resp *);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate struct ypbind_setdom {
1357c478bd9Sstevel@tonic-gate 	char *ypsetdom_domain;
1367c478bd9Sstevel@tonic-gate 	struct ypbind_binding *ypsetdom_bindinfo;
1377c478bd9Sstevel@tonic-gate };
1387c478bd9Sstevel@tonic-gate typedef struct ypbind_setdom ypbind_setdom;
13961961e0fSrobinson extern bool_t xdr_ypbind_setdom(XDR *, ypbind_setdom *);
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate #define	YPBINDPROG ((rpcprog_t)100007)
1427c478bd9Sstevel@tonic-gate #define	YPBINDVERS ((rpcvers_t)3)
1437c478bd9Sstevel@tonic-gate #define	YPBINDPROC_NULL ((rpcproc_t)0)
1447c478bd9Sstevel@tonic-gate extern void *ypbindproc_null_3();
1457c478bd9Sstevel@tonic-gate #define	YPBINDPROC_DOMAIN ((rpcproc_t)1)
1467c478bd9Sstevel@tonic-gate extern ypbind_resp *ypbindproc_domain_3();
1477c478bd9Sstevel@tonic-gate #define	YPBINDPROC_SETDOM ((rpcproc_t)2)
1487c478bd9Sstevel@tonic-gate extern void *ypbindproc_setdom_3();
1497c478bd9Sstevel@tonic-gate 
1507c478bd9Sstevel@tonic-gate extern struct timeval _ypserv_timeout;
1517c478bd9Sstevel@tonic-gate extern unsigned int _ypsleeptime;
1527c478bd9Sstevel@tonic-gate 
1537c478bd9Sstevel@tonic-gate extern int __yp_dobind(char *, struct dom_binding **);
1547c478bd9Sstevel@tonic-gate extern int __yp_dobind_rsvdport(char *, struct dom_binding **);
1557c478bd9Sstevel@tonic-gate extern void free_dom_binding(struct dom_binding *);
1567c478bd9Sstevel@tonic-gate extern CLIENT *__yp_clnt_create_rsvdport(const char *, rpcprog_t,
1577c478bd9Sstevel@tonic-gate     rpcvers_t, const char *, const uint_t, const uint_t);
1587c478bd9Sstevel@tonic-gate extern void __yp_rel_binding(struct dom_binding *);
1597c478bd9Sstevel@tonic-gate extern CLIENT *__clnt_create_loopback(rpcprog_t, rpcvers_t, int *);
1607c478bd9Sstevel@tonic-gate 
16161961e0fSrobinson #ifdef __cplusplus
16261961e0fSrobinson }
16361961e0fSrobinson #endif
16461961e0fSrobinson 
16561961e0fSrobinson #endif /* _YP_B_H */
166