mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-29 17:50:18 +00:00
322 lines
6.4 KiB
Plaintext
322 lines
6.4 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/BIN/RPCDUMP
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/LIBSTR.I
|
||
.INB INC/LIBTCPIP.I
|
||
*--------------------------------------
|
||
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
|
||
*--------------------------------------
|
||
ZPIPCfgPtr .EQ ZPBIN
|
||
ZPFrameBase .EQ ZPBIN+2
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA 0
|
||
.DA CS.END-CS.START Code Length To Relocate
|
||
.DA DS.END-DS.START Data Segment to Allocate
|
||
.DA 0
|
||
.DA 0
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.LIBSTR .DA LIBSTR
|
||
L.LIBTCPIP .DA LIBTCPIP
|
||
L.Socket .DA Socket
|
||
L.Socket.Dst.Addr .DA Socket.Dst.Addr
|
||
L.RPC.Request .DA RPC.Request
|
||
L.MSG.USAGE .DA MSG.USAGE
|
||
L.MSG.UNKNOWN .DA MSG.UNKNOWN
|
||
L.MSG.TIMEOUT .DA MSG.TIMEOUT
|
||
L.MSG.DUMP0 .DA MSG.DUMP0
|
||
L.MSG.DUMP1 .DA MSG.DUMP1
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT ldy #S.PS.hARGS
|
||
lda (pPs),y
|
||
beq .99
|
||
|
||
>LDYA L.LIBSTR
|
||
>SYSCALL SYS.LoadLibYA
|
||
sta hLIBSTR
|
||
|
||
>LDYA L.LIBTCPIP
|
||
>SYSCALL SYS.LoadLibYA
|
||
sta hLIBTCPIP
|
||
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.GET.IPCFG is TCPIP loaded ?
|
||
bcs .99
|
||
>STYA ZPIPCfgPtr
|
||
|
||
lda (ZPIPCfgPtr) Configured ?
|
||
bpl .99
|
||
|
||
ldx #3
|
||
ldy #S.IPCFG.IP+3
|
||
.1 lda (ZPIPCfgPtr),y
|
||
sta Socket.Src.Addr,x
|
||
dey
|
||
dex
|
||
bpl .1
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
clc
|
||
rts
|
||
|
||
.99 >LDYA L.MSG.USAGE
|
||
>SYSCALL SYS.PStrOutYA
|
||
lda #SYSMGR.ERRSYN
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN jsr Init.Timeout
|
||
|
||
.1 >PUSHW L.Socket.Dst.Addr
|
||
ldy #S.PS.hARGS
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>PUSHYA
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
|
||
bcc .2
|
||
|
||
>SYSCALL SYS.Sleep
|
||
jsr Wait.Timeout
|
||
bcc .1
|
||
|
||
ldy #S.PS.hARGS
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>PUSHYA
|
||
>LDYA L.MSG.UNKNOWN
|
||
>SYSCALL SYS.PStrOutYA
|
||
sec
|
||
rts
|
||
|
||
.2 >PUSHW L.Socket
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.NEW
|
||
bcs .99
|
||
|
||
txa
|
||
ldy #hSocket
|
||
sta (pData),y
|
||
|
||
.3 >PUSHWI RPC.Request.End-RPC.Request
|
||
>PUSHW L.RPC.Request
|
||
ldy #hSocket
|
||
>PUSHB (pData),y
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.SEND
|
||
bcc .4
|
||
|
||
>SYSCALL SYS.Sleep
|
||
jsr Wait.Timeout
|
||
bcc .3
|
||
bra .99
|
||
|
||
.4 jsr Init.Timeout
|
||
|
||
.5 ldy #hSocket
|
||
lda (pData),y
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.RCVDA
|
||
bcc .6
|
||
|
||
>SYSCALL SYS.Sleep
|
||
jsr Wait.Timeout
|
||
bcc .5
|
||
bra .99
|
||
|
||
.6 ldy #hFrame
|
||
sta (pData),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>STYA ZPFrameBase
|
||
|
||
jsr DumpRPCFrame
|
||
|
||
ldy #hFrame
|
||
lda (pData),y
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
lda #0
|
||
sec
|
||
rts
|
||
|
||
.99 ldy #S.PS.hARGS
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>PUSHYA
|
||
>LDYA L.MSG.TIMEOUT
|
||
>SYSCALL SYS.PStrOutYA
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT lda (pEvent)
|
||
bpl .1 is it a TIMER event?
|
||
|
||
ldy #TimeOut
|
||
lda (pData),y
|
||
beq .9
|
||
dec
|
||
sta (pData),y
|
||
.9 sec do not discard TIMER event
|
||
rts
|
||
|
||
.1 bit #S.EVT.F.KEY is it a KEY event?
|
||
beq .8
|
||
|
||
ldy #S.EVT.hDEV is Event from active IN device?
|
||
lda (pEvent),y
|
||
ldy #S.PS.hINDEV
|
||
cmp (pPs),y
|
||
bne .9
|
||
|
||
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
|
||
lda (pEvent),y
|
||
bne .9
|
||
|
||
ldy #S.EVT.DATALO
|
||
lda (pEvent),y
|
||
cmp #$03 Ctrl-C
|
||
bne .8
|
||
|
||
lda #$FF
|
||
ldy #bCTRLC
|
||
sta (pData),y
|
||
bra .8
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT ldy #hSocket
|
||
lda (pData),y
|
||
>LIBCALL hLIBTCPIP,LIBTCPIP.SKT.CLOSEA
|
||
|
||
lda hLIBSTR
|
||
beq .1
|
||
>SYSCALL SYS.UnloadLibA
|
||
|
||
.1 lda hLIBTCPIP
|
||
beq .8
|
||
>SYSCALL SYS.UnloadLibA
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
Init.Timeout ldy #TimeOut
|
||
lda #TIMEOUT.MAX
|
||
sta (pData),y
|
||
rts
|
||
*--------------------------------------
|
||
Wait.TimeOut sec
|
||
ldy #TimeOut
|
||
lda (pData),y
|
||
beq .9
|
||
ldy #bCTRLC
|
||
lda (pData),y
|
||
bmi .9
|
||
clc
|
||
.9 rts
|
||
*--------------------------------------
|
||
DumpRPCFrame lda #S.UDP+24
|
||
clc
|
||
adc ZPFrameBase
|
||
sta ZPFrameBase
|
||
lda /S.UDP+24
|
||
adc ZPFrameBase+1
|
||
sta ZPFrameBase+1
|
||
|
||
>LDYA L.MSG.DUMP0
|
||
>SYSCALL SYS.PStrOutYA
|
||
|
||
.1 ldy #3
|
||
lda (ZPFrameBase),y Value follows?
|
||
beq .9
|
||
|
||
ldy #18 port
|
||
>PUSHB (ZPFrameBase),y
|
||
iny
|
||
>PUSHB (ZPFrameBase),y
|
||
|
||
ldy #15 proto
|
||
>PUSHB (ZPFrameBase),y
|
||
|
||
ldy #11 version
|
||
>PUSHB (ZPFrameBase),y
|
||
|
||
ldy #4 program
|
||
.7 >PUSHB (ZPFrameBase),y
|
||
iny
|
||
cpy #8
|
||
bne .7
|
||
|
||
>PUSHW L.MSG.DUMP1
|
||
>LIBCALL hLIBSTR,LIBSTR.PRINTF
|
||
|
||
lda #20
|
||
clc
|
||
adc ZPFrameBase
|
||
sta ZPFrameBase
|
||
bcc .1
|
||
inc ZPFrameBase+1
|
||
bra .1
|
||
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.END
|
||
LIBSTR >PSTRING "libstr.o"
|
||
LIBTCPIP >PSTRING "libtcpip.o"
|
||
MSG.USAGE >PSTRING "Usage : RPCDUMP <ip|host>\n"
|
||
MSG.UNKNOWN >PSTRING "%S: Unknown host\n"
|
||
MSG.TIMEOUT >PSTRING "No response from %S\n"
|
||
MSG.DUMP0 >PSTRING "Program Ver Proto:Port\n"
|
||
MSG.DUMP1 >CSTRING "%10L %2d %2d:%D\n"
|
||
Socket .DA #S.SOCKET.SOCK.DGRAM
|
||
.BS 3
|
||
Socket.Src.Addr .BS 4
|
||
Socket.Src.Port .DA 0 Dynamic
|
||
Socket.Dst.Addr .BS 4
|
||
Socket.Dst.Port .DA UDP.PORT.PMAP
|
||
.BS 16
|
||
*--------------------------------------
|
||
RPC.Request .HS 12345678 XID
|
||
.HS 00000000 0=CALL
|
||
.HS 00000002 RPCVERS
|
||
.HS 000186A0 PROG=portmapper
|
||
.HS 00000002 VERS
|
||
.HS 00000004 PMAPPROC_DUMP
|
||
.HS 00000000 CRED
|
||
.HS 00000000
|
||
.HS 00000000 VERF
|
||
.HS 00000000
|
||
RPC.Request.End .EQ *
|
||
hLIBSTR .BS 1
|
||
hLIBTCPIP .BS 1
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
hSocket .BS 1
|
||
hFrame .BS 1
|
||
TimeOut .BS 1
|
||
bCTRLC .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE BIN/RPCDUMP.S
|
||
ASM
|