59,12 → 59,9 |
; main loop |
cmp byte[s], 0 |
jne resolve |
|
push str_welcome |
call [con_write_asciiz] |
main: |
; write prompt |
push str_prompt |
push str2 |
call [con_write_asciiz] |
; read string |
mov esi, s |
85,11 → 82,6 |
mov byte [esi-2], al |
pop esi |
|
; reset stats |
mov [stats.tx], 0 |
mov [stats.rx], 0 |
mov [stats.time], 0 |
|
resolve: |
; resolve name |
push esp ; reserve stack place |
219,47 → 211,41 |
|
; Done.. |
done: |
cmp [stats.rx], 0 |
jne @f |
xor eax, eax |
jmp .zero |
@@: |
xor edx, edx |
mov eax, [stats.time] |
div [stats.rx] |
.zero: |
push eax |
push [stats.rx] |
push [stats.tx] |
push str12 |
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 |
fail: |
push str5 |
call [con_write_asciiz] |
jmp main |
jmp done |
|
; Socket error |
fail2: |
push str6 |
call [con_write_asciiz] |
jmp main |
jmp done |
|
; Finally.. exit! |
exit: |
push 1 |
call [con_exit] |
|
mcall -1 |
|
|
; data |
title db 'ICMP echo (ping) client',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 |
title db 'ICMP - echo client',0 |
str2 db '> ',0 |
str3 db 'Pinging to ',0 |
str3b db ' with %u data bytes',10,0 |
|
271,6 → 257,7 |
str7 db 'bytes=%u seq=%u time=%u ms',10,0 |
str8 db 'timeout!',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 |
|
286,9 → 273,9 |
recvd dd ? ; received number of bytes in last packet |
|
stats: |
.tx dd ? |
.rx dd ? |
.time dd ? |
.tx dd 0 |
.rx dd 0 |
.time dd 0 |
|
; import |
align 4 |