From e825a8d2e775e3ea5b8f15e620ab78b33883c850 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Fri, 29 May 2026 18:16:03 +0200 Subject: [PATCH] nwconn: document and guard NCP 13 get station number Replace the old "Get connection ??" TODO for NCP function 0x13 with the documented old Get Station Number semantics. This simple legacy call returns the current station/connection number as a single byte and is used by old DOS requesters before the richer NCP 23 connection services. Keep the existing one-byte reply for normal connections, but reject invalid or unrepresentable connection numbers instead of silently truncating them. No queue or file service behavior change. --- src/nwconn.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/nwconn.c b/src/nwconn.c index f5d21e8..96b2d1e 100644 --- a/src/nwconn.c +++ b/src/nwconn.c @@ -579,10 +579,22 @@ static int handle_ncp_serv(void) } break; - case 0x13 : { /* Get connection ?? */ - /* TODO !!!!!!! */ - *responsedata=(uint8) act_connection; - data_len = 1; + case 0x13 : { /* Get Station Number */ + /* + * This is the old one-byte connection number call used by + * DOS requesters before the richer NCP 23 connection services. + * The SDK describes the client-visible API as + * NWGetConnectionNumber(); older low-level documentation names the + * underlying simple NCP 0x13 "Get Station Number". + */ + if (act_connection > 0 && act_connection < 256) { + *responsedata=(uint8) act_connection; + data_len = 1; + } else { + XDPRINTF((1, 0, "Get Station Number failed, conn=%d", + act_connection)); + completition = 0xff; + } } break;