1*3b0f7467SBill Paul %/* 2*3b0f7467SBill Paul % * Sun RPC is a product of Sun Microsystems, Inc. and is provided for 3*3b0f7467SBill Paul % * unrestricted use provided that this legend is included on all tape 4*3b0f7467SBill Paul % * media and as a part of the software program in whole or part. Users 5*3b0f7467SBill Paul % * may copy or modify Sun RPC without charge, but are not authorized 6*3b0f7467SBill Paul % * to license or distribute it to anyone else except as part of a product or 7*3b0f7467SBill Paul % * program developed by the user. 8*3b0f7467SBill Paul % * 9*3b0f7467SBill Paul % * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE 10*3b0f7467SBill Paul % * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR 11*3b0f7467SBill Paul % * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. 12*3b0f7467SBill Paul % * 13*3b0f7467SBill Paul % * Sun RPC is provided with no support and without any obligation on the 14*3b0f7467SBill Paul % * part of Sun Microsystems, Inc. to assist in its use, correction, 15*3b0f7467SBill Paul % * modification or enhancement. 16*3b0f7467SBill Paul % * 17*3b0f7467SBill Paul % * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE 18*3b0f7467SBill Paul % * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC 19*3b0f7467SBill Paul % * OR ANY PART THEREOF. 20*3b0f7467SBill Paul % * 21*3b0f7467SBill Paul % * In no event will Sun Microsystems, Inc. be liable for any lost revenue 22*3b0f7467SBill Paul % * or profits or other special, indirect and consequential damages, even if 23*3b0f7467SBill Paul % * Sun has been advised of the possibility of such damages. 24*3b0f7467SBill Paul % * 25*3b0f7467SBill Paul % * Sun Microsystems, Inc. 26*3b0f7467SBill Paul % * 2550 Garcia Avenue 27*3b0f7467SBill Paul % * Mountain View, California 94043 28*3b0f7467SBill Paul % */ 29*3b0f7467SBill Paul %/* 30*3b0f7467SBill Paul % * Copyright (c) 1984,1989 by Sun Microsystems, Inc. 31*3b0f7467SBill Paul % */ 32*3b0f7467SBill Paul 33*3b0f7467SBill Paul %/* from pmap_prot.x */ 34*3b0f7467SBill Paul 35*3b0f7467SBill Paul #ifdef RPC_HDR 36*3b0f7467SBill Paul % 37*3b0f7467SBill Paul %#ifndef _KERNEL 38*3b0f7467SBill Paul % 39*3b0f7467SBill Paul #endif 40*3b0f7467SBill Paul 41*3b0f7467SBill Paul /* 42*3b0f7467SBill Paul * Port Mapper Protocol Specification (in RPC Language) 43*3b0f7467SBill Paul * derived from RFC 1057 44*3b0f7467SBill Paul */ 45*3b0f7467SBill Paul 46*3b0f7467SBill Paul %/* 47*3b0f7467SBill Paul % * Protocol for the local binder service, or pmap. 48*3b0f7467SBill Paul % * 49*3b0f7467SBill Paul % * Copyright (C) 1984, Sun Microsystems, Inc. 50*3b0f7467SBill Paul % * 51*3b0f7467SBill Paul % * The following procedures are supported by the protocol: 52*3b0f7467SBill Paul % * 53*3b0f7467SBill Paul % * PMAPPROC_NULL() returns () 54*3b0f7467SBill Paul % * takes nothing, returns nothing 55*3b0f7467SBill Paul % * 56*3b0f7467SBill Paul % * PMAPPROC_SET(struct pmap) returns (bool_t) 57*3b0f7467SBill Paul % * TRUE is success, FALSE is failure. Registers the tuple 58*3b0f7467SBill Paul % * [prog, vers, prot, port]. 59*3b0f7467SBill Paul % * 60*3b0f7467SBill Paul % * PMAPPROC_UNSET(struct pmap) returns (bool_t) 61*3b0f7467SBill Paul % * TRUE is success, FALSE is failure. Un-registers pair 62*3b0f7467SBill Paul % * [prog, vers]. prot and port are ignored. 63*3b0f7467SBill Paul % * 64*3b0f7467SBill Paul % * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). 65*3b0f7467SBill Paul % * 0 is failure. Otherwise returns the port number where the pair 66*3b0f7467SBill Paul % * [prog, vers] is registered. It may lie! 67*3b0f7467SBill Paul % * 68*3b0f7467SBill Paul % * PMAPPROC_DUMP() RETURNS (struct pmaplist_ptr) 69*3b0f7467SBill Paul % * 70*3b0f7467SBill Paul % * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) 71*3b0f7467SBill Paul % * RETURNS (port, string<>); 72*3b0f7467SBill Paul % * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, 73*3b0f7467SBill Paul % * encapsulatedargs); 74*3b0f7467SBill Paul % * Calls the procedure on the local machine. If it is not registered, 75*3b0f7467SBill Paul % * this procedure is quite; ie it does not return error information!!! 76*3b0f7467SBill Paul % * This procedure only is supported on rpc/udp and calls via 77*3b0f7467SBill Paul % * rpc/udp. This routine only passes null authentication parameters. 78*3b0f7467SBill Paul % * This file has no interface to xdr routines for PMAPPROC_CALLIT. 79*3b0f7467SBill Paul % * 80*3b0f7467SBill Paul % * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. 81*3b0f7467SBill Paul % */ 82*3b0f7467SBill Paul % 83*3b0f7467SBill Paul const PMAPPORT = 111; /* portmapper port number */ 84*3b0f7467SBill Paul % 85*3b0f7467SBill Paul % 86*3b0f7467SBill Paul %/* 87*3b0f7467SBill Paul % * A mapping of (program, version, protocol) to port number 88*3b0f7467SBill Paul % */ 89*3b0f7467SBill Paul 90*3b0f7467SBill Paul struct pmap { 91*3b0f7467SBill Paul unsigned long pm_prog; 92*3b0f7467SBill Paul unsigned long pm_vers; 93*3b0f7467SBill Paul unsigned long pm_prot; 94*3b0f7467SBill Paul unsigned long pm_port; 95*3b0f7467SBill Paul }; 96*3b0f7467SBill Paul #ifdef RPC_HDR 97*3b0f7467SBill Paul % 98*3b0f7467SBill Paul %typedef pmap PMAP; 99*3b0f7467SBill Paul % 100*3b0f7467SBill Paul #endif 101*3b0f7467SBill Paul % 102*3b0f7467SBill Paul %/* 103*3b0f7467SBill Paul % * Supported values for the "prot" field 104*3b0f7467SBill Paul % */ 105*3b0f7467SBill Paul % 106*3b0f7467SBill Paul const PMAP_IPPROTO_TCP = 6; /* protocol number for TCP/IP */ 107*3b0f7467SBill Paul const PMAP_IPPROTO_UDP = 17; /* protocol number for UDP/IP */ 108*3b0f7467SBill Paul % 109*3b0f7467SBill Paul % 110*3b0f7467SBill Paul %/* 111*3b0f7467SBill Paul % * A list of mappings 112*3b0f7467SBill Paul % * 113*3b0f7467SBill Paul % * Below are two definitions for the pmaplist structure. This is done because 114*3b0f7467SBill Paul % * xdr_pmaplist() is specified to take a struct pmaplist **, rather than a 115*3b0f7467SBill Paul % * struct pmaplist * that rpcgen would produce. One version of the pmaplist 116*3b0f7467SBill Paul % * structure (actually called pm__list) is used with rpcgen, and the other is 117*3b0f7467SBill Paul % * defined only in the header file for compatibility with the specified 118*3b0f7467SBill Paul % * interface. 119*3b0f7467SBill Paul % */ 120*3b0f7467SBill Paul 121*3b0f7467SBill Paul struct pm__list { 122*3b0f7467SBill Paul pmap pml_map; 123*3b0f7467SBill Paul struct pm__list *pml_next; 124*3b0f7467SBill Paul }; 125*3b0f7467SBill Paul 126*3b0f7467SBill Paul typedef pm__list *pmaplist_ptr; /* results of PMAPPROC_DUMP */ 127*3b0f7467SBill Paul 128*3b0f7467SBill Paul #ifdef RPC_HDR 129*3b0f7467SBill Paul % 130*3b0f7467SBill Paul %typedef struct pm__list pmaplist; 131*3b0f7467SBill Paul %typedef struct pm__list PMAPLIST; 132*3b0f7467SBill Paul % 133*3b0f7467SBill Paul %#ifndef __cplusplus 134*3b0f7467SBill Paul %struct pmaplist { 135*3b0f7467SBill Paul % PMAP pml_map; 136*3b0f7467SBill Paul % struct pmaplist *pml_next; 137*3b0f7467SBill Paul %}; 138*3b0f7467SBill Paul %#endif 139*3b0f7467SBill Paul % 140*3b0f7467SBill Paul %#ifdef __cplusplus 141*3b0f7467SBill Paul %extern "C" { 142*3b0f7467SBill Paul %#endif 143*3b0f7467SBill Paul %extern bool_t xdr_pmaplist(XDR *, pmaplist**); 144*3b0f7467SBill Paul %#ifdef __cplusplus 145*3b0f7467SBill Paul %} 146*3b0f7467SBill Paul %#endif 147*3b0f7467SBill Paul % 148*3b0f7467SBill Paul #endif 149*3b0f7467SBill Paul 150*3b0f7467SBill Paul % 151*3b0f7467SBill Paul %/* 152*3b0f7467SBill Paul % * Arguments to callit 153*3b0f7467SBill Paul % */ 154*3b0f7467SBill Paul 155*3b0f7467SBill Paul struct rmtcallargs { 156*3b0f7467SBill Paul unsigned long prog; 157*3b0f7467SBill Paul unsigned long vers; 158*3b0f7467SBill Paul unsigned long proc; 159*3b0f7467SBill Paul opaque args<>; 160*3b0f7467SBill Paul }; 161*3b0f7467SBill Paul #ifdef RPC_HDR 162*3b0f7467SBill Paul % 163*3b0f7467SBill Paul %/* 164*3b0f7467SBill Paul % * Client-side only representation of rmtcallargs structure. 165*3b0f7467SBill Paul % * 166*3b0f7467SBill Paul % * The routine that XDRs the rmtcallargs structure must deal with the 167*3b0f7467SBill Paul % * opaque arguments in the "args" structure. xdr_rmtcall_args() needs to be 168*3b0f7467SBill Paul % * passed the XDR routine that knows the args' structure. This routine 169*3b0f7467SBill Paul % * doesn't need to go over-the-wire (and it wouldn't make sense anyway) since 170*3b0f7467SBill Paul % * the application being called knows the args structure already. So we use a 171*3b0f7467SBill Paul % * different "XDR" structure on the client side, p_rmtcallargs, which includes 172*3b0f7467SBill Paul % * the args' XDR routine. 173*3b0f7467SBill Paul % */ 174*3b0f7467SBill Paul %struct p_rmtcallargs { 175*3b0f7467SBill Paul % u_long prog; 176*3b0f7467SBill Paul % u_long vers; 177*3b0f7467SBill Paul % u_long proc; 178*3b0f7467SBill Paul % struct { 179*3b0f7467SBill Paul % u_int args_len; 180*3b0f7467SBill Paul % char *args_val; 181*3b0f7467SBill Paul % } args; 182*3b0f7467SBill Paul % xdrproc_t xdr_args; /* encodes args */ 183*3b0f7467SBill Paul %}; 184*3b0f7467SBill Paul % 185*3b0f7467SBill Paul #endif /* def RPC_HDR */ 186*3b0f7467SBill Paul % 187*3b0f7467SBill Paul % 188*3b0f7467SBill Paul %/* 189*3b0f7467SBill Paul % * Results of callit 190*3b0f7467SBill Paul % */ 191*3b0f7467SBill Paul 192*3b0f7467SBill Paul struct rmtcallres { 193*3b0f7467SBill Paul unsigned long port; 194*3b0f7467SBill Paul opaque res<>; 195*3b0f7467SBill Paul }; 196*3b0f7467SBill Paul #ifdef RPC_HDR 197*3b0f7467SBill Paul % 198*3b0f7467SBill Paul %/* 199*3b0f7467SBill Paul % * Client-side only representation of rmtcallres structure. 200*3b0f7467SBill Paul % */ 201*3b0f7467SBill Paul %struct p_rmtcallres { 202*3b0f7467SBill Paul % u_long port; 203*3b0f7467SBill Paul % struct { 204*3b0f7467SBill Paul % u_int res_len; 205*3b0f7467SBill Paul % char *res_val; 206*3b0f7467SBill Paul % } res; 207*3b0f7467SBill Paul % xdrproc_t xdr_res; /* decodes res */ 208*3b0f7467SBill Paul %}; 209*3b0f7467SBill Paul % 210*3b0f7467SBill Paul #endif /* def RPC_HDR */ 211*3b0f7467SBill Paul 212*3b0f7467SBill Paul /* 213*3b0f7467SBill Paul * Port mapper procedures 214*3b0f7467SBill Paul */ 215*3b0f7467SBill Paul 216*3b0f7467SBill Paul program PMAPPROG { 217*3b0f7467SBill Paul version PMAPVERS { 218*3b0f7467SBill Paul void 219*3b0f7467SBill Paul PMAPPROC_NULL(void) = 0; 220*3b0f7467SBill Paul 221*3b0f7467SBill Paul bool 222*3b0f7467SBill Paul PMAPPROC_SET(pmap) = 1; 223*3b0f7467SBill Paul 224*3b0f7467SBill Paul bool 225*3b0f7467SBill Paul PMAPPROC_UNSET(pmap) = 2; 226*3b0f7467SBill Paul 227*3b0f7467SBill Paul unsigned long 228*3b0f7467SBill Paul PMAPPROC_GETPORT(pmap) = 3; 229*3b0f7467SBill Paul 230*3b0f7467SBill Paul pmaplist_ptr 231*3b0f7467SBill Paul PMAPPROC_DUMP(void) = 4; 232*3b0f7467SBill Paul 233*3b0f7467SBill Paul rmtcallres 234*3b0f7467SBill Paul PMAPPROC_CALLIT(rmtcallargs) = 5; 235*3b0f7467SBill Paul } = 2; 236*3b0f7467SBill Paul } = 100000; 237*3b0f7467SBill Paul % 238*3b0f7467SBill Paul #ifdef RPC_HDR 239*3b0f7467SBill Paul %#define PMAPVERS_PROTO ((u_long)2) 240*3b0f7467SBill Paul %#define PMAPVERS_ORIG ((u_long)1) 241*3b0f7467SBill Paul % 242*3b0f7467SBill Paul %#else /* ndef _KERNEL */ 243*3b0f7467SBill Paul % 244*3b0f7467SBill Paul %#include <rpc/pmap_rmt.h> 245*3b0f7467SBill Paul % 246*3b0f7467SBill Paul %#ifdef __cplusplus 247*3b0f7467SBill Paul %extern "C" { 248*3b0f7467SBill Paul %#endif 249*3b0f7467SBill Paul % 250*3b0f7467SBill Paul %#define PMAPPORT 111 251*3b0f7467SBill Paul % 252*3b0f7467SBill Paul %struct pmap { 253*3b0f7467SBill Paul % long unsigned pm_prog; 254*3b0f7467SBill Paul % long unsigned pm_vers; 255*3b0f7467SBill Paul % long unsigned pm_prot; 256*3b0f7467SBill Paul % long unsigned pm_port; 257*3b0f7467SBill Paul %}; 258*3b0f7467SBill Paul %typedef struct pmap PMAP; 259*3b0f7467SBill Paul %extern bool_t xdr_pmap (XDR *, struct pmap *); 260*3b0f7467SBill Paul % 261*3b0f7467SBill Paul %struct pmaplist { 262*3b0f7467SBill Paul % struct pmap pml_map; 263*3b0f7467SBill Paul % struct pmaplist *pml_next; 264*3b0f7467SBill Paul %}; 265*3b0f7467SBill Paul %typedef struct pmaplist PMAPLIST; 266*3b0f7467SBill Paul %typedef struct pmaplist *pmaplist_ptr; 267*3b0f7467SBill Paul % 268*3b0f7467SBill Paul % 269*3b0f7467SBill Paul %#ifdef __cplusplus 270*3b0f7467SBill Paul %} 271*3b0f7467SBill Paul %#endif 272*3b0f7467SBill Paul % 273*3b0f7467SBill Paul %#endif /* ndef _KERNEL */ 274*3b0f7467SBill Paul #endif 275*3b0f7467SBill Paul 276