1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1990 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate /* 31*0Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 32*0Sstevel@tonic-gate * under license from the Regents of the University of California. 33*0Sstevel@tonic-gate */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" 36*0Sstevel@tonic-gate 37*0Sstevel@tonic-gate #include <rpc/types.h> 38*0Sstevel@tonic-gate #include "netconfig.h" 39*0Sstevel@tonic-gate #include <stdio.h> 40*0Sstevel@tonic-gate 41*0Sstevel@tonic-gate extern bool_t xdr_netconfig(); 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate #define BINDING "/var/yp/binding" 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #define YPSETNONE 0 46*0Sstevel@tonic-gate #define YPSETLOCAL 3 47*0Sstevel@tonic-gate #define YPSETALL 5 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate /* 50*0Sstevel@tonic-gate * This structure is used only in the ypxfr protocol and has 51*0Sstevel@tonic-gate * nothing to do with ypbind. 52*0Sstevel@tonic-gate */ 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate struct dom_binding { 55*0Sstevel@tonic-gate struct dom_binding *dom_pnext; 56*0Sstevel@tonic-gate char *dom_domain; 57*0Sstevel@tonic-gate struct ypbind_binding *dom_binding; 58*0Sstevel@tonic-gate CLIENT *dom_client; 59*0Sstevel@tonic-gate }; 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate /* Following structure is used only by ypbind */ 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate struct domain { 64*0Sstevel@tonic-gate struct domain *dom_pnext; 65*0Sstevel@tonic-gate char *dom_name; 66*0Sstevel@tonic-gate bool_t dom_boundp; 67*0Sstevel@tonic-gate unsigned short dom_vers; /* only YPVERS */ 68*0Sstevel@tonic-gate unsigned long dom_error; 69*0Sstevel@tonic-gate CLIENT * ping_clnt; 70*0Sstevel@tonic-gate struct ypbind_binding *dom_binding; 71*0Sstevel@tonic-gate int dom_report_success; /* Controls msg to /dev/console*/ 72*0Sstevel@tonic-gate int dom_broadcaster_pid; 73*0Sstevel@tonic-gate int bindfile; /* File with binding info in it */ 74*0Sstevel@tonic-gate int broadcaster_fd; 75*0Sstevel@tonic-gate FILE *broadcaster_pipe; /* to get answer from locater */ 76*0Sstevel@tonic-gate XDR broadcaster_xdr; /* xdr for pipe */ 77*0Sstevel@tonic-gate struct timeval lastping; /* info to avoid a ping storm */ 78*0Sstevel@tonic-gate FILE *cache_fp; /* file pointer opened on cache_file */ 79*0Sstevel@tonic-gate char *cache_file; /* cached version of server info */ 80*0Sstevel@tonic-gate }; 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate enum ypbind_resptype { 83*0Sstevel@tonic-gate YPBIND_SUCC_VAL = 1, 84*0Sstevel@tonic-gate YPBIND_FAIL_VAL = 2 85*0Sstevel@tonic-gate }; 86*0Sstevel@tonic-gate typedef enum ypbind_resptype ypbind_resptype; 87*0Sstevel@tonic-gate bool_t xdr_ypbind_resptype(); 88*0Sstevel@tonic-gate #define YPBIND_ERR_ERR 1 /* Internal error */ 89*0Sstevel@tonic-gate #define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */ 90*0Sstevel@tonic-gate #define YPBIND_ERR_RESC 3 /* System resource allocation failure */ 91*0Sstevel@tonic-gate #define YPBIND_ERR_NODOMAIN 4 /* Domain doesn't exist */ 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate /* Following struct is used only by ypwhich and yppoll */ 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate struct ypbind_domain { 96*0Sstevel@tonic-gate char *ypbind_domainname; 97*0Sstevel@tonic-gate long ypbind_vers; 98*0Sstevel@tonic-gate }; 99*0Sstevel@tonic-gate typedef struct ypbind_domain ypbind_domain; 100*0Sstevel@tonic-gate bool_t xdr_ypbind_domain(); 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate /* 103*0Sstevel@tonic-gate * This structure is used to store information about the server 104*0Sstevel@tonic-gate * Returned by ypbind to the libnsl/yp clients to contact ypserv. 105*0Sstevel@tonic-gate * Also used by ypxfr. 106*0Sstevel@tonic-gate */ 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate struct ypbind_binding { 109*0Sstevel@tonic-gate struct netconfig *ypbind_nconf; 110*0Sstevel@tonic-gate struct netbuf *ypbind_svcaddr; 111*0Sstevel@tonic-gate char *ypbind_servername; 112*0Sstevel@tonic-gate long ypbind_hi_vers; 113*0Sstevel@tonic-gate long ypbind_lo_vers; 114*0Sstevel@tonic-gate }; 115*0Sstevel@tonic-gate typedef struct ypbind_binding ypbind_binding; 116*0Sstevel@tonic-gate bool_t xdr_ypbind_binding(); 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate struct ypbind_resp { 119*0Sstevel@tonic-gate ypbind_resptype ypbind_status; 120*0Sstevel@tonic-gate union { 121*0Sstevel@tonic-gate u_long ypbind_error; 122*0Sstevel@tonic-gate struct ypbind_binding *ypbind_bindinfo; 123*0Sstevel@tonic-gate } ypbind_resp_u; 124*0Sstevel@tonic-gate }; 125*0Sstevel@tonic-gate typedef struct ypbind_resp ypbind_resp; 126*0Sstevel@tonic-gate bool_t xdr_ypbind_resp(); 127*0Sstevel@tonic-gate 128*0Sstevel@tonic-gate struct ypbind_setdom { 129*0Sstevel@tonic-gate char *ypsetdom_domain; 130*0Sstevel@tonic-gate struct ypbind_binding *ypsetdom_bindinfo; 131*0Sstevel@tonic-gate }; 132*0Sstevel@tonic-gate typedef struct ypbind_setdom ypbind_setdom; 133*0Sstevel@tonic-gate bool_t xdr_ypbind_setdom(); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate #define YPBINDPROG ((u_long)100007) 136*0Sstevel@tonic-gate #define YPBINDVERS ((u_long)3) 137*0Sstevel@tonic-gate #define YPBINDPROC_NULL ((u_long)0) 138*0Sstevel@tonic-gate extern void *ypbindproc_null_3(); 139*0Sstevel@tonic-gate #define YPBINDPROC_DOMAIN ((u_long)1) 140*0Sstevel@tonic-gate extern ypbind_resp *ypbindproc_domain_3(); 141*0Sstevel@tonic-gate #define YPBINDPROC_SETDOM ((u_long)2) 142*0Sstevel@tonic-gate extern void *ypbindproc_setdom_3(); 143*0Sstevel@tonic-gate 144*0Sstevel@tonic-gate 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * XXX - compiled and edited from yp.x 147*0Sstevel@tonic-gate * These structures are added here to 148*0Sstevel@tonic-gate * support binary compatibility with static 149*0Sstevel@tonic-gate * apps that use the old ypbind protocol. 150*0Sstevel@tonic-gate * These structures are lifted from 151*0Sstevel@tonic-gate * 4.x source lib/libc/yp/yp_prot.h 152*0Sstevel@tonic-gate * and rename with a suffix _2 to avoid 153*0Sstevel@tonic-gate * conflicts with similar structs for 154*0Sstevel@tonic-gate * native ypbind protocol, as above. 155*0Sstevel@tonic-gate */ 156*0Sstevel@tonic-gate 157*0Sstevel@tonic-gate typedef char *domainname_2; 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate struct ypbind_binding_2 { 160*0Sstevel@tonic-gate struct in_addr ypbind_binding_addr; /* In network order */ 161*0Sstevel@tonic-gate unsigned short int ypbind_binding_port; /* In network order */ 162*0Sstevel@tonic-gate }; 163*0Sstevel@tonic-gate typedef struct ypbind_binding_2 ypbind_binding_2; 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate struct ypbind_resp_2 { 166*0Sstevel@tonic-gate ypbind_resptype ypbind_status; 167*0Sstevel@tonic-gate union { 168*0Sstevel@tonic-gate unsigned long ypbind_error; 169*0Sstevel@tonic-gate ypbind_binding_2 ypbind_bindinfo; 170*0Sstevel@tonic-gate } ypbind_respbody_2; 171*0Sstevel@tonic-gate }; 172*0Sstevel@tonic-gate typedef struct ypbind_resp_2 ypbind_resp_2; 173*0Sstevel@tonic-gate 174*0Sstevel@tonic-gate struct ypbind_setdom_2 { 175*0Sstevel@tonic-gate char ypsetdom_domain[YPMAXDOMAIN + 1]; 176*0Sstevel@tonic-gate ypbind_binding_2 ypsetdom_binding; 177*0Sstevel@tonic-gate unsigned short ypsetdom_vers; 178*0Sstevel@tonic-gate }; 179*0Sstevel@tonic-gate typedef struct ypbind_setdom_2 ypbind_setdom_2; 180*0Sstevel@tonic-gate 181*0Sstevel@tonic-gate /* 182*0Sstevel@tonic-gate * ypbind V2 and ypbind V1 differ only in the "set domain" 183*0Sstevel@tonic-gate * procedure, which we don't support. 184*0Sstevel@tonic-gate */ 185*0Sstevel@tonic-gate #define YPBINDVERS_2 ((unsigned long)(2)) 186*0Sstevel@tonic-gate #define YPBINDVERS_1 ((unsigned long)(1)) 187*0Sstevel@tonic-gate extern ypbind_resp_2 * ypbindproc_domain_2(); 188*0Sstevel@tonic-gate extern int ypbindprog_2_freeresult(); 189*0Sstevel@tonic-gate 190*0Sstevel@tonic-gate /* the xdr functions */ 191*0Sstevel@tonic-gate extern bool_t xdr_ypbind_binding_2(); 192*0Sstevel@tonic-gate extern bool_t xdr_ypbind_resp_2(); 193