Rev 3545 | Rev 3600 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3545 | Rev 3556 | ||
---|---|---|---|
Line 140... | Line 140... | ||
140 | ; |
140 | ; |
141 | ;----------------------------------------------------------------- |
141 | ;----------------------------------------------------------------- |
142 | align 4 |
142 | align 4 |
143 | ICMP_input: |
143 | ICMP_input: |
Line 144... | Line 144... | ||
144 | 144 | ||
Line 145... | Line 145... | ||
145 | DEBUGF 1,"ICMP_input:\n" |
145 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input:\n" |
Line 146... | Line 146... | ||
146 | 146 | ||
147 | ; First, check the checksum (altough some implementations ignore it) |
147 | ; First, check the checksum (altough some implementations ignore it) |
Line 161... | Line 161... | ||
161 | jne .check_sockets |
161 | jne .check_sockets |
Line 162... | Line 162... | ||
162 | 162 | ||
163 | ; We well re-use the packet so we can create the response as fast as possible |
163 | ; We well re-use the packet so we can create the response as fast as possible |
Line 164... | Line 164... | ||
164 | ; Notice: this only works on pure ethernet |
164 | ; Notice: this only works on pure ethernet |
165 | 165 | ||
Line 166... | Line 166... | ||
166 | DEBUGF 1,"got echo request\n" |
166 | DEBUGF DEBUG_NETWORK_VERBOSE, "got echo request\n" |
Line 167... | Line 167... | ||
167 | mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply |
167 | mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply |
Line 256... | Line 256... | ||
256 | ; call IPv4_dest_to_dev |
256 | ; call IPv4_dest_to_dev |
257 | ; cmp edi,-1 |
257 | ; cmp edi,-1 |
258 | ; je .dump |
258 | ; je .dump |
259 | ; inc [ICMP_PACKETS_RX+edi] |
259 | ; inc [ICMP_PACKETS_RX+edi] |
Line 260... | Line 260... | ||
260 | 260 | ||
Line 261... | Line 261... | ||
261 | DEBUGF 1,"socket=%x\n", eax |
261 | DEBUGF DEBUG_NETWORK_VERBOSE, "socket=%x\n", eax |
262 | 262 | ||
263 | pusha |
263 | pusha |
264 | lea ecx, [eax + SOCKET.mutex] |
264 | lea ecx, [eax + SOCKET.mutex] |
Line 268... | Line 268... | ||
268 | mov esi, edx |
268 | mov esi, edx |
269 | jmp SOCKET_input |
269 | jmp SOCKET_input |
Line 270... | Line 270... | ||
270 | 270 | ||
271 | 271 | ||
Line 272... | Line 272... | ||
272 | .checksum_mismatch: |
272 | .checksum_mismatch: |
273 | DEBUGF 1,"checksum mismatch\n" |
273 | DEBUGF DEBUG_NETWORK_VERBOSE, "checksum mismatch\n" |
Line 274... | Line 274... | ||
274 | 274 | ||
275 | .dump: |
275 | .dump: |
Line 276... | Line 276... | ||
276 | DEBUGF 1,"ICMP_input: dumping\n" |
276 | DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n" |
Line 295... | Line 295... | ||
295 | ; |
295 | ; |
296 | ;----------------------------------------------------------------- |
296 | ;----------------------------------------------------------------- |
297 | align 4 |
297 | align 4 |
298 | ICMP_output: |
298 | ICMP_output: |
Line 299... | Line 299... | ||
299 | 299 | ||
Line 300... | Line 300... | ||
300 | DEBUGF 1,"Creating ICMP Packet\n" |
300 | DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n" |
Line 301... | Line 301... | ||
301 | 301 | ||
302 | push esi edi dx |
302 | push esi edi dx |
303 | 303 | ||
304 | mov edx, [eax + IP_SOCKET.LocalIP] |
304 | mov edx, [eax + IP_SOCKET.LocalIP] |
305 | mov eax, [eax + IP_SOCKET.RemoteIP] |
305 | mov eax, [eax + IP_SOCKET.RemoteIP] |
306 | add ecx, sizeof.ICMP_header |
306 | add ecx, sizeof.ICMP_header |
Line 307... | Line 307... | ||
307 | mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL |
307 | mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL |
Line 308... | Line 308... | ||
308 | call IPv4_output |
308 | call IPv4_output |
309 | jz .exit |
309 | jz .exit |
310 | 310 | ||
Line 331... | Line 331... | ||
331 | and cx, 3 |
331 | and cx, 3 |
332 | rep movsb |
332 | rep movsb |
Line 333... | Line 333... | ||
333 | 333 | ||
334 | sub edi, edx ;;; TODO: find a better way to remember start of packet |
334 | sub edi, edx ;;; TODO: find a better way to remember start of packet |
335 | push edx edi |
335 | push edx edi |
336 | DEBUGF 1,"Sending ICMP Packet\n" |
336 | DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n" |
337 | call [ebx + NET_DEVICE.transmit] |
337 | call [ebx + NET_DEVICE.transmit] |
338 | ret |
338 | ret |
339 | .exit: |
339 | .exit: |
340 | DEBUGF 1,"Creating ICMP Packet failed\n" |
340 | DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n" |
341 | add esp, 2*4 + 2 |
341 | add esp, 2*4 + 2 |
Line 354... | Line 354... | ||
354 | ; |
354 | ; |
355 | ;----------------------------------------------------------------- |
355 | ;----------------------------------------------------------------- |
356 | align 4 |
356 | align 4 |
357 | ICMP_output_raw: |
357 | ICMP_output_raw: |
Line 358... | Line 358... | ||
358 | 358 | ||
Line 359... | Line 359... | ||
359 | DEBUGF 1,"Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx |
359 | DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx |
Line 360... | Line 360... | ||
360 | 360 | ||
361 | push edx |
361 | push edx |
Line 369... | Line 369... | ||
369 | pop esi |
369 | pop esi |
370 | push edx |
370 | push edx |
371 | push eax |
371 | push eax |
Line 372... | Line 372... | ||
372 | 372 | ||
373 | push edi ecx |
373 | push edi ecx |
374 | DEBUGF 1,"copying %u bytes from %x to %x\n", ecx, esi, edi |
374 | DEBUGF DEBUG_NETWORK_VERBOSE, "copying %u bytes from %x to %x\n", ecx, esi, edi |
375 | rep movsb |
375 | rep movsb |
Line 376... | Line 376... | ||
376 | pop ecx edi |
376 | pop ecx edi |
Line 381... | Line 381... | ||
381 | xor edx, edx |
381 | xor edx, edx |
382 | call checksum_1 |
382 | call checksum_1 |
383 | call checksum_2 |
383 | call checksum_2 |
384 | mov [edi + ICMP_header.Checksum], dx |
384 | mov [edi + ICMP_header.Checksum], dx |
Line 385... | Line 385... | ||
385 | 385 | ||
386 | DEBUGF 1,"Sending ICMP Packet\n" |
386 | DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n" |
387 | call [ebx + NET_DEVICE.transmit] |
387 | call [ebx + NET_DEVICE.transmit] |
388 | ret |
388 | ret |
389 | .exit: |
389 | .exit: |
390 | DEBUGF 1,"Creating ICMP Packet failed\n" |
390 | DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n" |
391 | add esp, 4 |
391 | add esp, 4 |