Subversion Repositories Kolibri OS

Rev

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

Rev 3555 Rev 3589
Line 175... Line 175...
175
        cmp     edi, -1
175
        cmp     edi, -1
176
        jz      .exit
176
        jz      .exit
Line 177... Line 177...
177
 
177
 
Line 178... Line 178...
178
        inc     [ARP_PACKETS_RX + 4*edi]        ; update stats
178
        inc     [ARP_PACKETS_RX + 4*edi]        ; update stats
179
 
179
 
180
        DEBUGF  1,"ARP_input: got packet from %u.%u.%u.%u through device %u\n",\
180
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u through device %u\n",\
Line 181... Line 181...
181
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
181
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
182
        [edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
182
        [edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
Line 192... Line 192...
192
; Handle reply packets
192
; Handle reply packets
Line 193... Line 193...
193
 
193
 
194
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
194
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
Line 195... Line 195...
195
        jne     .maybe_request
195
        jne     .maybe_request
Line 196... Line 196...
196
 
196
 
197
        DEBUGF  1,"ARP_input: It's a reply\n"
197
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
198
 
198
 
Line 206... Line 206...
206
        je      .gotit
206
        je      .gotit
207
        add     esi, sizeof.ARP_entry
207
        add     esi, sizeof.ARP_entry
208
        dec     ecx
208
        dec     ecx
209
        jnz     .loop
209
        jnz     .loop
Line 210... Line 210...
210
 
210
 
211
        DEBUGF  1,"ARP_input: no matching entry found\n"
211
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: no matching entry found\n"
Line 212... Line 212...
212
        jmp     .exit
212
        jmp     .exit
213
 
213
 
Line 214... Line 214...
214
  .gotit:
214
  .gotit:
215
        DEBUGF  1,"ARP_input: found matching entry\n"
215
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: found matching entry\n"
Line 216... Line 216...
216
 
216
 
Line 217... Line 217...
217
        cmp     [esi + ARP_entry.TTL], ARP_STATIC_ENTRY         ; if it is a static entry, dont touch it
217
        cmp     [esi + ARP_entry.TTL], ARP_STATIC_ENTRY         ; if it is a static entry, dont touch it
218
        je      .exit
218
        je      .exit
Line 219... Line 219...
219
 
219
 
Line 234... Line 234...
234
 
234
 
235
  .maybe_request:
235
  .maybe_request:
236
        cmp     [edx + ARP_header.Opcode], ARP_REQ_OPCODE
236
        cmp     [edx + ARP_header.Opcode], ARP_REQ_OPCODE
Line 237... Line 237...
237
        jne     .exit
237
        jne     .exit
Line 238... Line 238...
238
 
238
 
239
        DEBUGF  1,"ARP_input: its a request\n"
239
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
240
 
240
 
Line 275... Line 275...
275
        movsd
275
        movsd
276
        movsw
276
        movsw
277
;        mov     ax , ETHER_ARP                                 ; It's already there, I'm sure of it!
277
;        mov     ax , ETHER_ARP                                 ; It's already there, I'm sure of it!
278
;        stosw
278
;        stosw
Line 279... Line 279...
279
 
279
 
Line 280... Line 280...
280
        DEBUGF  1,"ARP_input: Sending reply\n"
280
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: Sending reply\n"
281
 
281
 
Line 282... Line 282...
282
        call    [ebx + NET_DEVICE.transmit]
282
        call    [ebx + NET_DEVICE.transmit]
283
        ret
283
        ret
284
 
284
 
Line 285... Line 285...
285
  .collision:
285
  .collision:
286
        inc     [ARP_CONFLICTS + 4*edi]
286
        inc     [ARP_CONFLICTS + 4*edi]
287
        DEBUGF  1,"ARP_input: IP address conflict detected!\n"
287
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
Line 288... Line 288...
288
 
288
 
289
  .exit:
289
  .exit:
Line 290... Line 290...
290
        call    kernel_free
290
        call    kernel_free
291
        add     esp, 4                                          ; pop (balance stack)
291
        add     esp, 4                                          ; pop (balance stack)
Line 308... Line 308...
308
 
308
 
309
        push    eax                             ; DestIP
309
        push    eax                             ; DestIP
310
        pushd   [IP_LIST + edi]                 ; SenderIP
310
        pushd   [IP_LIST + edi]                 ; SenderIP
Line 311... Line 311...
311
        inc     [ARP_PACKETS_TX + edi]          ; assume we will succeed
311
        inc     [ARP_PACKETS_TX + edi]          ; assume we will succeed
312
 
312
 
Line 313... Line 313...
313
        DEBUGF  1,"ARP_output_request: ip=%u.%u.%u.%u\n",\
313
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u\n",\
Line 314... Line 314...
314
        [esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1
314
        [esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1
Line 342... Line 342...
342
        stosd                                   ;
342
        stosd                                   ;
343
        stosw                                   ;
343
        stosw                                   ;
344
        pop     eax                             ; DestIP
344
        pop     eax                             ; DestIP
345
        stosd                                   ;
345
        stosd                                   ;
Line 346... Line 346...
346
 
346
 
Line 347... Line 347...
347
        DEBUGF  1,"ARP_output_request: device=%x\n", ebx
347
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_output_request: device=%x\n", ebx
348
 
348
 
349
        push    edx ecx
349
        push    edx ecx
Line 350... Line 350...
350
        call    [ebx + NET_DEVICE.transmit]
350
        call    [ebx + NET_DEVICE.transmit]
351
        ret
351
        ret
352
 
352
 
353
  .exit:
353
  .exit:
354
        add     esp, 4 + 4
354
        add     esp, 4 + 4
Line 355... Line 355...
355
        DEBUGF  1,"ARP_output_request: failed\n"
355
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_output_request: failed\n"
Line 367... Line 367...
367
;
367
;
368
;-----------------------------------------------------------------      ; TODO: use a mutex
368
;-----------------------------------------------------------------      ; TODO: use a mutex
369
align 4
369
align 4
370
ARP_add_entry:
370
ARP_add_entry:
Line 371... Line 371...
371
 
371
 
Line 372... Line 372...
372
        DEBUGF  1,"ARP_add_entry: "
372
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_add_entry: "
373
 
373
 
374
        mov     ecx, [NumARP]
374
        mov     ecx, [NumARP]
Line 398... Line 398...
398
  .add:
398
  .add:
399
        mov     ecx, sizeof.ARP_entry/2
399
        mov     ecx, sizeof.ARP_entry/2
400
        rep     movsw
400
        rep     movsw
401
        inc     [NumARP]
401
        inc     [NumARP]
402
        sub     edi, sizeof.ARP_entry
402
        sub     edi, sizeof.ARP_entry
403
        DEBUGF  1,"entry=%u\n", eax
403
        DEBUGF  DEBUG_NETWORK_VERBOSE, "entry=%u\n", eax
Line 404... Line 404...
404
 
404
 
Line 405... Line 405...
405
        ret
405
        ret
406
 
406
 
407
  .error:
407
  .error:
408
        DEBUGF  1,"failed\n"
408
        DEBUGF  DEBUG_NETWORK_VERBOSE, "failed\n"
Line 409... Line 409...
409
        mov     eax, -1
409
        mov     eax, -1
Line 419... Line 419...
419
;
419
;
420
;-----------------------------------------------------------------
420
;-----------------------------------------------------------------
421
align 4
421
align 4
422
ARP_del_entry:
422
ARP_del_entry:
Line 423... Line 423...
423
 
423
 
424
        DEBUGF 1,"ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
424
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
425
        DEBUGF 1,"ARP_del_entry: IP=%u.%u.%u.%u\n", \
425
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
Line 426... Line 426...
426
        [esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
426
        [esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
427
 
427
 
428
        mov     ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
428
        mov     ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
Line 436... Line 436...
436
        xor     eax, eax
436
        xor     eax, eax
437
        mov     ecx, sizeof.ARP_entry/2
437
        mov     ecx, sizeof.ARP_entry/2
438
        rep     stosw
438
        rep     stosw
Line 439... Line 439...
439
 
439
 
440
        dec     [NumARP]
440
        dec     [NumARP]
Line 441... Line 441...
441
        DEBUGF 1,"ARP_del_entry: success\n"
441
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
Line 461... Line 461...
461
;
461
;
462
;-----------------------------------------------------------------
462
;-----------------------------------------------------------------
463
align 4
463
align 4
464
ARP_IP_to_MAC:
464
ARP_IP_to_MAC:
Line 465... Line 465...
465
 
465
 
466
        DEBUGF 1,"ARP_IP_to_MAC: %u.%u", al, ah
466
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
467
        rol     eax, 16
467
        rol     eax, 16
468
        DEBUGF 1,".%u.%u\n", al, ah
468
        DEBUGF  DEBUG_NETWORK_VERBOSE, ".%u.%u\n", al, ah
Line 469... Line 469...
469
        rol     eax, 16
469
        rol     eax, 16
470
 
470
 
Line 483... Line 483...
483
        je      .found_it
483
        je      .found_it
484
        add     esi, sizeof.ARP_entry
484
        add     esi, sizeof.ARP_entry
485
        loop    .scan_loop
485
        loop    .scan_loop
Line 486... Line 486...
486
 
486
 
487
  .not_in_list:
487
  .not_in_list:
Line 488... Line 488...
488
        DEBUGF  1,"ARP_IP_to_MAC: preparing for ARP request\n"
488
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: preparing for ARP request\n"
489
 
489
 
Line 490... Line 490...
490
;--------------------
490
;--------------------
Line 533... Line 533...
533
        jmp     .give_up
533
        jmp     .give_up
Line 534... Line 534...
534
 
534
 
Line 535... Line 535...
535
end if
535
end if
536
 
536
 
537
  .valid:
537
  .valid:
538
        DEBUGF  1,"ARP_IP_to_MAC: found MAC\n"
538
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: found MAC\n"
539
        movzx   eax, word[esi + ARP_entry.MAC]
539
        movzx   eax, word[esi + ARP_entry.MAC]
Line 540... Line 540...
540
        mov     ebx, dword[esi + ARP_entry.MAC + 2]
540
        mov     ebx, dword[esi + ARP_entry.MAC + 2]
541
        ret
541
        ret
542
 
542
 
543
  .full:
543
  .full:
544
        DEBUGF  1,"ARP_IP_to_MAC: table is full!\n"
544
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: table is full!\n"
545
        add     esp, 8
545
        add     esp, 8
546
  .give_up:
546
  .give_up:
Line 547... Line 547...
547
        DEBUGF  1,"ARP_IP_to_MAC: entry has no valid mapping!\n"
547
        DEBUGF  DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: entry has no valid mapping!\n"
548
        mov     eax, -1
548
        mov     eax, -1