Subversion Repositories Kolibri OS

Rev

Rev 4014 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4014 Rev 4019
Line 57... Line 57...
57
        push    80
57
        push    80
58
        call    [con_init]
58
        call    [con_init]
59
; main loop
59
; main loop
60
        cmp     byte[s], 0
60
        cmp     byte[s], 0
61
        jne     resolve
61
        jne     resolve
-
 
62
 
-
 
63
        push    str_welcome
-
 
64
        call    [con_write_asciiz]
62
main:
65
main:
63
; write prompt
66
; write prompt
64
        push    str2
67
        push    str_prompt
65
        call    [con_write_asciiz]
68
        call    [con_write_asciiz]
66
; read string
69
; read string
67
        mov     esi, s
70
        mov     esi, s
68
        push    256
71
        push    256
69
        push    esi
72
        push    esi
Line 80... Line 83...
80
        test    al, al
83
        test    al, al
81
        jnz     @b
84
        jnz     @b
82
        mov     byte [esi-2], al
85
        mov     byte [esi-2], al
83
        pop     esi
86
        pop     esi
Line -... Line 87...
-
 
87
 
-
 
88
; reset stats
-
 
89
        mov     [stats.tx], 0
-
 
90
        mov     [stats.rx], 0
-
 
91
        mov     [stats.time], 0
84
 
92
 
85
resolve:
93
resolve:
86
; resolve name
94
; resolve name
87
        push    esp     ; reserve stack place
95
        push    esp     ; reserve stack place
88
        push    esp     ; fourth parameter
96
        push    esp     ; fourth parameter
Line 209... Line 217...
209
        inc     [icmp_packet.seq]
217
        inc     [icmp_packet.seq]
210
        jmp     mainloop
218
        jmp     mainloop
Line 211... Line 219...
211
 
219
 
212
; Done..
220
; Done..
-
 
221
done:
-
 
222
        cmp     [stats.rx], 0
-
 
223
        jne     @f
-
 
224
        xor     eax, eax
-
 
225
        jmp     .zero
213
done:
226
  @@:
214
        xor     edx, edx
227
        xor     edx, edx
215
        mov     eax, [stats.time]
228
        mov     eax, [stats.time]
-
 
229
        div     [stats.rx]
216
        div     [stats.rx]
230
  .zero:
217
        push    eax
231
        push    eax
218
        push    [stats.rx]
232
        push    [stats.rx]
219
        push    [stats.tx]
233
        push    [stats.tx]
220
        push    str12
234
        push    str12
221
        call    [con_printf]
-
 
222
 
-
 
223
        push    str10
-
 
224
        call    [con_write_asciiz]
-
 
225
        call    [con_getch2]
235
        call    [con_printf]
226
        push    1
-
 
227
        call    [con_exit]
-
 
228
 
-
 
229
; Finally.. exit!
-
 
230
exit:
-
 
Line 231... Line 236...
231
        mcall   -1
236
        jmp     main
232
 
237
 
233
; DNS error
238
; DNS error
234
fail:
239
fail:
235
        push    str5
240
        push    str5
Line 236... Line 241...
236
        call    [con_write_asciiz]
241
        call    [con_write_asciiz]
237
        jmp     done
242
        jmp     main
238
 
243
 
239
; Socket error
244
; Socket error
240
fail2:
245
fail2:
-
 
246
        push    str6
-
 
247
        call    [con_write_asciiz]
-
 
248
        jmp     main
-
 
249
 
-
 
250
; Finally.. exit!
-
 
251
exit:
-
 
252
        push    1
Line 241... Line 253...
241
        push    str6
253
        call    [con_exit]
242
        call    [con_write_asciiz]
254
 
-
 
255
        mcall   -1
-
 
256
 
243
        jmp     done
257
 
244
 
258
; data
245
 
259
title   db      'ICMP echo (ping) client',0
Line 246... Line 260...
246
; data
260
str_welcome db  'Please enter the hostname or IP-address of the host you want to ping,',10
247
title   db      'ICMP - echo client',0
261
            db  'or just press enter to exit.',10,0
Line 255... Line 269...
255
 
269
 
256
str11   db      'Answer: ',0
270
str11   db      'Answer: ',0
257
str7    db      'bytes=%u seq=%u time=%u ms',10,0
271
str7    db      'bytes=%u seq=%u time=%u ms',10,0
258
str8    db      'timeout!',10,0
272
str8    db      'timeout!',10,0
259
str9    db      'miscompare at offset %u',10,0
-
 
Line 260... Line 273...
260
str10   db      10,'Press any key to exit',0
273
str9    db      'miscompare at offset %u',10,0
Line 261... Line 274...
261
 
274
 
262
str12   db      10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0
275
str12   db      10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0
Line 271... Line 284...
271
ip_ptr          dd ?
284
ip_ptr          dd ?
272
count           dd ?
285
count           dd ?
273
recvd           dd ?    ; received number of bytes in last packet
286
recvd           dd ?    ; received number of bytes in last packet
Line 274... Line 287...
274
 
287
 
275
stats:
288
stats:
276
        .tx     dd 0
289
        .tx     dd ?
277
        .rx     dd 0
290
        .rx     dd ?
Line 278... Line 291...
278
        .time   dd 0
291
        .time   dd ?
279
 
292
 
280
; import
293
; import