Rev 4435 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4435 | Rev 4469 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2010-2013. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2010-2014. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; ping.asm - ICMP echo client for KolibriOS ;; |
6 | ;; ping.asm - ICMP echo client for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
Line 160... | Line 160... | ||
160 | mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, MSG_DONTWAIT |
160 | mcall recv, [socketnum], buffer_ptr, BUFFERSIZE, MSG_DONTWAIT |
161 | cmp eax, -1 |
161 | cmp eax, -1 |
162 | je .no_response |
162 | je .no_response |
Line 163... | Line 163... | ||
163 | 163 | ||
164 | sub eax, ICMP_Packet.Data |
164 | sub eax, ICMP_Packet.Data |
165 | jb .no_response ; FIXME: use other error message? |
165 | jb .invalid |
Line 166... | Line 166... | ||
166 | mov [recvd], eax |
166 | mov [recvd], eax |
167 | 167 | ||
Line 168... | Line 168... | ||
168 | cmp word[buffer_ptr + ICMP_Packet.Identifier], IDENTIFIER |
168 | cmp word[buffer_ptr + ICMP_Packet.Identifier], IDENTIFIER |
169 | jne .no_response ; FIXME: use other error message? |
169 | jne .invalid |
170 | 170 | ||
171 | ; OK, we have a response, update stats and let the user know |
171 | ; OK, we have a response, update stats and let the user know |
Line 190... | Line 190... | ||
190 | push [recvd] |
190 | push [recvd] |
Line 191... | Line 191... | ||
191 | 191 | ||
192 | push str7 |
192 | push str7 |
Line 193... | Line 193... | ||
193 | call [con_printf] |
193 | call [con_printf] |
Line 194... | Line 194... | ||
194 | 194 | ||
195 | jmp continue |
195 | jmp .continue |
196 | 196 | ||
197 | ; Error in packet, print it to user |
197 | ; Error in packet, print it to user |
198 | .miscomp: |
198 | .miscomp: |
199 | sub edi, icmp_packet.data |
199 | sub edi, icmp_packet.data |
200 | push edi |
200 | push edi |
- | 201 | push str9 |
|
- | 202 | call [con_printf] |
|
- | 203 | jmp .continue |
|
- | 204 | ||
- | 205 | ; Invalid reply |
|
- | 206 | .invalid: |
|
Line 201... | Line 207... | ||
201 | push str9 |
207 | push str10 |
202 | call [con_printf] |
208 | call [con_write_asciiz] |
203 | jmp continue |
209 | jmp .continue |
204 | 210 | ||
Line 205... | Line 211... | ||
205 | ; Timeout! |
211 | ; Timeout! |
206 | .no_response: |
212 | .no_response: |
207 | push str8 |
213 | push str8 |
Line 208... | Line 214... | ||
208 | call [con_write_asciiz] |
214 | call [con_write_asciiz] |
209 | 215 | ||
Line 270... | Line 276... | ||
270 | 276 | ||
271 | str11 db 'Answer: ',0 |
277 | str11 db 'Answer: ',0 |
272 | str7 db 'bytes=%u seq=%u time=%u ms',10,0 |
278 | str7 db 'bytes=%u seq=%u time=%u ms',10,0 |
273 | str8 db 'timeout!',10,0 |
279 | str8 db 'timeout!',10,0 |
- | 280 | str9 db 'miscompare at offset %u',10,0 |
|
Line 274... | Line 281... | ||
274 | str9 db 'miscompare at offset %u',10,0 |
281 | str10 db 'reply invalid',10,0 |
Line 275... | Line 282... | ||
275 | 282 | ||
276 | str12 db 10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0 |
283 | str12 db 10,'Ping stats:',10,'%u packets sent, %u packets received',10,'average response time=%u ms',10,0 |