跳到主要内容

附录:卸载 Telnet(第 2 部分)

2.3. Condition 命令​

Condition 命令用于 Telnet,以修改传输特性,并在 Telnet 连接上启用或禁用 Telnet 选项。

2.3.1. 专门用法​

除正常用法外,Condition 命令在 Telnet 中还有专门用法。当选项选择由主机执行时(目前,这在中介级别 5 和 1 上进行,但在级别 9 上不进行),它用于控制选项的选择和协商过程。

为此定义了一组协议特有参数。它们在很大程度上基于 Telnet 的协商和子协商机制。对于简单的协商,有两个参数:一个协商类型(取自集合 {DO, DONT, WILL, WONT}),后面跟着所需选项的代码(数字)或名称(符号)。选项的代码在下文列出。H-FP 与 Telnet 之间接口和内部 Telnet 协议的一个基本区别是,请求(DO 或 WILL)中包含了额外参数。Telnet 协议的子协商在内部用来在 Telnet 数据流中传达这些信息。这些额外参数则使用选项特有的协议特有参数。

主机和 OPE 都可以发出这些 Condition 命令。由主机发出时,表示用户希望启用或禁用某个特定选项。OPE 随后在 Telnet 数据流中发出相应的协商命令(即 IAC <DO> <code>)。当选项协商的结果可用时,OPE 生成响应。对于 DO 和 WILL 类型,000 响应表示相应的接受(分别为 WILL 或 DO)。非零的响应码可能表示协商失败或协商被拒绝(以及其他情况)。对于 DONT 和 WONT 类型,000 响应表示该选项将被禁用。在这些情况下不应预期协商被拒绝。

当 Condition 命令由 OPE 发出时,表示连接的另一端正在协商更改。此时主机的响应表明主机对该选项协商所希望采取的行动。同样,有效的禁用选项请求(DONT 和 WONT 请求)应当总是得到 000 响应。

2.3.2. 协议特有参数​

使用 Condition 命令进行主要协商时,有两个协议特有参数。它们是协商类型和选项代码。协商类型取自集合 {DO, DONT, WILL, WONT}。选项代码是用于标识所协商的特定选项的数值。这些代码的值在此处列出,但与实际 Telnet 协商中使用的代码相同。代码如下:

Option Name     Option Code       Short Name

Transmit Binary 0 Binary
Echo 1 Echo
Suppress Go-Ahead 3 SuppressGA
Approximate Message Size 4 NAMS
Status 5 Status
Timing Mark 6 TimingMark
RCTE 7 RCTE
Line Length 8 LineLength
Page Size 9 PageSize
Carriage Return Disp 10 CRDisp
Horizontal Tabstops 11 HTabStops
Horizontal Tab Disp 12 HTabDisp
Formfeed Disposition 13 FFDisp
Vertical Tabstops 14 VTabStops
Vertical Tab Disposition 15 VTabDisp
Linefeed Disposition 16 LFDisp
Extended ASCII 17 ExASCII
Logout 18 Logout
Data Entry Terminal 20 DET
Terminal Type 24 TermType
Extended options list 255 ExOptions

此处未列出的选项当然也可以使用。代码编号应与 Telnet 协商中使用的选项代码相同。

2.3.2.1. 简单选项​

不需要额外参数的选项,使用上文简要描述、并在 Telnet 文档中更详细说明的简单协商机制。不需要额外参数。这些选项包括 Transmit Binary、Echo、Suppress Go Ahead、Status、Timing Mark 和 Logout 选项。

2.3.2.2. 近似消息大小选项(Approximate Message Size Option)​

近似消息大小选项需要两个参数。第一个参数指明所协商的近似消息大小适用于连接的本地端还是远端。DS 表示该大小适用于命令的发送方(即,如果由主机发出命令,DS 表示连接的本地端;如果由 OPE 发出,DS 表示连接的远端)。DR 表示该大小适用于命令的接收方(即,如果由主机发出命令,DR 表示远端;如果由 OPE 发出,DR 表示连接的本地端)。这一约定与 Telnet 的子协商机制一致。第二个字符是 ASCII 编码的数值,即消息大小的字符数。

2.3.3. 行宽和页面大小选项​

行宽和页面大小选项需要两个额外参数。第一个参数指明所协商的行宽或页面大小适用于连接的本地端还是远端,使用上文所述的 DS 和 DR 约定。第二个参数是 ASCII 编码的数值,其解释如下(假定 Condition 命令由主机发出):

0         The Host requests that it handle length or size
considerations for the direction indicated by
the first parameter.

1 to 253 The Host requests that the remote end handle
the size or length considerations for the
direction indicated by the first parameter, but
suggests that the value indicated be used as
the size or length.

254 The Host requests that the remote end handle
the size or length considerations for the
direction indicated by the first parameter, but
suggests that the size or length be considered
to be infinity.

255 The Host requests that the remote end handle
the tabstop considerations, and suggests
nothing about what the value should be.

如果 Condition 命令由 OPE 发出,则主机与远端的角色互换。

2.3.4. 制表位选项​

水平制表位和垂直制表位选项需要两个选项特有的参数。第一个是 DR 或 DS,如前所述。第二个是由空格分隔的一个或多个 ASCII 编码数值构成的列表,假定 Condition 命令由主机发出,其中每个值分别按如下方式解释:

0         The Host requests that it handle tabstops for
the direction indicated by the first parameter.

1 to 250 The Host requests that the remote end handle
the tabstop considerations for the direction
indicated by the first parameter, but suggests
that the value(s) indicated should be used as
the tabstops.

255 The Host requests that the remote end handle
the tabstop considerations for the direction
indicated by the first parameter, and suggests
nothing about what the value should be.

如果 Condition 命令由 OPE 发出,则主机与远端的角色互换。