54,8 → 54,67 |
ends |
|
|
align 4 |
uglobal |
|
IP_LIST rd MAX_IP |
SUBNET_LIST rd MAX_IP |
DNS_LIST rd MAX_IP |
GATEWAY_LIST rd MAX_IP |
|
IP_PACKETS_TX rd MAX_IP |
IP_PACKETS_RX rd MAX_IP |
|
FRAGMENT_LIST rb MAX_FRAGMENTS*FRAGMENT_slot.size |
endg |
|
|
;----------------------------------------------------------------- |
; |
; IPv4_init |
; |
; This function resets all IP variables |
; |
;----------------------------------------------------------------- |
macro IPv4_init { |
|
xor eax, eax |
mov edi, IP_LIST |
mov ecx, 4*MAX_IP |
rep stosd |
|
mov edi, FRAGMENT_LIST |
mov ecx, FRAGMENT_slot.size*MAX_FRAGMENTS/4 + 2*MAX_IP |
rep stosd |
|
} |
|
|
;----------------------------------------------------------------- |
; |
; Decrease TimeToLive of all fragment slots |
; |
;----------------------------------------------------------------- |
macro IPv4_decrease_fragment_ttls { |
|
local .loop |
|
mov esi, FRAGMENT_LIST |
mov ecx, MAX_FRAGMENTS |
.loop: |
cmp [esi + FRAGMENT_slot.ttl], 0 |
je .try_next |
dec [esi + FRAGMENT_slot.ttl] |
jnz .try_next |
DEBUGF 1,"Fragment slot timed-out!\n" |
;;; TODO: clear all entry's of timed-out slot |
.try_next: |
add esi, 4 |
loop .loop |
} |
|
|
|
macro IPv4_checksum ptr { |
|
; This is the fast procedure to create or check a IP header without options |
120,69 → 179,8 |
|
|
|
align 4 |
uglobal |
|
IP_LIST rd MAX_IP |
SUBNET_LIST rd MAX_IP |
DNS_LIST rd MAX_IP |
GATEWAY_LIST rd MAX_IP |
|
IP_PACKETS_TX rd MAX_IP |
IP_PACKETS_RX rd MAX_IP |
|
FRAGMENT_LIST rb MAX_FRAGMENTS*FRAGMENT_slot.size |
endg |
|
|
;----------------------------------------------------------------- |
; |
; IPv4_init |
; |
; This function resets all IP variables |
; |
;----------------------------------------------------------------- |
macro IPv4_init { |
|
xor eax, eax |
mov edi, IP_LIST |
mov ecx, 4*MAX_IP |
rep stosd |
|
mov edi, FRAGMENT_LIST |
mov ecx, FRAGMENT_slot.size*MAX_FRAGMENTS/4 + 2*MAX_IP |
rep stosd |
|
} |
|
|
;----------------------------------------------------------------- |
; |
; Decrease TimeToLive of all fragment slots |
; |
;----------------------------------------------------------------- |
macro IPv4_decrease_fragment_ttls { |
|
local .loop |
|
mov esi, FRAGMENT_LIST |
mov ecx, MAX_FRAGMENTS |
.loop: |
cmp [esi + FRAGMENT_slot.ttl], 0 |
je .try_next |
dec [esi + FRAGMENT_slot.ttl] |
jnz .try_next |
DEBUGF 1,"Fragment slot timed-out!\n" |
;;; TODO: clear all entry's of timed-out slot |
.try_next: |
add esi, 4 |
loop .loop |
} |
|
|
|
;----------------------------------------------------------------- |
; |
; IPv4_input: |
; |
; Will check if IP Packet isnt damaged |
608,6 → 606,8 |
test eax, 0xffff0000 ; error bits |
jnz .arp_error |
|
.continue: |
|
push ebx ; push the mac |
push ax |
|