aboutsummaryrefslogtreecommitdiffstats
path: root/src/programs.asm
diff options
context:
space:
mode:
authoruser <user@clank>2026-07-17 14:11:22 +0200
committeruser <user@clank>2026-07-17 14:11:22 +0200
commita2cb756693229c7880d926d2cdde2f838c697415 (patch)
treee327278e7d8b7150d7a2b01cf38b4895caab7356 /src/programs.asm
parentkernel: sys_sleep - a cooperative delay off the DIV timer (+ ping pacing) (diff)
downloadgbos-a2cb756693229c7880d926d2cdde2f838c697415.tar.gz
gbos-a2cb756693229c7880d926d2cdde2f838c697415.tar.xz
gbos-a2cb756693229c7880d926d2cdde2f838c697415.zip
net: DHCP client - lease the IP at boot instead of hardcoding it
The address is no longer baked in. net_init starts at 0.0.0.0; a DHCP client runs as the first thing on boot (init/shell forks it and waits), and only once it has a lease (or gives up) does the prompt appear. Kernel: - IP is configurable: 0.0.0.0 until leased; NET_SETIP op stores it. - 16-bit frame length. DHCP/BOOTP packets are ~272 bytes, over the old 255-byte frame cap, so net_slip_send takes a 16-bit length, net_pump assembles into a 320-byte buffer with a 16-bit wNetRxLen, and udp_send writes a 16-bit IP total. Payloads stay <=255 (kept small on purpose) so the per-protocol datalen math is unchanged. wNetTx/wNetRxBuf 256->320, SK_RXBUF 208->288. Userland: - c/dhcp.c: DISCOVER->OFFER->REQUEST->ACK over a UDP socket, then net_setip(); times out gracefully (shell still boots) if there's no server. sh.c runs it before the prompt. Bridge (self-contained DHCP server, no dnsmasq): - tunbridge.py + netboot intercept UDP->:67 and answer OFFER/ACK leasing 10.0.0.2 (gateway 10.0.0.1); everything else is bridged/NATed as before. Regression-tested ICMP/UDP/TCP after the 16-bit change. Verified end to end: dhcp: discovering dhcp: leased 10.0.0.2 /# ping 10.0.0.1 -> 4/4 (traffic from the leased address)
Diffstat (limited to 'src/programs.asm')
-rw-r--r--src/programs.asm7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/programs.asm b/src/programs.asm
index 9ae7f58..e89fe0c 100644
--- a/src/programs.asm
+++ b/src/programs.asm
@@ -127,6 +127,9 @@ ProgPing:
SECTION "prog_nslookup", ROMX[$4000], BANK[30]
ProgNslookup:
INCBIN "c/nslookup.bin"
+SECTION "prog_dhcp", ROMX[$4000], BANK[31]
+ProgDhcp:
+ INCBIN "c/dhcp.bin"
; -----------------------------------------------------------------------------
; PROG_SH (bank 3) - the shell, now written in C (c/sh.c): parses >/</| and
@@ -227,6 +230,8 @@ ProgramTable::
dw ProgPing
db LOW(BANK(ProgNslookup)), HIGH(BANK(ProgNslookup))
dw ProgNslookup
+ db LOW(BANK(ProgDhcp)), HIGH(BANK(ProgDhcp))
+ dw ProgDhcp
; -----------------------------------------------------------------------------
; NameTable (ROM0) - command name -> program id, searched by sys_lookup.
@@ -291,4 +296,6 @@ NameTable::
db PROG_PING
db "nslookup", 0
db PROG_NSLOOKUP
+ db "dhcp", 0
+ db PROG_DHCP
db 0