Rev 3609 | Rev 3640 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3609 | Rev 3638 | ||
---|---|---|---|
Line 362... | Line 362... | ||
362 | ;----------------------------------------------------------------- |
362 | ;----------------------------------------------------------------- |
363 | ; |
363 | ; |
364 | ; ARP_add_entry (or update) |
364 | ; ARP_add_entry (or update) |
365 | ; |
365 | ; |
366 | ; IN: esi = ptr to entry (can easily be made on the stack) |
366 | ; IN: esi = ptr to entry (can easily be made on the stack) |
367 | ; edi = device num |
367 | ; edi = device num*4 |
368 | ; OUT: eax = entry #, -1 on error |
368 | ; OUT: eax = entry #, -1 on error |
369 | ; esi = ptr to newly created entry |
369 | ; esi = ptr to newly created entry |
370 | ; |
370 | ; |
371 | ;----------------------------------------------------------------- ; TODO: use a mutex |
371 | ;----------------------------------------------------------------- ; TODO: use a mutex |
372 | align 4 |
372 | align 4 |
373 | ARP_add_entry: |
373 | ARP_add_entry: |
Line 374... | Line 374... | ||
374 | 374 | ||
Line 375... | Line 375... | ||
375 | DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi |
375 | DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi |
376 | 376 | ||
377 | mov ecx, [ARP_entries_num + 4*edi] |
377 | mov ecx, [ARP_entries_num + edi] |
Line 378... | Line 378... | ||
378 | cmp ecx, ARP_TABLE_SIZE ; list full ? |
378 | cmp ecx, ARP_TABLE_SIZE ; list full ? |
Line 379... | Line 379... | ||
379 | jae .full |
379 | jae .full |
Line 380... | Line 380... | ||
380 | 380 | ||
381 | ; From this point on, we can only fail if IP has a static entry, or if table is corrupt. |
381 | ; From this point on, we can only fail if IP has a static entry, or if table is corrupt. |
382 | 382 | ||
383 | inc [ARP_entries_num + 4*edi] ; assume we will succeed |
383 | inc [ARP_entries_num + edi] ; assume we will succeed |
384 | 384 | ||
385 | push edi |
385 | push edi |
386 | xor ecx, ecx |
386 | xor ecx, ecx |
387 | imul edi, ARP_TABLE_SIZE*sizeof.ARP_entry |
387 | imul edi, ARP_TABLE_SIZE*sizeof.ARP_entry/4 |
Line 417... | Line 417... | ||
417 | 417 | ||
Line 418... | Line 418... | ||
418 | ret |
418 | ret |
419 | 419 | ||
420 | .error: |
420 | .error: |
421 | pop edi |
421 | pop edi |
422 | dec [ARP_entries_num + 4*edi] |
422 | dec [ARP_entries_num + edi] |
423 | DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n" |
423 | DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n" |
424 | .full: |
424 | .full: |
Line 473... | Line 473... | ||
473 | ; ARP_IP_to_MAC |
473 | ; ARP_IP_to_MAC |
474 | ; |
474 | ; |
475 | ; This function translates an IP address to a MAC address |
475 | ; This function translates an IP address to a MAC address |
476 | ; |
476 | ; |
477 | ; IN: eax = IPv4 address |
477 | ; IN: eax = IPv4 address |
478 | ; edi = device number |
478 | ; edi = device number * 4 |
479 | ; OUT: eax = -1 on error, -2 means request send |
479 | ; OUT: eax = -1 on error, -2 means request send |
480 | ; else, ax = first two bytes of mac (high 16 bits of eax will be 0) |
480 | ; else, ax = first two bytes of mac (high 16 bits of eax will be 0) |
481 | ; ebx = last four bytes of mac |
481 | ; ebx = last four bytes of mac |
482 | ; edi = unchanged |
482 | ; edi = unchanged |
483 | ; |
483 | ; |
Line 485... | Line 485... | ||
485 | align 4 |
485 | align 4 |
486 | ARP_IP_to_MAC: |
486 | ARP_IP_to_MAC: |
Line 487... | Line 487... | ||
487 | 487 | ||
488 | DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah |
488 | DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah |
489 | rol eax, 16 |
489 | rol eax, 16 |
490 | DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u device: %u\n", al, ah, edi |
490 | DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u device*4: %u\n", al, ah, edi |
Line 491... | Line 491... | ||
491 | rol eax, 16 |
491 | rol eax, 16 |
492 | 492 | ||
Line 493... | Line 493... | ||
493 | cmp eax, 0xffffffff |
493 | cmp eax, 0xffffffff |
494 | je .broadcast |
494 | je .broadcast |
Line 495... | Line 495... | ||
495 | 495 | ||
496 | ;-------------------------------- |
496 | ;-------------------------------- |
497 | ; Try to find the IP in ARP_table |
497 | ; Try to find the IP in ARP_table |
498 | 498 | ||
499 | mov ecx, [ARP_entries_num + 4*edi] |
499 | mov ecx, [ARP_entries_num] |
500 | test ecx, ecx |
500 | test ecx, ecx |
Line 536... | Line 536... | ||
536 | 536 | ||
537 | ; Now send a request packet on the network |
537 | ; Now send a request packet on the network |
Line 538... | Line 538... | ||
538 | pop edi eax ; IP in eax, device number in ebx, for ARP_output_request |
538 | pop edi eax ; IP in eax, device number in ebx, for ARP_output_request |
539 | 539 | ||
540 | push esi edi |
540 | push esi edi |
541 | mov ebx, [NET_DRV_LIST + 4*edi] |
541 | mov ebx, [NET_DRV_LIST + edi] |
542 | call ARP_output_request |
542 | call ARP_output_request |
543 | pop edi esi |
543 | pop edi esi |
544 | .found_it: |
544 | .found_it: |
Line 653... | Line 653... | ||
653 | ret |
653 | ret |
Line 654... | Line 654... | ||
654 | 654 | ||
655 | .write: |
655 | .write: |
656 | ; esi = pointer to buffer |
656 | ; esi = pointer to buffer |
657 | mov edi, eax |
- | |
658 | shr edi, 2 |
657 | mov edi, eax |
659 | call ARP_add_entry ; out: eax = entry number, -1 on error |
658 | call ARP_add_entry ; out: eax = entry number, -1 on error |
Line 660... | Line 659... | ||
660 | ret |
659 | ret |
661 | 660 |