rsalz@bbn.com (Rich Salz) (03/04/88)
Submitted-by: Stephen X. Nahm <sxn@Sun.COM> Posting-number: Volume 13, Issue 85 Archive-name: rpc3.9/part08 [ THERE ARE 15 PARTS; DON'T BE FOOLED BY MY MISTAKE IN SOME EARLIER PARTS. --r$ ] #! /bin/sh # This is a shell archive. To extract, remove the header and type "sh filename" # cd rpcgen echo x - rpc_svcout.c cat > rpc_svcout.c <<'Funky_Stuff' /* @(#)rpc_svcout.c 1.2 87/11/24 3.9 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #ifndef lint static char sccsid[] = "@(#)rpc_svcout.c 1.6 87/06/24 (C) 1987 SMI"; #endif /* * rpc_svcout.c, Server-skeleton outputter for the RPC protocol compiler * Copyright (C) 1987, Sun Microsytsems, Inc. */ #include <stdio.h> #include <strings.h> #include "rpc_parse.h" #include "rpc_util.h" static char RQSTP[] = "rqstp"; static char TRANSP[] = "transp"; static char ARG[] = "argument"; static char RESULT[] = "result"; static char ROUTINE[] = "local"; /* * write most of the service, that is, everything but the registrations. */ void write_most() { list *l; definition *def; version_list *vp; for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind == DEF_PROGRAM) { for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { f_print(fout, "\nstatic void "); pvname(def->def_name, vp->vers_num); f_print(fout, "();"); } } } f_print(fout, "\n\n"); f_print(fout, "main()\n"); f_print(fout, "{\n"); f_print(fout, "\tSVCXPRT *%s;\n", TRANSP); f_print(fout, "\n"); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind != DEF_PROGRAM) { continue; } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { f_print(fout, "\tpmap_unset(%s, %s);\n", def->def_name, vp->vers_name); } } } /* * write a registration for the given transport */ void write_register(transp) char *transp; { list *l; definition *def; version_list *vp; f_print(fout, "\n"); f_print(fout, "\t%s = svc%s_create(RPC_ANYSOCK", TRANSP, transp); if (streq(transp, "tcp")) { f_print(fout, ", 0, 0"); } f_print(fout, ");\n"); f_print(fout, "\tif (%s == NULL) {\n", TRANSP); f_print(fout, "\t\tfprintf(stderr, \"cannot create %s service.\\n\");\n", transp); f_print(fout, "\t\texit(1);\n"); f_print(fout, "\t}\n"); for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind != DEF_PROGRAM) { continue; } for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { f_print(fout, "\tif (!svc_register(%s, %s, %s, ", TRANSP, def->def_name, vp->vers_name); pvname(def->def_name, vp->vers_num); f_print(fout, ", IPPROTO_%s)) {\n", streq(transp, "udp") ? "UDP" : "TCP"); f_print(fout, "\t\tfprintf(stderr, \"unable to register (%s, %s, %s).\\n\");\n", def->def_name, vp->vers_name, transp); f_print(fout, "\t\texit(1);\n"); f_print(fout, "\t}\n"); } } } /* * write the rest of the service */ void write_rest() { f_print(fout, "\tsvc_run();\n"); f_print(fout, "\tfprintf(stderr, \"svc_run returned\\n\");\n"); f_print(fout, "\texit(1);\n"); f_print(fout, "}\n"); } void write_programs(storage) char *storage; { list *l; definition *def; for (l = defined; l != NULL; l = l->next) { def = (definition *) l->val; if (def->def_kind == DEF_PROGRAM) { write_program(def, storage); } } } static write_program(def, storage) definition *def; char *storage; { version_list *vp; proc_list *proc; int filled; for (vp = def->def.pr.versions; vp != NULL; vp = vp->next) { f_print(fout, "\n"); if (storage != NULL) { f_print(fout, "%s ", storage); } f_print(fout, "void\n"); pvname(def->def_name, vp->vers_num); f_print(fout, "(%s, %s)\n", RQSTP, TRANSP); f_print(fout, " struct svc_req *%s;\n", RQSTP); f_print(fout, " SVCXPRT *%s;\n", TRANSP); f_print(fout, "{\n"); filled = 0; f_print(fout, "\tunion {\n"); for (proc = vp->procs; proc != NULL; proc = proc->next) { if (streq(proc->arg_type, "void")) { continue; } filled = 1; f_print(fout, "\t\t"); ptype(proc->arg_prefix, proc->arg_type, 0); pvname(proc->proc_name, vp->vers_num); f_print(fout, "_arg;\n"); } if (!filled) { f_print(fout, "\t\tint fill;\n"); } f_print(fout, "\t} %s;\n", ARG); f_print(fout, "\tchar *%s;\n", RESULT); f_print(fout, "\tbool_t (*xdr_%s)(), (*xdr_%s)();\n", ARG, RESULT); f_print(fout, "\tchar *(*%s)();\n", ROUTINE); f_print(fout, "\n"); f_print(fout, "\tswitch (%s->rq_proc) {\n", RQSTP); if (!nullproc(vp->procs)) { f_print(fout, "\tcase NULLPROC:\n"); f_print(fout, "\t\tsvc_sendreply(%s, xdr_void, NULL);\n", TRANSP); f_print(fout, "\t\treturn;\n\n"); } for (proc = vp->procs; proc != NULL; proc = proc->next) { f_print(fout, "\tcase %s:\n", proc->proc_name); f_print(fout, "\t\txdr_%s = xdr_%s;\n", ARG, stringfix(proc->arg_type)); f_print(fout, "\t\txdr_%s = xdr_%s;\n", RESULT, stringfix(proc->res_type)); f_print(fout, "\t\t%s = (char *(*)()) ", ROUTINE); pvname(proc->proc_name, vp->vers_num); f_print(fout, ";\n"); f_print(fout, "\t\tbreak;\n\n"); } f_print(fout, "\tdefault:\n"); printerr("noproc", TRANSP); f_print(fout, "\t\treturn;\n"); f_print(fout, "\t}\n"); f_print(fout, "\tbzero(&%s, sizeof(%s));\n", ARG, ARG); printif("getargs", TRANSP, "&", ARG); printerr("decode", TRANSP); f_print(fout, "\t\treturn;\n"); f_print(fout, "\t}\n"); f_print(fout, "\t%s = (*%s)(&%s, %s);\n", RESULT, ROUTINE, ARG, RQSTP); f_print(fout, "\tif (%s != NULL && !svc_sendreply(%s, xdr_%s, %s)) {\n", RESULT, TRANSP, RESULT, RESULT); printerr("systemerr", TRANSP); f_print(fout, "\t}\n"); printif("freeargs", TRANSP, "&", ARG); f_print(fout, "\t\tfprintf(stderr, \"unable to free arguments\\n\");\n"); f_print(fout, "\t\texit(1);\n"); f_print(fout, "\t}\n"); f_print(fout, "}\n\n"); } } static printerr(err, transp) char *err; char *transp; { f_print(fout, "\t\tsvcerr_%s(%s);\n", err, transp); } static printif(proc, transp, prefix, arg) char *proc; char *transp; char *prefix; char *arg; { f_print(fout, "\tif (!svc_%s(%s, xdr_%s, %s%s)) {\n", proc, transp, arg, prefix, arg); } nullproc(proc) proc_list *proc; { for (; proc != NULL; proc = proc->next) { if (streq(proc->proc_num, "0")) { return (1); } } return (0); } Funky_Stuff len=`wc -c < rpc_svcout.c` if [ $len != 7245 ] ; then echo error: rpc_svcout.c was $len bytes long, should have been 7245 fi echo x - rpc_util.c cat > rpc_util.c <<'Funky_Stuff' /* @(#)rpc_util.c 1.2 87/11/24 3.9 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ #ifndef lint static char sccsid[] = "@(#)rpc_util.c 1.5 87/06/24 (C) 1987 SMI"; #endif /* * rpc_util.c, Utility routines for the RPC protocol compiler * Copyright (C) 1987, Sun Microsystems, Inc. */ #include <stdio.h> #include "rpc_scan.h" #include "rpc_parse.h" #include "rpc_util.h" char curline[MAXLINESIZE]; /* current read line */ char *where = curline; /* current point in line */ int linenum = 0; /* current line number */ char *infilename; /* input filename */ #define NFILES 4 char *outfiles[NFILES]; /* output file names */ int nfiles; FILE *fout; /* file pointer of current output */ FILE *fin; /* file pointer of current input */ list *defined; /* list of defined things */ /* * Reinitialize the world */ reinitialize() { bzero(curline, MAXLINESIZE); where = curline; linenum = 0; defined = NULL; } /* * string equality */ streq(a, b) char *a; char *b; { return (strcmp(a, b) == 0); } /* * find a value in a list */ char * findval(lst, val, cmp) list *lst; char *val; int (*cmp) (); { for (; lst != NULL; lst = lst->next) { if ((*cmp) (lst->val, val)) { return (lst->val); } } return (NULL); } /* * store a value in a list */ void storeval(lstp, val) list **lstp; char *val; { list **l; list *lst; for (l = lstp; *l != NULL; l = (list **) & (*l)->next); lst = ALLOC(list); lst->val = val; lst->next = NULL; *l = lst; } static findit(def, type) definition *def; char *type; { return (streq(def->def_name, type)); } static char * fixit(type, orig) char *type; char *orig; { definition *def; def = (definition *) FINDVAL(defined, type, findit); if (def == NULL || def->def_kind != DEF_TYPEDEF) { return (orig); } switch (def->def.ty.rel) { case REL_VECTOR: return (def->def.ty.old_type); case REL_ALIAS: return (fixit(def->def.ty.old_type, orig)); default: return (orig); } } char * fixtype(type) char *type; { return (fixit(type, type)); } char * stringfix(type) char *type; { if (streq(type, "string")) { return ("wrapstring"); } else { return (type); } } void ptype(prefix, type, follow) char *prefix; char *type; int follow; { if (prefix != NULL) { if (streq(prefix, "enum")) { f_print(fout, "enum "); } else { f_print(fout, "struct "); } } if (streq(type, "bool")) { f_print(fout, "bool_t "); } else if (streq(type, "string")) { f_print(fout, "char *"); } else { f_print(fout, "%s ", follow ? fixtype(type) : type); } } static typedefed(def, type) definition *def; char *type; { if (def->def_kind != DEF_TYPEDEF || def->def.ty.old_prefix != NULL) { return (0); } else { return (streq(def->def_name, type)); } } isvectordef(type, rel) char *type; relation rel; { definition *def; for (;;) { switch (rel) { case REL_VECTOR: return (!streq(type, "string")); case REL_ARRAY: return (0); case REL_POINTER: return (0); case REL_ALIAS: def = (definition *) FINDVAL(defined, type, typedefed); if (def == NULL) { return (0); } type = def->def.ty.old_type; rel = def->def.ty.rel; } } } static char * locase(str) char *str; { char c; static char buf[100]; char *p = buf; while (c = *str++) { *p++ = (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c; } *p = 0; return (buf); } void pvname(pname, vnum) char *pname; char *vnum; { f_print(fout, "%s_%s", locase(pname), vnum); } /* * print a useful (?) error message, and then die */ void error(msg) char *msg; { printwhere(); f_print(stderr, "%s, line %d: ", infilename, linenum); f_print(stderr, "%s\n", msg); crash(); } /* * Something went wrong, unlink any files that we may have created and then * die. */ crash() { int i; for (i = 0; i < nfiles; i++) { (void) unlink(outfiles[i]); } exit(1); } void record_open(file) char *file; { if (nfiles < NFILES) { outfiles[nfiles++] = file; } else { f_print(stderr, "too many files!\n"); crash(); } } static char expectbuf[100]; static char *toktostr(); /* * error, token encountered was not the expected one */ void expected1(exp1) tok_kind exp1; { s_print(expectbuf, "expected '%s'", toktostr(exp1)); error(expectbuf); } /* * error, token encountered was not one of two expected ones */ void expected2(exp1, exp2) tok_kind exp1, exp2; { s_print(expectbuf, "expected '%s' or '%s'", toktostr(exp1), toktostr(exp2)); error(expectbuf); } /* * error, token encountered was not one of 3 expected ones */ void expected3(exp1, exp2, exp3) tok_kind exp1, exp2, exp3; { s_print(expectbuf, "expected '%s', '%s' or '%s'", toktostr(exp1), toktostr(exp2), toktostr(exp3)); error(expectbuf); } void tabify(f, tab) FILE *f; int tab; { while (tab--) { (void) fputc('\t', f); } } static token tokstrings[] = { {TOK_IDENT, "identifier"}, {TOK_CONST, "const"}, {TOK_RPAREN, ")"}, {TOK_LPAREN, "("}, {TOK_RBRACE, "}"}, {TOK_LBRACE, "{"}, {TOK_LBRACKET, "["}, {TOK_RBRACKET, "]"}, {TOK_STAR, "*"}, {TOK_COMMA, ","}, {TOK_EQUAL, "="}, {TOK_COLON, ":"}, {TOK_SEMICOLON, ";"}, {TOK_UNION, "union"}, {TOK_STRUCT, "struct"}, {TOK_SWITCH, "switch"}, {TOK_CASE, "case"}, {TOK_DEFAULT, "default"}, {TOK_ENUM, "enum"}, {TOK_TYPEDEF, "typedef"}, {TOK_INT, "int"}, {TOK_SHORT, "short"}, {TOK_LONG, "long"}, {TOK_UNSIGNED, "unsigned"}, {TOK_DOUBLE, "double"}, {TOK_FLOAT, "float"}, {TOK_CHAR, "char"}, {TOK_STRING, "string"}, {TOK_OPAQUE, "opaque"}, {TOK_BOOL, "bool"}, {TOK_VOID, "void"}, {TOK_PROGRAM, "program"}, {TOK_VERSION, "version"}, {TOK_EOF, "??????"} }; static char * toktostr(kind) tok_kind kind; { token *sp; for (sp = tokstrings; sp->kind != TOK_EOF && sp->kind != kind; sp++); return (sp->str); } static printbuf() { char c; int i; int cnt; # define TABSIZE 4 for (i = 0; c = curline[i]; i++) { if (c == '\t') { cnt = 8 - (i % TABSIZE); c = ' '; } else { cnt = 1; } while (cnt--) { (void) fputc(c, stderr); } } } static printwhere() { int i; char c; int cnt; printbuf(); for (i = 0; i < where - curline; i++) { c = curline[i]; if (c == '\t') { cnt = 8 - (i % TABSIZE); } else { cnt = 1; } while (cnt--) { (void) fputc('^', stderr); } } (void) fputc('\n', stderr); } Funky_Stuff len=`wc -c < rpc_util.c` if [ $len != 7773 ] ; then echo error: rpc_util.c was $len bytes long, should have been 7773 fi echo x - rpc_util.h cat > rpc_util.h <<'Funky_Stuff' /* @(#)rpc_util.h 1.2 87/11/24 3.9 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* @(#)rpc_util.h 1.6 87/06/24 (C) 1987 SMI */ /* * rpc_util.h, Useful definitions for the RPC protocol compiler * Copyright (C) 1987, Sun Microsystems, Inc. */ extern char *malloc(); #define alloc(size) malloc((unsigned)(size)) #define ALLOC(object) (object *) malloc(sizeof(object)) extern char *sprintf(); #define s_print (void) sprintf #define f_print (void) fprintf struct list { char *val; struct list *next; }; typedef struct list list; /* * Global variables */ #define MAXLINESIZE 1024 extern char curline[MAXLINESIZE]; extern char *where; extern int linenum; extern char *infilename; extern FILE *fout; extern FILE *fin; extern list *defined; /* * rpc_util routines */ void storeval(); #define STOREVAL(list,item) \ storeval(list,(char *)item) char *findval(); #define FINDVAL(list,item,finder) \ findval(list, (char *) item, finder) char *fixtype(); char *stringfix(); void pvname(); void ptype(); int isvectordef(); int streq(); void error(); void expected1(); void expected2(); void expected3(); void tabify(); void record_open(); /* * rpc_cout routines */ void cprint(); void emit(); /* * rpc_hout routines */ void print_datadef(); /* * rpc_svcout routines */ void write_most(); void write_register(); void write_rest(); void write_programs(); /* * rpc_clntout routines */ void write_stubs(); Funky_Stuff len=`wc -c < rpc_util.h` if [ $len != 2666 ] ; then echo error: rpc_util.h was $len bytes long, should have been 2666 fi cd .. echo done with directory rpcgen echo x - rpcsvc echo creating directory rpcsvc mkdir rpcsvc cd rpcsvc echo x - Makefile cat > Makefile <<'Funky_Stuff' # # @(#)Makefile 1.6 87/11/30 3.9 RPCSRC # # RPCCOM = rpcgen LIB = -lrpclib DESTDIR= HDRS= klm_prot.h mount.h nfs_prot.h nlm_prot.h rex.h rquota.h rnusers.h\ rquota.h rstat.h sm_inter.h spray.h yppasswd.h yp.h XFILES= bootparam_prot.x klm_prot.x mount.x nfs_prot.x nlm_prot.x \ rex.x rnusers.x rquota.x rstat.x sm_inter.x spray.x yppasswd.x yp.x BIN= rstat_svc GEN= rstat_svc.c rstat_xdr.c all: $(HDRS) $(BIN) install: $(HDRS) $(XFILES) @echo "Creating RPC service headers directory" -mkdir ${DESTDIR}/usr/include/rpcsvc && \ chown bin ${DESTDIR}/usr/include/rpcsvc && \ chmod 755 ${DESTDIR}/usr/include/rpcsvc @echo "Installing RPC service header and definition files" for i in $(HDRS) $(XFILES); do \ (install -c -m 644 $$i ${DESTDIR}/usr/include/rpcsvc) done -mkdir ${DESTDIR}/etc && chown bin ${DESTDIR}/etc && \ chmod 755 ${DESTDIR}/etc @echo "Installing RPC services in ${DESTDIR}/etc" @set -x;for i in ${BIN}; do \ (install -c -s $$i ${DESTDIR}/etc/$$i); done rstat_svc: rstat_proc.o rstat_svc.o rstat_xdr.o $(CC) $(LDFLAGS) -o $@ rstat_proc.o rstat_svc.o rstat_xdr.o $(LIB) rstat_proc.c: rstat.h klm_prot.h: $(RPCCOM) -h klm_prot.x -o $@ mount.h: $(RPCCOM) -h mount.x -o $@ nfs_prot.h: $(RPCCOM) -h nfs_prot.x -o $@ nlm_prot.h: $(RPCCOM) -h nlm_prot.x -o $@ rex.h: $(RPCCOM) -h rex.x -o $@ rnusers.h: $(RPCCOM) -h rnusers.x -o $@ rquota.h: $(RPCCOM) -h rquota.x -o $@ rstat.h: $(RPCCOM) -h rstat.x -o $@ sm_inter.h: $(RPCCOM) -h sm_inter.x -o $@ spray.h: $(RPCCOM) -h spray.x -o $@ yp.h: $(RPCCOM) -h yp.x -o $@ yppasswd.h: $(RPCCOM) -h yppasswd.x -o $@ rstat_svc.c: rstat.x $(RPCCOM) -s udp rstat.x -o $@ rstat_xdr.c: rstat.x $(RPCCOM) -c rstat.x -o $@ clean cleanup: rm -f *.o $(GEN) $(BIN) Funky_Stuff len=`wc -c < Makefile` if [ $len != 1755 ] ; then echo error: Makefile was $len bytes long, should have been 1755 fi echo x - bootparam_prot.x cat > bootparam_prot.x <<'Funky_Stuff' /* @(#)bootparam_prot.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)bootparam_prot.x 1.2 87/06/24 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * RPC for bootparms service. * There are two procedures: * WHOAMI takes a net address and returns a client name and also a * likely net address for routing * GETFILE takes a client name and file identifier and returns the * server name, server net address and pathname for the file. * file identifiers typically include root, swap, pub and dump */ #ifdef RPC_HDR %#include <rpc/types.h> %#include <sys/time.h> %#include <sys/errno.h> %#include <nfs/nfs.h> #endif const MAX_MACHINE_NAME = 255; const MAX_PATH_LEN = 1024; const MAX_FILEID = 32; const IP_ADDR_TYPE = 1; typedef string bp_machine_name_t<MAX_MACHINE_NAME>; typedef string bp_path_t<MAX_PATH_LEN>; typedef string bp_fileid_t<MAX_FILEID>; struct ip_addr_t { char net; char host; char lh; char impno; }; union bp_address switch (int address_type) { case IP_ADDR_TYPE: ip_addr_t ip_addr; }; struct bp_whoami_arg { bp_address client_address; }; struct bp_whoami_res { bp_machine_name_t client_name; bp_machine_name_t domain_name; bp_address router_address; }; struct bp_getfile_arg { bp_machine_name_t client_name; bp_fileid_t file_id; }; struct bp_getfile_res { bp_machine_name_t server_name; bp_address server_address; bp_path_t server_path; }; program BOOTPARAMPROG { version BOOTPARAMVERS { bp_whoami_res BOOTPARAMPROC_WHOAMI(bp_whoami_arg) = 1; bp_getfile_res BOOTPARAMPROC_GETFILE(bp_getfile_arg) = 2; } = 1; } = 100026; Funky_Stuff len=`wc -c < bootparam_prot.x` if [ $len != 2823 ] ; then echo error: bootparam_prot.x was $len bytes long, should have been 2823 fi echo x - klm_prot.x cat > klm_prot.x <<'Funky_Stuff' /* @(#)klm_prot.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)klm_prot.x 1.7 87/07/08 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * Kernel/lock manager protocol definition * Copyright (C) 1986 Sun Microsystems, Inc. * * protocol used between the UNIX kernel (the "client") and the * local lock manager. The local lock manager is a deamon running * above the kernel. */ program KLM_PROG { version KLM_VERS { klm_testrply KLM_TEST (struct klm_testargs) = 1; klm_stat KLM_LOCK (struct klm_lockargs) = 2; klm_stat KLM_CANCEL (struct klm_lockargs) = 3; /* klm_granted=> the cancel request fails due to lock is already granted */ /* klm_denied=> the cancel request successfully aborts lock request */ klm_stat KLM_UNLOCK (struct klm_unlockargs) = 4; } = 1; } = 100020; const LM_MAXSTRLEN = 1024; /* * lock manager status returns */ enum klm_stats { klm_granted = 0, /* lock is granted */ klm_denied = 1, /* lock is denied */ klm_denied_nolocks = 2, /* no lock entry available */ klm_working = 3 /* lock is being processed */ }; /* * lock manager lock identifier */ struct klm_lock { string server_name<LM_MAXSTRLEN>; netobj fh; /* a counted file handle */ int pid; /* holder of the lock */ unsigned l_offset; /* beginning offset of the lock */ unsigned l_len; /* byte length of the lock; * zero means through end of file */ }; /* * lock holder identifier */ struct klm_holder { bool exclusive; /* FALSE if shared lock */ int svid; /* holder of the lock (pid) */ unsigned l_offset; /* beginning offset of the lock */ unsigned l_len; /* byte length of the lock; * zero means through end of file */ }; /* * reply to KLM_LOCK / KLM_UNLOCK / KLM_CANCEL */ struct klm_stat { klm_stats stat; }; /* * reply to a KLM_TEST call */ union klm_testrply switch (klm_stats stat) { case klm_denied: struct klm_holder holder; default: /* All other cases return no arguments */ void; }; /* * arguments to KLM_LOCK */ struct klm_lockargs { bool block; bool exclusive; struct klm_lock alock; }; /* * arguments to KLM_TEST */ struct klm_testargs { bool exclusive; struct klm_lock alock; }; /* * arguments to KLM_UNLOCK */ struct klm_unlockargs { struct klm_lock alock; }; Funky_Stuff len=`wc -c < klm_prot.x` if [ $len != 3486 ] ; then echo error: klm_prot.x was $len bytes long, should have been 3486 fi echo x - mount.x cat > mount.x <<'Funky_Stuff' /* @(#)mount.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)mount.x 1.2 87/09/18 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * Protocol description for the mount program */ const MNTPATHLEN = 1024; /* maximum bytes in a pathname argument */ const MNTNAMLEN = 255; /* maximum bytes in a name argument */ const FHSIZE = 32; /* size in bytes of a file handle */ /* * The fhandle is the file handle that the server passes to the client. * All file operations are done using the file handles to refer to a file * or a directory. The file handle can contain whatever information the * server needs to distinguish an individual file. */ typedef opaque fhandle<FHSIZE>; /* * If a status of zero is returned, the call completed successfully, and * a file handle for the directory follows. A non-zero status indicates * some sort of error. The status corresponds with UNIX error numbers. */ union fhstatus switch (unsigned fhs_status) { case 0: fhandle fhs_fhandle; default: void; }; /* * The type dirpath is the pathname of a directory */ typedef string dirpath<MNTPATHLEN>; /* * The type name is used for arbitrary names (hostnames, groupnames) */ typedef string name<MNTNAMLEN>; /* * A list of who has what mounted */ struct mountlist { name ml_hostname; dirpath ml_directory; mountlist *ml_next; }; /* * A list of netgroups */ typedef struct groupnode *groups; struct groupnode { name gr_name; groups *gr_next; }; /* * A list of what is exported and to whom */ struct exports { dirpath ex_dir; groups ex_groups; exports *ex_next; }; program MOUNTPROG { /* * Version one of the mount protocol communicates with version two * of the NFS protocol. The only connecting point is the fhandle * structure, which is the same for both protocols. */ version MOUNTVERS { /* * Does no work. It is made available in all RPC services * to allow server reponse testing and timing */ void MOUNTPROC_NULL(void) = 0; /* * If fhs_status is 0, then fhs_fhandle contains the * file handle for the directory. This file handle may * be used in the NFS protocol. This procedure also adds * a new entry to the mount list for this client mounting * the directory. * Unix authentication required. */ fhstatus MOUNTPROC_MNT(dirpath) = 1; /* * Returns the list of remotely mounted filesystems. The * mountlist contains one entry for each hostname and * directory pair. */ mountlist MOUNTPROC_DUMP(void) = 2; /* * Removes the mount list entry for the directory * Unix authentication required. */ void MOUNTPROC_UMNT(dirpath) = 3; /* * Removes all of the mount list entries for this client * Unix authentication required. */ void MOUNTPROC_UMNTALL(void) = 4; /* * Returns a list of all the exported filesystems, and which * machines are allowed to import it. */ exports MOUNTPROC_EXPORT(void) = 5; /* * Identical to MOUNTPROC_EXPORT above */ exports MOUNTPROC_EXPORTALL(void) = 6; } = 1; } = 100005; Funky_Stuff len=`wc -c < mount.x` if [ $len != 4293 ] ; then echo error: mount.x was $len bytes long, should have been 4293 fi echo x - nfs_prot.x cat > nfs_prot.x <<'Funky_Stuff' /* @(#)nfs_prot.x 1.2 87/11/12 3.9 RPCSRC */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * nfs_prot.x 1.2 87/10/12 * Copyright 1987 Sun Microsystems, Inc. */ const NFS_PORT = 2049; const NFS_MAXDATA = 8192; const NFS_MAXPATHLEN = 1024; const NFS_MAXNAMLEN = 255; const NFS_FHSIZE = 32; const NFS_COOKIESIZE = 4; const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ /* * File types */ const NFSMODE_FMT = 0170000; /* type of file */ const NFSMODE_DIR = 0040000; /* directory */ const NFSMODE_CHR = 0020000; /* character special */ const NFSMODE_BLK = 0060000; /* block special */ const NFSMODE_REG = 0100000; /* regular */ const NFSMODE_LNK = 0120000; /* symbolic link */ const NFSMODE_SOCK = 0140000; /* socket */ const NFSMODE_FIFO = 0010000; /* fifo */ /* * Error status */ enum nfsstat { NFS_OK= 0, /* no error */ NFSERR_PERM=1, /* Not owner */ NFSERR_NOENT=2, /* No such file or directory */ NFSERR_IO=5, /* I/O error */ NFSERR_NXIO=6, /* No such device or address */ NFSERR_ACCES=13, /* Permission denied */ NFSERR_EXIST=17, /* File exists */ NFSERR_NODEV=19, /* No such device */ NFSERR_NOTDIR=20, /* Not a directory*/ NFSERR_ISDIR=21, /* Is a directory */ NFSERR_FBIG=27, /* File too large */ NFSERR_NOSPC=28, /* No space left on device */ NFSERR_ROFS=30, /* Read-only file system */ NFSERR_NAMETOOLONG=63, /* File name too long */ NFSERR_NOTEMPTY=66, /* Directory not empty */ NFSERR_DQUOT=69, /* Disc quota exceeded */ NFSERR_STALE=70, /* Stale NFS file handle */ NFSERR_WFLUSH=99 /* write cache flushed */ }; /* * File types */ enum ftype { NFNON = 0, /* non-file */ NFREG = 1, /* regular file */ NFDIR = 2, /* directory */ NFBLK = 3, /* block special */ NFCHR = 4, /* character special */ NFLNK = 5, /* symbolic link */ NFSOCK = 6, /* unix domain sockets */ NFBAD = 7, /* unused */ NFFIFO = 8 /* named pipe */ }; /* * File access handle */ struct nfs_fh { opaque data[NFS_FHSIZE]; }; /* * Timeval */ struct nfstime { unsigned seconds; unsigned useconds; }; /* * File attributes */ struct fattr { ftype type; /* file type */ unsigned mode; /* protection mode bits */ unsigned nlink; /* # hard links */ unsigned uid; /* owner user id */ unsigned gid; /* owner group id */ unsigned size; /* file size in bytes */ unsigned blocksize; /* prefered block size */ unsigned rdev; /* special device # */ unsigned blocks; /* Kb of disk used by file */ unsigned fsid; /* device # */ unsigned fileid; /* inode # */ nfstime atime; /* time of last access */ nfstime mtime; /* time of last modification */ nfstime ctime; /* time of last change */ }; /* * File attributes which can be set */ struct sattr { unsigned mode; /* protection mode bits */ unsigned uid; /* owner user id */ unsigned gid; /* owner group id */ unsigned size; /* file size in bytes */ nfstime atime; /* time of last access */ nfstime mtime; /* time of last modification */ }; typedef string filename<NFS_MAXNAMLEN>; typedef string nfspath<NFS_MAXPATHLEN>; /* * Reply status with file attributes */ union attrstat switch (nfsstat status) { case NFS_OK: fattr attributes; default: void; }; struct sattrargs { nfs_fh file; sattr attributes; }; /* * Arguments for directory operations */ struct diropargs { nfs_fh dir; /* directory file handle */ filename name; /* name (up to NFS_MAXNAMLEN bytes) */ }; struct diropokres { nfs_fh file; fattr attributes; }; /* * Results from directory operation */ union diropres switch (nfsstat status) { case NFS_OK: diropokres diropres; default: void; }; union readlinkres switch (nfsstat status) { case NFS_OK: nfspath data; default: void; }; /* * Arguments to remote read */ struct readargs { nfs_fh file; /* handle for file */ unsigned offset; /* byte offset in file */ unsigned count; /* immediate read count */ unsigned totalcount; /* total read count (from this offset)*/ }; /* * Status OK portion of remote read reply */ struct readokres { fattr attributes; /* attributes, need for pagin*/ opaque data<NFS_MAXDATA>; }; union readres switch (nfsstat status) { case NFS_OK: readokres reply; default: void; }; /* * Arguments to remote write */ struct writeargs { nfs_fh file; /* handle for file */ unsigned beginoffset; /* beginning byte offset in file */ unsigned offset; /* current byte offset in file */ unsigned totalcount; /* total write count (to this offset)*/ opaque data<NFS_MAXDATA>; }; struct createargs { diropargs where; sattr attributes; }; struct renameargs { diropargs from; diropargs to; }; struct linkargs { nfs_fh from; diropargs to; }; struct symlinkargs { diropargs from; nfspath to; sattr attributes; }; typedef opaque nfscookie[NFS_COOKIESIZE]; /* * Arguments to readdir */ struct readdirargs { nfs_fh dir; /* directory handle */ nfscookie cookie; unsigned count; /* number of directory bytes to read */ }; struct entry { unsigned fileid; filename name; nfscookie cookie; entry *nextentry; }; struct dirlist { entry *entries; bool eof; }; union readdirres switch (nfsstat status) { case NFS_OK: dirlist reply; default: void; }; struct statfsokres { unsigned tsize; /* preferred transfer size in bytes */ unsigned bsize; /* fundamental file system block size */ unsigned blocks; /* total blocks in file system */ unsigned bfree; /* free blocks in fs */ unsigned bavail; /* free blocks avail to non-superuser */ }; union statfsres switch (nfsstat status) { case NFS_OK: statfsokres reply; default: void; }; /* * Remote file service routines */ program NFS_PROGRAM { version NFS_VERSION { void NFSPROC_NULL(void) = 0; attrstat NFSPROC_GETATTR(nfs_fh) = 1; attrstat NFSPROC_SETATTR(sattrargs) = 2; void NFSPROC_ROOT(void) = 3; diropres NFSPROC_LOOKUP(diropargs) = 4; readlinkres NFSPROC_READLINK(nfs_fh) = 5; readres NFSPROC_READ(readargs) = 6; void NFSPROC_WRITECACHE(void) = 7; attrstat NFSPROC_WRITE(writeargs) = 8; diropres NFSPROC_CREATE(createargs) = 9; nfsstat NFSPROC_REMOVE(diropargs) = 10; nfsstat NFSPROC_RENAME(renameargs) = 11; nfsstat NFSPROC_LINK(linkargs) = 12; nfsstat NFSPROC_SYMLINK(symlinkargs) = 13; diropres NFSPROC_MKDIR(createargs) = 14; nfsstat NFSPROC_RMDIR(diropargs) = 15; readdirres NFSPROC_READDIR(readdirargs) = 16; statfsres NFSPROC_STATFS(nfs_fh) = 17; } = 2; } = 100003; Funky_Stuff len=`wc -c < nfs_prot.x` if [ $len != 7684 ] ; then echo error: nfs_prot.x was $len bytes long, should have been 7684 fi echo x - nlm_prot.x cat > nlm_prot.x <<'Funky_Stuff' /* @(#)nlm_prot.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro */ /* * Network lock manager protocol definition * Copyright (C) 1986 Sun Microsystems, Inc. * * protocol used between local lock manager and remote lock manager */ #ifdef RPC_HDR %#define LM_MAXSTRLEN 1024 %#define MAXNAMELEN LM_MAXSTRLEN+1 #endif /* * status of a call to the lock manager */ enum nlm_stats { nlm_granted = 0, nlm_denied = 1, nlm_denied_nolocks = 2, nlm_blocked = 3, nlm_denied_grace_period = 4 }; struct nlm_holder { bool exclusive; int svid; netobj oh; unsigned l_offset; unsigned l_len; }; union nlm_testrply switch (nlm_stats stat) { case nlm_denied: struct nlm_holder holder; default: void; }; struct nlm_stat { nlm_stats stat; }; struct nlm_res { netobj cookie; nlm_stat stat; }; struct nlm_testres { netobj cookie; nlm_testrply stat; }; struct nlm_lock { string caller_name<LM_MAXSTRLEN>; netobj fh; /* identify a file */ netobj oh; /* identify owner of a lock */ int svid; /* generated from pid for svid */ unsigned l_offset; unsigned l_len; }; struct nlm_lockargs { netobj cookie; bool block; bool exclusive; struct nlm_lock alock; bool reclaim; /* used for recovering locks */ int state; /* specify local status monitor state */ }; struct nlm_cancargs { netobj cookie; bool block; bool exclusive; struct nlm_lock alock; }; struct nlm_testargs { netobj cookie; bool exclusive; struct nlm_lock alock; }; struct nlm_unlockargs { netobj cookie; struct nlm_lock alock; }; #ifdef RPC_HDR %/* % * The following enums are actually bit encoded for efficient % * boolean algebra.... DON'T change them..... % */ #endif enum fsh_mode { fsm_DN = 0, /* deny none */ fsm_DR = 1, /* deny read */ fsm_DW = 2, /* deny write */ fsm_DRW = 3 /* deny read/write */ }; enum fsh_access { fsa_NONE = 0, /* for completeness */ fsa_R = 1, /* read only */ fsa_W = 2, /* write only */ fsa_RW = 3 /* read/write */ }; struct nlm_share { string caller_name<LM_MAXSTRLEN>; netobj fh; netobj oh; fsh_mode mode; fsh_access access; }; struct nlm_shareargs { netobj cookie; nlm_share share; bool reclaim; }; struct nlm_shareres { netobj cookie; nlm_stats stat; int sequence; }; struct nlm_notify { string name<MAXNAMELEN>; long state; }; /* * Over-the-wire protocol used between the network lock managers */ program NLM_PROG { version NLM_VERS { nlm_testres NLM_TEST(struct nlm_testargs) = 1; nlm_res NLM_LOCK(struct nlm_lockargs) = 2; nlm_res NLM_CANCEL(struct nlm_cancargs) = 3; nlm_res NLM_UNLOCK(struct nlm_unlockargs) = 4; /* * remote lock manager call-back to grant lock */ nlm_res NLM_GRANTED(struct nlm_testargs)= 5; /* * message passing style of requesting lock */ void NLM_TEST_MSG(struct nlm_testargs) = 6; void NLM_LOCK_MSG(struct nlm_lockargs) = 7; void NLM_CANCEL_MSG(struct nlm_cancargs) =8; void NLM_UNLOCK_MSG(struct nlm_unlockargs) = 9; void NLM_GRANTED_MSG(struct nlm_testargs) = 10; void NLM_TEST_RES(nlm_testres) = 11; void NLM_LOCK_RES(nlm_res) = 12; void NLM_CANCEL_RES(nlm_res) = 13; void NLM_UNLOCK_RES(nlm_res) = 14; void NLM_GRANTED_RES(nlm_res) = 15; } = 1; version NLM_VERSX { nlm_shareres NLM_SHARE(nlm_shareargs) = 20; nlm_shareres NLM_UNSHARE(nlm_shareargs) = 21; nlm_res NLM_NM_LOCK(nlm_lockargs) = 22; void NLM_FREE_ALL(nlm_notify) = 23; } = 3; } = 100021; Funky_Stuff len=`wc -c < nlm_prot.x` if [ $len != 3476 ] ; then echo error: nlm_prot.x was $len bytes long, should have been 3476 fi echo x - rex.x cat > rex.x <<'Funky_Stuff' /* @(#)rex.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)rex.x 1.3 87/09/18 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * Remote execution (rex) protocol specification */ const STRINGSIZE = 1024; typedef string rexstring<1024>; /* * values to pass to REXPROC_SIGNAL */ const SIGINT = 2; /* interrupt */ /* * Values for rst_flags, below */ const REX_INTERACTIVE = 1; /* interactive mode */ struct rex_start { rexstring rst_cmd<>; /* list of command and args */ rexstring rst_host; /* working directory host name */ rexstring rst_fsname; /* working directory file system name */ rexstring rst_dirwithin;/* working directory within file system */ rexstring rst_env<>; /* list of environment */ unsigned int rst_port0; /* port for stdin */ unsigned int rst_port1; /* port for stdout */ unsigned int rst_port2; /* port for stderr */ unsigned int rst_flags; /* options - see const above */ }; struct rex_result { int rlt_stat; /* integer status code */ rexstring rlt_message; /* string message for human consumption */ }; struct sgttyb { unsigned four; /* always equals 4 */ opaque chars[4]; /* chars[0] == input speed */ /* chars[1] == output speed */ /* chars[2] == kill character */ /* chars[3] == erase character */ unsigned flags; }; /* values for speeds above (baud rates) */ const B0 = 0; const B50 = 1; const B75 = 2; const B110 = 3; const B134 = 4; const B150 = 5; const B200 = 6; const B300 = 7; const B600 = 8; const B1200 = 9; const B1800 = 10; const B2400 = 11; const B4800 = 12; const B9600 = 13; const B19200 = 14; const B38400 = 15; /* values for flags above */ const TANDEM = 0x00000001; /* send stopc on out q full */ const CBREAK = 0x00000002; /* half-cooked mode */ const LCASE = 0x00000004; /* simulate lower case */ const ECHO = 0x00000008; /* echo input */ const CRMOD = 0x00000010; /* map \r to \r\n on output */ const RAW = 0x00000020; /* no i/o processing */ const ODDP = 0x00000040; /* get/send odd parity */ const EVENP = 0x00000080; /* get/send even parity */ const ANYP = 0x000000c0; /* get any parity/send none */ const NLDELAY = 0x00000300; /* \n delay */ const NL0 = 0x00000000; const NL1 = 0x00000100; /* tty 37 */ const NL2 = 0x00000200; /* vt05 */ const NL3 = 0x00000300; const TBDELAY = 0x00000c00; /* horizontal tab delay */ const TAB0 = 0x00000000; const TAB1 = 0x00000400; /* tty 37 */ const TAB2 = 0x00000800; const XTABS = 0x00000c00; /* expand tabs on output */ const CRDELAY = 0x00003000; /* \r delay */ const CR0 = 0x00000000; const CR1 = 0x00001000; /* tn 300 */ const CR2 = 0x00002000; /* tty 37 */ const CR3 = 0x00003000; /* concept 100 */ const VTDELAY = 0x00004000; /* vertical tab delay */ const FF0 = 0x00000000; const FF1 = 0x00004000; /* tty 37 */ const BSDELAY = 0x00008000; /* \b delay */ const BS0 = 0x00000000; const BS1 = 0x00008000; const CRTBS = 0x00010000; /* do backspacing for crt */ const PRTERA = 0x00020000; /* \ ... / erase */ const CRTERA = 0x00040000; /* " \b " to wipe out char */ const TILDE = 0x00080000; /* hazeltine tilde kludge */ const MDMBUF = 0x00100000; /* start/stop output on carrier intr */ const LITOUT = 0x00200000; /* literal output */ const TOSTOP = 0x00400000; /* SIGTTOU on background output */ const FLUSHO = 0x00800000; /* flush output to terminal */ const NOHANG = 0x01000000; /* no SIGHUP on carrier drop */ const L001000 = 0x02000000; const CRTKIL = 0x04000000; /* kill line with " \b " */ const PASS8 = 0x08000000; const CTLECH = 0x10000000; /* echo control chars as ^X */ const PENDIN = 0x20000000; /* tp->t_rawq needs reread */ const DECCTQ = 0x40000000; /* only ^Q starts after ^S */ const NOFLSH = 0x80000000; /* no output flush on signal */ struct tchars { unsigned six; /* always equals 6 */ opaque chars[6]; /* chars[0] == interrupt char */ /* chars[1] == quit char */ /* chars[2] == start output char */ /* chars[3] == stop output char */ /* chars[4] == end-of-file char */ /* chars[5] == input delimeter (like nl) */ }; struct ltchars { unsigned six; /* always equals 6 */ opaque chars[6]; /* chars[0] == stop process signal */ /* chars[1] == delayed stop process signal */ /* chars[2] == reprint line */ /* chars[3] == flush output */ /* chars[4] == word erase */ /* chars[5] == literal next character */ unsigned mode; }; struct rex_ttysize { int ts_lines; int ts_cols; }; struct rex_ttymode { sgttyb basic; /* standard unix tty flags */ tchars more; /* interrupt, kill characters, etc. */ ltchars yetmore; /* special Berkeley characters */ unsigned andmore; /* and Berkeley modes */ }; /* values for andmore above */ const LCRTBS = 0x0001; /* do backspacing for crt */ const LPRTERA = 0x0002; /* \ ... / erase */ const LCRTERA = 0x0004; /* " \b " to wipe out char */ const LTILDE = 0x0008; /* hazeltine tilde kludge */ const LMDMBUF = 0x0010; /* start/stop output on carrier intr */ const LLITOUT = 0x0020; /* literal output */ const LTOSTOP = 0x0040; /* SIGTTOU on background output */ const LFLUSHO = 0x0080; /* flush output to terminal */ const LNOHANG = 0x0100; /* no SIGHUP on carrier drop */ const LL001000 = 0x0200; const LCRTKIL = 0x0400; /* kill line with " \b " */ const LPASS8 = 0x0800; const LCTLECH = 0x1000; /* echo control chars as ^X */ const LPENDIN = 0x2000; /* needs reread */ const LDECCTQ = 0x4000; /* only ^Q starts after ^S */ const LNOFLSH = 0x8000; /* no output flush on signal */ program REXPROG { version REXVERS { /* * Start remote execution */ rex_result REXPROC_START(rex_start) = 1; /* * Wait for remote execution to terminate */ rex_result REXPROC_WAIT(void) = 2; /* * Send tty modes */ void REXPROC_MODES(rex_ttymode) = 3; /* * Send window size change */ void REXPROC_WINCH(rex_ttysize) = 4; /* * Send other signal */ void REXPROC_SIGNAL(int) = 5; } = 1; } = 100017; Funky_Stuff len=`wc -c < rex.x` if [ $len != 7115 ] ; then echo error: rex.x was $len bytes long, should have been 7115 fi echo x - rnusers.x cat > rnusers.x <<'Funky_Stuff' /* @(#)rnusers.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)rnusers.x 1.2 87/09/20 Copyr 1987 Sun Micro */ /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape * media and as a part of the software program in whole or part. Users * may copy or modify Sun RPC without charge, but are not authorized * to license or distribute it to anyone else except as part of a product or * program developed by the user. * * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. * * Sun RPC is provided with no support and without any obligation on the * part of Sun Microsystems, Inc. to assist in its use, correction, * modification or enhancement. * * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC * OR ANY PART THEREOF. * * In no event will Sun Microsystems, Inc. be liable for any lost revenue * or profits or other special, indirect and consequential damages, even if * Sun has been advised of the possibility of such damages. * * Sun Microsystems, Inc. * 2550 Garcia Avenue * Mountain View, California 94043 */ /* * Find out about remote users */ const MAXUSERS = 100; const MAXUTLEN = 256; struct utmp { string ut_line<MAXUTLEN>; string ut_name<MAXUTLEN>; string ut_host<MAXUTLEN>; int ut_time; }; struct utmpidle { utmp ui_utmp; unsigned int ui_idle; }; typedef utmp utmparr<MAXUSERS>; typedef utmpidle utmpidlearr<MAXUSERS>; program RUSERSPROG { /* * Includes idle information */ version RUSERSVERS_IDLE { int RUSERSPROC_NUM(void) = 1; utmpidlearr RUSERSPROC_NAMES(void) = 2; utmpidlearr RUSERSPROC_ALLNAMES(void) = 3; } = 1; /* * Old version does not include idle information */ version RUSERSVERS_ORIG { int RUSERSPROC_NUM(void) = 1; utmparr RUSERSPROC_NAMES(void) = 2; utmparr RUSERSPROC_ALLNAMES(void) = 3; } = 2; } = 100002; Funky_Stuff len=`wc -c < rnusers.x` if [ $len != 2151 ] ; then echo error: rnusers.x was $len bytes long, should have been 2151 fi echo x - rquota.x cat > rquota.x <<'Funky_Stuff' /* @(#)rquota.x 1.2 87/11/12 3.9 RPCSRC */ /* @(#)rquota.x 1.2 87/09/20 Copyr 1987 Sun Micro */ /* * Remote quota protocol * Requires unix authentication */ const RQ_PATHLEN = 1024; struct getquota_args { string gqa_pathp<RQ_PATHLEN>; /* path to filesystem of interest */ int gqa_uid; /* inquire about quota for uid */ }; /* * remote quota structure */ struct rquota { int rq_bsize; /* block size for block counts */ bool rq_active; /* indicates whether quota is active */ unsigned int rq_bhardlimit; /* absolute limit on disk blks alloc */ unsigned int rq_bsoftlimit; /* preferred limit on disk blks */ unsigned int rq_curblocks; /* current block count */ unsigned int rq_fhardlimit; /* absolute limit on allocated files */ unsigned int rq_fsoftlimit; /* preferred file limit */ unsigned int rq_curfiles; /* current # allocated files */ unsigned int rq_btimeleft; /* time left for excessive disk use */ unsigned int rq_ftimeleft; /* time left for excessive files */ }; enum gqr_status { Q_OK = 1, /* quota returned */ Q_NOQUOTA = 2, /* noquota for uid */ Q_EPERM = 3 /* no permission to access quota */ }; union getquota_rslt switch (gqr_status status) { case Q_OK: rquota gqr_rquota; /* valid if status == Q_OK */ case Q_NOQUOTA: void; case Q_EPERM: void; }; program RQUOTAPROG { version RQUOTAVERS { /* * Get all quotas */ getquota_rslt RQUOTAPROC_GETQUOTA(getquota_args) = 1; /* * Get active quotas only */ getquota_rslt RQUOTAPROC_GETACTIVEQUOTA(getquota_args) = 2; } = 1; } = 11; Funky_Stuff len=`wc -c < rquota.x` if [ $len != 1565 ] ; then echo error: rquota.x was $len bytes long, should have been 1565 fi echo x - rstat.x cd .. echo more files to follow exit -- Please send comp.sources.unix-related mail to rsalz@uunet.uu.net.