forked from KolibriOS/kolibrios
Better debug info for network, lots of improvements in TCP code
git-svn-id: svn://kolibrios.org@2891 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
@@ -219,7 +219,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
IPv4_checksum edx
|
||||
jnz .dump ; if checksum isn't valid then dump packet
|
||||
|
||||
DEBUGF 1,"IPv4 Checksum is correct\n"
|
||||
DEBUGF 1,"IPv4_input: Checksum ok\n"
|
||||
|
||||
;-----------------------------------
|
||||
; Check if destination IP is correct
|
||||
@@ -257,7 +257,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
|
||||
; or it's just not meant for us.. :(
|
||||
|
||||
DEBUGF 2,"IPv4_input - Destination address does not match!\n"
|
||||
DEBUGF 2,"IPv4_input: Destination address does not match!\n"
|
||||
jmp .dump
|
||||
|
||||
;------------------------
|
||||
@@ -301,11 +301,11 @@ IPv4_input: ; TODO: add IPv4
|
||||
cmp al, IP_PROTO_ICMP
|
||||
je ICMP_input
|
||||
|
||||
DEBUGF 2,"IPv4_input - unknown protocol: %u\n", al
|
||||
DEBUGF 2,"IPv4_input: unknown protocol %u\n", al
|
||||
|
||||
.dump:
|
||||
DEBUGF 2,"IPv4_input - dumping\n"
|
||||
; inc [dumped_rx_count]
|
||||
DEBUGF 2,"IPv4_input: dumping\n"
|
||||
; inc [dumped_rx_count] ;;; TODO
|
||||
call kernel_free
|
||||
add esp, 4 ; pop (balance stack)
|
||||
ret
|
||||
@@ -320,7 +320,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
xchg al , ah
|
||||
shl ax , 3
|
||||
|
||||
DEBUGF 1,"Fragmented packet, offset:%u, id:%x\n", ax, [edx + IPv4_header.Identification]:4
|
||||
DEBUGF 1,"IPv4_input: fragmented packet offset=%u id=%x\n", ax, [edx + IPv4_header.Identification]:4
|
||||
|
||||
test ax , ax ; Is this the first packet of the fragment?
|
||||
jz .is_first_fragment
|
||||
@@ -329,7 +329,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
;-------------------------------------------------------
|
||||
; We have a fragmented IP packet, but it's not the first
|
||||
|
||||
DEBUGF 1,"Middle fragmented packet received!\n"
|
||||
DEBUGF 1,"IPv4_input: Middle fragment packet received!\n"
|
||||
|
||||
call IPv4_find_fragment_slot
|
||||
cmp esi, -1
|
||||
@@ -362,7 +362,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
; We have received the first fragment
|
||||
|
||||
.is_first_fragment:
|
||||
DEBUGF 1,"First fragmented packet received!\n"
|
||||
DEBUGF 1,"IPv4_input: First fragment packet received!\n"
|
||||
; try to locate a free slot..
|
||||
mov ecx, MAX_FRAGMENTS
|
||||
mov esi, FRAGMENT_LIST
|
||||
@@ -396,7 +396,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
; We have received the last fragment
|
||||
|
||||
.is_last_fragment:
|
||||
DEBUGF 1,"Last fragmented packet received!\n"
|
||||
DEBUGF 1,"IPv4_input: Last fragment packet received!\n"
|
||||
|
||||
call IPv4_find_fragment_slot
|
||||
cmp esi, -1
|
||||
@@ -412,12 +412,12 @@ IPv4_input: ; TODO: add IPv4
|
||||
jne .destroy_slot_pop ; Damn, something screwed up, remove the whole slot (and free buffers too if possible!)
|
||||
mov cx, [esi + sizeof.FRAGMENT_entry + IPv4_header.TotalLength] ; Add total length
|
||||
xchg cl, ch
|
||||
DEBUGF 1,"Packet size: %u\n", cx
|
||||
DEBUGF 1,"IPv4_input: Packet size=%u\n", cx
|
||||
add ax, cx
|
||||
movzx cx, [esi + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Sub Header length
|
||||
and cx, 0x000F
|
||||
shl cx, 2
|
||||
DEBUGF 1,"Header size: %u\n", cx
|
||||
DEBUGF 1,"IPv4_input: Header size=%u\n", cx
|
||||
sub ax, cx
|
||||
mov edi, esi
|
||||
mov esi, [esi + FRAGMENT_entry.NextPtr]
|
||||
@@ -432,9 +432,9 @@ IPv4_input: ; TODO: add IPv4
|
||||
|
||||
mov cx, [edx + IPv4_header.TotalLength] ; Note: This time we dont substract Header length
|
||||
xchg cl , ch
|
||||
DEBUGF 1,"Packet size: %u\n", cx
|
||||
DEBUGF 1,"IPv4_input: Packet size=%u\n", cx
|
||||
add ax , cx
|
||||
DEBUGF 1,"Total Received data size: %u\n", eax
|
||||
DEBUGF 1,"IPv4_input: Total Received data size=%u\n", eax
|
||||
|
||||
push eax
|
||||
mov ax , [edx + IPv4_header.FlagsAndFragmentOffset]
|
||||
@@ -442,7 +442,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
shl ax , 3
|
||||
add cx , ax
|
||||
pop eax
|
||||
DEBUGF 1,"Total Fragment size: %u\n", ecx
|
||||
DEBUGF 1,"IPv4_input: Total Fragment size=%u\n", ecx
|
||||
|
||||
cmp ax, cx
|
||||
jne .destroy_slot_pop
|
||||
@@ -458,7 +458,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset
|
||||
xchg cl , ch ; intel byte order
|
||||
shl cx , 3 ; multiply by 8 and clear first 3 bits
|
||||
DEBUGF 1,"Fragment offset: %u\n", cx
|
||||
DEBUGF 1,"IPv4_input: Fragment offset=%u\n", cx
|
||||
|
||||
lea edi, [eax + ecx] ; Notice that edi will be equal to eax for first fragment
|
||||
movzx ebx, [edx + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Find header size (in ebx) of fragment
|
||||
@@ -505,7 +505,7 @@ IPv4_input: ; TODO: add IPv4
|
||||
.destroy_slot_pop:
|
||||
add esp, 4
|
||||
.destroy_slot:
|
||||
DEBUGF 1,"Destroy fragment slot!\n"
|
||||
DEBUGF 1,"IPv4_input: Destroy fragment slot!\n"
|
||||
; TODO!
|
||||
jmp .dump
|
||||
|
||||
@@ -613,7 +613,7 @@ IPv4_output:
|
||||
|
||||
IPv4_checksum edi
|
||||
add edi, sizeof.IPv4_header
|
||||
DEBUGF 1,"IPv4 Packet for device %x created successfully\n", ebx
|
||||
DEBUGF 1,"IPv4_output: success!\n"
|
||||
ret
|
||||
|
||||
.eth_error:
|
||||
@@ -623,13 +623,13 @@ IPv4_output:
|
||||
ret
|
||||
|
||||
.arp_error:
|
||||
DEBUGF 1,"IPv4_output: ARP error (0x%x)\n", eax
|
||||
DEBUGF 1,"IPv4_output: ARP error=%x\n", eax
|
||||
add esp, 3*4+2
|
||||
xor edi, edi
|
||||
ret
|
||||
|
||||
.too_large:
|
||||
DEBUGF 1,"IPv4_output: error: Packet too large!\n"
|
||||
DEBUGF 1,"IPv4_output: Packet too large!\n"
|
||||
xor edi, edi
|
||||
ret
|
||||
|
||||
@@ -706,7 +706,7 @@ IPv4_output_raw:
|
||||
|
||||
IPv4_checksum edi ;;;; todo: checksum for IP packet with options!
|
||||
add edi, sizeof.IPv4_header
|
||||
DEBUGF 1,"IPv4 Packet for device %x created successfully\n", ebx
|
||||
DEBUGF 1,"IPv4_output_raw: device=%x\n", ebx
|
||||
call [ebx + NET_DEVICE.transmit]
|
||||
ret
|
||||
|
||||
@@ -763,7 +763,7 @@ IPv4_fragment:
|
||||
push dword 0 ; offset
|
||||
|
||||
.new_fragment:
|
||||
DEBUGF 1,"Ipv4_fragment - new_fragmentn"
|
||||
DEBUGF 1,"Ipv4_fragment: new fragment"
|
||||
|
||||
|
||||
mov eax, [esp + 3*4]
|
||||
@@ -785,7 +785,7 @@ IPv4_fragment:
|
||||
add esi, [esp] ; offset
|
||||
|
||||
mov ecx, [esp + 1*4]
|
||||
DEBUGF 1,"IPv4_fragment - copying data (%u bytes)\n", ecx
|
||||
DEBUGF 1,"IPv4_fragment: copying %u bytes\n", ecx
|
||||
rep movsb
|
||||
|
||||
; now, correct header
|
||||
@@ -822,7 +822,7 @@ IPv4_fragment:
|
||||
sub ecx, [esp+2*4] ; ptr to ip header
|
||||
add ecx, [esp] ; offset
|
||||
|
||||
DEBUGF 1,"Ipv4_fragment - bytes remaining: %u\n", ecx
|
||||
DEBUGF 1,"Ipv4_fragment: %u bytes remaining\n", ecx
|
||||
|
||||
cmp ecx, [esp+1*4]
|
||||
jae .new_fragment
|
||||
@@ -831,11 +831,11 @@ IPv4_fragment:
|
||||
jmp .new_fragment
|
||||
|
||||
.err:
|
||||
DEBUGF 1,"Ipv4_fragment - failed\n"
|
||||
DEBUGF 1,"Ipv4_fragment: failed\n"
|
||||
.done:
|
||||
add esp, 12 + 4 + 6
|
||||
.err2:
|
||||
DEBUGF 1,"Ipv4_fragment - dumping\n"
|
||||
DEBUGF 1,"Ipv4_fragment: dumping\n"
|
||||
call kernel_free
|
||||
add esp, 4
|
||||
|
||||
|
Reference in New Issue
Block a user