Subversion Repositories Kolibri OS

Rev

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

Rev 3200 Rev 3203
Line 14... Line 14...
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
14
;;          GNU GENERAL PUBLIC LICENSE                             ;;
15
;;             Version 2, June- 1991                               ;;
15
;;             Version 2, June- 1991                               ;;
16
;;                                                                 ;;
16
;;                                                                 ;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line 18... Line 18...
18
 
18
 
Line 19... Line 19...
19
$Revision: 3200 $
19
$Revision: 3203 $
20
 
20
 
21
ARP_NO_ENTRY            = 0
21
ARP_NO_ENTRY            = 0
22
ARP_VALID_MAPPING       = 1
22
ARP_VALID_MAPPING       = 1
Line 361... Line 361...
361
;
361
;
362
; ARP_add_entry (or update)
362
; ARP_add_entry (or update)
363
;
363
;
364
; IN:  esi = ptr to entry (can easily be made on the stack)
364
; IN:  esi = ptr to entry (can easily be made on the stack)
365
; OUT: eax = entry #, -1 on error
365
; OUT: eax = entry #, -1 on error
-
 
366
;      edi = ptr to newly created entry
366
;
367
;
367
;-----------------------------------------------------------------      ; TODO: use a mutex
368
;-----------------------------------------------------------------      ; TODO: use a mutex
368
align 4
369
align 4
369
ARP_add_entry:
370
ARP_add_entry:
Line 396... Line 397...
396
 
397
 
397
  .add:
398
  .add:
398
        mov     ecx, sizeof.ARP_entry/2
399
        mov     ecx, sizeof.ARP_entry/2
399
        rep     movsw
400
        rep     movsw
-
 
401
        inc     [NumARP]
400
        inc     [NumARP]
402
        sub     edi, sizeof.ARP_entry
Line 401... Line 403...
401
        DEBUGF  1,"entry=%u\n", eax
403
        DEBUGF  1,"entry=%u\n", eax
Line 402... Line 404...
402
 
404
 
Line 496... Line 498...
496
        pushd   0                       ; mac
498
        pushd   0                       ; mac
497
        pushw   0
499
        pushw   0
498
        pushd   eax                     ; ip
500
        pushd   eax                     ; ip
499
        mov     esi, esp
501
        mov     esi, esp
500
        call    ARP_add_entry
502
        call    ARP_add_entry
501
        add     esp, sizeof.ARP_entry
503
        add     esp, sizeof.ARP_entry   ; clear the entry from stack
Line 502... Line 504...
502
 
504
 
503
        cmp     eax, -1
505
        cmp     eax, -1                 ; did ARP_add_entry fail?
Line 504... Line -...
504
        je      .full
-
 
505
 
506
        je      .full
506
; And send a request
507
 
507
        pop     edi eax
-
 
Line -... Line 508...
-
 
508
        mov     esi, edi
508
        call    ARP_output_request      ; IP in eax
509
        pop     edi eax                 ; IP in eax, device number in edi, for ARP_output_request
509
;; TODO: check if driver could transmit packet
510
 
Line -... Line 511...
-
 
511
        push    esi edi
-
 
512
        call    ARP_output_request      ; And send a request
510
 
513
        pop     edi esi
-
 
514
 
511
        mov     eax, -2                 ; request send
515
;-----------------------------------------------
512
        ret
516
; At this point, we got an ARP entry in the list
513
 
517
  .found_it:
-
 
518
        cmp     [esi + ARP_entry.Status], ARP_VALID_MAPPING             ; Does it have a MAC assigned?
-
 
519
        je      .valid
-
 
520
        cmp     [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE         ; Are we waiting for reply from remote end?
-
 
521
        jne     .give_up
-
 
522
        push    esi
Line -... Line 523...
-
 
523
        mov     esi, 10                 ; wait 10 ms
-
 
524
        call    delay_ms
514
  .found_it:
525
        pop     esi
515
        DEBUGF  1,"ARP_IP_to_MAC: found IP\n"
526
        jmp     .found_it               ; now check again
516
        cmp     [esi + ARP_entry.Status], ARP_VALID_MAPPING
527
 
Line 517... Line -...
517
        jne     .invalid
-
 
518
 
-
 
519
        movzx   eax, word [esi + ARP_entry.MAC]
-
 
520
        mov     ebx, dword[esi + ARP_entry.MAC + 2]
-
 
521
        ret
-
 
522
 
528
  .valid:
523
  .invalid:
529
        DEBUGF  1,"ARP_IP_to_MAC: found MAC\n"
524
        DEBUGF  1,"ARP_IP_to_MAC: entry has no valid mapping!\n"
530
        movzx   eax, word[esi + ARP_entry.MAC]
-
 
531
        mov     ebx, dword[esi + ARP_entry.MAC + 2]
-
 
532
        ret
525
        mov     eax, -1
533
 
526
        ret
534
  .full:
Line 527... Line 535...
527
 
535
        DEBUGF  1,"ARP_IP_to_MAC: table is full!\n"
528
  .full:
536
        add     esp, 8