Subversion Repositories Kolibri OS

Rev

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

Rev 2614 Rev 2629
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: 2614 $
19
$Revision: 2629 $
20
 
20
 
21
ARP_NO_ENTRY            = 0
21
ARP_NO_ENTRY            = 0
22
ARP_VALID_MAPPING       = 1
22
ARP_VALID_MAPPING       = 1
Line 154... Line 154...
154
; ARP_input
154
; ARP_input
155
;
155
;
156
;  IN:  Pointer to buffer in [esp]
156
;  IN:  Pointer to buffer in [esp]
157
;       size of buffer in [esp+4]
157
;       size of buffer in [esp+4]
158
;       packet size (without ethernet header) in ecx
158
;       packet size (without ethernet header) in ecx
-
 
159
;       packet ptr in edx
159
;  OUT: /
160
;  OUT: /
160
;
161
;
161
;-----------------------------------------------------------------
162
;-----------------------------------------------------------------
162
align 4
163
align 4
163
ARP_input:
164
ARP_input:
Line 171... Line 172...
171
 
172
 
172
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
173
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
Line 173... Line 174...
173
        jne     .maybe_request
174
        jne     .maybe_request
-
 
175
 
174
 
176
        DEBUGF  1,"ARP_input - it's a reply packet from %u.%u.%u.%u\n",\
Line 175... Line 177...
175
        DEBUGF  1,"ARP_input - it's a reply packet from %u.%u.%u.%u\n",\
177
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP+1]:1,\
176
        [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP+1]:1, [edx + ARP_header.SenderIP+2]:1, [edx + ARP_header.SenderIP+3]:1
178
        [edx + ARP_header.SenderIP+2]:1, [edx + ARP_header.SenderIP+3]:1
177
 
179
 
Line 202... Line 204...
202
        mov     [esi + ARP_entry.Status], ARP_VALID_MAPPING
204
        mov     [esi + ARP_entry.Status], ARP_VALID_MAPPING
203
        mov     [esi + ARP_entry.TTL], ARP_ENTRY_TTL
205
        mov     [esi + ARP_entry.TTL], ARP_ENTRY_TTL
Line 204... Line 206...
204
 
206
 
205
        mov     eax, dword [edx + ARP_header.SenderMAC]
207
        mov     eax, dword [edx + ARP_header.SenderMAC]
206
        mov     dword [esi+ARP_entry.MAC], eax
208
        mov     dword [esi+ARP_entry.MAC], eax
207
        mov     ax , word [edx + ARP_header.SenderMAC + 4]
209
        mov     cx, word [edx + ARP_header.SenderMAC + 4]
Line 208... Line 210...
208
        mov     word [esi+ARP_entry.MAC+4], ax
210
        mov     word [esi+ARP_entry.MAC+4], cx
Line 209... Line 211...
209
 
211
 
Line 223... Line 225...
223
        DEBUGF  1,"ARP Request packet through device: %u\n", edi
225
        DEBUGF  1,"ARP Request packet through device: %u\n", edi
224
        inc     [ARP_PACKETS_RX+4*edi]
226
        inc     [ARP_PACKETS_RX+4*edi]
Line 225... Line 227...
225
 
227
 
226
        mov     eax, [IP_LIST+4*edi]
228
        mov     eax, [IP_LIST+4*edi]
227
        cmp     eax, [edx + ARP_header.TargetIP]                ; Is it looking for my IP address?
229
        cmp     eax, [edx + ARP_header.TargetIP]                ; Is it looking for my IP address?
Line 228... Line 230...
228
        jne     .exit                                           ; TODO: instead of quitting, update local entrys with matching IP's ?
230
        jne     .exit
229
 
231
 
Line 230... Line 232...
230
        push    eax
232
        push    eax
Line 257... Line 259...
257
        movsd
259
        movsd
258
        movsw
260
        movsw
259
        lea     esi, [edx + ARP_header.SenderMAC]
261
        lea     esi, [edx + ARP_header.SenderMAC]
260
        movsd
262
        movsd
261
        movsw
263
        movsw
262
;        mov     ax , ETHER_ARP
264
;        mov     ax , ETHER_ARP                                 ; It's already there, I'm sure of it!
263
;        stosw
265
;        stosw
Line 264... Line 266...
264
 
266
 
Line 265... Line 267...
265
        DEBUGF  1,"ARP_input - Sending reply \n"
267
        DEBUGF  1,"ARP_input - Sending reply \n"
Line 490... Line 492...
490
        DEBUGF 1,"IP not found on list, preparing for ARP request\n"
492
        DEBUGF 1,"IP not found on list, preparing for ARP request\n"
Line 491... Line 493...
491
 
493
 
492
;--------------------
494
;--------------------
Line 493... Line 495...
493
; Send an ARP request
495
; Send an ARP request
Line -... Line 496...
-
 
496
 
494
 
497
        push    eax                     ; save IP for ARP_output_request
495
        push    eax
498
 
496
 
499
; Now create the ARP entry
497
        pushw   ARP_REQUEST_TTL
500
        pushw   ARP_REQUEST_TTL         ; TTL
498
        pushw   ARP_AWAITING_RESPONSE
501
        pushw   ARP_AWAITING_RESPONSE   ; status
499
        pushd   0
502
        pushd   0                       ; mac
500
        pushw   0
503
        pushw   0
501
        pushd   eax
504
        pushd   eax                     ; ip
Line 502... Line 505...
502
        mov     esi, esp
505
        mov     esi, esp
503
        call    ARP_add_entry
506
        call    ARP_add_entry
Line 504... Line 507...
504
        add     esp, sizeof.ARP_entry
507
        add     esp, sizeof.ARP_entry
505
 
508
 
506
        cmp     eax, -1
-
 
507
        je      .full
509
        cmp     eax, -1
508
 
-
 
509
        mov     ecx, eax
510
        je      .full
Line 510... Line -...
510
        pop     eax
-
 
511
        push    ecx
-
 
512
        call    ARP_output_request
-
 
513
 
-
 
514
;; TODO: check if driver could transmit packet
-
 
515
 
-
 
516
        pop     esi
-
 
517
        imul    esi, sizeof.ARP_entry
-
 
518
        add     esi, ARP_table
-
 
519
 
-
 
520
        mov     ecx, 25
-
 
521
  .wait_loop:
-
 
522
        cmp     [esi + ARP_entry.Status], 1
-
 
523
        je      .got_it
-
 
524
        push    esi
511
 
525
        mov     esi, 10
512
; And send a request
Line 526... Line 513...
526
        call    delay_ms
513
        pop     eax
527
        pop     esi
514
        call    ARP_output_request      ; IP in eax
528
        loop    .wait_loop
515
;; TODO: check if driver could transmit packet
529
 
516
 
Line 530... Line -...
530
        mov     eax, -2         ; request send
-
 
531
        ret
517
        mov     eax, -2                 ; request send
532
 
518
        ret
533
  .found_it:
519
 
Line 534... Line 520...
534
        DEBUGF  1,"found IP in ARPTable\n"
520
  .found_it: