Subversion Repositories Kolibri OS

Rev

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

Rev 3601 Rev 3643
Line 154... Line 154...
154
        pop     si
154
        pop     si
155
        cmp     dx, si
155
        cmp     dx, si
156
        pop     ecx edx
156
        pop     ecx edx
157
        jne     .checksum_mismatch
157
        jne     .checksum_mismatch
Line -... Line 158...
-
 
158
 
-
 
159
; Check packet type
158
 
160
 
159
        cmp     [edx + ICMP_header.Type], ICMP_ECHO             ; Is this an echo request?
161
        cmp     [edx + ICMP_header.Type], ICMP_ECHO             ; Is this an echo request?
Line -... Line 162...
-
 
162
        jne     .check_sockets
-
 
163
 
-
 
164
; Update stats (and validate device ptr)
-
 
165
        call    NET_ptr_to_num4
-
 
166
        cmp     edi, -1
-
 
167
        je      .dump
160
        jne     .check_sockets
168
        inc     [ICMP_PACKETS_RX + edi]
161
 
169
 
Line 162... Line 170...
162
; We well re-use the packet so we can create the response as fast as possible
170
; We well re-use the packet so we can create the response as fast as possible
163
; Notice: this only works on pure ethernet
171
; Notice: this only works on pure ethernet
Line 164... Line 172...
164
 
172
 
165
        DEBUGF  DEBUG_NETWORK_VERBOSE, "got echo request\n"
-
 
166
        mov     [edx + ICMP_header.Type], ICMP_ECHOREPLY        ; Change Packet type to reply
-
 
167
 
-
 
168
        mov     esi, [esp]                                      ; Start of buffer
-
 
169
 
-
 
170
; Update stats (and validate device ptr)
-
 
171
        call    NET_ptr_to_num
-
 
172
        cmp     edi, -1
-
 
173
        je      .dump
173
        DEBUGF  DEBUG_NETWORK_VERBOSE, "got echo request\n"
174
        inc     [ICMP_PACKETS_RX + 4*edi]
174
        mov     [edx + ICMP_header.Type], ICMP_ECHOREPLY        ; Change Packet type to reply
Line 175... Line 175...
175
        inc     [ICMP_PACKETS_TX + 4*edi]
175
 
Line 223... Line 223...
223
        call    checksum_2                                      ;
223
        call    checksum_2                                      ;
224
        mov     [eax + ICMP_header.Checksum], dx                ;
224
        mov     [eax + ICMP_header.Checksum], dx                ;
Line 225... Line 225...
225
 
225
 
226
; Transmit the packet (notice that packet ptr and packet size have been on stack since start of the procedure!)
226
; Transmit the packet (notice that packet ptr and packet size have been on stack since start of the procedure!)
-
 
227
        call    [ebx + NET_DEVICE.transmit]
-
 
228
        test    eax, eax
-
 
229
        jnz     @f
-
 
230
        call    NET_ptr_to_num4
-
 
231
        inc     [UDP_PACKETS_TX + edi]
227
        call    [ebx + NET_DEVICE.transmit]
232
       @@:
Line 252... Line 257...
252
        jne     .next_socket
257
        jne     .next_socket
Line 253... Line 258...
253
 
258
 
254
;        cmp     [eax + ICMP_SOCKET.Identifier],
259
;        cmp     [eax + ICMP_SOCKET.Identifier],
Line -... Line 260...
-
 
260
;        jne     .next_socket
255
;        jne     .next_socket
261
 
256
 
262
; Update stats (and validate device ptr)
257
;        call    IPv4_dest_to_dev
263
        call    NET_ptr_to_num4
258
;        cmp     edi,-1
264
        cmp     edi, -1
Line 259... Line 265...
259
;        je      .dump
265
        je      .dump
Line 260... Line 266...
260
;        inc     [ICMP_PACKETS_RX+edi]
266
        inc     [ICMP_PACKETS_RX + edi]
261
 
267
 
Line 334... Line 340...
334
 
340
 
335
        sub     edi, edx                                ;;; TODO: find a better way to remember start of packet
341
        sub     edi, edx                                ;;; TODO: find a better way to remember start of packet
336
        push    edx edi
342
        push    edx edi
337
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
343
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
-
 
344
        call    [ebx + NET_DEVICE.transmit]
-
 
345
        test    eax, eax
-
 
346
        jnz     @f
-
 
347
        call    NET_ptr_to_num4
-
 
348
        inc     [ICMP_PACKETS_TX + edi]
338
        call    [ebx + NET_DEVICE.transmit]
349
       @@:
339
        ret
350
        ret
340
  .exit:
351
  .exit:
341
        DEBUGF  DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
352
        DEBUGF  DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
342
        add     esp, 2*4 + 2
353
        add     esp, 2*4 + 2
Line 384... Line 395...
384
        call    checksum_2
395
        call    checksum_2
385
        mov     [edi + ICMP_header.Checksum], dx
396
        mov     [edi + ICMP_header.Checksum], dx
Line 386... Line 397...
386
 
397
 
387
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
398
        DEBUGF  DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
-
 
399
        call    [ebx + NET_DEVICE.transmit]
-
 
400
        test    eax, eax
-
 
401
        jnz     @f
-
 
402
        call    NET_ptr_to_num4
-
 
403
        inc     [ICMP_PACKETS_TX + edi]
388
        call    [ebx + NET_DEVICE.transmit]
404
       @@:
389
        ret
405
        ret
390
  .exit:
406
  .exit:
391
        DEBUGF  DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
407
        DEBUGF  DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
392
        add     esp, 4
408
        add     esp, 4