Kernel version 0.9 : TCPIP, new RAW socket type for ICMP

This commit is contained in:
Rémy GIBERT 2017-01-30 17:30:39 +01:00
parent 1d95ec18e7
commit 8c891ccf04
14 changed files with 331 additions and 271 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,7 +14,7 @@ AUTO 6
*--------------------------------------
TIMEOUT.MAX .EQ 20 2 sec.
*--------------------------------------
ZPFrameBase .EQ ZPBIN
ZPFrameBase .EQ ZPBIN
ZPFrameLen .EQ ZPBIN+2
ZPFramePtr1 .EQ ZPBIN+4
ZPIPCfgPtr .EQ ZPBIN+6
@ -36,41 +36,96 @@ CS.START cld
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.Socket .DA Socket
L.MSG.IPKO .DA MSG.IPKO
L.MSG.USAGE .DA MSG.USAGE
L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.HOSTOK .DA MSG.HOSTOK
L.MSG2 .DA MSG2
L.MSG3 .DA MSG3
.DA 0
*--------------------------------------
CS.INIT >SYSCALL GetArgC
cmp #1
bne .1
lda #SYSMGR.ERRSYN
sec
rts
.1 >LDYA L.LIBTCPIP
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLibYA
bcs .9
sta hLIBTCPIP
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
bcs .9
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 rts
*--------------------------------------
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
>STYA ZPIPCfgPtr
lda (ZPIPCfgPtr) Configured ?
bpl .9
bmi CS.RUN.IPOK
ldy #S.IPCFG.HDEV
lda (ZPIPCfgPtr),y
sta hDev
>LDYA L.MSG.IPKO
>SYSCALL CPrintFYA
lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
CS.RUN.IPOK >SYSCALL GetArgC
cmp #1
beq .9
jsr Init.Timeout
.2 >PUSHW pData DST.IP
lda #1
>SYSCALL GetArgA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc CS.RUN.HOSTOK
>SYSCALL Sleep
jsr Wait.Timeout
bcc .2
lda #1
>SYSCALL GetArgA
>PUSHYA
>LDYA L.MSG.UNKNOWN
bra .99
.9 >LDYA L.MSG.USAGE
.99 >SYSCALL CPrintFYA
lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
CS.RUN.HOSTOK lda #1
>SYSCALL GetArgA
>PUSHYA
ldy #DST.IP+3
>PUSHB (pData),y DST.IP+3
dey
>PUSHB (pData),y DST.IP+2
dey
>PUSHB (pData),y DST.IP+1
dey
>PUSHB (pData),y DST.IP
>LDYA L.MSG.HOSTOK
>SYSCALL CPrintFYA
CS.RUN.ECHO ldx #3
ldy #S.IPCFG.IP+3
.1 lda (ZPIPCfgPtr),y
sta Socket.Src.Addr,x
dey
dex
bpl .1
lda A2OSX.RANDOM16
ldy #Identifier
sta (pData),y
sta Socket.Src.Port
lda A2OSX.RANDOM16+1
iny
sta (pData),y
sta Socket.Src.Port+1
lda #0
ldy #Sequence
@ -78,80 +133,20 @@ CS.INIT >SYSCALL GetArgC
iny
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 sec
rts
*--------------------------------------
CS.RUN jsr Init.Timeout
.1 >PUSHW pData DST.IP
lda #1
>SYSCALL GetArgA
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc .2
>SYSCALL Sleep
jsr Wait.Timeout
bcc .1
lda #1
>SYSCALL GetArgA
>PUSHYA
>LDYA L.MSG0
>SYSCALL CPrintFYA
lda #1
sec
rts
.2 lda #1
>SYSCALL GetArgA
>PUSHYA
ldy #3
>PUSHB (pData),y DST.IP+3
dey
>PUSHB (pData),y DST.IP+2
dey
>PUSHB (pData),y DST.IP+1
>PUSHB (pData) DST.IP
>LDYA L.MSG1
>SYSCALL CPrintFYA
CS.RUN.ECHO >LIBCALL hLIBTCPIP,LIBTCPIP.NEW.ICMP.FRAME
>STYA ZPFrameBase
txa
ldy #hFrame
sta (pData),y
lda #S.ICMP+32-2
sta (ZPFrameBase)
lda /S.ICMP+32-2
ldy #1
ldy #S.ICMP.SEQUENCE
sta (ZPFrameBase),y
ldx #3
ldy #0
.10 lda (pData),y
pha
iny
dex
bpl .10
ldx #3
ldy #S.IP.DST+3
.1 pla
txa
sta (ZPFrameBase),y
dey
dex
bpl .1
ldy #S.ICMP.TYPE
lda #S.ICMP.TYPE.ECHOREQ
sta (ZPFrameBase),y
>PUSHW L.Socket
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.NEW
bcs .99
txa
ldy #hSocket
sta (pData),y
ldy #Identifier
lda (pData),y
@ -264,47 +259,11 @@ CS.DOEVENT lda (pEvent)
dec
sta (pData),y
.9 sec do not discard TIMER event
rts
*--------------------------------------
ldy #S.EVT.DATALO Get Frame hMem
lda (pEvent),y
>SYSCALL GetMemPtrA
>STYA ZPFrameBase
ldy #S.IP.PROTOCOL
lda (ZPFrameBase),y
cmp #S.IP.PROTOCOL.ICMP
bne .9
ldy #S.ICMP.TYPE
lda (ZPFrameBase),y
cmp #S.ICMP.TYPE.ECHOREP
bne .9
ldy #S.ICMP.IDENTIFIER
lda (ZPFrameBase),y
tax
iny
lda (ZPFrameBase),y
ldy #Identifier+1
cmp (pData),y
bne .9
dey
txa
cmp (pData),y
bne .9
jsr CS.EVENT.REPLY
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.EVENT.REPLY lda #TIMEOUT.MAX
CS.Print.REPLY lda #TIMEOUT.MAX
sec
ldy #TimeOut
sbc (pData),y
@ -371,23 +330,37 @@ Wait.TimeOut sec
*--------------------------------------
CS.END
LIBTCPIP >PSTR "libtcpip.o"
MSG0 >CSTR "%S: Unknown host\n"
MSG1 >CSTR "PING %d.%d.%d.%d (%S)\n"
MSG.IPKO >CSTR "TCP/IP Not Loaded/Configured.\n"
MSG.USAGE >CSTR "Usage : PING <ip|host>\n"
MSG.UNKNOWN >CSTR "%S: Unknown host\n"
MSG.HOSTOK >CSTR "PING %d.%d.%d.%d (%S)\n"
MSG2 >CSTR "%d.%d.%d.%d: TimeOut/Host unreachable\n"
MSG3 >CSTR "32 bytes from %d.%d.%d.%d, icmp_seq=%D, ttl=%d, time=%D ms\n"
hLIBTCPIP .BS 1
hDev .BS 1
TimeOut.ms .BS 2
Socket .DA #S.SOCKET.SOCK.RAW
.BS 2
.BS #S.IP.PROTOCOL.ICMP
Socket.Src.Addr .BS 4
Socket.Src.Port .BS 2 Identifier
Socket.Dst.Addr .BS 4
Socket.Dst.Port .DA 0 not used
.BS 16
*--------------------------------------
ICMP.Request .DA #S.ICMP.TYPE.ECHOREQ
.DA #0 CODE
.DA 0 CHECKSUM
ICMP.Request.ID .BS 2
ICMP.Request.SQ .BS 2
.AS "ABCDEFGHIJKLMNOP"
.AS "QRSTUVWXYZ012345"
*--------------------------------------
.DUMMY
.OR 0
DS.START
DST.IP .BS 4
hFrame .BS 1
TimeOut .BS 1
Identifier .BS 2
Sequence .BS 2
bReply .BS 1
TimeOut .BS 1
DS.END
.ED
*--------------------------------------

