Subversion Repositories Kolibri OS

Rev

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

Rev 2888 Rev 2891
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: 2888 $
19
$Revision: 2891 $
20
 
20
 
21
ARP_NO_ENTRY            = 0
21
ARP_NO_ENTRY            = 0
22
ARP_VALID_MAPPING       = 1
22
ARP_VALID_MAPPING       = 1
Line 161... Line 161...
161
;
161
;
162
;-----------------------------------------------------------------
162
;-----------------------------------------------------------------
163
align 4
163
align 4
164
ARP_input:
164
ARP_input:
Line 165... Line -...
165
 
-
 
166
        DEBUGF  1,"ARP_input - start\n"
165
 
167
        cmp     ecx, sizeof.ARP_header
166
        cmp     ecx, sizeof.ARP_header
Line 168... Line 167...
168
        jb      .exit
167
        jb      .exit
169
 
168
 
Line 170... Line 169...
170
;---------------------
169
;---------------------
171
; Handle Reply packets
170
; Handle Reply packets
Line 172... Line 171...
172
 
171
 
173
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
172
        cmp     [edx + ARP_header.Opcode], ARP_REP_OPCODE
174
        jne     .maybe_request
173
        jne     .maybe_request
Line 175... Line 174...
175
 
174
 
176
        DEBUGF  1,"ARP_input - it's a reply packet from %u.%u.%u.%u\n",\
175
        DEBUGF  1,"ARP_input: got reply packet from %u.%u.%u.%u\n",\
Line 192... Line 191...
192
        jnz     .loop
191
        jnz     .loop
Line 193... Line 192...
193
 
192
 
Line 194... Line 193...
194
        jmp     .exit
193
        jmp     .exit
195
 
194
 
Line 196... Line 195...
196
  .gotit:
195
  .gotit:
197
        DEBUGF  1,"ARP_input - found matching entry\n"
196
        DEBUGF  1,"ARP_input: found matching entry\n"
Line 198... Line 197...
198
 
197
 
Line 199... Line 198...
199
        cmp     [esi + ARP_entry.TTL], ARP_STATIC_ENTRY         ; if it is a static entry, dont touch it
198
        cmp     [esi + ARP_entry.TTL], ARP_STATIC_ENTRY         ; if it is a static entry, dont touch it
200
        je      .exit
199
        je      .exit
Line 201... Line 200...
201
 
200
 
Line 220... Line 219...
220
        jne     .exit
219
        jne     .exit
Line 221... Line 220...
221
 
220
 
222
        call    NET_ptr_to_num
221
        call    NET_ptr_to_num
223
        cmp     edi, -1
222
        cmp     edi, -1
224
        jz      .exit
223
        jz      .exit
225
        DEBUGF  1,"ARP Request packet through device: %u\n", edi
224
        DEBUGF  1,"ARP_input: got request packet through device: %u\n", edi
Line 226... Line 225...
226
        inc     [ARP_PACKETS_RX+4*edi]
225
        inc     [ARP_PACKETS_RX + 4*edi]
227
 
226
 
228
        mov     eax, [IP_LIST+4*edi]
227
        mov     eax, [IP_LIST + 4*edi]
Line 262... Line 261...
262
        movsd
261
        movsd
263
        movsw
262
        movsw
264
;        mov     ax , ETHER_ARP                                 ; It's already there, I'm sure of it!
263
;        mov     ax , ETHER_ARP                                 ; It's already there, I'm sure of it!
265
;        stosw
264
;        stosw
Line 266... Line 265...
266
 
265
 
Line 267... Line 266...
267
        DEBUGF  1,"ARP_input - Sending reply \n"
266
        DEBUGF  1,"ARP_input: Sending reply\n"
268
 
267
 
Line 269... Line 268...
269
        call    [ebx + NET_DEVICE.transmit]
268
        call    [ebx + NET_DEVICE.transmit]
270
        ret
269
        ret
271
 
270
 
Line 272... Line 271...
272
  .exit:
271
  .exit:
273
        call    kernel_free
272
        call    kernel_free
Line 274... Line 273...
274
        add     esp, 4                                          ; pop (balance stack)
