home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3543 / UCSPI < prev    next >
Encoding:
Text File  |  1991-06-26  |  9.2 KB  |  207 lines

  1. UNIX Client-Server Program Interface, UCSPI-1991
  2. Copyright 1991, Daniel J. Bernstein
  3.  
  4.  
  5. 1. Introduction
  6.  
  7. This document describes the UNIX Client-Server Program Interface, UCSPI
  8. (ooks-pie), a standard program-based interface to client-server
  9. communications tools under UNIX and its variants. (UNIX is a trademark
  10. of AT&T.)
  11.  
  12. UCSPI is designed to solve several problems. First, although most
  13. networked applications today are essentially independent of the
  14. underlying communications protocol, each program must provide direct
  15. support for each protocol. To run a TCP/IP program over DECnet or
  16. through other IPC mechanisms requires rewriting and recompiling the
  17. program. In contrast, an application written for UCSPI will work without
  18. change over any communications medium.
  19.  
  20. Second, no standard tools are provided for shell scripts to take
  21. advantage of networking. A UCSPI-compliant communications tool is
  22. automatically usable within a shell script or from other languages.
  23.  
  24. Third, current applications have no mechanism for passing information
  25. about a communications link. A typical TCP/IP connection to a BSD
  26. machine may go through inetd, an access controller, and one or two
  27. applications. Each level may do several system calls, disk reads, and
  28. network requests for a name lookup and possibly authentication, instead
  29. of getting the information once and passing it down to the next level.
  30. In the case of logins, a user shell cannot even determine reliably where
  31. the connection is from. In contrast, a UCSPI-compliant tool will collect
  32. all necessary information and pass it through environment variables to
  33. the lower layers.
  34.  
  35. A program is not compliant with UCSPI-1991 if it does not satisfy any
  36. rule marked MUST. It is compliant if it satisfies all the rules marked
  37. MUST. In that case, it is unconditionally compliant if it satisfies all
  38. the rules marked SHOULD, and conditionally compliant otherwise.
  39.  
  40.  
  41. 2. The general UCSPI interface
  42.  
  43. UCSPI clients and servers are executable programs. They MUST accept a
  44. command line in the following general format:
  45.  
  46.   <program> <options> <address> <userprogram> <arg...>
  47.  
  48. Here <program> is the name of the client or server, <options> are zero
  49. or more option arguments, <address> is a protocol-specific address,
  50. <userprogram> is a user-specified program to run upon any connection,
  51. and <arg...> are zero or more arguments to pass through to <userprogram>
  52. without interpretation.
  53.  
  54. UCSPI killers are executable programs. They MUST accept a command line
  55. in the following general format:
  56.  
  57.   <program> <options> <address>
  58.  
  59. Each client, server, and killer MUST support some protocol, as defined
  60. below. <address> SHOULD take up a constant number of arguments, as
  61. defined by the protocol. <options> SHOULD be processed by the getopt
  62. standard; in particular, an argument of -- SHOULD terminate <options>.
  63.  
  64. If <program> is a client or server, it MUST change descriptors 6 and 7
  65. and certain environment variables as described below before executing
  66. <userprogram>. <program> MUST NOT interpret, quote, or unquote <arg...>
  67. in any way. <program> may or may not fork before executing
  68. <userprogram>. <program> SHOULD NOT change its process state in any
  69. other way before executing <userprogram>. <program> SHOULD close
  70. descriptors 6 and 7 immediately upon entry.
  71.  
  72. <program> MUST NOT assume that any other particular descriptors are open
  73. or closed. <program> may assume that a certain number of descriptors are
  74. available. <program> SHOULD NOT assume anything else about its process
  75. state; in particular, <program> SHOULD NOT attempt to find its
  76. controlling terminal device, and <program> SHOULD NOT use getlogin().
  77.  
  78.  
  79. 3. Servers
  80.  
  81. If <program> is a UCSPI server, it MUST wait for a client to connect to
  82. <address>. It SHOULD NOT accept connections from clients that do not
  83. support the same protocol. Upon accepting a connection, it MUST spawn
  84. <userprogram> with the given <arg...>, descriptor 6 reading from the
  85. connection, and descriptor 7 writing to the connection. It MUST then
  86. continue accepting connections to the same <address>.
  87.  
  88. <program> MUST set the following environment variables for
  89. <userprogram>: PROTO=<PROTO>, where <PROTO> is the communications
  90. protocol used by the connection; <PROTO>LOCAL=<serveraddress>, where
  91. <serveraddress> is <address> in a server format defined by the protocol;
  92. <PROTO>REMOTE=<clientaddress>, where <clientaddress> is some information
  93. about the client in a client format defined by the protocol. <PROTO>
  94. MUST consist of characters selected from ABCDEFGHIJKLMNOPQRSTUVWXYZ,
  95. abcdefghijklmnopqrstuvwxyz, and 0123456789; it MUST NOT be longer than
  96. 100 characters. <serveraddress> and <clientaddress> SHOULD use solely
  97. printable ASCII characters, SHOULD have a predefined maximum length,
  98. and MUST NOT contain newline or null.
  99.  
  100. A server SHOULD accept the following options: -q to turn off all error
  101. messages; -Q to turn on error messages, negating any previous -q; -4 to
  102. immediately write the value of <PROTO>LOCAL, followed by a newline, to
  103. descriptor 4, and then close descriptor 4.
  104.  
  105. If the server receives signal SIGTERM, it MUST exit with exit code 0;
  106. this SHOULD NOT terminate any current connections. If the server cannot
  107. perform its functions, it MUST exit with a nonzero exit code. The server
  108. SHOULD interpret SIGINT the same way as SIGTERM.
  109.  
  110.  
  111. 4. Clients
  112.  
  113. If <program> is a UCSPI client, it MUST connect to a server at
  114. <address>. It SHOULD NOT connect to a server that does not support the
  115. same protocol. Upon connecting, it MUST spawn <userprogram> with the
  116. given <arg...>, descriptor 6 reading from the connection, and descriptor
  117. 7 writing to the connection. It SHOULD NOT make further connections.
  118.  
  119. <program> MUST set the following environment variables for
  120. <userprogram>: PROTO=<PROTO>, <PROTO>LOCAL=<clientaddress>, and
  121. <PROTO>REMOTE=<serveraddress>. Here <PROTO>, <clientaddress>, and
  122. <remoteaddress> are under the same rules as for servers, but note that
  123. the roles of <PROTO>LOCAL and <PROTO>REMOTE are reversed. The protocol
  124. may allow <clientaddress> and <serveraddress> to be only partially
  125. defined for a given connection, so the client's <PROTO>LOCAL may not
  126. agree with the server's <PROTO>REMOTE, and vice versa.
  127.  
  128. A client SHOULD accept the following options: -q to turn off all error
  129. messages; -Q to turn on error messages, negating any previous -q.
  130.  
  131. If the client cannot perform its functions, it MUST exit with a nonzero
  132. exit code.
  133.  
  134.  
  135. 5. Killers
  136.  
  137. If <program> is a UCSPI killer, it MUST tell a server at <address> to
  138. immediately stop accepting connections, just as if the server process
  139. had received SIGTERM. It SHOULD NOT have this effect upon a server that
  140. does not support the same protocol. The server may or may not accept the
  141. kill request.
  142.  
  143. A killer SHOULD accept the following options: -q to turn off all error
  144. messages; -Q to turn on error messages, negating any previous -q.
  145.  
  146. If the killer cannot perform its functions, it MUST exit with a nonzero
  147. exit code.
  148.  
  149.  
  150. 6. Protocols
  151.  
  152. A protocol MUST define at least the following information: Its name,
  153. <PROTO>. The format and meaning of <address>. The number of arguments
  154. <address> takes, or a notice that it does not take a constant number of
  155. arguments. Client and server address format. The maximum lengths of
  156. <serveraddress> and <clientaddress>, or a notice that they may grow to
  157. any length. The address character set, if it is not merely alphanumeric.
  158.  
  159. A protocol may define the following information, and more: Supported
  160. options. The forking behavior of clients and servers. Any changes to the
  161. process state not required by UCSPI. The implementation of the
  162. underlying protocol, and how it interacts with other protocols. The
  163. nature of the descriptors passed to <userprogram>. The preferred names
  164. of the client, server, and killer programs. The circumstances under
  165. which a server will ignore a killer.
  166.  
  167. It is expected that all protocols will provide reliable two-way
  168. full-duplex strictly ordered not necessarily timed stream communication,
  169. though some protocols may also provide other types of communication
  170. (e.g., expedited [``out-of-band''] transmission, in which the stream is
  171. no longer ordered).
  172.  
  173. All clients and servers must obey any rules imposed by a protocol in
  174. order to support that protocol. If a program supporting a protocol
  175. cannot be unconditionally compliant with UCSPI-1991, the protocol is
  176. at most conditionally compliant.
  177.  
  178.  
  179. 7. Protocol management
  180.  
  181. Public protocol definitions may be registered with the UCSPI
  182. Administrator. The UCSPI Administrator will normally refuse a
  183. registration request only on the grounds of a namespace problem, and in
  184. that case he will suggest an acceptable name.
  185.  
  186. All protocol names beginning with X are reserved for experimental or
  187. nonstandard use. All protocol names beginning with x are reserved for
  188. extended namespaces whose management is allocated to other authorities.
  189.  
  190. Further requests for interpretation or revision of UCSPI should be sent
  191. to the UCSPI Administrator. The UCSPI Administrator may designate one or
  192. more reference implementations of a registered protocol, and where the
  193. reference implementation establishes an interpretation not required by
  194. this document but not in conflict with this document, that
  195. interpretation should be considered binding until the UCSPI standard is
  196. revised.
  197.  
  198.  
  199. The following protocol names have been registered as of 6/16/91:
  200.  
  201.   TCP
  202.   UNDOM
  203.  
  204.  
  205. UCSPI Administrator
  206. Daniel J. Bernstein, brnstnd@nyu.edu
  207.