View File

@ -25,14 +25,14 @@ K.TCP.WSIZE .EQ K.TCP.MSS
LIBTCPIP.SET.IPCFG .EQ 4
LIBTCPIP.GET.IPCFG .EQ 6
LIBTCPIP.NEW.ICMP.FRAME .EQ 8
*LIBTCPIP.NEW.ICMP.FRAME .EQ 8
*LIBTCPIP.NEW.TCP.FRAME .EQ 10
*LIBTCPIP.NEW.UDP.FRAME .EQ 12
*LIBTCPIP.NEW.IP.FRAME .EQ 14
*LIBTCPIP.NEW.ARP.FRAME .EQ 16
*LIBTCPIP.NEW.ETH.FRAME .EQ 18
LIBTCPIP.SEND.ICMP.FRAME .EQ 20
*LIBTCPIP.SEND.ICMP.FRAME .EQ 20
*LIBTCPIP.SEND.TCP.FRAME .EQ 22
*LIBTCPIP.SEND.UDP.FRAME .EQ 24
*LIBTCPIP.SEND.IP.FRAME .EQ 26
@ -158,7 +158,8 @@ S.SOCKET.STATUS.FINWT2 .EQ 8
S.SOCKET.STATUS.CLOSING .EQ 9
S.SOCKET.STATUS.TIMEWT .EQ 10
*S.SOCKET.PARENT .EQ 3
S.SOCKET.RAW.PROTO .EQ 3
S.SOCKET.SRC.ADDR .EQ 4
S.SOCKET.SRC.PORT .EQ 8
S.SOCKET.DST.ADDR .EQ 10
@ -193,8 +194,8 @@ S.ETH.FRAMELEN .EQ 0
S.ETH.DSTMAC .EQ 2
S.ETH.SRCMAC .EQ 8
S.ETH.ETHERTYPE .EQ 14
S.ETH.ETHERTYPE.IP .EQ $800
S.ETH.ETHERTYPE.ARP .EQ $806
S.ETH.ETHERTYPE.IP .EQ $800
S.ETH.ETHERTYPE.ARP .EQ $806
*
S.ETH .EQ 2+6+6+2
*--------------------------------------
@ -218,9 +219,9 @@ S.IP.IDENTIFICATION .EQ S.ETH+4 $0000
S.IP.FRAGMENT.FLAGS .EQ S.ETH+6
S.IP.TTL .EQ S.ETH+8
S.IP.PROTOCOL .EQ S.ETH+9
S.IP.PROTOCOL.ICMP .EQ 1
S.IP.PROTOCOL.TCP .EQ 6
S.IP.PROTOCOL.UDP .EQ 17
S.IP.PROTOCOL.ICMP .EQ 1
S.IP.PROTOCOL.TCP .EQ 6
S.IP.PROTOCOL.UDP .EQ 17
S.IP.HDR.CHECKSUM .EQ S.ETH+10
S.IP.SRC .EQ S.ETH+12
S.IP.DST .EQ S.ETH+16
@ -228,9 +229,9 @@ S.IP.DST .EQ S.ETH+16
S.IP .EQ S.ETH+20
*--------------------------------------
S.ICMP.TYPE .EQ S.IP+0
S.ICMP.TYPE.ECHOREP .EQ 0
S.ICMP.TYPE.UNREACH .EQ 3
S.ICMP.TYPE.ECHOREQ .EQ 8
S.ICMP.TYPE.ECHOREP .EQ 0
S.ICMP.TYPE.UNREACH .EQ 3
S.ICMP.TYPE.ECHOREQ .EQ 8
S.ICMP.CODE .EQ S.IP+1
S.ICMP.CHECKSUM .EQ S.IP+2
S.ICMP.IDENTIFIER .EQ S.IP+4
@ -252,12 +253,12 @@ S.TCP.ACK.NUMBER .EQ S.IP+8
S.TCP.DATAOFFSET .EQ S.IP+12
S.TCP.DATAOFFSET20 .EQ $50
S.TCP.OPTIONS .EQ S.IP+13
S.TCP.OPTIONS.URG .EQ %00100000
S.TCP.OPTIONS.ACK .EQ %00010000
S.TCP.OPTIONS.PSH .EQ %00001000
S.TCP.OPTIONS.RST .EQ %00000100
S.TCP.OPTIONS.SYN .EQ %00000010
S.TCP.OPTIONS.FIN .EQ %00000001
S.TCP.OPTIONS.URG .EQ %00100000
S.TCP.OPTIONS.ACK .EQ %00010000
S.TCP.OPTIONS.PSH .EQ %00001000
S.TCP.OPTIONS.RST .EQ %00000100
S.TCP.OPTIONS.SYN .EQ %00000010
S.TCP.OPTIONS.FIN .EQ %00000001
S.TCP.WINDOW .EQ S.IP+14
S.TCP.CHECKSUM .EQ S.IP+16
S.TCP.URGPTR .EQ S.IP+18

