2016-01-16 22:04:22 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
NEW.ETH.FRAME >PUSHWI K.ETH.FRAME.LEN
|
|
|
|
|
>PUSHBI S.MEM.F.INIT0
|
|
|
|
|
>SYSCALL SYS.GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA ZPFrameBase1
|
|
|
|
|
clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SEND.ICMP.FRAME >PULLW ZPFrameBase1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
jsr FRM.GetLen1
|
|
|
|
|
SEND.ICMP.FRAME.I
|
2016-01-16 22:04:22 +00:00
|
|
|
|
>PUSHW ZPFrameLen1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
>PUSHWI S.ICMP.TYPE-2
|
|
|
|
|
|
|
|
|
|
ldy #S.ICMP.CHECKSUM
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
iny
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
jsr IP.ComputeChecksum
|
|
|
|
|
|
|
|
|
|
phy
|
|
|
|
|
ldy #S.ICMP.CHECKSUM
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
iny
|
|
|
|
|
pla
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
|
|
|
|
|
bra SEND.IP.FRAME.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SEND.TCP.FRAME >PULLW ZPFrameBase1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
jsr FRM.GetLen1
|
|
|
|
|
SEND.TCP.FRAME.I
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bra SEND.IP.FRAME.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SEND.UDP.FRAME >PULLW ZPFrameBase1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
jsr FRM.GetLen1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
SEND.UDP.FRAME.I
|
|
|
|
|
ldy #S.UDP.LENGTH+1
|
|
|
|
|
lda ZPFrameLen1
|
|
|
|
|
sec
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc #S.IP-2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
dey
|
|
|
|
|
lda ZPFrameLen1+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc /S.IP-2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
bra SEND.IP.FRAME.I
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SEND.IP.FRAME >PULLW ZPFrameBase1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
jsr FRM.GetLen1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
SEND.IP.FRAME.I ldx #3
|
|
|
|
|
ldy #S.IP.SRC+3
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.10 lda IPCFG+S.IPCFG.IP,x
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta (ZPFrameBase1),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
dey
|
|
|
|
|
dex
|
|
|
|
|
bpl .10
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.TOTAL.LENGTH+1
|
|
|
|
|
lda ZPFrameLen1
|
|
|
|
|
sec
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc #S.ETH-2
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
dey
|
|
|
|
|
lda ZPFrameLen1+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
sbc /S.ETH-2
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
ldy #S.IP.HDR.CHECKSUM
|
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
iny
|
2016-01-16 22:04:22 +00:00
|
|
|
|
sta (ZPFrameBase1),y
|
|
|
|
|
|
|
|
|
|
stz IP.CHECKSUM RESET.IP.CHECKSUM
|
|
|
|
|
stz IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
clc
|
2016-01-16 22:04:22 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.V.IHL.DSCP.ECN
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldx #10 10 words for IP Header
|
|
|
|
|
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.1 lda (ZPFrameBase1),y
|
|
|
|
|
adc IP.CHECKSUM
|
|
|
|
|
sta IP.CHECKSUM
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPFrameBase1),y
|
2016-01-16 22:04:22 +00:00
|
|
|
|
adc IP.CHECKSUM+1
|
|
|
|
|
sta IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
|
|
|
|
dex
|
2016-01-16 22:04:22 +00:00
|
|
|
|
bne .1
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
ldy #S.IP.HDR.CHECKSUM
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda IP.CHECKSUM
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #0
|
2016-01-16 22:04:22 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
sta (ZPFrameBase1),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
iny
|
2016-01-16 22:04:22 +00:00
|
|
|
|
lda IP.CHECKSUM+1
|
2016-03-13 22:09:00 +00:00
|
|
|
|
adc #0
|
2016-01-16 22:04:22 +00:00
|
|
|
|
eor #$FF
|
|
|
|
|
sta (ZPFrameBase1),y
|
2016-03-13 22:09:00 +00:00
|
|
|
|
|
|
|
|
|
ldy #S.IP.PROTOCOL
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
cmp #S.IP.PROTOCOL.TCP
|
|
|
|
|
bne .3
|
|
|
|
|
jsr TCP.ComputeChecksum
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.3 cmp #S.IP.PROTOCOL.UDP
|
|
|
|
|
bne .8
|
|
|
|
|
jsr UDP.ComputeChecksum
|
|
|
|
|
|
|
|
|
|
.8 lda DevFlags
|
|
|
|
|
and #S.DEVINFO.NET.FLAGS.ARPOFFLOAD
|
|
|
|
|
bne .81
|
|
|
|
|
|
|
|
|
|
jsr ARP.RESOLVE
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
.81 >PUSHW ZPFrameBase1
|
|
|
|
|
ldx #DEVMGR.NET.SEND
|
|
|
|
|
jmp NetDevJmp
|
2016-01-16 22:04:22 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
SEND.ARP.FRAME >PUSHW ZPFrameBase1
|
|
|
|
|
ldx #DEVMGR.NET.SEND
|
|
|
|
|
jmp NetDevJmp
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
SEND.ETH.FRAME >PUSHW ZPFrameBase1
|
|
|
|
|
ldx #DEVMGR.NET.SEND
|
|
|
|
|
jmp NetDevJmp
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
RCVD.FRAME >PULLW ZPFrameBase1
|
|
|
|
|
bra *
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
RCVD.FRAMEA sta hFrame1
|
|
|
|
|
>SYSCALL SYS.GetMemPtrA
|
|
|
|
|
>STYA ZPFrameBase1
|
|
|
|
|
|
|
|
|
|
jsr FRM.GetLen1
|
|
|
|
|
|
|
|
|
|
ldy #S.ETH.ETHERTYPE
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
tax
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
|
|
|
|
|
cmp #S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.ARP
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
jmp ARP.IN
|
|
|
|
|
|
|
|
|
|
.1 cmp #S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .9
|
|
|
|
|
cpx /S.ETH.ETHERTYPE.IP
|
|
|
|
|
bne .9
|
|
|
|
|
|
2016-03-16 16:37:02 +00:00
|
|
|
|
jmp IP.IN
|
|
|
|
|
|
2016-03-13 22:09:00 +00:00
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2016-01-16 22:04:22 +00:00
|
|
|
|
*--------------------------------------
|
2016-03-13 22:09:00 +00:00
|
|
|
|
FRM.GetLen1 lda (ZPFrameBase1) Get Frame Len
|
|
|
|
|
sta ZPFrameLen1
|
|
|
|
|
ldy #1
|
|
|
|
|
lda (ZPFrameBase1),y
|
|
|
|
|
sta ZPFrameLen1+1
|
2016-01-16 22:04:22 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE LIB/LIBTCPIP.S.FRM
|
|
|
|
|
LOAD LIB/LIBTCPIP.S
|
|
|
|
|
ASM
|