From e442252d72f1aab4c332a76983cd3924ce2b492b Mon Sep 17 00:00:00 2001 From: user Date: Fri, 17 Jul 2026 13:29:42 +0200 Subject: net: keep network packets out of the console (fixes shell garbage on netboot) The link port is both the console-input fallback and the network. At the shell prompt the host's multicast (mDNS/LLMNR/IGMP) was fed to the serial and KGetc read those packet bytes as console input -> garbage in the shell, OSK unusable. Two-part fix: - KGetc now skips SLIP frames (0xC0-delimited) on the serial console path, so inbound packets never surface as console input. Plain injected bytes (the headless tunbridge command path) still pass through. New wConInSkip flag. - netboot/tunbridge only forward IP packets destined to 10.0.0.2 (drop the multicast noise at the bridge). Verified: GB sits at a clean "/#" prompt while all packets (noise included) are forwarded; being-pinged (3/3) and wget still work. On the emulator, the OSK is SELECT=space, START=enter, A=z, B=x, d-pad=WASD/arrows. --- src/kdata.asm | 1 + src/syscall.asm | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/kdata.asm b/src/kdata.asm index 6c520dd..6333f38 100644 --- a/src/kdata.asm +++ b/src/kdata.asm @@ -56,6 +56,7 @@ wFsPath:: DS 40 ; kernel-side copy of a path argument wFsSlashPtr::DS 2 ; last '/' seen while splitting a path wListDir:: DS 1 ; directory sys_list enumerates wKChar:: DS 1 ; scratch for KPutc +wConInSkip:: DS 1 ; console input: mid-SLIP-frame? (skip net packets) wKillParent::DS 1 ; scratch for sys_kill wPsBuf:: DS 2 ; scratch for sys_ps wPnStart:: DS 2 ; scratch for sys_progname diff --git a/src/syscall.asm b/src/syscall.asm index 5b40ef0..04e9661 100644 --- a/src/syscall.asm +++ b/src/syscall.asm @@ -137,6 +137,29 @@ KGetc:: bit 7, a jr nz, .yield ld a, [rSB] ; A = serial byte + ; The link port is also the network. Skip SLIP frames (0xC0-delimited) so + ; inbound packets never surface as console input; plain bytes (an injected + ; command in headless use) still pass through. + ld b, a + ld a, [wConInSkip] + or a + jr nz, .inframe + ld a, b + cp SLIP_END + jr z, .frameopen + ld a, b ; ordinary byte -> console input + jr .done +.frameopen + ld a, 1 + ld [wConInSkip], a + jr .poll +.inframe + ld a, b + cp SLIP_END + jr nz, .poll ; still inside a frame -> discard + xor a + ld [wConInSkip], a ; frame end -> resume + jr .poll .done and a ; CF = 0 (not EOF) ret -- cgit v1.3.1-sl0p