View File

@ -4,56 +4,25 @@ NEW
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
* Out:
*/--------------------------------------
* #FRM.NewA
* ##In:
* A = S.IP.PROTOCOL.???
* ##Out:
* Y,A = Frame PTR
* X = hMem
*--------------------------------------
NEW.ICMP.FRAME jsr NEW.IP.FRAME
bcs .9
ldy #S.IP.PROTOCOL
lda #S.IP.PROTOCOL.ICMP
sta (ZPFrameBase),y
>LDYA ZPFrameBase
clc
.9 rts
*--------------------------------------
* Out:
* Y,A = Frame PTR
* X = hMem
*--------------------------------------
NEW.TCP.FRAME jsr NEW.IP.FRAME
bcs .9
ldy #S.IP.PROTOCOL
lda #S.IP.PROTOCOL.TCP
sta (ZPFrameBase),y
>LDYA ZPFrameBase
clc
.9 rts
*--------------------------------------
* Out:
* Y,A = Frame PTR
* X = hMem
*--------------------------------------
NEW.UDP.FRAME jsr NEW.IP.FRAME
bcs .9
ldy #S.IP.PROTOCOL
lda #S.IP.PROTOCOL.UDP
sta (ZPFrameBase),y
>LDYA ZPFrameBase
clc
.9 rts
*--------------------------------------
* Out:
* Y,A = Frame PTR
* X = hMem
*--------------------------------------
NEW.IP.FRAME >PUSHWI K.ETH.FRAME.LEN
*\--------------------------------------
FRM.NewA sta .1+2
>PUSHWI K.ETH.FRAME.LEN
>PUSHBI S.MEM.F.INIT0
>SYSCALL GetMem
bcs .9
>STYA ZPFrameBase
ldy #S.IP.PROTOCOL
.1 lda #$ff
sta (ZPFrameBase),y
lda DevFlags
and #S.DEVSTAT.NET.FLAGS.IPOFFLOAD
bne .9
@ -89,11 +58,7 @@ NEW.IP.FRAME >PUSHWI K.ETH.FRAME.LEN
>LDYA ZPFrameBase
.9 rts
*--------------------------------------
SEND.ICMP.FRAME >PULLW ZPFrameBase
jsr FRM.GetLen
stz hFrameOut
SEND.ICMP.FRAME.I
>PUSHW ZPFrameLen
FRM.SendICMP >PUSHW ZPFrameLen
>PUSHWI S.ICMP.TYPE-2
ldy #S.ICMP.CHECKSUM
@ -111,20 +76,13 @@ SEND.ICMP.FRAME.I
pla
sta (ZPFrameBase),y
bra SEND.IP.FRAME.I
bra FRM.SendIP
*--------------------------------------
SEND.TCP.FRAME >PULLW ZPFrameBase
jsr FRM.GetLen
stz hFrameOut
SEND.TCP.FRAME.I
FRM.SendTCP
bra SEND.IP.FRAME.I
bra FRM.SendIP
*--------------------------------------
SEND.UDP.FRAME >PULLW ZPFrameBase
jsr FRM.GetLen
stz hFrameOut
SEND.UDP.FRAME.I
ldy #S.UDP.LENGTH+1
FRM.SendUDP ldy #S.UDP.LENGTH+1
lda ZPFrameLen
sec
sbc #S.IP-2
@ -133,13 +91,8 @@ SEND.UDP.FRAME.I
lda ZPFrameLen+1
sbc /S.IP-2
sta (ZPFrameBase),y
bra SEND.IP.FRAME.I
*--------------------------------------
SEND.IP.FRAME >PULLW ZPFrameBase
jsr FRM.GetLen
stz hFrameOut
SEND.IP.FRAME.I ldx #3 Copy SRC.IP even if IP offload
FRM.SendIP ldx #3 Copy SRC.IP even if IP offload
ldy #S.IP.SRC+3 for proper UDP/TCP CRC calculation
.1 lda IPCFG+S.IPCFG.IP,x

View File

@ -1,23 +1,26 @@
PR#3
PREFIX /A2OSX.SRC
NEW
LOMEM $A00
INC 1
AUTO 6
.LIST OFF
*--------------------------------------
ICMP.IN ldy #S.ICMP.TYPE
lda (ZPFrameBase),y
cmp #S.ICMP.TYPE.ECHOREP
beq ICMP.IN.ECHOREP
cmp #S.ICMP.TYPE.ECHOREQ
bne .9
bne ICMP.IN.EXIT
ldy #S.IP.DST
ldx #S.IPCFG.IP
ICMP.IN.ECHOREQ ldy #S.IP.DST+3
ldx #3
.1 lda (ZPFrameBase),y
cmp IPCFG,x
bne .9
iny
inx
cpx #S.IPCFG.IP+4
cmp IPCFG+S.IPCFG.IP,x
bne ICMP.IN.EXIT
dey
dex
bne .1
ldy #S.ICMP.TYPE
@ -59,11 +62,66 @@ ICMP.IN ldy #S.ICMP.TYPE
lda #S.ARPCACHE.STATUS.RESOLVED
jsr ARP.ADD.I
stz hFrameOut DO NOT QUEUE/DISCARD this frame,it is SOURCE frame!!!
jmp SEND.ICMP.FRAME.I
.9 sec
lda hFrameIn
sta hFrameOut DO NOT DISCARD this frame,it is SOURCE frame!!!
jmp FRM.SendICMP
ICMP.IN.EXIT lda hFrameIn
>SYSCALL FreeMemA
rts
*--------------------------------------
ICMP.IN.ECHOREP jsr IP.FillTmpSocketSrcDst
lda #S.IP.PROTOCOL.ICMP
sta TmpSocket+S.SOCKET.RAW.PROTO
ldy #S.ICMP.IDENTIFIER
lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.SRC.PORT+1
iny
lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.SRC.PORT
>LDYA L.SKT.TABLE
>STYA ZPPtrSKT
ldx #0
.3 lda (ZPPtrSKT)
beq .7
cmp #S.SOCKET.SOCK.RAW
bne .7
ldy #S.SOCKET.SRC.ADDR
.4 lda (ZPPtrSKT),y
cmp TmpSocket,y
bne .7
iny
cpy #S.SOCKET.DST.PORT Compare SRC.ADDR,SRC.PORT,DST.ADDR
bne .4
lda hFrameIn
jsr SKT.AddToQueueA
bcs .9 Q full, discard...
rts DO NOT Discard this queued frame
.7 lda ZPPtrSKT
clc
adc #S.SOCKET
sta ZPPtrSKT
bcc .8
inc ZPPtrSKT+1
.8 inx
cpx #K.SKTTABLE.SIZE
bne .3
.9 lda hFrameIn
>SYSCALL FreeMemA
rts
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S.ICMP
LOAD LIB/LIBTCPIP.S

View File

@ -93,6 +93,24 @@ IP.ComputeChecksum
eor #$FF
rts
*--------------------------------------
IP.FillTmpSocketSrcDst
ldy #S.IP.SRC+3
ldx #3
.1 lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.DST.ADDR,x
dey
dex
bpl .1
ldy #S.IP.DST+3
ldx #3
.2 lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.SRC.ADDR,x
dey
dex
bpl .2
rts
*--------------------------------------
IP.SetDestMAC ldy #S.IP.DST
lda (ZPFrameBase),y
iny

View File

@ -1,6 +1,6 @@
PR#3
PREFIX /A2OSX.SRC
NEW
LOMEM $A00
INC 1
AUTO 6
.LIST OFF
@ -8,7 +8,7 @@ AUTO 6
* IN : PULLW = PTR to S.SOCKET template
* OUT :
* YA=PTR to new S.SOCKET
* X hSocket 128<x<255
* X=hSocket
*--------------------------------------
SKT.NEW >PULLW ZPTmpPtr1
@ -53,9 +53,7 @@ SKT.NEW >PULLW ZPTmpPtr1
bmi .5 Already found an empty slot
>LDYA ZPTmpPtr2
>STYA ZPTmpPtr3
txa
ora #$80
sta TmpOffset
stx TmpOffset
.5 lda ZPTmpPtr2
clc
@ -115,11 +113,9 @@ SKT.ACCEPTA jsr SKT.GetA
sec
.9 rts
*--------------------------------------
SKT.SENDA
sec
rts
* SKT.Send
*--------------------------------------
SKT.SEND >PULLB hSocket
SKT.Send >PULLB hSocket
pha
>PULLW ZPDataPtr
>PULLW ZPDataLen
@ -132,13 +128,18 @@ SKT.SEND >PULLB hSocket
beq SKT.SEND.UDP
cpx #S.SOCKET.SOCK.STREAM
bne .99
bne .1
jmp SKT.SEND.TCP
.1 cpx #S.SOCKET.SOCK.RAW
bne .99
jmp SKT.SEND.RAW
.99 sec
.9 rts
*--------------------------------------
SKT.SEND.UDP jsr NEW.UDP.FRAME
SKT.SEND.UDP lda #S.IP.PROTOCOL.UDP
jsr FRM.NewA
bcs .9
stx hFrameOut
@ -213,7 +214,7 @@ SKT.SEND.UDP jsr NEW.UDP.FRAME
inc ZPTmpPtr1
bra .3
.4 jmp SEND.UDP.FRAME.I
.4 jmp FRM.SendUDP
.9 rts
*--------------------------------------
SKT.SEND.TCP
@ -221,6 +222,22 @@ SKT.SEND.TCP
sec
rts
*--------------------------------------
SKT.SEND.RAW ldy #S.SOCKET.RAW.PROTO
lda (ZPPtrSKT),y
cmp #S.IP.PROTOCOL.ICMP
bne .9
jsr FRM.NewA
bcs .9
stx hFrameOut
jmp FRM.SendIP
.9 sec
rts
*--------------------------------------
SKT.RCVDA jsr SKT.GetA
bcs .9
@ -332,7 +349,8 @@ SKT.AddToQueueL pha
sec
rts
*--------------------------------------
SKT.AddToQueueD ldy #S.SOCKET.DQ.HEAD
SKT.AddToQueueA sta .2+1
ldy #S.SOCKET.DQ.HEAD
lda (ZPPtrSKT),y
tax
inc
@ -349,7 +367,8 @@ SKT.AddToQueueD ldy #S.SOCKET.DQ.HEAD
clc
adc #S.SOCKET.DQ
tay
lda hFrameOut
.2 lda #$ff
sta (ZPPtrSKT),y
clc
rts

