Subversion Repositories Kolibri OS

Rev

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

Rev 2629 Rev 2877
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: 2629 $
19
$Revision: 2877 $
20
 
20
 
21
ARP_NO_ENTRY            = 0
21
ARP_NO_ENTRY            = 0
22
ARP_VALID_MAPPING       = 1
22
ARP_VALID_MAPPING       = 1
Line 280... Line 280...
280
;---------------------------------------------------------------------------
280
;---------------------------------------------------------------------------
281
;
281
;
282
; ARP_output_request
282
; ARP_output_request
283
;
283
;
284
; IN:  ip in eax
284
; IN:  ip in eax
-
 
285
;      device in edi
285
; OUT: /
286
; OUT: /
286
;
287
;
287
;---------------------------------------------------------------------------
288
;---------------------------------------------------------------------------
288
align 4
289
align 4
289
ARP_output_request:
290
ARP_output_request:
Line 290... Line 291...
290
 
291
 
Line 291... Line -...
291
        DEBUGF 1,"Create ARP Packet\n"
-
 
292
 
292
        DEBUGF 1,"Create ARP Packet\n"
293
        call    IPv4_dest_to_dev
293
 
Line 294... Line 294...
294
        push    eax                             ; DestIP
294
        push    eax                             ; DestIP
Line 439... Line 439...
439
; ARP_IP_to_MAC
439
; ARP_IP_to_MAC
440
;
440
;
441
;  This function translates an IP address to a MAC address
441
;  This function translates an IP address to a MAC address
442
;
442
;
443
;  IN:  eax = IPv4 address
443
;  IN:  eax = IPv4 address
-
 
444
;       edi = device number
444
;  OUT: eax = -1 on error, -2 means request send
445
;  OUT: eax = -1 on error, -2 means request send
445
;      else, ax = first two bytes of mac (high 16 bits of eax will be 0)
446
;      else, ax = first two bytes of mac (high 16 bits of eax will be 0)
446
;       ebx = last four bytes of mac
447
;       ebx = last four bytes of mac
-
 
448
;       edi = unchanged
447
;
449
;
448
;-----------------------------------------------------------------
450
;-----------------------------------------------------------------
449
align 4
451
align 4
450
ARP_IP_to_MAC:
452
ARP_IP_to_MAC:
Line 455... Line 457...
455
        rol     eax, 16
457
        rol     eax, 16
Line 456... Line 458...
456
 
458
 
457
        cmp     eax, 0xffffffff
459
        cmp     eax, 0xffffffff
Line 458... Line -...
458
        je      .broadcast
-
 
459
 
-
 
460
; if ((Remote IP & subnet_mask) == (local IP & subnet_mask ))
-
 
461
; destination is on same subnet
-
 
462
; else, destination is remote and must use a gateway
-
 
463
 
-
 
464
        call    IPv4_dest_to_dev
-
 
465
        mov     ebx, [IP_LIST + edi]
-
 
466
        and     ebx, [SUBNET_LIST + edi]
-
 
467
 
-
 
468
        mov     ecx, eax
-
 
469
        and     ecx, [SUBNET_LIST + edi]
-
 
470
 
-
 
471
        cmp     ecx, ebx
-
 
472
        je      .local
-
 
473
 
-
 
474
        mov     eax, [GATEWAY_LIST + edi]
-
 
475
        DEBUGF  1,"requested IP is not on subnet, using default gateway\n"
460
        je      .broadcast
476
 
461
 
Line 477... Line -...
477
;--------------------------------
-
 
478
; Try to find the IP in ARP_table
462
;--------------------------------
479
 
463
; Try to find the IP in ARP_table
480
  .local:
464
 
481
        mov     ecx, [NumARP]
465
        mov     ecx, [NumARP]
482
        test    ecx, ecx
466
        test    ecx, ecx
Line 492... Line 476...
492
        DEBUGF 1,"IP not found on list, preparing for ARP request\n"
476
        DEBUGF 1,"IP not found on list, preparing for ARP request\n"
Line 493... Line 477...
493
 
477
 
494
;--------------------
478
;--------------------
Line 495... Line 479...
495
; Send an ARP request
479
; Send an ARP request
Line 496... Line 480...
496
 
480
 
497
        push    eax                     ; save IP for ARP_output_request
481
        push    eax edi                    ; save IP for ARP_output_request
498
 
482
 
499
; Now create the ARP entry
483
; Now create the ARP entry
Line 508... Line 492...
508
 
492
 
509
        cmp     eax, -1
493
        cmp     eax, -1
Line 510... Line 494...
510
        je      .full
494
        je      .full
511
 
495
 
512
; And send a request
496
; And send a request
513
        pop     eax
497
        pop     edi eax
Line 514... Line 498...
514
        call    ARP_output_request      ; IP in eax
498
        call    ARP_output_request      ; IP in eax
515
;; TODO: check if driver could transmit packet
499
;; TODO: check if driver could transmit packet
Line 530... Line 514...
530
        mov     eax, -1
514
        mov     eax, -1
531
        ret
515
        ret
Line 532... Line 516...
532
 
516
 
533
  .full:
517
  .full:
534
        DEBUGF  1,"ARP table is full!\n"
518
        DEBUGF  1,"ARP table is full!\n"
535
        pop     eax
519
        add     esp, 8
536
        mov     eax, -1
520
        mov     eax, -1
Line 537... Line 521...
537
        ret
521
        ret
538
 
522