forked from KolibriOS/kolibrios
Ping: fixed divide by zero error, improved user interface.
git-svn-id: svn://kolibrios.org@4019 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ab9ac88115
commit
83cca53cfa
@ -59,9 +59,12 @@ start:
|
|||||||
; main loop
|
; main loop
|
||||||
cmp byte[s], 0
|
cmp byte[s], 0
|
||||||
jne resolve
|
jne resolve
|
||||||
|
|
||||||
|
push str_welcome
|
||||||
|
call [con_write_asciiz]
|
||||||
main:
|
main:
|
||||||
; write prompt
|
; write prompt
|
||||||
push str2
|
push str_prompt
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
; read string
|
; read string
|
||||||
mov esi, s
|
mov esi, s
|
||||||
@ -82,6 +85,11 @@ main:
|
|||||||
mov byte [esi-2], al
|
mov byte [esi-2], al
|
||||||
pop esi
|
pop esi
|
||||||
|
|
||||||
|
; reset stats
|
||||||
|
mov [stats.tx], 0
|
||||||
|
mov [stats.rx], 0
|
||||||
|
mov [stats.time], 0
|
||||||
|
|
||||||
resolve:
|
resolve:
|
||||||
; resolve name
|
; resolve name
|
||||||
push esp ; reserve stack place
|
push esp ; reserve stack place
|
||||||
@ -211,41 +219,47 @@ mainloop:
|
|||||||
|
|
||||||
; Done..
|
; Done..
|
||||||
done:
|
done:
|
||||||
|
cmp [stats.rx], 0
|
||||||
|
jne @f
|
||||||
|
xor eax, eax
|
||||||
|
jmp .zero
|
||||||
|
@@:
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov eax, [stats.time]
|
mov eax, [stats.time]
|
||||||
div [stats.rx]
|
div [stats.rx]
|
||||||
|
.zero:
|
||||||
push eax
|
push eax
|
||||||
push [stats.rx]
|
push [stats.rx]
|
||||||
push [stats.tx]
|
push [stats.tx]
|
||||||
push str12
|
push str12
|
||||||
call [con_printf]
|
call [con_printf]
|
||||||
|
jmp main
|
||||||
push str10
|
|
||||||
call [con_write_asciiz]
|
|
||||||
call [con_getch2]
|
|
||||||
push 1
|
|
||||||
call [con_exit]
|
|
||||||
|
|
||||||
; Finally.. exit!
|
|
||||||
exit:
|
|
||||||
mcall -1
|
|
||||||
|
|
||||||
; DNS error
|
; DNS error
|
||||||
fail:
|
fail:
|
||||||
push str5
|
push str5
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp done
|
jmp main
|
||||||
|
|
||||||
; Socket error
|
; Socket error
|
||||||
fail2:
|
fail2:
|
||||||
push str6
|
push str6
|
||||||
call [con_write_asciiz]
|
call [con_write_asciiz]
|
||||||
jmp done
|
jmp main
|
||||||
|
|
||||||
|
; Finally.. exit!
|
||||||
|
exit:
|
||||||
|
push 1
|
||||||
|
call [con_exit]
|
||||||
|
|
||||||
|
mcall -1
|
||||||
|
|
||||||
|
|
||||||
; data
|
; data
|
||||||
title db 'ICMP - echo client',0
|
title db 'ICMP echo (ping) client',0
|
||||||
str2 db '> ',0
|
str_welcome db 'Please enter the hostname or IP-address of the host you want to ping,',10
|
||||||
|
db 'or just press enter to exit.',10,0
|
||||||
|
str_prompt db 10,'> ',0
|
||||||
str3 db 'Pinging to ',0
|
str3 db 'Pinging to ',0
|
||||||
str3b db ' with %u data bytes',10,0
|
str3b db ' with %u data bytes',10,0
|
||||||
|
|
||||||
@ -257,7 +271,6 @@ str11 db 'Answer: ',0
|
|||||||
str7 db 'bytes=%u seq=%u time=%u ms',10,0
|
str7 db 'bytes=%u seq=%u time=%u ms',10,0
|
||||||
str8 db 'timeout!',10,0
|
str8 db 'timeout!',10,0
|
||||||
str9 db 'miscompare at offset %u',10,0
|
str9 db 'miscompare at offset %u',10,0
|
||||||
str10 db 10,'Press any key to exit',0
|
|
||||||
|
|
||||||
str12 db 10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0
|
str12 db 10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0
|
||||||
|
|
||||||
@ -273,9 +286,9 @@ count dd ?
|
|||||||
recvd dd ? ; received number of bytes in last packet
|
recvd dd ? ; received number of bytes in last packet
|
||||||
|
|
||||||
stats:
|
stats:
|
||||||
.tx dd 0
|
.tx dd ?
|
||||||
.rx dd 0
|
.rx dd ?
|
||||||
.time dd 0
|
.time dd ?
|
||||||
|
|
||||||
; import
|
; import
|
||||||
align 4
|
align 4
|
||||||
|
Loading…
Reference in New Issue
Block a user