View File

@ -346,7 +346,7 @@ TCP.SendMSG sta TCP.MSG+S.TCP.OPTIONS
bpl .3
>PUSHW L.TCP.MSG
jsr SEND.TCP.FRAME
* jsr FRM.SendTCP
clc
rts

View File

@ -5,13 +5,7 @@ INC 1
AUTO 6
.LIST OFF
*--------------------------------------
UDP.IN ldy #S.IP.SRC+3
ldx #3
.1 lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.DST.ADDR,x
dey
dex
bpl .1
UDP.IN jsr IP.FillTmpSocketSrcDst
ldy #S.UDP.SRCPORT
lda (ZPFrameBase),y
@ -20,14 +14,6 @@ UDP.IN ldy #S.IP.SRC+3
lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.DST.PORT
ldy #S.IP.DST+3
ldx #3
.2 lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.SRC.ADDR,x
dey
dex
bpl .2
ldy #S.UDP.DSTPORT
lda (ZPFrameBase),y
sta TmpSocket+S.SOCKET.SRC.PORT+1
@ -69,7 +55,8 @@ UDP.IN ldy #S.IP.SRC+3
cpy #S.SOCKET.DST.PORT+2
bne .5
jsr SKT.AddToQueueD
lda hFrameIn
jsr SKT.AddToQueueA
bcs .9 Q full, discard...
rts DO NOT Discard this queued frame

