⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 courier.tbl.me

📁 早期freebsd实现
💻 ME
📖 第 1 页 / 共 4 页
字号:
\" $Header: courier.tbl.me,v 1.8 87/03/17 09:32:52 ed Exp $\" $Header: courier.tbl.me,v 1.8 87/03/17 09:32:52 ed Exp $\" $Log:	courier.tbl.me,v $\" Revision 1.8  87/03/17  09:32:52  ed\" Added -I switch to establish search path for DEPENDS UPON files.\" \" Revision 1.7  86/11/22  07:12:05  jqj\" small changes reflecting differences between 4.3bsd and 4.2 Maryland XNS.\" \" Revision 1.6  86/05/12  09:02:43  jqj\" minor revisions\" \" Revision 1.5  85/03/26  06:30:58  jqj\" Revised public alpha-test version, released 26 March 1985\" \" Revision 1.4  85/03/11  16:46:01  jqj\" Public alpha-test version, released 11 March 1985\" .lg 0.fo ''%''.(l C.ps +4.bXNS Courier under UNIX (4.3BSD).ps -4.sp 2.r.he $ XNS Courier $ $Date: 87/03/17 09:32:52 $J.Q. JohnsonComputer Science DepartmentCornell University405 Upson HallIthaca, NY  14853.)l.sh 1 "Introduction".ppThis document describes the implementation and useof the Courier remote procedure call protocol for Berkeley UNIX(version 4.3), with XNS..sp 1.nf.b.(c********************************************************Warning:  this document is a DRAFT design specification.It has not yet been fully implemented, and the details ofthe interface it specifies (particularly with respect to Courier servers) are subject to change.  Send designcomments to jqj@cornell.ARPA or jqj@cornell.UUCP.********************************************************.)c.r.fi.sp 1.uh "Changes since previous revision:".npAdded discussion of encapsulated protocols..npAdded discussion of Clearinghouse library calls for finding a connection,and relationship of connections to outstanding RPCs..uh "Earlier changes:".npChanged names of generated file names to include version number.Added discussion on scope of names vs. DEPENDS UPON modules..npUsers must now link Courier program ``Foo'' with Foo1_support.o..npAdded some discussion of freeing dynamic storage via clear_Foo..npChanged.i CourierOpen()to take ns_addr structure rather than a string host name.  Routines forconverting from name to address (using Clearinghouse) have not yet beendesigned. .npChanged ERROR discussion to indicate that an ERROR is mapped to a longwith value > 65535..npChanged description of BDT to reflect use of .i BDTread()and.i BDTwrite() ..npAdded SPPMAXDATA..npChanged discussion of BulkData constants to indicate that things nowwork correctly..sh 2 "General Description".ppCourier is both a protocol and a specification language.The protocol describes how remote procedures are invoked andhow parameters and results of various data types are transmitted.The specification language, somewhat reminiscent of Mesa,provides a simple way of defining the remote interfaces of distributedprograms..ppThis implementation is an attempt to allow UNIX C programmers toconstruct distributed Courier programs to communicate with otherCourier implementations layered on XNS.  It thus requires kernelsupport for XNS Sequenced Packet Protocol sockets..ppThe simplest form of distributed program using Courierconsists of three parts.The first is the specification,written in the Courier language.The specification must declare all procedures ofthe program that will be called remotely (the.i "server procedures" ).The next part is the implementation, in C, of the server procedures.Finally, there is the client portion of the program, also in C, which callsthe server procedures.Note that either the client or server portion of the program may beomitted if the UNIX program is designed to act with a non-UNIXpartner; for example, a simple printing client under UNIX might sendfiles to a Xerox laser printer using the Printing protocol publishedand supported by Xerox..sh 2 "Acknowledgements".ppContributors to the current implementation have includedJQ Johnson, the primary implementor of the current version of theCourier compiler under UNIX,Eric Cooper, the author of the original UNIX Courier/TCP compiler,Jeff Mogul, the author of the exception signalling mechanism usedhere to handle abort and reject messages,James O'Toole, Chris Torek, and Mark Weiser,the authors of the 4.2BSD version of UNIX kernel support for XNS,Keith Sklower, the author of the present (4.3BSD) version of UNIX kernel support,Lee Moore, and Bill Nesheim..ppSome of the software is copyright 1984 by Eric Cooper, and is forresearch use only; it may be freely distributed but may not besold as a commercial product..sh 2 "References".ppThis document assumes familiarity with the Courier language,details of which may be found inthe Courier protocol definition,.i "Courier: The Remote Procedure Call Protocol" ,Xerox System Integration Standard 038112,December 1981, and ``Appendix F, Bulk Data Transfer,'' Xerox SystemIntegration Standard 038112 Add. 1, October 1982.However, for reference purposes, a grammar for the Courier languagemay be found in the appendix to this document..ppUsers of Bulk Data Transfer will need to interact with SPP (Sequenced Packet Protocol)streams, and may wish to see.i "Internet Transport Protocols" ,Xerox System Integration Standard 028112, December 1981..ppThose interested in the workings of UNIX networking might consult``A 4.2bsd Interprocess Communications Primer,''(DRAFT of March 11, 1983), by Samuel J. Leffler, Robert S. Fabry, andWilliam N. Joy, and the ``4.2BSD System Manual,''(Revised July, 1983), by William Joy .i "et al" ..ppThis document is also supplemented by various UNIX manual pages, notably.i "xnscourier(3) " ,and.i "except(3)" ..sh 2 "Software and Hardware Dependencies".ppThis package requires the following software to operate:.(l4.3BSD (currently tested only for VAX and Gould versions)PCC, 4.3BSD version (probably\-limited testing has been done with Tartan C).)l.ppTo communicate with Xerox products you will need an Ethernetinterface.  Most of the existing example applications depend heavily onthe existence of a Xerox Clearinghouse somewhere on the local network..sh 1 "The Courier Specification Language".ppThe Courier specification language is documented (loosely) in the Xerox``Courier: The Remote Procedure Call Protocol.''  Our compilerimplements a large subset of the specification.  Note that the embeddingof Courier constructs in a message or bit stream is usually irrelevant to theapplications programmer, who need only be concerned with the semanticsof the Courier datatypes.  The courier compiler and runtimes translateCourier datatypes into more easily managed C constructs and handle theprotocol of communication with the remote system..ppThis implementation places several restrictions on the specificationsit will accept:.npNo forward references are permitted in the courierspecification.  The user must reorder type specifications so that alltypes and constants are defined before they are used.Special provisions are made for recursive type declarations of the formtypically found in Bulk Data ``StreamOf'' declarations; see thediscussion of BDT below for details.  General recursive declarations,e.g. that of the Filing ``Filter,'' are not supported..npThe Courier specification is unclear as to lexical issues, name scope, and name overloading.In the current compiler, names should contain only upper and lower caseletters or digits.  Also, all constants, types, andenumeration tags within a module should have distinct names.  Enumerationtag names are currently global; thus, different enumeration types, evenin different modules, may not have the same tags..npConstants of type CHOICE are not fully supported.  In particular, theyare allowed only if the active arm of the choice is a nill record..npConstants of type SEQUENCE are not supported.  Constants of type ARRAY(which have the same syntax as SEQUENCE constants) are supported, but arenot rangechecked; ``Vect: ARRAY 10 OF INTEGER = {1,2,3}'' is accepted,though illegal..npThis implementation supports DEPENDS UPON andreferenced types and constants.  However, the semantics of referencedenumeration constants is unclear.  Also, this implementationdoes not support recursive dependencies..lpWe think we've eliminated all other restrictions, but we're probably wrong..sh 2 "Predefined types".ppThe following typedefs correspond to predefined Courier types:.(b.TSc c cl l l.Courier type	C typedef	Implemented (on VAX) asBOOLEAN	Boolean	char (0==TRUE, 1==FALSE)CARDINAL	Cardinal	unsigned shortLONG CARDINAL	LongCardinal	unsigned longINTEGER	Integer	shortLONG INTEGER	LongInteger	longSTRING	String	char*UNSPECIFIED	Unspecified	unsigned shortLONG UNSPECIFIED	LongUnspecified	unsigned long.TE.)bNote that the representations of these types as seen by the applicationsprogrammer are quite different from those sent over a Courier SPP connection.For example, on the VAX a Cardinal's bytes are swapped before beingsent out in network byte order.  A UNIX String corresponds to a pointer toa null-terminated array of characters while a Courier serialized STRINGcontains a count directly followed by an array of characters.  Notein particular that this implementation doesnot support Courier STRINGs containing the ascii character NUL..sh 2 "Constructed types".ppThe Courier enumeration, array, and (non-null) record typescorrespond to C enumerations, arrays, and structures respectively.The Courier null record corresponds to an int..ppThe Courier sequence and choice typespose some problems when they are mapped into C.This is because an object of one of these typesmust contain run-time information (the length of the sequenceor which choice is present)that is implicit in Courier, but must be made explicitin C.Furthermore, the C programmer must bear the responsibility of keepingthis information consistent..ppA sequence type is mapped into a structure consistingof a Cardinal called.i "length" ,and a pointer to the sequence elements called.i "sequence" .The consistency requirement is that.i "length"indicate the number of elements in the array pointed toby.i "sequence" ..ppA choice type is mapped into a structure consistingof an enumeration element called.i "designator" ,and a union of all the possible choices.The designator is of the enumeration type defined(implicitly or explicitly)in the declaration of the choice type.If this enumeration consists of elements.i A ,.i B ,and.i C ,then the choices are accessible as.i A_case ,.i B_case ,and.i C_case .The consistency requirement is that.i "designator"contain the enumeration value corresponding towhich choice currently occupies the union..sh 2 "Constants".ppThe Courier specification is silent on the precise representations ofnumbers and strings.  In this implementation, numbers may be representedas an optional minus sign followed by asequence of decimal digits or a sequence of octal digits followedby ``B''.  A constant of type STRING is represented by a sequence of characters enclosed indouble quotation marks; it has the same restrictions as a C literal string (noembedded newlines, use ``\e'' as a prefix character, etc.) except that doubledouble quotes are permitted to indicate quotations inside the string..sp 1.nfminInt: INTEGER = -2147483648;		-- or 20000000000B --lastCard: CARDINAL = 177777B;		-- or 65535 --quotedName: STRING = "my name is \"jqj""\en";.fi.sp 1.ppAlthough the Courier language allows constants ofany type to be declared,it is difficult to define constants of constructed typesin C programs.This implementation normally handles constants by creatingstatic variables initialized to the values of the (possibly structured)constants.  The technique is not in general possible for structured constants of type CHOICEsince they are implemented as C ``unions'', so this implementation does notsupport constants which contain a non-null CHOICE.  As a special case,constants whose selected variant is a null record are allowed, e.g..sp 1	myImmediate: BulkData.Immediate = immediate [];.sp 1.sh 2 "Procedures".ppPROCEDURE constants correspond to C functions plus a numeric jump tableindex used in serialization of procedure calls on the network.Procedure declarations may include argument lists, result lists, anderror lists.  The argument list of the corresponding C function contains one parameter for each parameter specified in the declaration,but isexpanded by the addition of 2 parameters (see below).  The result listspecifies a C structure to be returned by the C function containing theresults; for a procedure, Foo, this result list is of type FooResults.Thus, a procedure declared.sp 1	Example: PROCEDURE [ ] RETURNS [ a: Foo, b: Baz ] = 0;.sp 1would be implemented by a C function with no argumentsreturning a structure of type ExampleResults with definitionsomething like.sp 1.nf	typedef struct {		Foo a;		Baz b;	} ExampleResults.fi.sp 1Note that Foo and Baz might be arbitrarily complex structures;see ``Constructed Types'' above..ppImporting a PROCEDURE from a DEPENDS UPON module imports only its jumptable index..sh 2 "ERROR constants".ppAn ERROR constant corresponds to a defined numeric value, and possiblyto a C structure describing its argument list.  For example,.sp 1	OtherError: ERROR [ errorstring: STRING ] = 1;.sp 1corresponds approximately to the C declarations:.sp 1.nf	#define OtherError (1+ERROR_OFFSET)	typedef struct {		String errorstring;	} OtherErrorArgs;.fi.sp 1Note that ERROR values must be specified in the range 0 to 65535, butthat they produce a symbol which appears to the C programmerwith values of type intin the range 65536 to 131171 (in some contexts, the user may wish totreat C error values in the range 0 to 65535 as Unix error numbers).The structure corresponding to the errormay be useful in creating and referencing error argumentsin C functions..sh 2 "Scope of Names".ppGiven a courier program beginning.sp	Example : PROGRAM 537 VERSION 1 =.sptypes and constants declared in this program belong to the module ``Example1'';Their full names have prefixed to them the program name and version number.Given the declaration of ``minInt'' above, the XNS Courier compiler actuallyproduces a header file (here.i Example1.h )containing the C declaration:.sp 1.nfstatic Integer Example1_minInt = {-2147483648};.fi.sp 1.ppThis prefixing implies that a C programmer may refer to several differentremote Courier programs without risk of name collision.For programmer convenience a second header file (here.i Example1_defs.h )is also created by the compiler containing macro definitions which widenthe scope to ``Example1'' and allow the programmer to refer to types andconstants without explicit qualification.  The programmer may includewhichever header file he prefers..ppNote that types and constants obtained from a DEPENDS UPON inclusion mustbe referenced using fully qualified form.  Note also that structure members,procedure arguments, and enum tags are not currently qualified; bewarepotential name conflicts!.sh 1 "Running the Courier Compiler".ppThe specification file is expected to have the extension.i ".cr" .Consider the following skeletal Courier program definition:.sp	Example : PROGRAM 537 VERSION 1 = BEGIN ... END..spThe name of this Courier program is ``Example''; it is version 1.By convention, this specification would stored in the file.i "Example1.cr" .The ``537'' in this example is illustrative only;the program number is uniquely allocated from the range of LongCardinalsby Xerox.  See Appendix B of the Courier standard for program numberassignment procedures..ppThe first step is to use the Courier compiler on the specification.Assuming.i "xnscourier"is in your path (it is .i "/usr/new/xnscourier"on the Berkeley distribution), type.sp 1	xnscourier Example1.cr.sp 1If there are no errors in compilation,the following files will be produced:.(b.TS

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -