Further fixing of ARP_add_entry. Now entries can be re-added if they were removed once before.

git-svn-id: svn://kolibrios.org@3148 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-12-31 14:21:41 +00:00
parent f986b74d68
commit a62ea51291

View File

@ -355,32 +355,27 @@ ARP_add_entry:
cmp ecx, ARP_TABLE_SIZE ; list full ? cmp ecx, ARP_TABLE_SIZE ; list full ?
jae .error jae .error
mov eax, dword [esi + ARP_entry.MAC] xor eax, eax
mov bx, word [esi + ARP_entry.MAC + 4]
xor ecx, ecx
mov edi, ARP_table mov edi, ARP_table
mov ecx, [esi + ARP_entry.IP]
.loop: .loop:
cmp dword [edi + ARP_entry.MAC], eax ; Check for duplicate MAC's cmp [edi + ARP_entry.Status], ARP_NO_ENTRY ; is this slot empty?
jne .maybe_next ; je .add
cmp word [edi + ARP_entry.MAC + 4], bx ;
jne .maybe_next ;
cmp [edi + ARP_entry.TTL], ARP_STATIC_ENTRY cmp [edi + ARP_entry.IP], ecx ; if not, check if it doesnt collide
jne .maybe_next
cmp [edi + ARP_entry.TTL], ARP_STATIC_ENTRY ; ok, its the same IP, update it if not static
jne .add jne .add
cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY
jne .error
.maybe_next: .maybe_next: ; try the next slot
add edi, sizeof.ARP_entry add edi, sizeof.ARP_entry
inc ecx inc eax
cmp ecx, ARP_TABLE_SIZE cmp eax, ARP_TABLE_SIZE
jae .error jae .error
jmp .loop jmp .loop
.add: .add:
mov eax, ecx
mov ecx, sizeof.ARP_entry/2 mov ecx, sizeof.ARP_entry/2
rep movsw rep movsw
inc [NumARP] inc [NumARP]
@ -405,16 +400,22 @@ ARP_add_entry:
align 4 align 4
ARP_del_entry: ARP_del_entry:
DEBUGF 1,"ARP_del_entry: entry=%u entrys=%u\n", esi, [NumARP] DEBUGF 1,"ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
DEBUGF 1,"ARP_del_entry: IP=%u.%u.%u.%u\n", \
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
mov ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry mov ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
sub ecx, esi sub ecx, esi
shr ecx, 1 shr ecx, 1
mov edi, esi mov edi, esi
lea esi, [edi + sizeof.ARP_entry] add esi, sizeof.ARP_entry
rep movsw rep movsw
xor eax, eax
mov ecx, sizeof.ARP_entry/2
rep stosw
dec [NumARP] dec [NumARP]
DEBUGF 1,"ARP_del_entry: success\n" DEBUGF 1,"ARP_del_entry: success\n"