diff --git a/REDESIGN.md b/REDESIGN.md index 50fa10f..e7a5f37 100644 --- a/REDESIGN.md +++ b/REDESIGN.md @@ -661,6 +661,130 @@ This keeps the future NetWare 4.x work aligned with the provider/process split: `nwdirectory`, `nwnds`, and `nwbind` may be separate processes or modules, but they should not be separate sources of truth for identity and directory data. +## Transport split for future TCP/IP support + +Future TCP/IP support should be introduced as a transport code/library split, +not as a new daemon. The transport layer is below the NCP dispatcher: it owns +wire IO, peer addressing, framing, and transport-specific discovery or watchdog +behavior. It does not own Bindery, Queue, Directory, File, Semaphore, or other +NCP provider semantics. + +The intended source-level split is: + +```text +src/nwtransport.c + common transport API and helpers + transport-neutral peer/session descriptors + dispatch to the selected transport implementation + +src/nwipx.c + existing IPX-specific implementation + ipxAddr_t conversion and compatibility helpers + IPX socket send/receive + SAP/RIP, IPX watchdog, and IPX broadcast behavior where applicable + +src/nwtcp.c + later TCP/IP implementation + TCP listener/session/framing code + IPv4/IPv6 peer address handling + no SAP/RIP assumptions + +src/nwconn.c + NCP session logic + request decode, dispatch handoff, reply construction + should gradually use transport-neutral peer/session data + +src/nwserv.c + process supervision and connection lifecycle + uses the transport layer for listener and peer management +``` + +These files should be linked into the existing `nwserv`/`nwconn` process model. +`nwtransport` is a boundary in the code, not an `nwtransport` process. Creating +a separate transport daemon would add an IPC hop for every NCP packet, complicate +disconnect/error handling, and make TCP stream ownership harder without adding a +clear NetWare service boundary. + +The long-term direction is to remove raw IPX assumptions from higher layers. +Today, the connection path still exposes `ipxAddr_t` in important places. A +future cleanup should introduce a transport-neutral peer descriptor, for +example conceptually: + +```c +typedef enum { + NW_TRANSPORT_IPX, + NW_TRANSPORT_TCP +} NwTransportKind; + +typedef struct { + NwTransportKind kind; + union { + ipxAddr_t ipx; + struct { + unsigned char addr[16]; + unsigned short port; + unsigned char family; + } tcp; + } u; +} NwTransportPeer; +``` + +The exact structure should follow the existing mars-nwe style, but the ownership +rule is the important part: NCP providers should not care whether a request came +from IPX or TCP/IP. They should see a connection/session and an NCP request, +not a raw network address type. + +The transport API can start small. Useful conceptual operations are: + +```c +nwtransport_peer_equal(); +nwtransport_peer_to_string(); +nwtransport_recv(); +nwtransport_send(); +nwtransport_close_peer(); +nwtransport_peer_kind(); +``` + +As with the NCP context design, these names are placeholders. The first +implementation can wrap the existing IPX behavior and leave TCP stubs out until +there is a real TCP/IP target. The goal is to stop new code from spreading +`ipxAddr_t` into providers that should remain transport-independent. + +IPX-specific behavior must remain isolated. SAP/RIP, IPX broadcast, and the +existing IPX watchdog behavior are compatibility details of the IPX transport or +its immediate `nwserv` integration. TCP/IP should not be forced to emulate IPX +SAP/RIP internally. If TCP/IP later needs discovery or service advertisement, +that should be designed as a TCP/IP-specific mechanism rather than hidden behind +old IPX-only assumptions. + +The intended relationship is therefore: + +```text +IPX client -> nwipx -> nwtransport -> nwconn -> NCP dispatcher -> providers +TCP client -> nwtcp -> nwtransport -> nwconn -> NCP dispatcher -> providers +``` + +The provider/process rule still applies: + +```text +Provider boundary does not imply process boundary. +Transport boundary does not imply process boundary either. +``` + +Good future cleanup sequence: + +1. document the current IPX ownership in `nwserv.c` and `nwconn.c`; +2. add `nwtransport.c`/transport headers as wrappers around existing IPX paths; +3. move IPX-only helpers into `nwipx.c` without behavior changes; +4. gradually replace raw `ipxAddr_t` use in session-neutral code with a + transport-neutral peer/session descriptor; +5. keep NCP providers and the endpoint audit table transport-independent; +6. add `nwtcp.c` only after the IPX wrapper boundary is stable. + +This keeps TCP/IP support compatible with the broader redesign: transport IO is +separated from NCP semantics, but the existing `nwserv`/`nwconn` process model +remains intact. + ## Logging connection The dispatch redesign also supports the desired log cleanup. If every request