View File

@ -45,14 +45,14 @@ CS.START cld
.DA SET.IPCFG
.DA GET.IPCFG
.DA NEW.ICMP.FRAME
.DA $ffff NEW.ICMP.FRAME
.DA $ffff NEW.TCP.FRAME
.DA $ffff NEW.UDP.FRAME
.DA $ffff NEW.IP.FRAME
.DA $ffff NEW.ARP.FRAME
.DA $ffff NEW.ETH.FRAME
.DA SEND.ICMP.FRAME
.DA $ffff SEND.ICMP.FRAME
.DA $ffff SEND.TCP.FRAME
.DA $ffff SEND.UDP.FRAME
.DA $ffff SEND.IP.FRAME
@ -75,7 +75,7 @@ CS.START cld
.DA SKT.NEW
.DA $FFFF
.DA SKT.ACCEPTA
.DA SKT.SENDA
.DA $FFFF
.DA SKT.SEND
.DA SKT.RCVDA
.DA $FFFF

10
_Docs/LIBTCPIP.md Normal file
View File

@ -0,0 +1,10 @@
*** Auto generated by docgen.cmd ***
#FRM.NewA
##In:
+ A = S.IP.PROTOCOL.???
##Out:
* Y,A = Frame PTR
* X = hMem

View File

@ -6,10 +6,12 @@ SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
for /f %%a in ('copy /Z "%~f0" nul') do set "CR=%%a"
mode con:cols=40 lines=24
mode con:cols=80 lines=24
cls
echo Apple //e
echo Apple //e
set /a c=0
set DOCFILE=%~dp0..\_Docs\KERNEL.md
@ -20,14 +22,12 @@ echo.
echo Scanning KERNEL Src Files...
echo.
set /a c=0
for /f %%F in ('dir /b /ogn %~dp0..\SYS\KERNEL.S*.txt') do (
for /f %%F in ('dir /b /ogn "%~dp0..\SYS\KERNEL.S*.txt"') do (
set FN=%%F
set /a c+=1
set /p "=!c! - !FN! !CR!" <NUL
set bInDoc=0
for /F "tokens=*" %%L in (%~dp0..\SYS\!FN!) do (
for /F "tokens=*" %%L in ('type "%~dp0..\SYS\!FN!"') do (
set LINE=%%L
if defined LINE (
set bOut=1
@ -51,6 +51,47 @@ for /f %%F in ('dir /b /ogn %~dp0..\SYS\KERNEL.S*.txt') do (
)
)
)
set DOCFILE=%~dp0..\_Docs\LIBTCPIP.md
echo # A2osX LIBTCPIP API >!DOCFILE!
echo *** Auto generated by docgen.cmd *** >!DOCFILE!
echo.
echo Scanning LIBTCPIP Src Files...
echo.
for /f %%F in ('dir /b /ogn "%~dp0..\LIB\LIBTCPIP.S*.txt"') do (
set FN=%%F
set /a c+=1
set /p "=!c! - !FN! !CR!" <NUL
set bInDoc=0
for /F "tokens=*" %%L in ('type "%~dp0..\LIB\!FN!"') do (
set LINE=%%L
if defined LINE (
set bOut=1
if "!LINE:~0,2!" EQU "*/" (
set bInDoc=1
set bOut=0
)
if "!LINE:~0,2!" EQU "*\" (
set bInDoc=0
set bOut=0
)
if !bInDoc! EQU 1 (
if !bOut! EQU 1 (
if "!line:~0,4!" EQU "* " set LINE= + !LINE:~4!
if "!line:~0,3!" EQU "* " set LINE=+ !LINE:~3!
if "!line:~0,2!" EQU "* " set LINE=!LINE:~2!
if "!line:~0,1!" EQU "#" echo.>>!DOCFILE!
(echo !LINE!)>>!DOCFILE!
)
)
)
)
)
echo.
echo.
echo All done : !c! Files scanned.