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 #include <synch.h> 41 #include <netdb.h> 42 43 extern bool_t xdr_netconfig(XDR *, struct netconfig *); 44 45 #define BINDING "/var/yp/binding" 46 #define YPSETLOCAL 3 47 48 struct dom_binding { 49 struct dom_binding *dom_pnext; 50 char *dom_domain; 51 struct ypbind_binding *dom_binding; 52 CLIENT *dom_client; 53 int cache_bad; 54 int fd; /* fd in dom_client */ 55 dev_t rdev; /* device id of fd */ 56 int ref_count; /* number of threads using this structure */ 57 int need_free; /* if true, this structure needs to be freed */ 58 mutex_t server_name_lock; /* protects server name in dom_binding */ 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 int 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 }; 79 80 enum ypbind_resptype { 81 YPBIND_SUCC_VAL = 1, 82 YPBIND_FAIL_VAL = 2 83 }; 84 typedef enum ypbind_resptype ypbind_resptype; 85 extern bool_t xdr_ypbind_resptype(XDR *, ypbind_resptype *); 86 #define YPBIND_ERR_ERR 1 /* Internal error */ 87 #define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */ 88 #define YPBIND_ERR_RESC 3 /* System resource allocation failure */ 89 #define YPBIND_ERR_NODOMAIN 4 /* Domain doesn't exist */ 90 91 /* Following struct is used only by ypwhich and yppoll */ 92 93 struct ypbind_domain { 94 char *ypbind_domainname; 95 rpcvers_t ypbind_vers; 96 }; 97 typedef struct ypbind_domain ypbind_domain; 98 bool_t xdr_ypbind_domain(XDR *, ypbind_domain *); 99 100 /* 101 * This structure is used to store information about the server 102 * Returned by ypbind to the libnsl/yp clients to contact ypserv. 103 * Also used by ypxfr. 104 */ 105 106 struct ypbind_binding { 107 struct netconfig *ypbind_nconf; 108 struct netbuf *ypbind_svcaddr; 109 char *ypbind_servername; 110 rpcvers_t ypbind_hi_vers; 111 rpcvers_t ypbind_lo_vers; 112 }; 113 typedef struct ypbind_binding ypbind_binding; 114 bool_t xdr_ypbind_binding(XDR *, ypbind_binding *); 115 116 struct ypbind_resp { 117 ypbind_resptype ypbind_status; 118 union { 119 u_int ypbind_error; 120 struct ypbind_binding *ypbind_bindinfo; 121 } ypbind_resp_u; 122 }; 123 typedef struct ypbind_resp ypbind_resp; 124 bool_t xdr_ypbind_resp(XDR *, ypbind_resp *); 125 126 struct ypbind_setdom { 127 char *ypsetdom_domain; 128 struct ypbind_binding *ypsetdom_bindinfo; 129 }; 130 typedef struct ypbind_setdom ypbind_setdom; 131 bool_t xdr_ypbind_setdom(XDR *, ypbind_setdom *); 132 133 #define YPBINDPROG ((rpcprog_t)100007) 134 #define YPBINDVERS ((rpcvers_t)3) 135 #define YPBINDPROC_NULL ((rpcproc_t)0) 136 extern void *ypbindproc_null_3(); 137 #define YPBINDPROC_DOMAIN ((rpcproc_t)1) 138 extern ypbind_resp *ypbindproc_domain_3(); 139 #define YPBINDPROC_SETDOM ((rpcproc_t)2) 140 extern void *ypbindproc_setdom_3(); 141 142 extern struct timeval _ypserv_timeout; 143 extern unsigned int _ypsleeptime; 144 145 extern int __yp_dobind(char *, struct dom_binding **); 146 extern int __yp_dobind_rsvdport(char *, struct dom_binding **); 147 extern void free_dom_binding(struct dom_binding *); 148 extern CLIENT *__yp_clnt_create_rsvdport(const char *, rpcprog_t, 149 rpcvers_t, const char *, const uint_t, const uint_t); 150 extern void __yp_rel_binding(struct dom_binding *); 151 extern CLIENT *__clnt_create_loopback(rpcprog_t, rpcvers_t, int *); 152 153 extern int _fcntl(int, int, ...); 154 extern uint_t _sleep(uint_t); 155