Subversion Repositories Kolibri OS

Rev

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

Rev 4469 Rev 5249
Line 56... Line 56...
56
        push    25
56
        push    25
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     parse_param
Line 62... Line 62...
62
 
62
 
63
        push    str_welcome
63
        push    str_welcome
64
        call    [con_write_asciiz]
64
        call    [con_write_asciiz]
65
main:
65
main:
Line 88... Line 88...
88
; reset stats
88
; reset stats
89
        mov     [stats.tx], 0
89
        mov     [stats.tx], 0
90
        mov     [stats.rx], 0
90
        mov     [stats.rx], 0
91
        mov     [stats.time], 0
91
        mov     [stats.time], 0
Line -... Line 92...
-
 
92
 
-
 
93
parse_param:
-
 
94
        mov     [count], 4      ; default number of pings to send
-
 
95
 
-
 
96
; Check if any additional parameters were given
-
 
97
        mov     esi, s
-
 
98
        mov     ecx, 1024
-
 
99
  .addrloop:
-
 
100
        lodsb
-
 
101
        test    al, al
-
 
102
        jz      .resolve
-
 
103
        cmp     al, ' '
-
 
104
        jne     .addrloop
-
 
105
        mov     byte[esi-1], 0
-
 
106
        jmp     .param
-
 
107
 
-
 
108
  .param_loop:
-
 
109
        lodsb
-
 
110
        test    al, al
-
 
111
        jz      .resolve
-
 
112
        cmp     al, ' '
-
 
113
        jne     .invalid
-
 
114
  .param:
-
 
115
        lodsb
-
 
116
        cmp     al, '-'
-
 
117
        jne     .invalid
-
 
118
        lodsb
-
 
119
        cmp     al, 't'
-
 
120
        jne     @f
-
 
121
        mov     [count], -1     ; infinite
-
 
122
        jmp     .param_loop
-
 
123
  @@:
-
 
124
        ; implement more parameters here
-
 
125
  .invalid:
-
 
126
        push    str13
-
 
127
        call    [con_write_asciiz]
-
 
128
        jmp     main
92
 
129
 
93
resolve:
130
  .resolve:
94
; resolve name
131
; resolve name
95
        push    esp     ; reserve stack place
132
        push    esp     ; reserve stack place
96
        push    esp     ; fourth parameter
133
        push    esp     ; fourth parameter
97
        push    0       ; third parameter
134
        push    0       ; third parameter
Line 129... Line 166...
129
        mcall   connect, [socketnum], sockaddr1, 18
166
        mcall   connect, [socketnum], sockaddr1, 18
Line 130... Line 167...
130
 
167
 
131
        mcall   40, 1 shl 7 ; + 7
168
        mcall   40, 1 shl 7 ; + 7
Line 132... Line -...
132
;        call    [con_cls]
-
 
133
 
-
 
134
        mov     [count], 4
169
;        call    [con_cls]
135
 
170
 
Line 136... Line 171...
136
        push    str3
171
        push    str3
137
        call    [con_write_asciiz]
172
        call    [con_write_asciiz]
Line 142... Line 177...
142
        push    (icmp_packet.length - ICMP_Packet.Data)
177
        push    (icmp_packet.length - ICMP_Packet.Data)
143
        push    str3b
178
        push    str3b
144
        call    [con_printf]
179
        call    [con_printf]
Line 145... Line 180...
145
 
180
 
-
 
181
mainloop:
-
 
182
        call    [con_get_flags]
-
 
183
        test    eax, 0x200                      ; con window closed?
-
 
184
        jnz     exit_now
146
mainloop:
185
 
147
        inc     [stats.tx]
186
        inc     [stats.tx]
148
        mcall   26,9
187
        mcall   26, 9
149
        mov     [time_reference], eax
188
        mov     [time_reference], eax
Line 215... Line 254...
215
 
254
 
216
; Send more ICMP packets ?
255
; Send more ICMP packets ?
217
  .continue:
256
  .continue:
Line -... Line 257...
-
 
257
        inc     [icmp_packet.seq]
-
 
258
 
218
        inc     [icmp_packet.seq]
259
        cmp     [count], -1
219
 
260
        je      .forever
220
        dec     [count]
261
        dec     [count]
221
        jz      done
262
        jz      done
Line 222... Line 263...
222
 
263
  .forever:
Line 223... Line 264...
223
        mcall   5, 100  ; wait a second
264
        mcall   5, 100  ; wait a second
Line 256... Line 297...
256
 
297
 
257
; Finally.. exit!
298
; Finally.. exit!
258
exit:
299
exit:
259
        push    1
300
        push    1
260
        call    [con_exit]
301
        call    [con_exit]
261
 
302
exit_now:
Line 262... Line 303...
262
        mcall   -1
303
        mcall   -1
263
 
304
 
Line 271... Line 312...
271
str3b   db      ' with %u data bytes',10,0
312
str3b   db      ' with %u data bytes',10,0
Line 272... Line 313...
272
 
313
 
273
str4    db      10,0
314
str4    db      10,0
274
str5    db      'Name resolution failed.',10,0
315
str5    db      'Name resolution failed.',10,0
-
 
316
str6    db      'Could not open socket',10,0
Line 275... Line 317...
275
str6    db      'Could not open socket',10,0
317
str13   db      'Invalid parameter(s)',10,0
276
 
318
 
277
str11   db      'Answer: ',0
319
str11   db      'Answer: ',0
278
str7    db      'bytes=%u seq=%u time=%u ms',10,0
320
str7    db      'bytes=%u seq=%u time=%u ms',10,0
Line 315... Line 357...
315
        con_printf,       'con_printf',     \
357
        con_printf,       'con_printf',     \
316
        con_exit,       'con_exit',     \
358
        con_exit,       'con_exit',     \
317
        con_gets,       'con_gets',\
359
        con_gets,       'con_gets',\
318
        con_cls,        'con_cls',\
360
        con_cls,        'con_cls',\
319
        con_getch2,     'con_getch2',\
361
        con_getch2,     'con_getch2',\
320
        con_set_cursor_pos, 'con_set_cursor_pos'
362
        con_set_cursor_pos, 'con_set_cursor_pos',\
-
 
363
        con_get_flags,  'con_get_flags'
Line 321... Line 364...
321
 
364
 
Line 322... Line 365...
322
socketnum       dd ?
365
socketnum       dd ?
323
 
366