mirror of
https://github.com/A2osX/A2osX.git
synced 2024-09-10 22:54:59 +00:00
270 lines
5.5 KiB
Plaintext
270 lines
5.5 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
*--------------------------------------
|
||
* 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 (ZPFrameBase1),y
|
||
>LDYA ZPFrameBase1
|
||
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 (ZPFrameBase1),y
|
||
>LDYA ZPFrameBase1
|
||
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 (ZPFrameBase1),y
|
||
>LDYA ZPFrameBase1
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Out:
|
||
* Y,A = Frame PTR
|
||
* X = hMem
|
||
*--------------------------------------
|
||
NEW.IP.FRAME jsr NEW.ETH.FRAME
|
||
bcs .9
|
||
|
||
ldy #S.ETH.ETHERTYPE
|
||
lda /S.ETH.ETHERTYPE.IP
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #S.ETH.ETHERTYPE.IP
|
||
sta (ZPFrameBase1),y
|
||
|
||
ldy #S.IP.V.IHL.DSCP.ECN
|
||
lda #$45
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #$0
|
||
sta (ZPFrameBase1),y
|
||
|
||
ldy #S.IP.IDENTIFICATION
|
||
sta (ZPFrameBase1),y
|
||
inc
|
||
iny
|
||
sta (ZPFrameBase1),y
|
||
dec
|
||
ldy #S.IP.FRAGMENT.FLAGS
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
sta (ZPFrameBase1),y
|
||
|
||
ldy #S.IP.TTL
|
||
lda #K.IP.TTL
|
||
sta (ZPFrameBase1),y
|
||
>LDYA ZPFrameBase1
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Out:
|
||
* Y,A = Frame PTR
|
||
* X = hMem
|
||
*--------------------------------------
|
||
NEW.ARP.FRAME jsr NEW.ETH.FRAME
|
||
bcs .9
|
||
|
||
ldy #S.ETH.ETHERTYPE
|
||
lda /S.ETH.ETHERTYPE.ARP
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #S.ETH.ETHERTYPE.ARP
|
||
sta (ZPFrameBase1),y
|
||
|
||
ldy #S.ARP.HTYPE
|
||
lda #0
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #1
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #8
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #0
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #6
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
lda #4
|
||
sta (ZPFrameBase1),y
|
||
>LDYA ZPFrameBase1
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* Out:
|
||
* Y,A = Frame PTR
|
||
* X = hMem
|
||
*--------------------------------------
|
||
NEW.ETH.FRAME >PUSHWI K.ETH.FRAME.LEN
|
||
>PUSHBI S.MEM.F.INIT0
|
||
>SYSCALL SYS.GetMem
|
||
bcs .9
|
||
>STYA ZPFrameBase1
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.ICMP.FRAME >PULLW ZPFrameBase1
|
||
>PULLW ZPFrameLen1
|
||
|
||
>PUSHW ZPFrameLen1
|
||
>PUSHWI S.ICMP.TYPE
|
||
jsr IP.ComputeChecksum
|
||
|
||
phy
|
||
ldy #S.ICMP.CHECKSUM
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
pla
|
||
sta (ZPFrameBase1),y
|
||
|
||
bra SEND.IP.FRAME.I
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.TCP.FRAME >PULLW ZPFrameBase1
|
||
>PULLW ZPFrameLen1
|
||
bra SEND.IP.FRAME.I
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.UDP.FRAME >PULLW ZPFrameBase1
|
||
>PULLW ZPFrameLen1
|
||
SEND.UDP.FRAME.I
|
||
ldy #S.UDP.LENGTH+1
|
||
lda ZPFrameLen1
|
||
sec
|
||
sbc #S.IP
|
||
sta (ZPFrameBase1),y
|
||
dey
|
||
lda ZPFrameLen1+1
|
||
sbc /S.IP
|
||
sta (ZPFrameBase1),y
|
||
lda #0 SET.UDP.CHECKSUM
|
||
ldy #S.UDP.CHECKSUM (0 = Disable UDP Checksum)
|
||
sta (ZPFrameBase1),y
|
||
iny
|
||
sta (ZPFrameBase1),y
|
||
bra SEND.IP.FRAME.I
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.IP.FRAME >PULLW ZPFrameBase1
|
||
>PULLW ZPFrameLen1
|
||
|
||
SEND.IP.FRAME.I ldx #S.IPCFG.IP
|
||
ldy #S.IP.SRC
|
||
|
||
.10 lda IPCFG,x
|
||
sta (ZPFrameBase1),y
|
||
inx
|
||
iny
|
||
cpy #S.IP.SRC+4
|
||
bne .10
|
||
|
||
jsr ARP.RESOLVE
|
||
bcs .9
|
||
ldy #S.IP.TOTAL.LENGTH+1
|
||
lda ZPFrameLen1
|
||
sec
|
||
sbc #S.ETH
|
||
sta (ZPFrameBase1),y
|
||
dey
|
||
lda ZPFrameLen1+1
|
||
sbc /S.ETH
|
||
sta (ZPFrameBase1),y
|
||
|
||
stz IP.CHECKSUM RESET.IP.CHECKSUM
|
||
stz IP.CHECKSUM+1
|
||
stz IP.CHECKSUM+2
|
||
* stz IP.CHECKSUM+3 Optimized for IP Header
|
||
|
||
ldy #S.IP.V.IHL.DSCP.ECN
|
||
.1 lda (ZPFrameBase1),y
|
||
tax
|
||
iny
|
||
lda (ZPFrameBase1),y
|
||
iny
|
||
clc
|
||
adc IP.CHECKSUM
|
||
sta IP.CHECKSUM
|
||
txa
|
||
adc IP.CHECKSUM+1
|
||
sta IP.CHECKSUM+1
|
||
bcc .2
|
||
inc IP.CHECKSUM+2
|
||
*.2 bne .3 Optimized for IP Header
|
||
* inc IP.CHECKSUM+3 Optimized for IP Header
|
||
.2 cpy #S.IP
|
||
bne .1
|
||
|
||
lda IP.CHECKSUM
|
||
clc
|
||
adc IP.CHECKSUM+2
|
||
eor #$FF
|
||
ldy #S.IP.HDR.CHECKSUM+1
|
||
sta (ZPFrameBase1),y
|
||
dey
|
||
lda IP.CHECKSUM+1
|
||
* adc IP.CHECKSUM+3 Optimized for IP Header
|
||
adc #0 Optimized for IP Header
|
||
eor #$FF
|
||
sta (ZPFrameBase1),y
|
||
bra SEND.ETH.FRAME
|
||
.9 rts
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.ARP.FRAME >PULLW ZPFrameBase1
|
||
SEND.ARP.FRAME.I
|
||
>LDYAI S.ARP default ARP Frame length
|
||
>STYA ZPFrameLen1
|
||
*--------------------------------------
|
||
* In:
|
||
* Out:
|
||
*--------------------------------------
|
||
SEND.ETH.FRAME >PUSHW ZPFrameLen1
|
||
>PUSHW ZPFrameBase1
|
||
ldx #DEVMGR.NET.SEND
|
||
jsr NetDevJmp
|
||
rts
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE LIB/LIBTCPIP.S.FRM
|
||
LOAD LIB/LIBTCPIP.S
|
||
ASM
|