# SecLink Terminal Demo Standalone DOS terminal emulator combining the DVX windowed GUI with SecLink encrypted serial communication. Part of the DVX GUI project. This is NOT a DXE app -- it is a freestanding program with its own `main()` that initializes the DVX GUI directly and manages its own event loop. Unlike the DXE apps (progman, notepad, clock, dvxdemo) which run inside the DVX Shell, this program demonstrates how to use the DVX widget system outside the shell framework. Connects to a remote BBS through the SecLink proxy, providing a full ANSI terminal in a DVX-style window with encrypted transport. ## Architecture ``` termdemo (DOS, 86Box) | +--- DVX GUI windowed desktop, ANSI terminal widget | +--- SecLink encrypted serial link | | | +--- packet HDLC framing, CRC-16, Go-Back-N ARQ | +--- security DH key exchange, XTEA-CTR cipher | +--- rs232 ISR-driven UART I/O | COM port (86Box emulated modem) | TCP:2323 | secproxy (Linux) | TCP:23 | Remote BBS ``` All traffic between the terminal and the proxy is encrypted via XTEA-CTR on SecLink channel 0. The proxy decrypts and forwards plaintext to the BBS over telnet. ## Usage ``` termdemo [com_port] [baud_rate] ``` | Argument | Default | Description | |-------------|---------|--------------------------| | `com_port` | 1 | COM port number (1-4) | | `baud_rate` | 115200 | Serial baud rate | Examples: ``` termdemo # COM1 at 115200 termdemo 2 # COM2 at 115200 termdemo 1 57600 # COM1 at 57600 termdemo -h # show usage ``` ## Startup Sequence 1. Seed the RNG from hardware entropy (PIT-based on DOS). 2. Open SecLink on the specified COM port (8N1, no handshake). 3. Perform DH key exchange (blocks until the proxy completes its side). 4. Initialize the DVX GUI (1024x768, 16bpp VESA). 5. Create a resizable terminal window with menu bar and status bar. 6. Register an idle callback so serial data is polled during GUI idle. 7. Enter the main loop. The handshake completes in text mode before the GUI starts, so the DOS console shows progress messages during connection setup. ## Main Loop Each iteration: 1. `secLinkPoll()` -- read serial data, decrypt, deliver to ring buffer. 2. `dvxUpdate()` -- process mouse, keyboard, paint, and window events. During paint, the terminal widget calls `commRead` to drain the ring buffer and render new data. An idle callback also calls `secLinkPoll()` so incoming data is processed even when the user is not interacting with the terminal. ## Data Flow ``` BBS -> proxy -> serial -> secLinkPoll() -> onRecv() -> ring buffer -> commRead() -> wgtAnsiTermWrite() -> ANSI parser -> screen Keyboard -> widgetAnsiTermOnKey() -> commWrite() -> secLinkSend() -> serial -> proxy -> BBS ``` A 4KB ring buffer (`RECV_BUF_SIZE`) bridges the SecLink receive callback (which fires asynchronously during `secLinkPoll()`) and the terminal widget's comm read interface (which is polled synchronously during the widget paint cycle). This decoupling is necessary because the callback can fire at any time during polling, but the terminal widget expects to read data synchronously. ## GUI - **Window**: resizable, titled "SecLink Terminal" - **Menu bar**: File -> Quit - **Terminal**: 80x25 ANSI terminal widget with 1000-line scrollback - **Status bar**: shows COM port, baud rate, and encryption status The ANSI terminal widget supports standard escape sequences including cursor control, SGR colors (16-color CGA palette), erase, scroll, insert/delete lines, and DEC private modes (cursor visibility, line wrap). ## Test Setup 1. Start the SecLink proxy on the Linux host: ``` secproxy 2323 bbs.example.com 23 ``` 2. Configure 86Box with a COM port pointing at the proxy's listen port (TCP client mode, port 2323, no telnet negotiation). 3. Run the terminal inside 86Box: ``` termdemo ``` 4. The handshake completes, the GUI appears, and BBS output is displayed in the terminal window. ## Building ``` make # builds ../bin/termdemo.exe (and all dependency libs) make clean # removes objects and binary ``` The Makefile automatically builds all dependency libraries before linking. Objects are placed in `../obj/termdemo/`, the binary in `../bin/`. Target: DJGPP cross-compiler, 486+ CPU, VESA VBE 2.0+ video. ## Dependencies All libraries are built into `../lib/`: | Library | Purpose | |------------------|--------------------------------------| | `libdvx.a` | DVX windowed GUI and widget system | | `libseclink.a` | Secure serial link wrapper | | `libpacket.a` | HDLC framing and reliability | | `libsecurity.a` | DH key exchange and XTEA cipher | | `librs232.a` | ISR-driven UART serial driver | ## Files ``` termdemo/ termdemo.c terminal emulator program Makefile DJGPP cross-compilation build ```