From d3474c18fcb164ce414885bc840bf1f990ed8562 Mon Sep 17 00:00:00 2001 From: Jesse Friedman Date: Sat, 13 Apr 2019 02:34:40 -0400 Subject: [PATCH] Adding EXOPL support to telnet-test --- util/telnet-test.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/util/telnet-test.c b/util/telnet-test.c index 63b8409..e27f5f7 100644 --- a/util/telnet-test.c +++ b/util/telnet-test.c @@ -28,6 +28,8 @@ static const telnet_telopt_t telopts[] = { { TELNET_TELOPT_MSSP, TELNET_WILL, TELNET_DONT }, { TELNET_TELOPT_NEW_ENVIRON, TELNET_WILL, TELNET_DONT }, { TELNET_TELOPT_TTYPE, TELNET_WILL, TELNET_DONT }, + { TELNET_TELOPT_EXOPL, TELNET_WILL, TELNET_DONT }, + { 300, TELNET_WILL, TELNET_DONT }, /* a dummy EXOPL telopt */ { -1, 0, 0 } }; @@ -61,7 +63,7 @@ static const char *get_cmd(unsigned char cmd) { } } -static const char *get_opt(unsigned char opt) { +static const char *get_opt(short opt) { switch (opt) { case 0: return "BINARY"; case 1: return "ECHO"; @@ -108,6 +110,7 @@ static const char *get_opt(unsigned char opt) { case 86: return "COMPRESS2"; case 93: return "ZMP"; case 255: return "EXOPL"; + case 300: return "LIBTELNET-TEST-EXOPL-TELOPT"; /* our custom dummy EXOPL option */ default: return "unknown"; } } @@ -221,28 +224,29 @@ static void event_print(telnet_t *telnet, telnet_event_t *ev, void *ud) { stprintf(state, "IAC %d (%s)\n", (int)ev->iac.cmd, get_cmd(ev->iac.cmd)); break; case TELNET_EV_WILL: - stprintf(state, "WILL %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); + stprintf(state, "WILL %d (%s)\n", (int)ev->neg.telopt_extended, get_opt(ev->neg.telopt_extended)); break; case TELNET_EV_WONT: - stprintf(state, "WONT %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); + stprintf(state, "WONT %d (%s)\n", (int)ev->neg.telopt_extended, get_opt(ev->neg.telopt_extended)); break; case TELNET_EV_DO: - stprintf(state, "DO %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); + stprintf(state, "DO %d (%s)\n", (int)ev->neg.telopt_extended, get_opt(ev->neg.telopt_extended)); break; case TELNET_EV_DONT: - stprintf(state, "DONT %d (%s)\n", (int)ev->neg.telopt, get_opt(ev->neg.telopt)); + stprintf(state, "DONT %d (%s)\n", (int)ev->neg.telopt_extended, get_opt(ev->neg.telopt_extended)); break; case TELNET_EV_SUBNEGOTIATION: - switch (ev->sub.telopt) { + switch (ev->sub.telopt_extended) { case TELNET_TELOPT_ENVIRON: case TELNET_TELOPT_NEW_ENVIRON: case TELNET_TELOPT_TTYPE: case TELNET_TELOPT_ZMP: case TELNET_TELOPT_MSSP: + case TELNET_TELOPT_EXOPL: /* print nothing */ break; default: - stprintf(state, "SUB %d (%s) [%zi]\n", (int)ev->sub.telopt, get_opt(ev->sub.telopt), ev->sub.size); + stprintf(state, "SUB %d (%s) [%zi]\n", (int)ev->sub.telopt_extended, get_opt(ev->sub.telopt_extended), ev->sub.size); break; } break;