aboutsummaryrefslogtreecommitdiff
path: root/j1demo/firmware/tftp.fs
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2019-10-30 20:04:56 +0100
committerDimitri Sokolyuk <demon@dim13.org>2019-10-30 20:04:56 +0100
commita76977af62010a392c16010c367185e61e856ffe (patch)
tree56cf4177d5bc0e3ead781d1c60818c13b1df0f3c /j1demo/firmware/tftp.fs
parentc0165d167d7cb40d80028bcf7a4a6b160b5a7e83 (diff)
mv to docs
Diffstat (limited to 'j1demo/firmware/tftp.fs')
-rw-r--r--j1demo/firmware/tftp.fs67
1 files changed, 0 insertions, 67 deletions
diff --git a/j1demo/firmware/tftp.fs b/j1demo/firmware/tftp.fs
deleted file mode 100644
index da40aa2..0000000
--- a/j1demo/firmware/tftp.fs
+++ /dev/null
@@ -1,67 +0,0 @@
-( TFTP JCB 09:16 11/11/10)
-
-variable blocknum
-
-: tftp-ack ( -- )
- d# 2 ETH.IP.SRCIP mac-inoffset mac@n arp-lookup if
- ETH.IP.UDP.SOURCEPORT packet@
- d# 1077
- d# 2 ETH.IP.SRCIP mac-inoffset mac@n
- net-my-ip
- 2over arp-lookup
- ( dst-port src-port dst-ip src-ip *ethaddr )
- udp-header
- d# 4 mac-pkt-,
- blocknum @ mac-pkt-,
- udp-wrapup mac-send
- then
-;
-
-: tftp-handler ( -- )
- IP_PROTO_UDP ip-isproto if
- OFFSET_UDP_DESTPORT packet@ d# 69 = if
- udp-checksum? if
- ETH.IP.UDP.TFTP.OPCODE packet@
- s" tftp opcode=" type dup hex4 cr
- dup d# 2 = if
- s" WRQ filename: " type
- ETH.IP.UDP.TFTP.RWRQ.FILENAME mac-inoffset d# 32 mac-dump
-
- d# 0 blocknum !
- tftp-ack
- then
- drop
- then
- then
- OFFSET_UDP_DESTPORT packet@ d# 1077 = if
- udp-checksum? if
- ETH.IP.UDP.TFTP.OPCODE packet@
- s" tftp opcode=" type dup hex4 cr
- dup d# 3 = if
- s" tftp recv=" type ETH.IP.UDP.TFTP.DATA.BLOCK packet@ hex4 s" expected=" type blocknum @ 1+ hex4 cr
- blocknum @ 1+
- ETH.IP.UDP.TFTP.DATA.BLOCK packet@ = if
- \ data at ETH.IP.UDP.TFTP.DATA.DATA
- ETH.IP.UDP.TFTP.DATA.DATA mac-inoffset
- blocknum @ d# 9 lshift h# 2000 +
- d# 256 0do
- over mac@ h# 5555 xor over h# 3ffe min !
- 2+ swap 2+ swap
- loop
- 2drop
- d# 1 blocknum +!
- tftp-ack
- ETH.IP.UDP.LENGTH packet@ d# 12 - 0= if
- h# 2000 h# 100 dump
- bootloader
- then
- else
- s" unexpected blocknum" type cr
- tftp-ack
- then
- then
- drop
- then
- then
- then
-;