273
        add     esp, 4                                          ; pop (balance stack)
275
 
274
 
Line 287... Line 286...
287
;
286
;
288
;---------------------------------------------------------------------------
287
;---------------------------------------------------------------------------
289
align 4
288
align 4
290
ARP_output_request:
289
ARP_output_request:
Line 291... Line -...
291
 
-
 
292
        DEBUGF 1,"Create ARP Packet\n"
-
 
293
 
290
 
294
        push    eax                             ; DestIP
291
        push    eax                             ; DestIP
Line -... Line 292...
-
 
292
        pushd   [IP_LIST + edi]                 ; SenderIP
-
 
293
 
-
 
294
        DEBUGF  1,"ARP_output_request: ip=%u.%u.%u.%u\n",\
295
        pushd   [IP_LIST+edi]                   ; SenderIP
295
        [esp]:1, [esp + 1]:1, [esp + 2]:1, [esp + 3]:1
Line 296... Line 296...
296
 
296
 
297
        mov     ebx, [NET_DRV_LIST+edi]         ; device ptr
297
        mov     ebx, [NET_DRV_LIST + edi]       ; device ptr
298
 
298
 
Line 323... Line 323...
323
        stosd                                   ;
323
        stosd                                   ;
324
        stosw                                   ;
324
        stosw                                   ;
325
        pop     eax                             ; DestIP
325
        pop     eax                             ; DestIP
326
        stosd                                   ;
326
        stosd                                   ;
Line 327... Line 327...
327
 
327
 
Line 328... Line 328...
328
        DEBUGF 1,"ARP Packet for device %x created successfully\n", ebx
328
        DEBUGF  1,"ARP_output_request: device=%x\n", ebx
329
 
329
 
330
        push    edx ecx
330
        push    edx ecx
Line 331... Line 331...
331
        call    [ebx + NET_DEVICE.transmit]
331
        call    [ebx + NET_DEVICE.transmit]
332
        ret
332
        ret
333
 
333
 
334
  .exit:
334
  .exit:
335
        add     esp, 4+4
335
        add     esp, 4 + 4
Line 336... Line 336...
336
        DEBUGF  1,"Create ARP Packet - failed\n"
336
        DEBUGF  1,"ARP_output_request: failed\n"
Line 390... Line 390...
390
        rep     movsw
390
        rep     movsw
Line 391... Line 391...
391
 
391
 
392
        lea     esi, [edi - sizeof.ARP_entry]
392
        lea     esi, [edi - sizeof.ARP_entry]
393
        inc     [NumARP]
393
        inc     [NumARP]
394
        pop     eax
394
        pop     eax
Line 395... Line -...
395
        DEBUGF 1,"entry %u created\n", eax
-
 
396
 
-
 
397
  .exit:
395
        DEBUGF  1,"entry=%u\n", eax
Line 398... Line 396...
398
        DEBUGF 1,"exiting\n"
396
 
399
        ret
397
        ret
400
 
398
 
401
  .error:
399
  .error:
Line 402... Line 400...
402
        DEBUGF 1,"error!\n"
400
        DEBUGF  1,"failed\n"
Line 413... Line 411...
413
;
411
;
414
;-----------------------------------------------------------------
412
;-----------------------------------------------------------------
415
align 4
413
align 4
416
ARP_del_entry:
414
ARP_del_entry:
Line 417... Line 415...
417
 
415
 
Line 418... Line 416...
418
        DEBUGF 1,"ARP_del_entry %x, total entrys: %u\n", esi, [NumARP]
416
        DEBUGF 1,"ARP_del_entry: entry=%u entrys=%u\n", esi, [NumARP]
419
 
417
 
420
        mov     ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
418
        mov     ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
Line 421... Line 419...
421
        sub     ecx, esi
419
        sub     ecx, esi
422
        shr     ecx, 1
420
        shr     ecx, 1
423
 
421
 
Line 424... Line 422...
424
        mov     edi, esi
422
        mov     edi, esi
425
        lea     esi, [edi + sizeof.ARP_entry]
423
        lea     esi, [edi + sizeof.ARP_entry]
Line 426... Line 424...
426
        rep     movsw
424
        rep     movsw