home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / protocol / newprotocol.txt < prev    next >
Text File  |  2020-01-01  |  47KB  |  1,070 lines

  1. SOME MINOR ADDITIONS TO THE KERMIT PROTOCOL
  2.  
  3.   Begun: November 1997 
  4.  
  5.   D R A F T  #  11
  6.  
  7. Thu Oct 17 16:33:57 2002
  8.  
  9. ROUGH DRAFT - TO BE FLESHED OUT AFTER DISCUSSION
  10.  
  11. For next book... prefixing.  Suppose you have 98 Ctrl-C's in a row,
  12. and Ctrl-C is unprefixed.  Then you get ~~xxx (where x is Ctrl-C), because
  13. 97th and 98th are only two in a row and don't get collapsed.  But this leaves
  14. three of them in a row in the packet, which can kill the transfer.  Ditto for
  15. plus signs, or any other char.  There has to be a rule to prevent this.
  16. (Maybe Ctrl-C should always be prefixed, since C-Kermit accepts ^C^C^C to
  17. break out of packet mode by default.)
  18.  
  19. The same thing can happen (with very low probability) at the end of the data
  20. field, before the block check.  For that matter, it's possible to have a
  21. Type-3 block check of "+++", which could disconnect the modem.  Not that I've
  22. ever heard of such a thing happening in 20 years...
  23.  
  24.  
  25. Items that still need to be addressed:
  26.  
  27.  . Do something about Error packets -- block check type, frame number?
  28.  
  29.  . Add something about sending the file's original name -- a new attribute
  30.    maybe.
  31.  
  32.  . A generic way to represent file permissions on the wire, and then
  33.    REMOTE SET FILE PERMISSION, etc.  Very cumbersome if done portably...
  34.    Also, how to represent permissions in "universal directory listings"?
  35.  
  36. 0. REMOTE SET TRANSFER MODE (DONE)
  37.  
  38. Allows the client to set the server's transfer mode.  Code: 410.
  39. Value: 0 for automatic, 1 for manual.
  40.  
  41. How about REMOTE SET FILE PATTERNS { ON, OFF }?  Not needed, since REMOTE SET
  42. TRANSFER-MODE takes care of this.  If it were needed, however, then we'd also
  43. need to way for the client to modify the server's pattern list.
  44.  
  45. 0.0.1. REMOTE SET MATCH { FIFO, DOTFILE } { ON, OFF }
  46.  
  47. DOTFILE = 330
  48. FIFO    = 331
  49. 332-339 saved for other wildcard/match settings.
  50.  
  51. (Note: 320 is FILE CHARACTER-SET)
  52.  
  53. 0.1. WHATAMI2
  54.  
  55. For greater client/server coupling however, we're going to need a second
  56. WHATAMI field.
  57.  
  58. 0.1.1. Transfer Mode
  59.  
  60. REMOTE SET TRANSFER MODE isn't good enough.  GET /BINARY or GET /TEXT really
  61. have to force the transfer mode to the one indicated, no matter what, just as
  62. SEND /TEXT (or /BINARY) does.  But it only sets the *prevailing* mode.
  63. Internally these also set TRANSFER MODE to MANUAL for the duration of the
  64. command, but there is presently no protocol for the client to tell the server
  65. its transfer mode, so if the server has XFER MODE AUTO and PATTERNS ON, this
  66. will still take precedence on a per-file basis.  In the worst case "get /text
  67. foo.com" will result in a binary transfer if "*.com" is in the server's binary
  68. pattern list.
  69.  
  70. Thus we need a way for GET /<mode> to *temporarily* set the server's transfer
  71. mode to MANUAL.  One way to do this is already sketched out for Extended GET.
  72. But it requires the client to send an O packet, which few servers understand.
  73. This should be implemented eventually anyway, but in the meantime we can do
  74. the same thing by adding a new WHATAMI bit.  Unfortunately, however, the
  75. WHATAMI field is full, so now we need a second one, which directly follows the
  76. (variable-length) system ID field.  The new field is called WHATAMI2, with the
  77. same format as WHATAMI:
  78.  
  79.     Bit 5    Bit 4      Bit 3      Bit 2      Bit 1      Bit 0
  80.   +--------+----------+----------+----------+-----------+----------+
  81.   |     1  | reserved | reserved | CHARSETS | RECURSIVE | XFERMODE |
  82.   +--------+----------+----------+----------+-----------+----------+
  83.  
  84.   Bit 5
  85.     Is set to 1 to indicate that the other bits are to be believed.
  86.     This allows this field to be skipped over in the event it is not
  87.     implemented, but a subsequent field is added.
  88.  
  89.   XFERMODE
  90.     0 = Automatic.
  91.     1 = Manual.
  92.  
  93.   RECURSIVE (See Section 0.1.2)
  94.     0 = This will not be a recursive transfer
  95.     1 = This is to be a recursive transfer
  96.     
  97.   CHARSETS (See Section 0.1.3)
  98.     0 = My TRANSFER CHARACTER SET is TRANSPARENT
  99.     1 = My TRANSFER CHARACTER SET is not TRANSPARENT
  100.  
  101. The binary bit-encoded value is made printable by tochar() and then decoded
  102. by the receiver using unchar().
  103.  
  104. This mechanism lets the client control the server's transfer mode.  The
  105. client's transfer mode is controlled by:
  106.  
  107.  a. The most recent SET TRANSFER MODE { AUTOMATIC, MANUAL }, which
  108.     sets the prevailing mode (the default is AUTOMATIC); and:
  109.  
  110.  b. Any mode switch (/BINARY, /TEXT, etc) included with a SEND, GET, or other
  111.     file-transfer command, which sets the transfer to MANUAL for the duration
  112.     of the command; the prevailing mode is restored afterwards.
  113.  
  114. The WHATAMI2 XFERMODE bit lets the client control the server's transfer mode.
  115. This is automatically "temporary", since each client SEND/GET command will set
  116. it appropriately.
  117.  
  118. 0.1.2. Pathnames
  119.  
  120. Next problem: GET /RECURSIVE works without having to tell the server to SET
  121. SEND PATHNAMES RELATIVE first because GET /RECURSIVE has its own packet type.
  122. But SEND /RECURSIVE still requires you to SET RECEIVE PATHNAMES RELATIVE on
  123. the server first, since there is nothing special in the I or S packet to tell
  124. the server to expect a recursive transfer.
  125.  
  126. The WHATAMI2 RECURSIVE bit lets the client tell the server that incoming files
  127. will have pathnames attached and the server should automatically switch to
  128. RECEIVE PATHNAMES RELATIVE.  But what if the user does not want the server
  129. to do this?  We need:
  130.  
  131.   SET RECEIVE PATHNAMES AUTO
  132.  
  133. to be the default, which means OFF normally, but RELATIVE if I'm a server
  134. and the client sets the WHATAMI2 RECURSIVE bit.  If the user has set RECEIVE
  135. PATHNAMES to anything else but AUTO, then that value is used instead.
  136. The RECEIVE PATHNAMES value is saved and restored around the transfer, so if
  137. it was AUTO it goes back to AUTO.
  138.  
  139. The reserved bits in the WHATAMI2 field must be set to 0.  At such time as
  140. they are defined, their definitions must be such that the 0 value corresponds
  141. to previous and/or default behavior, so that their use will not cause
  142. interoperability problems with Kermit versions in which they are still
  143. reserved.
  144.  
  145. 0.1.3. Character Sets
  146.  
  147. Now, assuming all the aforementioned rules are in effect, we still have
  148. problem.  Suppose the client and server are on "like platforms" and therefore
  149. would slip into FILE TYPE BINARY and TRANSFER MODE MANUAL automatically.  This
  150. is just fine as long as character-set translation was not desired.  Therefore
  151. the WHATAMI2 word also includes a CHARSETS bit, which is 0 for Kermits whose
  152. TRANSFER CHARACTER-SET is TRANSPARENT, and 1 if an actual transfer charset
  153. has been selected.  Now the rule is:
  154.  
  155. Do not switch to TRANSFER MODE MANUAL automatically if the WHATAMI2:CSET bit
  156. is 1.
  157.  
  158. But this makes it potentially harder to recover broken transfers between like
  159. systems.
  160.  
  161.  
  162. 1. DIRECTORY OPERATIONS
  163.  
  164. The aim of these changes is to allow the exchange of directory trees or file
  165. systems.  It is assumed that all file systems are either tree-structured or
  166. flat.  Hardly any protocol changes are needed, mainly just agreements on data
  167. formats.  Most of the features are implemented outside the protocol: recursive
  168. SEND commands, automatic directory creation during RECEIVE commands, etc.
  169.  
  170. 1.0. Directory Name Format Selection (DONE)
  171.  
  172. (This is simplified considerably in Draft 2 after I implemented it in C-K...)
  173.  
  174. SET FILE NAMES { CONVERTED, LITERAL }
  175.   Now applies to pathnames too.  For pathnames, CONVERTED means that the
  176.   native directory notation is converted to standard format when sending,
  177.   and the standard format is assumed when receiving.
  178.  
  179. The related command:
  180.  
  181.   SET { SEND, RECEIVE } PATHNAMES { OFF, ABSOLUTE, RELATIVE }
  182.  
  183. then applies as usual.  PATHNAMES are OFF by default, in which case nothing is
  184. different.  When SEND PATHNAMES is ABSOLUTE or RELATIVE, then the FILE NAMES
  185. setting is applied to them just as it is to the rest of the filename.
  186.  
  187. When receiving files, a Kermit program should be expected to understand its
  188. own native format and the standard one; it cannot be expected to understand a
  189. foreign directory notation.  Thus SET FILE NAMES CONVERTED should be used
  190. between unlike systems.
  191.  
  192. Notes:
  193.  
  194.  1. There is no reason why there can't be separate SET FILE NAMES commands
  195.     and settings for each direction.
  196.  
  197.  2. We haven't said anything that affects the protocol yet, that comes
  198.     in the next section.
  199.  
  200. 1.1. Kermit Protocol Directory Name Representation (DONE)
  201.  
  202. UNIX notation shall be used for directories when FILE NAMES are CONVERTED.
  203. Forward slash (/) is the directory separator.  If a / appears as a literal
  204. character in a directory name, then it should be written as //.  A file or
  205. directory specification beginning with / is absolute, otherise it is relative.
  206. This is more or less the same scheme used by Info-ZIP and so it is widely
  207. proven in the real world.
  208.  
  209. As always, the rule regarding letters when FILE NAMES are CONVERTED is to
  210. uppercase when sending.  The receiver handles letters according to its own
  211. convention.
  212.  
  213. Symbolic names like "." and ".." should be expanded before transmission.
  214.  
  215. For the time being, we should use the rule that device names are always
  216. discarded (e.g. DOS disk letters, VMS disk names, etc).
  217.  
  218. Note: I have this working now in VMS as well as UNIX:
  219.  
  220.  FILENAMES   SEND PATHNAMES  UNIX Result               VMS Result
  221.   CONVERTED   OFF             OOFA.TXT                  OOFA.TXT 
  222.   CONVERTED   RELATIVE        BLAH/OOFA.TXT             BLAH/OOFA.TXT 
  223.   CONVERTED   ABSOLUTE        /W/FDC/TMP/BLAH/OOFA.TXT  /FDC/BLAH/OOFA.TXT
  224.   LITERAL     OFF             oofa.txt                  OOFA.TXT 
  225.   LITERAL     RELATIVE        blah/oofa.txt             [.BLAH]OOFA.TXT 
  226.   LITERAL     ABSOLUTE        /w/fdc/tmp/blah/oofa.txt  [FDC.BLAH]OOFA.TXT
  227.  
  228. 1.2. Client/Server Directory Operations
  229.  
  230. REMOTE MKDIR <name>
  231.   G packet function code "m" (yes, lowercase).  Creates the specified
  232.   directory.  Names are as in 1.1 (absolute or relative).  (DONE)
  233.  
  234. REMOTE RMDIR <name>
  235.   G packet function code "d".  Removes specified directory.  Name can
  236.   be wild.  (DONE)
  237.  
  238. REMOTE RMDIR /RECURSIVE <name>
  239.   G packet function code "t".  Removes specified directory tree and all
  240.   its contents.  Like rm -Rf in UNIX.  Name can be wild.  (NOT DONE)
  241.  
  242. 1.3. GET /RECURSIVE (DONE)
  243.  
  244. New packet types:
  245.  
  246. V for GET /RECURSIVE.
  247.   Tells server to send all files that match the given specification in
  248.   the current or given directory tree.  Otherwise just like G for GET
  249.   (DONE).
  250.  
  251. W for GET /DELETE /RECURSIVE.
  252.   Like V, but the server should delete each file after it is sent
  253.   successfully (DONE).
  254.  
  255. That should do it.
  256.  
  257. 1.4. EXTENDED GET
  258.  
  259. July 1998: No, it shouldn't.  Because what about /RECOVER, etc?  We are nearly
  260. out of (uppercase) packet types, and can't afford to add a new one for every
  261. combination of GET switches; even if we could, this unnecessarily
  262. overcomplicates the FSA that implements the protocol.
  263.  
  264. Definition: Simple GET-Class Packet -- Any of the following:
  265.   R - Original GET packet
  266.   H - GET /DELETE (= RETRIEVE)
  267.   V - GET /RECURSIVE
  268.   W - GET /DELETE /RECURSIVE
  269.  
  270. We should not have used up those packet types, but it's too late now.  From
  271. now on, all new GET options go through a new Extended GET (XGET) packet, type
  272. "O", which is (a) capable of expressing all combinations of GET options
  273. (including those already expressed in the existing simple GET-class packets),
  274. and (b) extensible:
  275.  
  276.   O - (New) Extended GET
  277.  
  278. With this addition, GET-Class Packets include the Simple GET-Class Packets
  279. plus the O-packet.
  280.  
  281. Note that many GET commands are "ambiguous" in the sense that they could
  282. result in either a Simple GET-Class packet or an Extended GET packet.
  283. Suppose the client picks one form, but the server only implements the other?
  284. To resolve this situation in a user-friendly manner, the rule must be:
  285.  
  286.   Any Kermit client that implements Extended GET must also implement all
  287.   of the Simple GET-Class packets (R, H, V, and W).  Any GET command that
  288.   can be expressed in a Simple GET-Class packet must be expressed that way;
  289.   an Extended GET packet should be used only for combinations that are not
  290.   expressible in a Simple GET-Class packet.
  291.   
  292. The server, of course, should accept either form.
  293.  
  294. Negotiation:
  295.  
  296. None.  If a server receives an O packet and does not understand it, it 
  297. returns an Error packet in the normal fashion.
  298.  
  299. Format:
  300.  
  301. Packet type: O.  Data field contains options and selectors in Modified PLV
  302. (Parameter, Length, Value) format.  Modified PLV format is just like PLV
  303. format, except that a special escape character may be placed in the Length
  304. field to indicate that the Value field begins with a 2-character length.
  305. This allows for fields longer than 94, and in fact allows fields up to 8836
  306. bytes long.  Since any printable character is allowed in the regular PLV
  307. length field, this escape character must be either a control character or an
  308. 8-bit character, which is OK, since it will be encoded according to normal
  309. rules (see below).  The escape mechanism should be used only when a value
  310. is longer than 94 bytes, which should happen only with filenames, and then
  311. only rarely.  The escape character is Ctrl-V (SYN, ASCII 22).
  312.  
  313. Parameters:
  314.  
  315. O: Options (bits to ANDed together, result converted to a decimal string):
  316.     1 = Delete each source file after it is sent successfully (/DELETE)
  317.     2 = Recursive (/RECURSIVE)
  318.     4 = Recover (/RECOVER)
  319.     8 = Filename is a command (/COMMAND)
  320.    16 = Reserved
  321.    32 = Reserved
  322.  
  323. *** Is there some reason this is limited to a single 6-bit byte?
  324.  
  325. *** To be added (to first or second byte):
  326.    xx = Use filemode given in yy, no matter what -- overrides all else
  327.    yy = 0 = text, 1 = binary
  328.  
  329. This is to allow GET /TEXT and GET /BINARY in the client to override any other
  330. kind of automatic transfer-mode determination in the server.  If the user says
  331. /TEXT or /BINARY, they mean it.
  332.  
  333. o: Reserved as a second Options byte.
  334.  
  335. M: Local Transfer Mode (sets the server's mode for this transaction only):
  336.    0 = Text
  337.    1 = Binary or Image
  338.    2 = Auto (default)
  339.    3 = Labeled
  340.  
  341. P: Pathnames:
  342.    0 = Server should send with pathnames stripped
  343.    1 = Server should send with relative pathnames   
  344.    2 = Server should send with absolute pathnames
  345.  
  346. N: Name Conversion:
  347.    0 = Server should send with literal names
  348.    1 = Server should send with converted names
  349.  
  350. X: Transfer character set (client tells server which xfer charset to use;
  351.    server picks corresponding file charset automatically by association).
  352.  
  353. E: Exception name or pattern (was X).
  354.    There can be more than one of these.  The entire exception list applies
  355.    to all filespecs.
  356.  
  357. F: Filespec:
  358.    Name or wildcard for requested file(s).
  359.    There can be more than one of these.
  360.  
  361. L: Larger than (size in bytes)
  362.  
  363. S: Smaller than (size in bytes)
  364.  
  365. A: After.  File date-time, yyyymmdd hh:mm:ss, client's local time.
  366.    Only send files modified AFTER the given date-time.
  367.  
  368. a: After2.  File date-time, yyyymmdd hh:mm:ss, client's local time.
  369.    Only send files modified ON OR AFTER the given date-time.
  370.  
  371. B: Before. File date-time, yyyymmdd hh:mm:ss, client's local time.
  372.    Only send files modified BEFORE the given date-time.
  373.  
  374. b: Before2. File date-time, yyyymmdd hh:mm:ss, client's local time.
  375.    Only send files modified ON OR BEFORE the given date-time.
  376.  
  377. C: After.  File date-time, yyyymmdd hh:mm:ss, GMT.
  378.    Only send files modified AFTER the given date-time.
  379.  
  380. c: After2.  File date-time, yyyymmdd hh:mm:ss, GMT.
  381.    Only send files modified ON OR AFTER the given date-time.
  382.  
  383. D: Before. File date-time, yyyymmdd hh:mm:ss, GMT.
  384.    Only send files modified BEFORE the given date-time.
  385.  
  386. c: Before2. File date-time, yyyymmdd hh:mm:ss, GMT.
  387.    Only send files modified ON OR BEFORE the given date-time.
  388.  
  389. @: End of Parameters
  390.  
  391. Note that the P and N parameters raise a tricky question for the command
  392. language, since these parameters can apply separately at each end.  For
  393. example, does GET /FILENAMES:LITERAL mean the server should send filenames
  394. literally, the client store them literally, or both?  Ditto for GET
  395. /COMMAND?  Currently this means the incoming file is to be fed to a command,
  396. as opposed to telling the server that it should be sending from a command
  397. (for which purpose we presently use "!" notation in the filename).
  398.  
  399. O-Packets must be encoded -- unlike S/I/A packets -- because parameters
  400. and/or length fields might have any value at all.  Thus PLV processing by
  401. the server must take place AFTER decoding.
  402.  
  403. Examples:
  404.  
  405. Here are some sample O packets:
  406.  
  407. 1.  ^A0 OO!7F&blah.x@ 0      ; GET /DEL /RECURS /RECOV blah.x
  408. 2.  ^A3 OO!7M!1F&blah.x@ T   ; GET /DEL /RECURS /RECOV /BIN blah.x
  409. 3.  ^A. OO!7F##abc@ 7        ; GET /DEL /RECURS /RECOV abc
  410. 4.  ^A. OO!7F##~#a@ R        ; GET /DEL /RECURS /RECOV aaa
  411. 5.  ^A  O!3FO!7F#V!)abcdefghij...(lots more)...qrstuvwxyz@ 3
  412.  
  413. (1) shows that the M field is omitted when /TEXT or /BINARY not given.
  414. (2) shows that the M field is included when /TEXT or /BINARY is given.
  415. (3) shows how a length field of 3 is encoded as ##.
  416. (4) shows a filename that compresses to 3 characters.
  417.  
  418. (5) shows what happens when a filename is more then 94 chars long --
  419. the O-packet data field begins with an extended header ("!3F"), then the F
  420. parameter length field is a Control-V character, indicating the first two
  421. characters of the value field are a 2-byte length ("!)").  On clear channels
  422. or when Ctrl-V is unprefixed, it will be inserted literally rather than
  423. encoded as "#V".
  424.  
  425. Protocol:
  426.  
  427. If the client sends an option not understood by the server, the server MUST
  428. send an Error packet and return to server command wait.  Otherwise, the
  429. resulting transfer could be incorrect (wrong mode, wrong file, wrong
  430. destination, etc).  Thus, the client should not send options that were not
  431. specified by user (e.g. supply default options that were not given
  432. explicitly).
  433.  
  434. Since filenames can be quite long, and any number of them can be included in
  435. an XGET command, the resulting parameter list could easily be greater than the
  436. negotiated packet length.  Therefore we must allow for a series of O packets,
  437. as we do with A packets.
  438.  
  439. We do, however, require that each parameter be totally contained within a
  440. packet, just as we do for A packets.  Although it might be desirable to allow
  441. filenames, etc, to span packets, there is no pressing need for this (it is not
  442. allowed in F or R packets, nor with A-packet parameters, and nobody is
  443. complaining), and it would add considerable complication to the
  444. implementation.  Therefore, the restriction that a filename must fit within
  445. the negotiated packet length is not changed by this protocol addition.
  446.  
  447. Note that Simple GET-Class packets are not acknowledged; instead the server
  448. reverses the direction of the protocol by sending an S packet.  O packets, on
  449. the other hand, must be numbered and, except for the last (or only) one,
  450. acknowledged individually.  This means the final O packet MUST contain an End
  451. Of Parameters marker (@) as its last parameter.  (Of course the final O-packet
  452. can be NAK'd, in which case the client must retransmit it.)
  453.  
  454. As with any other GET operation, the server responds by resetting the sequence
  455. number to 0 and sending S(0), except in this case, only after the final
  456. O-Packet.  A potential problem occurs if the S(0) sent in response to a final
  457. O-Packet whose sequence number was not 0 is lost.  In this case, the client
  458. might time out and retransmit O(x).  But x is not a valid sequence number any
  459. more so the server's transport layer will reject it with an error packet.  But
  460. this is an unnecessary error, since all the server really needs to do is
  461. retransmit S(0).  To avoid this situation, the following rule should be
  462. added:
  463.  
  464.   When the window size is 1 and a packet arrives, save it (or if memory 
  465.   is at a premium, save its control fields).  Whenever a new packet arrives,
  466.   compare it with the previous one and if it is a duplicate, ignore it.
  467.  
  468. Or... if this causes too much overhead, put another ugly heuristic into the
  469. transport layer similar to the one for E packets...
  470.  
  471. Wildcards and Patterns:
  472.  
  473. Unlike regular GET, XGET should define a standard format for filenames and
  474. patterns, so clients need not know the special syntax of the server's
  475. underlying platform.
  476.  
  477. Thus the following characters in filenames and patterns are reserved:
  478.  
  479.  * = matches any sequence of 0 or more characters
  480.  ? = matches any single character
  481.  / = directory separator (portable filenames are in UNIX format)
  482.  
  483. But how to quote these characters when they are to be taken literally?
  484. First note that we also want to accept platform-specific syntax, and in a
  485. very common case, this includes DOS-format pathnames.  Which rules out
  486. backslash as a quote character.  Similarly for any other ASCII character.
  487. Therefore the quote character should be a control character:
  488.  
  489.   ^V (Control-V)
  490.  
  491. This is natural for UNIX and TOPS-10/20 users and is very unlikely to appear
  492. in a filename (in case it does, it can quote itself).  The Ctrl-V is encoded
  493. with the SET SEND CONTROl-PREFIX provided it is not included in the
  494. SET CONTROL UNPREFIX set.
  495.  
  496. Possible conflicts occur on platforms that use wildcards differently,
  497. e.g. AOS/VS, where "*" matches any string of characters up to a period, and
  498. "+" matches any string of characters.  If incoming "*" is translated to "+",
  499. then how would the client get the AOS/VS functionality?  (With "*." -- so
  500. let's not worry about it.)
  501.  
  502. 2. 32-BIT CRC
  503.  
  504. We might as well, why not.  The code for the CHKT field in the init string 
  505. is "4".  32-bit CRC must not be implemented in the absence of 16-bit CRC.  A
  506. special rule applies here, namely if one Kermit says "4" and the other says
  507. "3", then fall back to "3" instead of "1".  The generating polynomial is:
  508.  
  509.   X^32+X^26+X^23+X^22+X^16+X^12+X^11+X^10+X^8+X^7+X^5+X^4+X^2+X^1+X^0
  510.  
  511. taken "backwards" with the highest-order term in the lowest-order bit.  The
  512. X^32 term is "implied"; the LSB is the X^31 term, etc.  The X^0 term (usually
  513. shown as "+1") results in the MSB being 1.  Code will be based on the well
  514. known and open Gary Brown code that everybody else uses.
  515.  
  516. Unlike the type 1, 2, and 3 block checks, the 32-bit one should be encoded
  517. to never contain a blank.  We can either use the same encoding as for the
  518. 16-bit CRC but excess-33 instead of -32 (resulting in 6 bytes), or we can
  519. write it more compactly as a base-94 number whose lowest digit is "!".  (How
  520. many bytes is that?)
  521.  
  522. (Joe notes that there might not be much value here, but we have learned that
  523. trying to persuade the masses that the reason we don't have such-and-such a
  524. feature that the others (read "Zmodem") have by filling blackboards full of
  525. math never works -- better to just go along...  Anyway, this is just for the
  526. protocol definition, not necessarily to be implemented anywhere, and certainly
  527. not *required* anywhere.)
  528.  
  529. 3. EX-POST-FACTO PER-FILE CRC CHECKING
  530.  
  531. MS-DOS Kermit and C-Kermit can accumulate a 16-bit CRC of an entire
  532. transaction, and they include a rather cumbersome process for comparing the
  533. CRCs afterward, which works only in a client/server setting, and is script
  534. based:
  535.  
  536.   <file-transfer-command>
  537.   if fail <do something>
  538.   remote query kermit crc16
  539.   if not = \v(query) \v(crc16) <we got trouble>
  540.  
  541. Obviously this can be expected to succeed only for binary-mode transfers,
  542. and so scripts that use this technique will break in text mode.
  543.  
  544. A more general mechanism can be added to the protocol itself as follows:
  545.  
  546.  a. Add a new S/I packet parameter, after the last one that is defined,
  547.     whatever that is (don't worry, I'll look it up).  A single byte, this
  548.     character has the same values as the Block Check parameter, except only
  549.     "3" or "4" should be allowed.
  550.  
  551.  b. Add SET commands to turn the feature ON and OFF.  It should be OFF by
  552.     default, to avoid the extra overhead.
  553.  
  554.  c. When ON, it should be operative only for binary-mode transfers.
  555.  
  556.  d. At the end of file, the file sender puts the following in the Z-packet
  557.     data field: The letter C and then the decimal character representation of
  558.     the negotiated type of CRC for the file.
  559.  
  560.  e. If the CRC from (d) does not agree with the receiver's CRC, the receiver
  561.     ACKs the Z packet with a Data field of N, optionally followed by its own
  562.     CRC, otherwise it ACKs with either an empty data field or the letter C
  563.     followed by the CRC (exactly as in the Z packet).  It is up to the
  564.     receiver how to dispose of the file when the CRCs don't match.
  565.  
  566.  f. When the sender receives a CRC mismatch indication, the SEND command must
  567.     fail.  But what does this mean when a file group is being sent?  Should it
  568.     stop and send an error packet or go on to the next file?  This must be a
  569.     user choice, so there will need to be some SET commands...  In any case,
  570.     if it is a SEND /DELETE (aka MOVE) operation, then the source file must
  571.     not be deleted.  Appropriate notations must be made in the transaction
  572.     log, if any, etc.
  573.  
  574. The per-file CRC mechanism operates independently of the \v(crc16) variable,
  575. which accumulates a CRC over the entire transfer, which could obviously become
  576. bollixed if a mixture of text and binary files were transferred in the same
  577. transaction, as can occur with VMS C-Kermit.
  578.  
  579. 4. The Capabilities Mask
  580.  
  581. We're out of bits, except for the "continued" bit.  But if we use the
  582. continuation mechanism, we'll no doubt break every non-Kermit-Project Kermit
  583. implementation on earth, and probably also many of the old ones in our own
  584. collection.  So to add more capability bits, we'll need to leave the
  585. "continued" bit blank, and add the second capabilities mask at the end.
  586.  
  587. But the next available field is after a PLV field (system ID) and so it's
  588. also not in a fixed place...
  589.  
  590. Solution: Recycle the three Checkpoint bytes, since Checkpointing has never
  591. been implemented and nobody has seen the spec.  Currently we have (counting
  592. from 0):
  593.  
  594.   S[13] = '0';  <-- '0' means WONT CHECKPOINT.
  595.   S[14] = '_';
  596.   S[15] = '_';
  597.   S[16] = '_';
  598.  
  599. S[13] (according to the checkpoint proposal) can have the following values:
  600.  
  601.   0 = WONT  I won't do it (SET CHECKPOINT DISABLED)
  602.   1 = WILL  I will do it if asked (SET CHECKPOINT ENABLED)
  603.   2 = DO    Please do it (SET CHECKPOINT ON)
  604.  
  605. Now we give it a new one:
  606.  
  607.   9 = XCAPAS (extended capability field)
  608.  
  609. This clearly identifies the following bytes as capability words and not
  610. some vestige of checkpointing.  The XCAPAS bytes are filled right to left
  611. in normal 6bit+32 format.  Unused XCAPAS bytes are set to accent grave (`),
  612. which is outside the 6bit_32 range and therefore would not be mistaken for
  613. a capability word.
  614.  
  615. New S[16] Capability bits:
  616.  
  617.  1 = UTF8 Filenames (UTF8NAMES)
  618.  2 = GMT (UCT) file timestamps (GMTSTAMPS)
  619.  4 = (free...)
  620.  
  621. 5. Info Exchange (NOT IMPLEMENTED YET)
  622.  
  623. The idea is for the two Kermits to exchange information with each other that
  624. applies to the transaction as a whole, but is beyond the scope of (too
  625. voluminous for) the S/Y or I/Y exchange.
  626.  
  627.   a. Add a new capability bit for this.
  628.   b. The file sender sets this bit in its S packet.
  629.   c. The file receiver agrees by setting the same bit in its ACK(S).
  630.  
  631. At this point, if the two Kermits have agreed, the sender may (but need not)
  632. send an "L" packet, which contains an unencoded parameter-length-value (PLV)
  633. sequence (just like an "A" packet) of information applying to the connection
  634. and the entire transfer.  Parameters (all are optional):
  635.  
  636.   F = (Sender only) Number of files (expressed as decimal string)
  637.  
  638.   L = (Sender only) Total length, decimal string.  Obviously iffy for
  639.       text-mode transfers, but we've always had that problem.
  640.  
  641.   E = Encoding: Kermit transfer character-set designation for text used in 
  642.       any of these fields that can contain arbitrary text.  Default = ASCII.
  643.       Syntax: exactly as in A packet.
  644.  
  645.   H = Hostname (e.g. so local Kermit can show remote host's name on the
  646.       file transfer display).
  647.  
  648.   D = Current directory, syntax according to SET FILE NAMES.
  649.  
  650.   O = Organization name.  Arbitrary text, encoding specified in E.
  651.  
  652.   C = Country code (ISO 3166).
  653.  
  654.   T = Connection type (to allow automatic choices of various things based
  655.       on whether the connection is known to be reliable -- e.g. TCP/IP at
  656.       *both* ends).  Number.  0 = unknown (usually the case when in remote
  657.       mode); 1 = serial port; 2 = ISDN; 3 = TCP; 4 = UDP; 5 = CTERM; 6 = LAT;
  658.       etc etc.
  659.  
  660.   A = Address.  Interpreted according to connection type.  This can be the IP
  661.       hostname, IP address, or other address specific to the network type, or
  662.       telephone phone number in +1(212)7654321 format, for display on the
  663.       other Kermit's screen, or logging, or callback, or any other desired
  664.       reason.  All sorts of uses for this one can be imagined.
  665.  
  666.   X = Encryption identifier (this needs spelling out).
  667.  
  668.   K = Public key for X, when applicable (more thought needed).
  669.  
  670.   N = (Receiver only): No.  Refuses the transaction.  Optionally one or more
  671.       more parameter letters are given as data, to indicate the reason for
  672.       refusal.
  673.  
  674.   Also add specific platform identifier, OS name and version, Kermit software
  675.   name and version, endianness, ...
  676.  
  677. The order doesn't matter, except that if E is given, it must precede any
  678. arbitrary-text fields.  We can have up to 96 parameters, one for each 7-bit
  679. graphic character.  One must be reserved as an escape for when we run out.
  680.  
  681. NOTE: "L" was our last unused uppercase letter for packet types.  Additional
  682. packet types will be lowercase letters or other graphic characters.  At least
  683. one must be reserved as an escape for when we run out.
  684.  
  685. Notes on encyrption (from Jeff):
  686.  
  687. Now that the PGP style of public key encryption is no longer covered by patent
  688. and it looks like the IETF is going to accept PGP encryption as their
  689. standard, Kermit public key encryption could work like this:
  690.  
  691. . The sender and receiver would negotiate the type of encryption to use.
  692.  
  693. . The receiver would then deliver its public key to the sender.  
  694.  
  695. . The sender would then encrypt all data for the transaction using
  696.   that public key, which only the receiver would be able to decrypt.
  697.  
  698. This would allow Kermit to generate keys completely on the fly without any
  699. need for local files or user intervention.
  700.  
  701. 6. Extended Sequence Numbers and Window Size
  702.  
  703. 32 just isn't big enough, e.g. for interplanetary transfers, not to mention
  704. the Internet some days.  But we can't increase it beyond 32 because it is
  705. limited to the half the sequence-number range, which is 64.  So for larger
  706. windows we must increse the sequence number space.  But we can't do this in
  707. the regular sequence number field, at least not significantly, because it is
  708. restricted to a 64-byte codeset (in theory maybe 94, but that too would
  709. require a change in the protocol, and as long as we're changing it, let's
  710. shoot higher).
  711.  
  712. (*** This not so important any more because of streaming ***)
  713.  
  714. 6.1. Negotiation
  715.  
  716.   a. Add a new capability bit for this.
  717.   b. The file sender sets this bit in its S packet.
  718.   c. The file receiver agrees by setting the same bit in its ACK(S).
  719.   d. Add another 2-byte field to the init string, XWINDO.
  720.  
  721. This works exactly like long packet negotiation.  If the bit is set then we
  722. fetch the actual window size from the two XWINDO bytes, which are in excess-32
  723. base-95 notation, just like the extended packet length.  The receiver that
  724. doesn't understand this option, of course, fetches the window size from the
  725. regular WINDO field.  When this option is negotiated, the maximum sequence
  726. number is thus 95^2 - 1 = 9024, and the maximum window size is half that, or
  727. 4512.  A 4512-packet window of 9024-byte packets (the theoretical maximum)
  728. would require about 7MB of packet buffers.  Obviously a smaller actual maximum
  729. can be imposed by the implementation.
  730.  
  731. 6.2. Packet Format
  732.  
  733. When an extended window size is negotiated, the packet sequence number is
  734. indicated as ` (backquote, ASCII 96) to indicate that the full 2-byte base-95
  735. packet number is included in the extended header.  For long packets, this goes
  736. between the length and the header checksum.  For short packets, it forms the
  737. extended header by itself (with the header checksum of course).
  738.  
  739. 6.3. Improved Packet Framing
  740.  
  741. There is nothing in a basic Kermit packet to indicate where the data ends and
  742. the block check begins.  But we have the opportunity in extended-sequence
  743. packets to use a better format.  In these packets, the packet length indicates
  744. the beginning of a PLV format block check.  Parameters are the block-check
  745. codes (1, 2, 3, B, 4).  The length indicates the number of bytes in the block
  746. check.  Then the block check.  In addition to preventing foulups, this allows
  747. the block check type to be varied dynamically throughout the transaction.  It
  748. also allows a graphic character to be placed after the block check in case it
  749. ends with a blank.
  750.  
  751. Thus "Kermit-II" packets add 6 bytes of overhead to short packets:
  752.  
  753.  . The wasted SEQ byte
  754.  . The 3-byte extended header
  755.  . 2 extra bytes for the packet block check
  756.  
  757. and 5 bytes for long packets:
  758.  
  759.  . The wasted SEQ byte
  760.  . 2 bytes in the extended header that is already there
  761.  . 2 extra bytes for the packet block check
  762.  
  763. 7. Supervisory Packets
  764.  
  765. These can be used for "out of band" functions.  Supervisory packets must be
  766. numbered, just like regular ones, because otherwise there is no way for the
  767. receiver to indicate that it was or wasn't received.
  768.  
  769. Let's call this a "u" packet.  It can be sent only by the file sender, and
  770. it can be sent at any time during a transaction if negotiated:
  771.  
  772.   a. Add a new capability bit for this.
  773.   b. The file sender sets this bit in its S packet.
  774.   c. The file receiver agrees by setting the same bit in its ACK(S).
  775.  
  776. Contents are, again, the familiar PLV sequences.  Some possible parameters:
  777.  
  778.   M = Message.  To be logged or shown in the display.
  779.   W = Change window size
  780.   P = Change packet length
  781.   R = Reset to defaults
  782.   S = Sync
  783.   D = Drain
  784.   B = Buffer credit
  785.  
  786. (I'm not really sure yet whether any of these make sense, or what they would
  787. do, or how they would work, or what else we can do here, so this is mainly
  788. just a placeholder.)
  789.  
  790. The sender ACKs with the normal indications (Y or N, length, list of tags).
  791.  
  792. If the file receiver wants to send a supervisory message, it can be placed
  793. into the data field of any D-packet ACK: the letter "u" followed by PLV
  794. sequences (we can't put these in *any* ACK because some already are allowed to
  795. contain arbitrary string data, e.g. ACK(F), tsk tsk).  The file sender
  796. "acknowledges" by sending a "u" packet, which must then be ACK'd by the
  797. receiver with an empty ACK.
  798.  
  799. 8. Compression
  800.  
  801. (Note: much of this discussion also applies to per-file encryption...)
  802.  
  803. This is indicated in the A packet.  The book says attribute * (Encoding) is
  804. the place to do this and lists Huffman Encoding (Q) as an example of
  805. compression.  So we can add something like "Z" for ZIP/Zlib compression.  So
  806. far so good.
  807.  
  808. The " (Type) field that lists the filetype, A (text) or B (binary).
  809. Unfortunately, this has become synonymous with "transfer mode".  Which has not
  810. been a problem until now.
  811.  
  812. What if we want to send a text file with compression?  We must do all the
  813. character-set and record-format conversion first, then compress it, and the
  814. transfer must occur in binary mode, yet the receiver must know to apply its
  815. normal text-mode conversions upon it after decompressing.
  816.  
  817. Questions:
  818.  
  819.  1. Should we define a capability bit for compression?
  820.     . Yes, so the two Kermits can negotiate about it in the normal way.
  821.     . No, because there might be many compression methods.
  822.     Maybe it's best to skip the capability bit and simply lump this in
  823.     with Attribute capability, and then let the Attribute refusal mechanism
  824.     take care of negotiation.
  825.  
  826. But then there's no way for the sender to bid for compression but fall back
  827. to noncompression if the receiver fails to agree.  UNLESS...
  828.  
  829. If the receiver explicitly "ACKs" the compression in its ACK(A), then it will
  830. be compressed, otherwise it won't be.
  831.  
  832.  2. How do we specify that we are sending a compressed text file?
  833.     . The *Z attribute overrides the "A attribute?  No, because old Kermits
  834.       would not know to do this and so would corrupt the file.
  835.     . Always send in binary mode ("B), but notify the receiver in some other
  836.       way that once uncompressed, it's a text file.  This would work with
  837.       old Kermits (the received compressed file would be stored as sent,
  838.       binary, and could be decompressed afterwards).
  839.       
  840. But where is the other info?  How about this:  *ZA means compressed text,
  841. *ZB means compressed binary.
  842.  
  843. When compression was selected, the SET FILE TYPE value would move to the *Z?
  844. field, and the "file type" would be binary
  845.  
  846. 9. Format of System-Dependent File Permissions in A-Packets (DONE)
  847.  
  848. The format of this field (the "," attribute) is interpreted according to the
  849. System ID ("." Attribute).
  850.  
  851. For UNIX (System ID = U1), it's the familiar 3-digit octal number, the
  852. low-order 9 bits of the filemode: Owner, Group, World, e.g. 660 = read/write
  853. access for owner and group, none for world, recorded as a 3-digit octal string.
  854.  
  855. For VMS (System ID = D7), it's a 4-digit hex string, representing the 16-bit
  856. file protection WGOS fields (World,Group,Owner,System), in that order (which
  857. is the reverse of how they're shown in a directory listing); in each field,
  858. Bit 0 = Read, 1 = Write, 2 = Execute, 3 = Delete.  A bit value of 0 means
  859. permission is granted, 1 means permission is denied.  Sample:
  860.  
  861.   r-01-00-^A/!FWERMIT.EXE'" 
  862.   s-01-00-^AE!Y/amd/watsun/w/fdc/new/wermit.exe.DV
  863.   r-02-01-^A]"A."D7""B8#119980101 18:14:05!#8531&872960,$A20B-!7(#512@ #.Y
  864.   s-02-01-^A%"Y.5!                                     ^^^^^^
  865.  
  866. A VMS directory listing shows the file's protection as (E,RWED,RED,RE) which
  867. really means (S=E,O=RWED,G=RED,W=RE), which is reverse order from the internal
  868. storage, so (RE,RED,RWED,E).  Now translate each letter to its corresponding
  869. bit:
  870.  
  871.   RE=0101, RED=1101, RWED=1111, E=0010
  872.  
  873. Now reverse the bits:
  874.  
  875.   RE=1010, RED=0010, RWED=0000, E=1101
  876.  
  877. This gives the 16-bit quantity: 
  878.  
  879.   1010001000001101
  880.  
  881. This is the internal representation of the VMS file permission; in hex:
  882.  
  883.   A20B
  884.  
  885. as shown in the sample packet above.
  886.  
  887. The VMS format probably would also apply to RSX or any other FILES-11 system.
  888.  
  889. 10. Handling of Generic Protection
  890.  
  891. To be used when the two systems are different (and/or do not recognize or
  892. understand each other's local protection codes).
  893.  
  894. First of all, the book is wrong.  This should not be the World protection, 
  895. but the Owner protection.  The other fields should be set according to system
  896. defaults (e.g. UNIX umask, VMS default protection, etc), except that no
  897. non-Owner field should give more permissions than the Owner field.
  898.  
  899. 11. Dates and Times in Attribute Packets
  900.  
  901. In keeping with good protocol design, conversions of dates and times between
  902. two Kermit partners, if they are to be done at all, require a standard
  903. date/time on the wire, so each Kermit program needs to know only how to
  904. convert between its local time and the standard, and does NOT need to know
  905. anything about the other Kermit's timezone.  The standard time is GMT.
  906.  
  907. The date-time attribute in the A packet should be clearly described as LOCAL
  908. TIME, not to be converted.
  909.  
  910. The use of GMT can be negotiated via capability bits.  See Section 4.
  911.  
  912. Ditto for the Extended GET packet described above...
  913.  
  914. 12. Tight Coupling of Client and Server via TELNET Protocol
  915.  
  916. Described in IKSD and TELNET KERMIT OPTION RFCs.
  917.  
  918. 13. REMOTE EXIT (DONE)
  919.  
  920. BYE logs out the server's job.  FINISH returns to either the command prompt
  921. or the shell depending on how the server was started.  But the client does
  922. not necessarily know how the server was started.  REMOTE EXIT addresses this
  923. (partially) by telling the server to exit to the shell, no matter how it was
  924. started.  Format: Generic Server Command X.  Protocol: If EXIT is disabled,
  925. server sends an Error packet and does not exit; otherwise, it sends an ACK
  926. and exits.  The classic problem of the ACK being lost can occur here, just
  927. as it can with BYE, or the B packet.
  928.  
  929. 14. REMOTE STATUS
  930.  
  931. This one is in the Kermit book but was never described or implemented.
  932. Let's define it as a short string that indicates the server's capabilities,
  933. in PLV notation.  The string is returned in the Data field of of the ACK to
  934. the REMOTE STATUS command, and thus may not exceed the negotiated packet
  935. length.  The data field is encoded in the normal fashion.  The parameters
  936. returned are:
  937.  
  938.  0 - Login status (3 bytes)
  939.      0 = Not logged in but login is required
  940.      1 = Logged in as a user
  941.      2 = Logged in anonymously
  942.  
  943.  1 - IKS status (3 bytes)
  944.      0 = IKS not available
  945.      1 = IKS available but not negotiated
  946.      2 = IKS negotiated, indicates tight coupling of client and server
  947.  
  948.  2 - Acceptable Client Packet Type List (up to about 24 bytes):
  949.      A string containing the "top level" commands that are available for
  950.      for execution (i.e. that are both implemented and enabled).  The string
  951.      is composed of the packet types that may be sent to the server when it
  952.      is in server command wait state, e.g. "CGHIJORSVW".  There is no need to
  953.      include standard types such as BDEFXNY, etc; if they are included, they
  954.      are ignored.
  955.  
  956.  3 - Acceptable REMOTE Command List (up to about 30 bytes):
  957.      A string containing the REMOTE commands that are available for execution
  958.      (implemented and enabled).  The string is composed of the Generic Server
  959.      Command subtypes, e.g. "ACDEFHIJKLQRSTUVWXdm".
  960.   
  961. The client parses the response and sets local variables accordingly, and
  962. also may display an appropriate message, and set up detailed information to
  963. be displayed in a subsequent SHOW SERVER command.  It might also
  964. disable/remove/mark client commands that are unavailable in the server.
  965.  
  966. NOTE: In case this features should grow beyond the capacity of a single
  967. Data field, it can become a long-form reply, but a new packet would be
  968. needed to distinguish it from other server long-form replies.
  969.  
  970. 15. REMOTE LOGIN (DONE)
  971.  
  972. The book doesn't say what should happen if it fails.  The server should
  973. send an Error packet with text "Access denied."
  974.  
  975. Also, the book says nothing about the authentication method, which is fine.
  976. It depends entirely on the implementation.
  977.  
  978. 16. UNICODE (DONE)
  979.  
  980. UCS-2 Level 1, Group 00, Plane 00: FCS and TCS
  981. UTF-8 Level 1, Group 00, Plane 00: FCS and TCS
  982.  
  983. TCS Kermit designators:
  984.  
  985. UCS-2: I162 (= Level 1)
  986. UTF-8: I190 (= Level 1, but accept I196 incoming = Level unspecified).
  987.  
  988. There is no restriction regarding breaking of UCS-2 or UTF-8 sequences
  989. across packets.
  990.  
  991. 17. FILE SIZE (OPEN)
  992.  
  993. When sending a file, we put the file size into the A packet.  But this is
  994. not terribly useful when FCS is single-byte and TCS is multibyte (or v.v.).
  995. But the protocol definition says the file size must be used, not the estimated
  996. "transfer size".  The receiver has no way of knowing about any expansion or
  997. compaction of the orignal file, since it can only see the transfer encoding.
  998. So we need another attribute: estimated expansion factor (as a percent).
  999.  
  1000. 18. CANCELLATION (DONE)
  1001.  
  1002. The protocol allows X or Z in the ACK to a D packet.  It must be (has been)
  1003. extended to also allow this in the ACK to the Z packet, because of streaming,
  1004. to catch the edge case when an entire file's contents fits in a single
  1005. data packet, or for empty files.
  1006.  
  1007. 19. UTF-8 FILENAMES
  1008.  
  1009. The coding of filenames has never been specified because the A packet, in
  1010. which the charset is given, comes before the F packet.  So when a filename
  1011. comes in, we have no idea what its character set is (we can *guess* that it
  1012. is the current TRANSFER character set, but that's far from certain).
  1013.  
  1014. Now that there is a universal character set and a standard Internet
  1015. representation for it, i.e. UTF-8, we can use that for all filenames,
  1016. regardless of the file or transfer character set, as long as the two Kermits
  1017. agree beforehand.  Negotiation is done simply by setting the UTF8NAMES
  1018. capability bit.  If both Kermits set it, names are encoded in UTF8.  If not,
  1019. the (unspecified and unpredictable) previous method is used.  When UTF8
  1020. names are used:
  1021.  
  1022.  . When receiving files, we convert all incoming filenames from UTF8 to the
  1023.    current file character set (after deciding what it is based on the
  1024.    incoming transfer charset via file associations).  The tricky part is, we
  1025.    don't know what the transfer charset is until the A-packet comes;
  1026.    therefore we have to defer opening the output file until we get the Z or
  1027.    first D packet -- but we already do that.  But when the F-packet comes, we
  1028.    have to put the local name in the ACK, and what character set we use for
  1029.    that???  UTF-8 is the only one that makes sense, but since we generally
  1030.    return the full pathname and possibly do other conversions (or we have an
  1031.    as-name), this requires that we (a) convert the incoming UTF-8 name to
  1032.    whatever character set is used locally for filenames, then (b) construct
  1033.    the new filename, and (c) convert the result back to UTF-8.
  1034.  
  1035.    Unfortunately, this whole area is a minefield.  We can neither assume
  1036.    that all local filenames have the same encoding, nor that every filename
  1037.    has the same encoding as the file's contents.  In any case, binary file
  1038.    contents have no encoding at all.  Also:
  1039.  
  1040.    - What about filename collisions?  They will work only if we GUESS
  1041.      right about the encoding for the local filename before we have the
  1042.      information we must know to guess right (the transfer character set).
  1043.  
  1044.    - What about "set file names converted"?  Case folding in Unicode
  1045.      requires lookups in two big databases.
  1046.  
  1047.    - Do we allow filenames to include combining characters?  If we do,
  1048.      that's MORE database lookups (character properties) AND a sort, e.g.
  1049.      to convert to Normalization Form C.  What if there is no mapping to
  1050.      the current character set?
  1051.      
  1052.    - etc etc etc...  No doubt other problems would surface in the course of
  1053.      implementation.
  1054.  
  1055.  . When sending files, we get the local file's character set with filescan
  1056.    or whatever, and then ASSUME the filename is in the same character set,
  1057.    and convert to UTF-8 for the F-packet.  Obviously this assumption might
  1058.    be wrong.  Perhaps we can check it by filescanning the name itself, but
  1059.    names are generally not long enough to give a reliable result.  Even if
  1060.    this works:
  1061.  
  1062.    - The ACK comes back in UTF-8.  How do we display it?  Convert it to the
  1063.      local FILE character set?  How do we record it in the Transaction log?
  1064.      Do we need to let the user specify not only the file and transfer
  1065.      character sets, but also the console and log character sets?
  1066.  
  1067.    - etc etc.
  1068.  
  1069. This is not as simple as it seemed at first!
  1070.