libmudtelnet_rs/
telnet.rs

1//! Telnet command and option constants.
2//!
3//! This module provides `u8` constants for Telnet opcodes and option codes
4//! used across the parser and by your application code.
5//!
6//! Quick reference
7//! ```
8//! use libmudtelnet_rs::telnet::op_command as cmd;
9//! use libmudtelnet_rs::telnet::op_option as opt;
10//! assert_eq!(cmd::IAC, 255);
11//! assert_eq!(cmd::WILL, 251);
12//! assert_eq!(opt::GMCP, 201);
13//! ```
14
15// Define a public u8 constant with the given name and constant value.
16macro_rules! u8_const {
17  ($name: ident, $value: expr) => {
18    pub const $name: u8 = $value;
19  };
20}
21
22/// Module containing constants for Telnet Command codes.
23// TODO(XXX): rename to cmd.
24pub mod op_command {
25  u8_const!(IAC, 255);
26  u8_const!(WILL, 251);
27  u8_const!(WONT, 252);
28  u8_const!(DO, 253);
29  u8_const!(DONT, 254);
30  u8_const!(NOP, 241);
31  u8_const!(SB, 250);
32  u8_const!(SE, 240);
33  u8_const!(IS, 0);
34  u8_const!(SEND, 1);
35  u8_const!(GA, 249);
36  u8_const!(EOR, 239);
37}
38
39/// Module containing constants for Telnet Option codes.
40// TODO(XXX): rename to opt.
41pub mod op_option {
42  u8_const!(BINARY, 0);
43  u8_const!(ECHO, 1);
44  u8_const!(RCP, 2);
45  u8_const!(SGA, 3);
46  u8_const!(NAMS, 4);
47  u8_const!(STATUS, 5);
48  u8_const!(TM, 6);
49  u8_const!(RCTE, 7);
50  u8_const!(NAOL, 8);
51  u8_const!(NAOP, 9);
52  u8_const!(NAOCRD, 10);
53  u8_const!(NAOHTS, 11);
54  u8_const!(NAOHTD, 12);
55  u8_const!(NAOFFD, 13);
56  u8_const!(NAOVTS, 14);
57  u8_const!(NAOVTD, 15);
58  u8_const!(NAOLFD, 16);
59  u8_const!(XASCII, 17);
60  u8_const!(LOGOUT, 18);
61  u8_const!(BM, 19);
62  u8_const!(DET, 20);
63  u8_const!(SUPDUP, 21);
64  u8_const!(SUPDUPOUTPUT, 22);
65  u8_const!(SNDLOC, 23);
66  u8_const!(TTYPE, 24);
67  u8_const!(EOR, 25);
68  u8_const!(TUID, 26);
69  u8_const!(OUTMRK, 27);
70  u8_const!(TTYLOC, 28);
71  u8_const!(_3270REGIME, 29);
72  u8_const!(X3PAD, 30);
73  u8_const!(NAWS, 31);
74  u8_const!(TSPEED, 32);
75  u8_const!(LFLOW, 33);
76  u8_const!(LINEMODE, 34);
77  u8_const!(XDISPLOC, 35);
78  u8_const!(ENVIRON, 36);
79  u8_const!(AUTHENTICATION, 37);
80  u8_const!(ENCRYPT, 38);
81  u8_const!(NEWENVIRON, 39);
82  u8_const!(MSSP, 70);
83  u8_const!(ZMP, 93);
84  u8_const!(EXOPL, 255);
85  u8_const!(MCCP2, 86);
86  u8_const!(MCCP3, 87);
87  u8_const!(GMCP, 201);
88  u8_const!(CHARSET, 42); // Character Set negotiation (RFC 2066)
89  u8_const!(MSDP, 69); // MUD Server Data Protocol
90  u8_const!(MXP, 91); // MUD eXtension Protocol
91  u8_const!(ATCP, 200); // Achaea Telnet Client Protocol (legacy)
92}
93
94/// MSDP subnegotiation byte tags (canonical bytes only; no parser).
95/// Spec: <https://tintin.mudhalla.net/protocols/msdp/>
96pub mod msdp {
97  u8_const!(VAR, 1); // MSDP variable tag (0x01)
98  u8_const!(VAL, 2); // MSDP value tag (0x02)
99  u8_const!(TABLE_OPEN, 3); // MSDP table open tag (0x03)
100  u8_const!(TABLE_CLOSE, 4); // MSDP table close tag (0x04)
101  u8_const!(ARRAY_OPEN, 5); // MSDP array open tag (0x05)
102  u8_const!(ARRAY_CLOSE, 6); // MSDP array close tag (0x06)
103}