📄 ppp.asm
字号:
push ecx
mov esi, abortres
mov edi, aborts
xor ecx, ecx
mov cl, byte [abortcnt]
call scanaborts ; scan 'em
pop ecx
pop edi
pop esi
and eax, eax
jz noabortdec
pop eax
xor eax, eax
jmp sw_exit
noabortdec:
pop eax
noabortflush:
mov byte [abortcnt], 0
noabort:
;--!
cmp [esi+edx], bl
je sw_003
xor edx, edx
; Added 28/4/03
cmp [esi+edx], bl
je sw_003
jmp sw_001
sw_003: ; They are the same
inc edx
cmp [esi+edx], byte 0
jne sw_001
xor eax, eax
inc eax
jmp sw_exit
sw_002:
; Test for data to send to modem
cmp [ edi + eax ], byte 0
je sw_001
; Is it a '|' character?
cmp [ edi + eax ], byte '|'
jne sw_004
push eax
call gettimer
cmp eax, 100
pop eax
jl sw_001
; restart the timer
push eax
xor eax, eax
call settimer
pop eax
; Move to next character
inc eax
jmp sw_001
sw_004:
push edx
push eax
; restart the timer
xor eax, eax
call settimer
; Test for tx ready.
; OR, wait then send
push edi
mov eax, 5
mov ebx, 1
int 0x40 ; 10ms delay
pop edi
; send the character
pop eax
mov bl, [edi + eax]
mov ecx, [comport]
inc eax
push eax
mov eax, 43
int 0x40
pop eax
pop edx
cmp [ edi + eax ], byte 0
jne sw_001
cmp [ esi + edx ], byte 0
jne sw_001
xor eax, eax
inc eax
sw_exit:
; return success (1) or failure (0) in eax
ret
if DEBUG_OUTPUT = TRUE
;****************************************************************************
; Function
; debug_output
;
; Description
; prints a description of the PPP protocol's data exchanges to the
; debug board
;
; esi holds ptr to msg to display
;
; Nothing preserved; I'm assuming a pusha/popa is done before calling
;
;****************************************************************************
debug_output:
cmp esi, RX_IP
jne do_001
call debug_print_string
call debug_print_rx_ip
mov esi, IP_DATA1
call debug_print_string
mov esi, CRLF
call debug_print_string
mov esi, IP_DATA2
call debug_print_string
ret
do_001:
cmp esi, TX_IP
jne do_002
call debug_print_string
call debug_print_tx_ip
mov esi, IP_DATA1
call debug_print_string
mov esi, CRLF
call debug_print_string
mov esi, IP_DATA2
call debug_print_string
ret
do_002:
; Print PPP protocol information
if DEBUG_PPP_OUTPUT = TRUE
call debug_print_string
mov esi, CRLF
call debug_print_string
end if
ret
txCom2:
push ecx
wait_txd2t:
mov eax,43
mov ecx,0x80000000 + 0x2f8 + 5
int 0x40
and bl, 0x40
cmp bl, 0
jz wait_txd2t ; loop until free
pop ebx
; send the character
mov ecx, 0x2f8
mov eax, 43
int 0x40
ret
;****************************************************************************
; Function
; debug_print_string
;
; Description
; prints a string to the debug board
;
; esi holds ptr to msg to display
;
; Nothing preserved; I'm assuming a pusha/popa is done before calling
;
;****************************************************************************
debug_print_string:
mov cl, [esi]
cmp cl, 0
jnz dps_001
ret
dps_001:
if DEBUG_PORT2_OUTPUT = TRUE
pusha
call txCom2
popa
end if
mov eax,63
mov ebx, 1
push esi
int 0x40
pop esi
inc esi
jmp debug_print_string
; This is used for translating hex to ASCII for display or output
hexchars db '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
IP_DATA1 db 'TCP From: xxxxxxxx To: xxxxxxxx SrcP: xxxx DestP: xxxx',0
IP_DATA2 db 'Seq: xxxxxxxx Ack: xxxxxxxx Flags: xx dataLen: xxxx',13,10,0
debug_print_rx_ip:
mov esi, rx_str + 4 ; The ip buffer address start
mov edi, IP_DATA1
cmp [esi+9], byte 1
jne rnICMP
mov eax,'ICMP'
jmp drp
rnICMP:
cmp [esi+9], byte 6
jne rnTCP
mov eax,'TCP '
jmp drp
rnTCP:
cmp [esi+9], byte 17
jne rnUDP
mov eax,'UDP '
jmp drp
rnUDP:
drp:
mov [edi], eax
call fillData
ret
debug_print_tx_ip:
mov esi, ip_buff ; The ip buffer address start
mov edi, IP_DATA1
cmp [esi+9], byte 1
jne tnICMP
mov eax,'ICMP'
jmp dtp
tnICMP:
cmp [esi+9], byte 6
jne tnTCP
mov eax,'TCP '
jmp dtp
tnTCP:
cmp [esi+9], byte 17
jne tnUDP
mov eax,'UDP '
jmp dtp
tnUDP:
dtp:
mov [edi], eax
call fillData
ret
fillData:
; Display from IP
mov cl, [esi+12]
mov edx, 11
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+13]
mov edx, 13
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+14]
mov edx, 15
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+15]
mov edx, 17
call wbyte ; byte in cl, dest in edi+edx
; Display to IP
mov cl, [esi+16]
mov edx, 24
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+17]
mov edx, 26
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+18]
mov edx, 28
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+19]
mov edx, 30
call wbyte ; byte in cl, dest in edi+edx
; Only display extra data for TCP
cmp [esi+9], byte 6 ; TCP?
je nTCP
; display source port
mov [edi+32], byte 0
mov edi, IP_DATA2
mov [edi], byte 0
ret
nTCP:
mov [edi+32], byte ' '
mov cl, [esi+20]
mov edx, 39
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+21]
mov edx, 41
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+22]
mov edx, 51
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+23]
mov edx, 53
call wbyte ; byte in cl, dest in edi+edx
mov edi, IP_DATA2
mov [edi], byte 'S'
mov cl, [esi+24]
mov edx, 5
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+25]
mov edx, 7
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+26]
mov edx, 9
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+27]
mov edx, 11
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+28]
mov edx, 19
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+29]
mov edx, 21
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+30]
mov edx, 23
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+31]
mov edx, 25
call wbyte ; byte in cl, dest in edi+edx
mov cl, [esi+33]
and cl, 0x3F
mov edx, 35
call wbyte ; byte in cl, dest in edi+edx
; Display the size of the received packet
mov dh, [esi + 2]
mov dl, [esi + 3]
sub dx, 40
mov cl, dh
mov edx, 48
call wbyte ; byte in cl, dest in edi+edx
mov dh, [esi + 2]
mov dl, [esi + 3]
sub dx, 40
mov cl, dl
mov edx, 50
call wbyte ; byte in cl, dest in edi+edx
ret
wbyte: ; byte in cl, dest in edi+edx, edi unchanged
xor eax, eax
mov al, cl
shr al, 4
mov bl, [eax + hexchars]
mov [edi+edx], bl
inc edx
mov al, cl
and al, 0x0f
mov bl, [eax + hexchars]
mov [edi+edx], bl
ret
else
debug_output:
ret
end if
; DATA AREA
; debug msgs
RX_IP db 'R: ',0
TX_IP db 'T: ',0
CRLF db 13,10,0
RX_LCP_REQ db 'RX_LCP_REQ',0
RX_LCP_ACK db 'RX_LCP_ACK',0
RX_LCP_NAK db 'RX_LCP_NAK',0
RX_LCP_REJ db 'RX_LCP_REJ',0
RX_LCP_ECHO_REQ db 'RX_LCP_ECHO_REQ',0
RX_PAP_ACK db 'RX_PAP_ACK',0
RX_IPCP_REQ db 'RX_IPCP_REQ',0
RX_IPCP_ACK db 'RX_IPCP_ACK',0
RX_IPCP_NAK db 'RX_IPCP_NAK ( IP Address assigned )',0
RX_CCP_REQ db 'RX_CCP_REQ',0
TX_LCP_REQ db 'TX_LCP_REQ',0
TX_PAP_REQ db 'TX_PAP_REQ',0
TX_IPCP_REQ db 'TX_IPCP_REQ',0
; Labels for GUI buttons
button1_text db 'DIAL'
button1_text_len db 4
button3_text db 'DISCONNECT'
button3_text_len db 10
comport dd 0
comirq dd 0
; Pointer to prompt shown to user
prompt dd 0
prompt_len db 0
; Application Title
window_label:
db 'PPP DIALER',0
txmsg: db 'Tx bytes :'
txmsglen:
rxmsg: db 'Rx bytes :'
rxmsglen:
timerValue dd 0
sendwaitTime dd 0
; Prompts displayed to the user
welcomep db 'Select an option below, see ppp.txt'
welcomep_len db 35
dialfp db 'Connect Failed...'
dialfp_len db 17
connectedp db 'Connected to Host'
connectedp_len db 17
conp db 'Connecting to Host'
conp_len db 18
pppOnp db 'PPP Started'
pppOnp_len db 11
IPOnp db 'IP Link established'
IPOnp_len db 19
discp db 'Disconnected from Host'
discp_len db 22
hangp db 'Hanging up Modem......'
hangp_len db 22
PPPconSend db 0x7e,0xff,0x7d,0x23,0x08,0x08,0x08,0x08,0
PPPconWait db '~~',0
hangupWait db 'ATZ',0
hangupSend db '|||+++|||',10,13,'ATH',10,13,'|ATZ',10,13,0
; Shrirang 2/5/03
abortres: times(50) db 0
abortcnt db 0
;--!
LCPREQStr db 0x0e,0x02,0x06,0x00, 0x0a, 0x00, 0x00, 0x07, 0x02, 0x08, 0x02
PAPREQStr db 14, 4, 'free', 4, 'free'
IPCPREQStr db 10, 3, 6, 0, 0, 0, 0
irqtable: dd 0x3f8 + 0x01000000 ; read port 0x3f8, byte
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
checksum1 dd 0
checksum2 dd 0
packet dd 0
state dd 0
extended dd 0
number dd 0
tx_end dd 0
tx_ptr dd 0
rx_ptr dd 0
addr1 db 0
addr2 db 0
addr3 db 0
addr4 db 0
rxbytes dd 0
txbytes dd 0
; End of application code and data marker
I_END:
rx_str: rb MaxRx + 1
tx_str: rb MaxTx + 1
ip_buff: rb 1500
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -