Disabled network debug output by default.

git-svn-id: svn://kolibrios.org@3556 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-05-28 19:19:23 +00:00
parent 3adc7b1d8e
commit e93a49b442
16 changed files with 282 additions and 279 deletions

View File

@ -77,7 +77,7 @@ $Revision$
USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices USE_COM_IRQ equ 1 ; make irq 3 and irq 4 available for PCI devices
; Enabling the next line will enable serial output console ; Enabling the next line will enable serial output console
debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used ;debug_com_base equ 0x3f8 ; 0x3f8 is com1, 0x2f8 is com2, 0x3e8 is com3, 0x2e8 is com4, no irq's are used
; The following constant, if nonzero, duplicates debug output to the screen. ; The following constant, if nonzero, duplicates debug output to the screen.
debug_direct_print equ 0 debug_direct_print equ 0

View File

@ -177,7 +177,7 @@ ARP_input:
inc [ARP_PACKETS_RX + 4*edi] ; update stats inc [ARP_PACKETS_RX + 4*edi] ; update stats
DEBUGF 1,"ARP_input: got packet from %u.%u.%u.%u through device %u\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u through device %u\n",\
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\ [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
[edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi [edx + ARP_header.SenderIP + 2]:1, [edx + ARP_header.SenderIP + 3]:1, edi
@ -194,7 +194,7 @@ ARP_input:
cmp [edx + ARP_header.Opcode], ARP_REP_OPCODE cmp [edx + ARP_header.Opcode], ARP_REP_OPCODE
jne .maybe_request jne .maybe_request
DEBUGF 1,"ARP_input: It's a reply\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
mov ecx, [NumARP] mov ecx, [NumARP]
test ecx, ecx test ecx, ecx
@ -208,16 +208,16 @@ ARP_input:
dec ecx dec ecx
jnz .loop jnz .loop
DEBUGF 1,"ARP_input: no matching entry found\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: no matching entry found\n"
jmp .exit jmp .exit
.gotit: .gotit:
DEBUGF 1,"ARP_input: found matching entry\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: found matching entry\n"
cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY ; if it is a static entry, dont touch it cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY ; if it is a static entry, dont touch it
je .exit je .exit
DEBUGF 1,"ARP_input: updating entry\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: updating entry\n"
mov [esi + ARP_entry.Status], ARP_VALID_MAPPING mov [esi + ARP_entry.Status], ARP_VALID_MAPPING
mov [esi + ARP_entry.TTL], ARP_ENTRY_TTL mov [esi + ARP_entry.TTL], ARP_ENTRY_TTL
@ -236,7 +236,7 @@ ARP_input:
cmp [edx + ARP_header.Opcode], ARP_REQ_OPCODE cmp [edx + ARP_header.Opcode], ARP_REQ_OPCODE
jne .exit jne .exit
DEBUGF 1,"ARP_input: its a request\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
mov eax, [IP_LIST + 4*edi] mov eax, [IP_LIST + 4*edi]
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address? cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
@ -277,20 +277,20 @@ ARP_input:
; mov ax , ETHER_ARP ; It's already there, I'm sure of it! ; mov ax , ETHER_ARP ; It's already there, I'm sure of it!
; stosw ; stosw
DEBUGF 1,"ARP_input: Sending reply\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: Sending reply\n"
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
ret ret
.collision: .collision:
inc [ARP_CONFLICTS + 4*edi] inc [ARP_CONFLICTS + 4*edi]
DEBUGF 1,"ARP_input: IP address conflict detected!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
.exit: .exit:
call kernel_free call kernel_free
add esp, 4 ; pop (balance stack) add esp, 4 ; pop (balance stack)
DEBUGF 1,"ARP_input: exiting\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: exiting\n"
ret ret
@ -310,7 +310,7 @@ ARP_output_request:
pushd [IP_LIST + edi] ; SenderIP pushd [IP_LIST + edi] ; SenderIP
inc [ARP_PACKETS_TX + edi] ; assume we will succeed inc [ARP_PACKETS_TX + edi] ; assume we will succeed
DEBUGF 1,"ARP_output_request: ip=%u.%u.%u.%u\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u\n",\
[esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1 [esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1
mov ebx, [NET_DRV_LIST + edi] ; device ptr mov ebx, [NET_DRV_LIST + edi] ; device ptr
@ -344,7 +344,7 @@ ARP_output_request:
pop eax ; DestIP pop eax ; DestIP
stosd ; stosd ;
DEBUGF 1,"ARP_output_request: device=%x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: device=%x\n", ebx
push edx ecx push edx ecx
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
@ -352,7 +352,7 @@ ARP_output_request:
.exit: .exit:
add esp, 4 + 4 add esp, 4 + 4
DEBUGF 1,"ARP_output_request: failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: failed\n"
sub eax, eax sub eax, eax
ret ret
@ -369,7 +369,7 @@ ARP_output_request:
align 4 align 4
ARP_add_entry: ARP_add_entry:
DEBUGF 1,"ARP_add_entry: " DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: "
mov ecx, [NumARP] mov ecx, [NumARP]
cmp ecx, ARP_TABLE_SIZE ; list full ? cmp ecx, ARP_TABLE_SIZE ; list full ?
@ -400,12 +400,12 @@ ARP_add_entry:
rep movsw rep movsw
inc [NumARP] inc [NumARP]
sub edi, sizeof.ARP_entry sub edi, sizeof.ARP_entry
DEBUGF 1,"entry=%u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "entry=%u\n", eax
ret ret
.error: .error:
DEBUGF 1,"failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "failed\n"
mov eax, -1 mov eax, -1
ret ret
@ -421,8 +421,8 @@ ARP_add_entry:
align 4 align 4
ARP_del_entry: ARP_del_entry:
DEBUGF 1,"ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP] DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
DEBUGF 1,"ARP_del_entry: IP=%u.%u.%u.%u\n", \ DEBUGF DEBUG_NETWORK_VERBOSE, "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 [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
@ -438,7 +438,7 @@ ARP_del_entry:
rep stosw rep stosw
dec [NumARP] dec [NumARP]
DEBUGF 1,"ARP_del_entry: success\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
ret ret
@ -463,9 +463,9 @@ ARP_del_entry:
align 4 align 4
ARP_IP_to_MAC: ARP_IP_to_MAC:
DEBUGF 1,"ARP_IP_to_MAC: %u.%u", al, ah DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
rol eax, 16 rol eax, 16
DEBUGF 1,".%u.%u\n", al, ah DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u\n", al, ah
rol eax, 16 rol eax, 16
cmp eax, 0xffffffff cmp eax, 0xffffffff
@ -485,7 +485,7 @@ ARP_IP_to_MAC:
loop .scan_loop loop .scan_loop
.not_in_list: .not_in_list:
DEBUGF 1,"ARP_IP_to_MAC: preparing for ARP request\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: preparing for ARP request\n"
;-------------------- ;--------------------
; Send an ARP request ; Send an ARP request
@ -535,16 +535,16 @@ else
end if end if
.valid: .valid:
DEBUGF 1,"ARP_IP_to_MAC: found MAC\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: found MAC\n"
movzx eax, word[esi + ARP_entry.MAC] movzx eax, word[esi + ARP_entry.MAC]
mov ebx, dword[esi + ARP_entry.MAC + 2] mov ebx, dword[esi + ARP_entry.MAC + 2]
ret ret
.full: .full:
DEBUGF 1,"ARP_IP_to_MAC: table is full!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: table is full!\n"
add esp, 8 add esp, 8
.give_up: .give_up:
DEBUGF 1,"ARP_IP_to_MAC: entry has no valid mapping!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: entry has no valid mapping!\n"
mov eax, -1 mov eax, -1
ret ret

View File

@ -112,7 +112,7 @@ local .loop, .next
jmp .done jmp .done
.died: .died:
DEBUGF 2,"IPv4 Fragment slot timed-out!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4 Fragment slot timed-out!\n"
;;; TODO: clear all entry's of timed-out slot ;;; TODO: clear all entry's of timed-out slot
jmp .next jmp .next
@ -205,10 +205,10 @@ macro IPv4_checksum ptr {
align 4 align 4
IPv4_input: ; TODO: add IPv4 raw sockets support IPv4_input: ; TODO: add IPv4 raw sockets support
DEBUGF 2,"IPv4_input, packet from: %u.%u.%u.%u ",\ DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input, packet from: %u.%u.%u.%u ",\
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\ [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
[edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1 [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1
DEBUGF 2,"to: %u.%u.%u.%u\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "to: %u.%u.%u.%u\n",\
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\ [edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1 [edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
@ -218,7 +218,7 @@ IPv4_input: ; TODO: add IPv4
IPv4_checksum edx IPv4_checksum edx
jnz .dump ; if checksum isn't valid then dump packet jnz .dump ; if checksum isn't valid then dump packet
DEBUGF 1,"IPv4_input: Checksum ok\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
;----------------------------------- ;-----------------------------------
; Check if destination IP is correct ; Check if destination IP is correct
@ -256,7 +256,7 @@ IPv4_input: ; TODO: add IPv4
; or it's just not meant for us.. :( ; or it's just not meant for us.. :(
DEBUGF 2,"IPv4_input: Destination address does not match!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Destination address does not match!\n"
jmp .dump jmp .dump
;------------------------ ;------------------------
@ -300,10 +300,10 @@ IPv4_input: ; TODO: add IPv4
cmp al, IP_PROTO_ICMP cmp al, IP_PROTO_ICMP
je ICMP_input je ICMP_input
DEBUGF 2,"IPv4_input: unknown protocol %u\n", al DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: unknown protocol %u\n", al
.dump: .dump:
DEBUGF 1,"IPv4_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
inc [IP_packets_dumped] ; FIXME: use correct interface inc [IP_packets_dumped] ; FIXME: use correct interface
call kernel_free call kernel_free
add esp, 4 ; pop (balance stack) add esp, 4 ; pop (balance stack)
@ -319,7 +319,7 @@ IPv4_input: ; TODO: add IPv4
xchg al, ah xchg al, ah
shl ax, 3 shl ax, 3
DEBUGF 1,"IPv4_input: fragmented packet offset=%u id=%x\n", ax, [edx + IPv4_header.Identification]:4 DEBUGF DEBUG_NETWORK_VERBOSE, "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? test ax, ax ; Is this the first packet of the fragment?
jz .is_first_fragment jz .is_first_fragment
@ -328,7 +328,7 @@ IPv4_input: ; TODO: add IPv4
;------------------------------------------------------- ;-------------------------------------------------------
; We have a fragmented IP packet, but it's not the first ; We have a fragmented IP packet, but it's not the first
DEBUGF 1,"IPv4_input: Middle fragment packet received!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
call IPv4_find_fragment_slot call IPv4_find_fragment_slot
cmp esi, -1 cmp esi, -1
@ -361,7 +361,7 @@ IPv4_input: ; TODO: add IPv4
; We have received the first fragment ; We have received the first fragment
.is_first_fragment: .is_first_fragment:
DEBUGF 1,"IPv4_input: First fragment packet received!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: First fragment packet received!\n"
; try to locate a free slot.. ; try to locate a free slot..
mov ecx, MAX_FRAGMENTS mov ecx, MAX_FRAGMENTS
mov esi, FRAGMENT_LIST mov esi, FRAGMENT_LIST
@ -395,7 +395,7 @@ IPv4_input: ; TODO: add IPv4
; We have received the last fragment ; We have received the last fragment
.is_last_fragment: .is_last_fragment:
DEBUGF 1,"IPv4_input: Last fragment packet received!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
call IPv4_find_fragment_slot call IPv4_find_fragment_slot
cmp esi, -1 cmp esi, -1
@ -411,12 +411,12 @@ IPv4_input: ; TODO: add IPv4
jne .destroy_slot_pop ; Damn, something screwed up, remove the whole slot (and free buffers too if possible!) 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 mov cx, [esi + sizeof.FRAGMENT_entry + IPv4_header.TotalLength] ; Add total length
xchg cl, ch xchg cl, ch
DEBUGF 1,"IPv4_input: Packet size=%u\n", cx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Packet size=%u\n", cx
add ax, cx add ax, cx
movzx cx, [esi + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Sub Header length movzx cx, [esi + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Sub Header length
and cx, 0x000F and cx, 0x000F
shl cx, 2 shl cx, 2
DEBUGF 1,"IPv4_input: Header size=%u\n", cx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Header size=%u\n", cx
sub ax, cx sub ax, cx
mov edi, esi mov edi, esi
mov esi, [esi + FRAGMENT_entry.NextPtr] mov esi, [esi + FRAGMENT_entry.NextPtr]
@ -431,9 +431,9 @@ IPv4_input: ; TODO: add IPv4
mov cx, [edx + IPv4_header.TotalLength] ; Note: This time we dont substract Header length mov cx, [edx + IPv4_header.TotalLength] ; Note: This time we dont substract Header length
xchg cl, ch xchg cl, ch
DEBUGF 1,"IPv4_input: Packet size=%u\n", cx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Packet size=%u\n", cx
add ax, cx add ax, cx
DEBUGF 1,"IPv4_input: Total Received data size=%u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Total Received data size=%u\n", eax
push eax push eax
mov ax, [edx + IPv4_header.FlagsAndFragmentOffset] mov ax, [edx + IPv4_header.FlagsAndFragmentOffset]
@ -441,7 +441,7 @@ IPv4_input: ; TODO: add IPv4
shl ax, 3 shl ax, 3
add cx, ax add cx, ax
pop eax pop eax
DEBUGF 1,"IPv4_input: Total Fragment size=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Total Fragment size=%u\n", ecx
cmp ax, cx cmp ax, cx
jne .destroy_slot_pop jne .destroy_slot_pop
@ -457,7 +457,7 @@ IPv4_input: ; TODO: add IPv4
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset
xchg cl, ch ; intel byte order xchg cl, ch ; intel byte order
shl cx, 3 ; multiply by 8 and clear first 3 bits shl cx, 3 ; multiply by 8 and clear first 3 bits
DEBUGF 1,"IPv4_input: Fragment offset=%u\n", cx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Fragment offset=%u\n", cx
lea edi, [eax + ecx] ; Notice that edi will be equal to eax for first fragment 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 movzx ebx, [edx + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Find header size (in ebx) of fragment
@ -504,7 +504,7 @@ IPv4_input: ; TODO: add IPv4
.destroy_slot_pop: .destroy_slot_pop:
add esp, 4 add esp, 4
.destroy_slot: .destroy_slot:
DEBUGF 1,"IPv4_input: Destroy fragment slot!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Destroy fragment slot!\n"
; TODO! ; TODO!
jmp .dump jmp .dump
@ -568,7 +568,7 @@ IPv4_find_fragment_slot:
align 4 align 4
IPv4_output: IPv4_output:
DEBUGF 1,"IPv4_output: size=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u\n", ecx
cmp ecx, 65500 ; Max IPv4 packet size cmp ecx, 65500 ; Max IPv4 packet size
ja .too_large ja .too_large
@ -614,23 +614,23 @@ IPv4_output:
IPv4_checksum edi IPv4_checksum edi
add edi, sizeof.IPv4_header add edi, sizeof.IPv4_header
DEBUGF 2,"IPv4_output: success!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
ret ret
.eth_error: .eth_error:
DEBUGF 2,"IPv4_output: ethernet error\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: ethernet error\n"
add esp, 3*4+2+6 add esp, 3*4+2+6
xor edi, edi xor edi, edi
ret ret
.arp_error: .arp_error:
DEBUGF 2,"IPv4_output: ARP error=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: ARP error=%x\n", eax
add esp, 3*4+2 add esp, 3*4+2
xor edi, edi xor edi, edi
ret ret
.too_large: .too_large:
DEBUGF 2,"IPv4_output: Packet too large!\n" DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n"
xor edi, edi xor edi, edi
ret ret
@ -713,7 +713,7 @@ IPv4_output_raw:
IPv4_checksum edi ;;;; todo: checksum for IP packet with options! IPv4_checksum edi ;;;; todo: checksum for IP packet with options!
add edi, sizeof.IPv4_header add edi, sizeof.IPv4_header
DEBUGF 2,"IPv4_output_raw: device=%x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
ret ret
@ -722,7 +722,7 @@ IPv4_output_raw:
.arp_error: .arp_error:
add esp, 8+4+4 add esp, 8+4+4
.too_large: .too_large:
DEBUGF 2,"IPv4_output_raw: Failed\n" DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n"
sub edi, edi sub edi, edi
ret ret
@ -742,7 +742,7 @@ IPv4_output_raw:
align 4 align 4
IPv4_fragment: IPv4_fragment:
DEBUGF 1,"IPv4_fragment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment\n"
and ecx, not 111b ; align 4 and ecx, not 111b ; align 4
@ -770,7 +770,7 @@ IPv4_fragment:
push dword 0 ; offset push dword 0 ; offset
.new_fragment: .new_fragment:
DEBUGF 1,"Ipv4_fragment: new fragment" DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment"
mov eax, [esp + 3*4] mov eax, [esp + 3*4]
@ -792,7 +792,7 @@ IPv4_fragment:
add esi, [esp] ; offset add esi, [esp] ; offset
mov ecx, [esp + 1*4] mov ecx, [esp + 1*4]
DEBUGF 1,"IPv4_fragment: copying %u bytes\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_fragment: copying %u bytes\n", ecx
rep movsb rep movsb
; now, correct header ; now, correct header
@ -829,7 +829,7 @@ IPv4_fragment:
sub ecx, [esp+2*4] ; ptr to ip header sub ecx, [esp+2*4] ; ptr to ip header
add ecx, [esp] ; offset add ecx, [esp] ; offset
DEBUGF 1,"Ipv4_fragment: %u bytes remaining\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: %u bytes remaining\n", ecx
cmp ecx, [esp+1*4] cmp ecx, [esp+1*4]
jae .new_fragment jae .new_fragment
@ -838,11 +838,11 @@ IPv4_fragment:
jmp .new_fragment jmp .new_fragment
.err: .err:
DEBUGF 1,"Ipv4_fragment: failed\n" DEBUGF DEBUG_NETWORK_ERROR, "Ipv4_fragment: failed\n"
.done: .done:
add esp, 12 + 4 + 6 add esp, 12 + 4 + 6
.err2: .err2:
DEBUGF 1,"Ipv4_fragment: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
@ -886,7 +886,7 @@ IPv4_route:
mov eax, [GATEWAY_LIST] mov eax, [GATEWAY_LIST]
.found_it: .found_it:
DEBUGF 1,"IPv4_dest_to_dev: %u\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
ret ret
.broadcast: .broadcast:

View File

@ -83,7 +83,7 @@ macro IPv6_init {
align 4 align 4
IPv6_input: IPv6_input:
DEBUGF 2,"IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
[edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\ [edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\
[edx + IPv6_header.SourceAddress + 2]:2,[edx + IPv6_header.SourceAddress + 3]:2,\ [edx + IPv6_header.SourceAddress + 2]:2,[edx + IPv6_header.SourceAddress + 3]:2,\
[edx + IPv6_header.SourceAddress + 4]:2,[edx + IPv6_header.SourceAddress + 5]:2,\ [edx + IPv6_header.SourceAddress + 4]:2,[edx + IPv6_header.SourceAddress + 5]:2,\
@ -93,7 +93,7 @@ IPv6_input:
[edx + IPv6_header.SourceAddress + 12]:2,[edx + IPv6_header.SourceAddress + 13]:2,\ [edx + IPv6_header.SourceAddress + 12]:2,[edx + IPv6_header.SourceAddress + 13]:2,\
[edx + IPv6_header.SourceAddress + 14]:2,[edx + IPv6_header.SourceAddress + 15]:2 [edx + IPv6_header.SourceAddress + 14]:2,[edx + IPv6_header.SourceAddress + 15]:2
DEBUGF 1,"IPv6_input to: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input to: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
[edx + IPv6_header.DestinationAddress + 0]:2,[edx + IPv6_header.DestinationAddress + 1]:2,\ [edx + IPv6_header.DestinationAddress + 0]:2,[edx + IPv6_header.DestinationAddress + 1]:2,\
[edx + IPv6_header.DestinationAddress + 2]:2,[edx + IPv6_header.DestinationAddress + 3]:2,\ [edx + IPv6_header.DestinationAddress + 2]:2,[edx + IPv6_header.DestinationAddress + 3]:2,\
[edx + IPv6_header.DestinationAddress + 4]:2,[edx + IPv6_header.DestinationAddress + 5]:2,\ [edx + IPv6_header.DestinationAddress + 4]:2,[edx + IPv6_header.DestinationAddress + 5]:2,\
@ -143,10 +143,10 @@ IPv6_input:
; cmp al, 58 ; cmp al, 58
; je ICMP6_input ; je ICMP6_input
DEBUGF 2,"IPv6_input - unknown protocol: %u\n", al DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - unknown protocol: %u\n", al
.dump: .dump:
DEBUGF 1,"IPv6_input - dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
@ -166,7 +166,7 @@ IPv6_input:
; Hop-by-Hop ; Hop-by-Hop
.hop_by_hop: .hop_by_hop:
DEBUGF 1,"IPv6_input - hop by hop\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - hop by hop\n"
pushw [esi] ; 8 bit identifier for option type pushw [esi] ; 8 bit identifier for option type
movzx eax, byte[esi + 1] ; Hdr Ext Len movzx eax, byte[esi + 1] ; Hdr Ext Len
inc eax ; first 8 octets not counted inc eax ; first 8 octets not counted
@ -195,7 +195,7 @@ IPv6_input:
.pad_n: .pad_n:
movzx eax, byte[esi + 1] movzx eax, byte[esi + 1]
DEBUGF 1,"IPv6_input - pad %u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - pad %u\n", eax
inc esi inc esi
inc esi inc esi
add esi, eax add esi, eax
@ -203,7 +203,7 @@ IPv6_input:
jmp .hop_by_hop jmp .hop_by_hop
.pad_1: .pad_1:
DEBUGF 1,"IPv6_input - pad 1\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - pad 1\n"
inc esi inc esi
dec ecx dec ecx
jmp .hop_by_hop jmp .hop_by_hop
@ -211,11 +211,11 @@ IPv6_input:
.dest_opts: .dest_opts:
DEBUGF 1,"IPv6_input - dest opts\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dest opts\n"
jmp .nextheader jmp .nextheader
.routing: .routing:
DEBUGF 1,"IPv6_input - routing\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - routing\n"
pushw [esi] ; 8 bit identifier for option type pushw [esi] ; 8 bit identifier for option type
movzx eax, byte[esi + 1] ; Hdr Ext Len movzx eax, byte[esi + 1] ; Hdr Ext Len
inc eax ; first 8 octets not counted inc eax ; first 8 octets not counted
@ -238,7 +238,7 @@ IPv6_input:
jmp .nextheader jmp .nextheader
.fragment: .fragment:
DEBUGF 1,"IPv6_input - fragment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - fragment\n"
jmp .nextheader jmp .nextheader

View File

@ -59,7 +59,7 @@ macro PPPoE_init {
align 4 align 4
PPPoE_discovery_input: PPPoE_discovery_input:
DEBUGF 2,"PPPoE_discovery_input\n" DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_input\n"
; First, find open PPPoE socket ; First, find open PPPoE socket
@ -84,7 +84,7 @@ PPPoE_discovery_input:
jmp SOCKET_input jmp SOCKET_input
.dump: .dump:
DEBUGF 1,'PPPoE_discovery_input: dumping\n' DEBUGF DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
call kernel_free call kernel_free
add esp, 4 add esp, 4
ret ret
@ -103,7 +103,7 @@ PPPoE_discovery_input:
align 4 align 4
PPPoE_discovery_output: PPPoE_discovery_output:
DEBUGF 2,"PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
; RFC2516: An entire PADI packet (including the PPPoE header) MUST NOT ; RFC2516: An entire PADI packet (including the PPPoE header) MUST NOT
; exceed 1484 octets. ; exceed 1484 octets.
@ -123,7 +123,7 @@ PPPoE_discovery_output:
cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH cmp [ebx + NET_DEVICE.type], NET_TYPE_ETH
jne .bad jne .bad
DEBUGF 2,"PPPoE_discovery_output: device=%x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx
; Create packet. ; Create packet.
push ecx esi push ecx esi
@ -193,7 +193,7 @@ PPPoE_session_input:
xchg cl, ch xchg cl, ch
mov ax, [edx + PPPoE_frame.SessionID] mov ax, [edx + PPPoE_frame.SessionID]
DEBUGF 2,"PPPoE_input: session ID=%x, length=%u\n", ax, cx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: session ID=%x, length=%u\n", ax, cx
cmp ax, [PPPoE_SID] cmp ax, [PPPoE_SID]
jne .dump jne .dump
@ -207,10 +207,10 @@ PPPoE_session_input:
; je IPv6_input ; je IPv6_input
jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
DEBUGF 2,"PPPoE_input: Unknown protocol=%x\n", ax DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
.dump: .dump:
DEBUGF 2,"PPPoE_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
ret ret
@ -238,7 +238,7 @@ PPPoE_session_input:
align 4 align 4
PPPoE_output: PPPoE_output:
DEBUGF 1,"PPPoE_output: size=%u device=%x\n", ecx, ebx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
pushw di pushw di
pushw [PPPoE_SID] pushw [PPPoE_SID]
@ -263,7 +263,7 @@ PPPoE_output:
sub ecx, 2 sub ecx, 2
add edi, PPPoE_frame.Payload + 2 add edi, PPPoE_frame.Payload + 2
DEBUGF 1,"PPPoE_output: success!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: success!\n"
ret ret
@ -276,7 +276,7 @@ PPPoE_output:
PPPoE_start_connection: PPPoE_start_connection:
DEBUGF 2,"PPPoE_start_connection: %x\n", cx DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
cmp [PPPoE_SID], 0 cmp [PPPoE_SID], 0
jne .fail jne .fail
@ -296,7 +296,7 @@ PPPoE_start_connection:
align 4 align 4
PPPoE_stop_connection: PPPoE_stop_connection:
DEBUGF 2,"PPPoE_stop_connection\n" DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_stop_connection\n"
xor eax, eax xor eax, eax
mov [PPPoE_SID], ax mov [PPPoE_SID], ax

View File

@ -56,7 +56,7 @@ ETH_input:
mov eax, [esp] mov eax, [esp]
mov ecx, [esp+4] mov ecx, [esp+4]
DEBUGF 1,"ETH_input: size=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE,"ETH_input: size=%u\n", ecx
cmp ecx, ETH_FRAME_MINIMUM cmp ecx, ETH_FRAME_MINIMUM
jb .dump jb .dump
sub ecx, sizeof.ETH_header sub ecx, sizeof.ETH_header
@ -79,10 +79,10 @@ ETH_input:
cmp ax, ETHER_PPP_SESSION cmp ax, ETHER_PPP_SESSION
je PPPoE_session_input je PPPoE_session_input
DEBUGF 2,"ETH_input: Unknown packet type=%x\n", ax DEBUGF DEBUG_NETWORK_ERROR, "ETH_input: Unknown packet type=%x\n", ax
.dump: .dump:
DEBUGF 2,"ETH_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE,"ETH_input: dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
ret ret
@ -107,7 +107,7 @@ ETH_input:
align 4 align 4
ETH_output: ETH_output:
DEBUGF 1,"ETH_output: size=%u device=%x\n", ecx, ebx DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
cmp ecx, [ebx + NET_DEVICE.mtu] cmp ecx, [ebx + NET_DEVICE.mtu]
ja .exit ja .exit
@ -137,7 +137,7 @@ ETH_output:
cmp edx, ETH_FRAME_MINIMUM cmp edx, ETH_FRAME_MINIMUM
jbe .adjust_size jbe .adjust_size
.done: .done:
DEBUGF 1,"ETH_output: ptr=%x size=%u\n", eax, edx DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: ptr=%x size=%u\n", eax, edx
ret ret
.adjust_size: .adjust_size:
@ -146,13 +146,13 @@ ETH_output:
jmp .done jmp .done
.out_of_ram: .out_of_ram:
DEBUGF 2,"ETH_output: Out of ram!\n" DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n"
add esp, 4+4+2+4 add esp, 4+4+2+4
sub edi, edi sub edi, edi
ret ret
.exit: .exit:
DEBUGF 2,"ETH_output: Packet too large!\n" DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n"
sub edi, edi sub edi, edi
ret ret

View File

@ -38,8 +38,8 @@ ICMP_UNREACH_HOST_PROHIB = 10 ; ditto
ICMP_UNREACH_TOSNET = 11 ; bad tos for net ICMP_UNREACH_TOSNET = 11 ; bad tos for net
ICMP_UNREACH_TOSHOST = 12 ; bad tos for host ICMP_UNREACH_TOSHOST = 12 ; bad tos for host
ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib ICMP_UNREACH_FILTER_PROHIB = 13 ; admin prohib
ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio. ICMP_UNREACH_HOST_PRECEDENCE = 14 ; host prec vio.
ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff ICMP_UNREACH_PRECEDENCE_CUTOFF = 15 ; prec cutoff
ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down ICMP_SOURCEQUENCH = 4 ; Packet lost, slow down
@ -142,7 +142,7 @@ macro ICMP_init {
align 4 align 4
ICMP_input: ICMP_input:
DEBUGF 1,"ICMP_input:\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input:\n"
; First, check the checksum (altough some implementations ignore it) ; First, check the checksum (altough some implementations ignore it)
@ -163,7 +163,7 @@ ICMP_input:
; We well re-use the packet so we can create the response as fast as possible ; We well re-use the packet so we can create the response as fast as possible
; Notice: this only works on pure ethernet ; Notice: this only works on pure ethernet
DEBUGF 1,"got echo request\n" DEBUGF DEBUG_NETWORK_VERBOSE, "got echo request\n"
mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply mov [edx + ICMP_header.Type], ICMP_ECHOREPLY ; Change Packet type to reply
mov esi, [esp] ; Start of buffer mov esi, [esp] ; Start of buffer
@ -258,7 +258,7 @@ ICMP_input:
; je .dump ; je .dump
; inc [ICMP_PACKETS_RX+edi] ; inc [ICMP_PACKETS_RX+edi]
DEBUGF 1,"socket=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket=%x\n", eax
pusha pusha
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
@ -270,10 +270,10 @@ ICMP_input:
.checksum_mismatch: .checksum_mismatch:
DEBUGF 1,"checksum mismatch\n" DEBUGF DEBUG_NETWORK_VERBOSE, "checksum mismatch\n"
.dump: .dump:
DEBUGF 1,"ICMP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
call kernel_free call kernel_free
add esp, 4 ; pop (balance stack) add esp, 4 ; pop (balance stack)
@ -297,7 +297,7 @@ ICMP_input:
align 4 align 4
ICMP_output: ICMP_output:
DEBUGF 1,"Creating ICMP Packet\n" DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
push esi edi dx push esi edi dx
@ -308,7 +308,7 @@ ICMP_output:
call IPv4_output call IPv4_output
jz .exit jz .exit
DEBUGF 1,"full icmp packet size: %u\n", edx DEBUGF DEBUG_NETWORK_VERBOSE, "full icmp packet size: %u\n", edx
pop word [edi + ICMP_header.Type] ; Write both type and code bytes at once pop word [edi + ICMP_header.Type] ; Write both type and code bytes at once
pop dword [edi + ICMP_header.Identifier] ; identifier and sequence number pop dword [edi + ICMP_header.Identifier] ; identifier and sequence number
@ -333,11 +333,11 @@ ICMP_output:
sub edi, edx ;;; TODO: find a better way to remember start of packet sub edi, edx ;;; TODO: find a better way to remember start of packet
push edx edi push edx edi
DEBUGF 1,"Sending ICMP Packet\n" DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
ret ret
.exit: .exit:
DEBUGF 1,"Creating ICMP Packet failed\n" DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
add esp, 2*4 + 2 add esp, 2*4 + 2
ret ret
@ -356,7 +356,7 @@ ICMP_output:
align 4 align 4
ICMP_output_raw: ICMP_output_raw:
DEBUGF 1,"Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
push edx push edx
@ -371,7 +371,7 @@ ICMP_output_raw:
push eax push eax
push edi ecx push edi ecx
DEBUGF 1,"copying %u bytes from %x to %x\n", ecx, esi, edi DEBUGF DEBUG_NETWORK_VERBOSE, "copying %u bytes from %x to %x\n", ecx, esi, edi
rep movsb rep movsb
pop ecx edi pop ecx edi
@ -383,11 +383,11 @@ ICMP_output_raw:
call checksum_2 call checksum_2
mov [edi + ICMP_header.Checksum], dx mov [edi + ICMP_header.Checksum], dx
DEBUGF 1,"Sending ICMP Packet\n" DEBUGF DEBUG_NETWORK_VERBOSE, "Sending ICMP Packet\n"
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
ret ret
.exit: .exit:
DEBUGF 1,"Creating ICMP Packet failed\n" DEBUGF DEBUG_NETWORK_ERROR, "Creating ICMP Packet failed\n"
add esp, 4 add esp, 4
ret ret

View File

@ -59,7 +59,7 @@ LOOP_input:
push ecx push ecx
push eax push eax
DEBUGF 1,"LOOP_input: size=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: size=%u\n", ecx
lea edx, [eax + 2] lea edx, [eax + 2]
mov ax, word[eax] mov ax, word[eax]
mov ebx, LOOPBACK_DEVICE mov ebx, LOOPBACK_DEVICE
@ -67,10 +67,10 @@ LOOP_input:
cmp ax, ETHER_IPv4 cmp ax, ETHER_IPv4
je IPv4_input je IPv4_input
DEBUGF 2,"LOOP_input: Unknown packet type=%x\n", ax DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", ax
.dump: .dump:
DEBUGF 2,"LOOP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
ret ret
@ -93,7 +93,7 @@ LOOP_input:
align 4 align 4
LOOP_output: LOOP_output:
DEBUGF 1,"LOOP_output\n" DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
push ecx push ecx
push di push di
@ -114,11 +114,11 @@ LOOP_output:
mov ebx, LOOPBACK_DEVICE mov ebx, LOOPBACK_DEVICE
.done: .done:
DEBUGF 2,"LOOP_output: ptr=%x size=%u\n", eax, edx DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, edx
ret ret
.out_of_ram: .out_of_ram:
DEBUGF 2,"LOOP_output: failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: failed\n"
add esp, 2+4 add esp, 2+4
sub edi, edi sub edi, edi
ret ret

View File

@ -263,7 +263,7 @@ sys_socket:
.number = ($ - .table) / 4 - 1 .number = ($ - .table) / 4 - 1
s_error: s_error:
DEBUGF 2,"SOCKET: error\n" DEBUGF DEBUG_NETWORK_ERROR, "SOCKET: error\n"
mov dword [esp+32], -1 mov dword [esp+32], -1
ret ret
@ -281,7 +281,7 @@ s_error:
align 4 align 4
SOCKET_open: SOCKET_open:
DEBUGF 2,"SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi
push ecx edx esi push ecx edx esi
call SOCKET_alloc call SOCKET_alloc
@ -289,7 +289,7 @@ SOCKET_open:
jz s_error jz s_error
mov [esp+32], edi ; return socketnumber mov [esp+32], edi ; return socketnumber
DEBUGF 2,"socknum=%u\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi
; push edx ; push edx
; and edx, SO_NONBLOCK ; and edx, SO_NONBLOCK
@ -321,7 +321,7 @@ SOCKET_open:
je .pppoe je .pppoe
.no_ppp: .no_ppp:
DEBUGF 2,"Unknown socket family/protocol\n" DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_open: Unknown socket family/protocol\n"
ret ret
align 4 align 4
@ -394,7 +394,7 @@ align 4
align 4 align 4
SOCKET_bind: SOCKET_bind:
DEBUGF 2,"SOCKET_bind: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_bind: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -444,7 +444,7 @@ SOCKET_bind:
call SOCKET_check_port call SOCKET_check_port
jz s_error ; ZF is set by socket_check_port, on error jz s_error ; ZF is set by socket_check_port, on error
DEBUGF 1,"SOCKET_bind: local ip=%u.%u.%u.%u\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_bind: local ip=%u.%u.%u.%u\n",\
[eax + IP_SOCKET.LocalIP + 0]:1,[eax + IP_SOCKET.LocalIP + 1]:1,\ [eax + IP_SOCKET.LocalIP + 0]:1,[eax + IP_SOCKET.LocalIP + 1]:1,\
[eax + IP_SOCKET.LocalIP + 2]:1,[eax + IP_SOCKET.LocalIP + 3]:1 [eax + IP_SOCKET.LocalIP + 2]:1,[eax + IP_SOCKET.LocalIP + 3]:1
@ -467,7 +467,7 @@ SOCKET_bind:
align 4 align 4
SOCKET_connect: SOCKET_connect:
DEBUGF 2,"SOCKET_connect: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_connect: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -616,7 +616,7 @@ align 4
align 4 align 4
SOCKET_listen: SOCKET_listen:
DEBUGF 2,"SOCKET_listen: socknum=%u backlog=%u\n", ecx, edx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_listen: socknum=%u backlog=%u\n", ecx, edx
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -668,7 +668,7 @@ SOCKET_listen:
align 4 align 4
SOCKET_accept: SOCKET_accept:
DEBUGF 2,"SOCKET_accept: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_accept: socknum=%u sockaddr=%x length=%u\n", ecx, edx, esi
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -718,7 +718,7 @@ SOCKET_accept:
align 4 align 4
SOCKET_close: SOCKET_close:
DEBUGF 2,"SOCKET_close: socknum=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_close: socknum=%u\n", ecx
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -767,7 +767,7 @@ SOCKET_close:
align 4 align 4
SOCKET_receive: SOCKET_receive:
DEBUGF 2,"SOCKET_receive: socknum=%u bufaddr=%x buflength=%u flags=%x\n", ecx, edx, esi, edi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: socknum=%u bufaddr=%x buflength=%u flags=%x\n", ecx, edx, esi, edi
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -778,7 +778,7 @@ SOCKET_receive:
align 4 align 4
SOCKET_receive_dgram: SOCKET_receive_dgram:
DEBUGF 1,"SOCKET_receive: DGRAM\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: DGRAM\n"
mov ebx, esi mov ebx, esi
mov edi, edx ; addr to buffer mov edi, edx ; addr to buffer
@ -787,14 +787,14 @@ SOCKET_receive_dgram:
get_from_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, .block ; destroys esi and ecx get_from_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, .block ; destroys esi and ecx
mov ecx, [esi + socket_queue_entry.data_size] mov ecx, [esi + socket_queue_entry.data_size]
DEBUGF 1,"SOCKET_receive: %u bytes data\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: %u bytes data\n", ecx
cmp ecx, ebx cmp ecx, ebx
ja .too_small ja .too_small
push [esi + socket_queue_entry.buf_ptr] ; save the buffer addr so we can clear it later push [esi + socket_queue_entry.buf_ptr] ; save the buffer addr so we can clear it later
mov esi, [esi + socket_queue_entry.data_ptr] mov esi, [esi + socket_queue_entry.data_ptr]
DEBUGF 1,"SOCKET_receive: Source buffer=%x real addr=%x\n", [esp], esi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Source buffer=%x real addr=%x\n", [esp], esi
mov [esp+32+4], ecx ; return number of bytes copied mov [esp+32+4], ecx ; return number of bytes copied
; copy the data ; copy the data
@ -816,7 +816,7 @@ SOCKET_receive_dgram:
.too_small: .too_small:
DEBUGF 2,"SOCKET_receive: Buffer too small\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Buffer too small\n"
jmp s_error jmp s_error
.block: .block:
@ -846,7 +846,7 @@ SOCKET_receive_local:
align 4 align 4
SOCKET_receive_stream: SOCKET_receive_stream:
DEBUGF 1,"SOCKET_receive: STREAM\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: STREAM\n"
mov ebx, edi mov ebx, edi
mov ecx, esi mov ecx, esi
@ -902,7 +902,7 @@ SOCKET_receive_stream:
align 4 align 4
SOCKET_send: SOCKET_send:
DEBUGF 2,"SOCKET_send: socknum=%u data ptr=%x length=%u flags=%x\n", ecx, edx, esi, edi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: socknum=%u data ptr=%x length=%u flags=%x\n", ecx, edx, esi, edi
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -916,7 +916,7 @@ SOCKET_send:
align 4 align 4
SOCKET_send_udp: SOCKET_send_udp:
DEBUGF 1,"SOCKET_send: UDP\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: UDP\n"
mov [esp+32], ecx mov [esp+32], ecx
call UDP_output call UDP_output
@ -928,7 +928,7 @@ SOCKET_send_udp:
align 4 align 4
SOCKET_send_tcp: SOCKET_send_tcp:
DEBUGF 1,"SOCKET_send: TCP\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: TCP\n"
push eax push eax
add eax, STREAM_SOCKET.snd add eax, STREAM_SOCKET.snd
@ -944,7 +944,7 @@ SOCKET_send_tcp:
align 4 align 4
SOCKET_send_ip: SOCKET_send_ip:
DEBUGF 1,"SOCKET_send: IPv4\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: IPv4\n"
mov [esp+32], ecx mov [esp+32], ecx
call IPv4_output_raw call IPv4_output_raw
@ -956,7 +956,7 @@ SOCKET_send_ip:
align 4 align 4
SOCKET_send_icmp: SOCKET_send_icmp:
DEBUGF 1,"SOCKET_send: ICMP\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: ICMP\n"
mov [esp+32], ecx mov [esp+32], ecx
call ICMP_output_raw call ICMP_output_raw
@ -968,7 +968,7 @@ SOCKET_send_icmp:
align 4 align 4
SOCKET_send_pppoe: SOCKET_send_pppoe:
DEBUGF 1,"SOCKET_send: PPPoE\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n"
mov [esp+32], ecx mov [esp+32], ecx
mov ebx, [eax + SOCKET.device] mov ebx, [eax + SOCKET.device]
@ -998,7 +998,7 @@ SOCKET_send_local:
align 4 align 4
SOCKET_send_local_: SOCKET_send_local_:
DEBUGF 1,"SOCKET_send: LOCAL\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: LOCAL\n"
; get the other side's socket and check if it still exists ; get the other side's socket and check if it still exists
mov eax, [eax + SOCKET.device] mov eax, [eax + SOCKET.device]
@ -1037,7 +1037,7 @@ SOCKET_send_local_:
align 4 align 4
SOCKET_get_opt: SOCKET_get_opt:
DEBUGF 2,"SOCKET_get_opt\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_get_opt\n"
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -1087,7 +1087,7 @@ SOCKET_get_opt:
align 4 align 4
SOCKET_set_opt: SOCKET_set_opt:
DEBUGF 2,"SOCKET_set_opt\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_set_opt\n"
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz s_error
@ -1116,7 +1116,7 @@ SOCKET_set_opt:
jz s_error jz s_error
mov [eax + SOCKET.device], edx mov [eax + SOCKET.device], edx
DEBUGF 1,"SOCKET_set_opt: Bound socket %x to device %x\n",eax, edx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_set_opt: Bound socket %x to device %x\n",eax, edx
mov dword [esp+32], 0 ; success! mov dword [esp+32], 0 ; success!
ret ret
@ -1158,7 +1158,7 @@ SOCKET_set_opt:
align 4 align 4
SOCKET_pair: SOCKET_pair:
DEBUGF 2,"SOCKET_pair\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n"
call SOCKET_alloc call SOCKET_alloc
jz s_error jz s_error
@ -1217,7 +1217,7 @@ SOCKET_pair:
align 4 align 4
SOCKET_debug: SOCKET_debug:
DEBUGF 1,"SOCKET_debug\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_debug\n"
mov edi, edx mov edi, edx
@ -1266,7 +1266,7 @@ SOCKET_debug:
align 4 align 4
SOCKET_find_port: SOCKET_find_port:
DEBUGF 2,"SOCKET_find_port\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_find_port\n"
push ebx esi ecx push ebx esi ecx
@ -1327,7 +1327,7 @@ SOCKET_find_port:
align 4 align 4
SOCKET_check_port: SOCKET_check_port:
DEBUGF 2,"SOCKET_check_port: " DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_port: "
mov ecx, [eax + SOCKET.Protocol] mov ecx, [eax + SOCKET.Protocol]
mov edx, [eax + IP_SOCKET.LocalIP] mov edx, [eax + IP_SOCKET.LocalIP]
@ -1347,11 +1347,11 @@ SOCKET_check_port:
cmp [esi + UDP_SOCKET.LocalPort], bx cmp [esi + UDP_SOCKET.LocalPort], bx
jne .next_socket jne .next_socket
DEBUGF 2,"local port %x already in use\n", bx ; FIXME: find a way to print big endian values with debugf DEBUGF DEBUG_NETWORK_VERBOSE, "local port %x already in use\n", bx ; FIXME: find a way to print big endian values with debugf
ret ret
.port_ok: .port_ok:
DEBUGF 2,"local port %x is free\n", bx ; FIXME: find a way to print big endian values with debugf DEBUGF DEBUG_NETWORK_VERBOSE, "local port %x is free\n", bx ; FIXME: find a way to print big endian values with debugf
mov [eax + UDP_SOCKET.LocalPort], bx mov [eax + UDP_SOCKET.LocalPort], bx
or bx, bx ; clear the zero-flag or bx, bx ; clear the zero-flag
ret ret
@ -1378,7 +1378,7 @@ SOCKET_check_port:
align 4 align 4
SOCKET_input: SOCKET_input:
DEBUGF 2,"SOCKET_input: socket=%x, data=%x size=%u\n", eax, esi, ecx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket=%x, data=%x size=%u\n", eax, esi, ecx
mov [esp+4], ecx mov [esp+4], ecx
push esi push esi
@ -1386,7 +1386,7 @@ SOCKET_input:
add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, SOCKET_input.full add_to_queue (eax + SOCKET_QUEUE_LOCATION), SOCKET_QUEUE_SIZE, sizeof.socket_queue_entry, SOCKET_input.full
DEBUGF 1,"SOCKET_input: success\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: success\n"
add esp, sizeof.socket_queue_entry add esp, sizeof.socket_queue_entry
pusha pusha
@ -1397,7 +1397,7 @@ SOCKET_input:
jmp SOCKET_notify jmp SOCKET_notify
.full: .full:
DEBUGF 2,"SOCKET_input: socket %x is full!\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_input: socket %x is full!\n", eax
pusha pusha
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
@ -1424,7 +1424,7 @@ SOCKET_ring_create:
stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SW stdcall create_ring_buffer, SOCKET_MAXDATA, PG_SW
pop edx pop edx
DEBUGF 1,"SOCKET_ring_created: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_created: %x\n", eax
pusha pusha
lea ecx, [esi + RING_BUFFER.mutex] lea ecx, [esi + RING_BUFFER.mutex]
@ -1458,7 +1458,7 @@ SOCKET_ring_create:
align 4 align 4
SOCKET_ring_write: SOCKET_ring_write:
DEBUGF 1,"SOCKET_ring_write: ringbuff=%x ptr=%x size=%u\n", eax, esi, ecx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_write: ringbuff=%x ptr=%x size=%u\n", eax, esi, ecx
; lock mutex ; lock mutex
pusha pusha
@ -1474,7 +1474,7 @@ SOCKET_ring_write:
mov ecx, edi mov ecx, edi
.copy: .copy:
mov edi, [eax + RING_BUFFER.write_ptr] mov edi, [eax + RING_BUFFER.write_ptr]
DEBUGF 2,"SOCKET_ring_write: %u bytes from %x to %x\n", ecx, esi, edi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_write: %u bytes from %x to %x\n", ecx, esi, edi
; update write ptr ; update write ptr
push edi push edi
@ -1532,7 +1532,7 @@ SOCKET_ring_write:
align 4 align 4
SOCKET_ring_read: SOCKET_ring_read:
DEBUGF 1,"SOCKET_ring_read: ringbuff=%x ptr=%x size=%u offset=%x\n", eax, edi, ecx, edx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_read: ringbuff=%x ptr=%x size=%u offset=%x\n", eax, edi, ecx, edx
pusha pusha
lea ecx, [eax + RING_BUFFER.mutex] lea ecx, [eax + RING_BUFFER.mutex]
@ -1555,7 +1555,7 @@ SOCKET_ring_read:
ja .less_data ja .less_data
.copy: .copy:
DEBUGF 2,"SOCKET_ring_read: %u bytes from %x to %x\n", ecx, esi, edi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_read: %u bytes from %x to %x\n", ecx, esi, edi
push ecx push ecx
shr ecx, 1 shr ecx, 1
jnc .nb jnc .nb
@ -1578,7 +1578,7 @@ SOCKET_ring_read:
call mutex_unlock ; TODO: check what registers this function actually destroys call mutex_unlock ; TODO: check what registers this function actually destroys
popa popa
DEBUGF 1,"SOCKET_ring_read: no data at all!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_read: no data at all!\n"
xor ecx, ecx xor ecx, ecx
ret ret
@ -1602,7 +1602,7 @@ SOCKET_ring_read:
align 4 align 4
SOCKET_ring_free: SOCKET_ring_free:
DEBUGF 1,"SOCKET_ring_free: %u bytes from ring %x\n", ecx, eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_free: %u bytes from ring %x\n", ecx, eax
push eax ecx push eax ecx
lea ecx, [eax + RING_BUFFER.mutex] lea ecx, [eax + RING_BUFFER.mutex]
@ -1627,7 +1627,7 @@ SOCKET_ring_free:
ret ret
.error: ; we could free all available bytes, but that would be stupid, i guess.. .error: ; we could free all available bytes, but that would be stupid, i guess..
DEBUGF 1,"SOCKET_ring_free: buffer=%x error!\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ring_free: buffer=%x error!\n", eax
add [eax + RING_BUFFER.size], ecx add [eax + RING_BUFFER.size], ecx
push eax push eax
@ -1652,7 +1652,7 @@ SOCKET_ring_free:
align 4 align 4
SOCKET_block: SOCKET_block:
DEBUGF 1,"SOCKET_block: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
pushf pushf
cli cli
@ -1667,14 +1667,14 @@ SOCKET_block:
; Remember the thread ID so we can wake it up again ; Remember the thread ID so we can wake it up again
mov edx, [edx + TASKDATA.pid] mov edx, [edx + TASKDATA.pid]
DEBUGF 1,"SOCKET_block: suspending thread: %u\n", edx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: suspending thread: %u\n", edx
mov [eax + SOCKET.TID], edx mov [eax + SOCKET.TID], edx
pop edx pop edx
call change_task call change_task
popf popf
DEBUGF 1,"SOCKET_block: continueing\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: continueing\n"
ret ret
@ -1692,7 +1692,7 @@ SOCKET_block:
align 4 align 4
SOCKET_notify: SOCKET_notify:
DEBUGF 1,"SOCKET_notify: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: %x\n", eax
call SOCKET_check call SOCKET_check
jz .error jz .error
@ -1728,7 +1728,7 @@ SOCKET_notify:
shl ecx, 8 shl ecx, 8
or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK or [ecx + SLOT_BASE + APPDATA.event_mask], EVENT_NETWORK
DEBUGF 1,"SOCKET_notify: Raised a network event!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Raised a network event!\n"
jmp .done jmp .done
@ -1756,7 +1756,7 @@ SOCKET_notify:
; Run the thread ; Run the thread
mov [esi + TASKDATA.state], 0 ; Running mov [esi + TASKDATA.state], 0 ; Running
DEBUGF 1,"SOCKET_notify: Unblocked socket!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
.done: .done:
pop esi ecx eax pop esi ecx eax
@ -1785,7 +1785,7 @@ SOCKET_alloc:
push ebx push ebx
stdcall kernel_alloc, SOCKETBUFFSIZE stdcall kernel_alloc, SOCKETBUFFSIZE
DEBUGF 1, "SOCKET_alloc: ptr=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_alloc: ptr=%x\n", eax
or eax, eax or eax, eax
jz .exit jz .exit
@ -1821,7 +1821,7 @@ SOCKET_alloc:
.last_socket: .last_socket:
mov [last_socket_num], edi mov [last_socket_num], edi
mov [eax + SOCKET.Number], edi mov [eax + SOCKET.Number], edi
DEBUGF 1, "SOCKET_alloc: number=%u\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_alloc: number=%u\n", edi
; Fill in PID ; Fill in PID
mov ebx, [TASK_BASE] mov ebx, [TASK_BASE]
@ -1878,7 +1878,7 @@ SOCKET_alloc:
align 4 align 4
SOCKET_free: SOCKET_free:
DEBUGF 1, "SOCKET_free: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: %x\n", eax
call SOCKET_check call SOCKET_check
jz .error jz .error
@ -1906,7 +1906,7 @@ SOCKET_free:
mov ebx, [eax + SOCKET.NextPtr] mov ebx, [eax + SOCKET.NextPtr]
mov eax, [eax + SOCKET.PrevPtr] mov eax, [eax + SOCKET.PrevPtr]
DEBUGF 1, "SOCKET_free: linking socket %x to socket %x\n", eax, ebx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: linking socket %x to socket %x\n", eax, ebx
test eax, eax test eax, eax
jz @f jz @f
@ -1921,7 +1921,7 @@ SOCKET_free:
call kernel_free call kernel_free
pop ebx pop ebx
DEBUGF 1, "SOCKET_free: success!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_free: success!\n"
.error: .error:
ret ret
@ -1939,7 +1939,7 @@ SOCKET_free:
align 4 align 4
SOCKET_fork: SOCKET_fork:
DEBUGF 1,"SOCKET_fork: %x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_fork: %x\n", ebx
; Exit if backlog queue is full ; Exit if backlog queue is full
mov eax, [ebx + SOCKET_QUEUE_LOCATION + queue.size] mov eax, [ebx + SOCKET_QUEUE_LOCATION + queue.size]
@ -1971,7 +1971,7 @@ SOCKET_fork:
.fail2: .fail2:
add esp, 4+4+4 add esp, 4+4+4
.fail: .fail:
DEBUGF 1,"SOCKET_fork: failed\n" DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_fork: failed\n"
xor eax, eax xor eax, eax
ret ret
@ -1990,7 +1990,7 @@ SOCKET_fork:
align 4 align 4
SOCKET_num_to_ptr: SOCKET_num_to_ptr:
DEBUGF 1,"SOCKET_num_to_ptr: num=%u ", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_num_to_ptr: num=%u ", ecx
mov eax, net_sockets mov eax, net_sockets
@ -2003,11 +2003,11 @@ SOCKET_num_to_ptr:
test eax, eax test eax, eax
DEBUGF 1,"ptr=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "ptr=%x\n", eax
ret ret
.error: .error:
DEBUGF 1,"not found\n", eax DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_nuto_ptr: not found\n", eax
ret ret
@ -2025,18 +2025,18 @@ SOCKET_num_to_ptr:
align 4 align 4
SOCKET_ptr_to_num: SOCKET_ptr_to_num:
DEBUGF 1,"SOCKET_ptr_to_num: ptr=%x ", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_ptr_to_num: ptr=%x ", eax
call SOCKET_check call SOCKET_check
jz .error jz .error
mov eax, [eax + SOCKET.Number] mov eax, [eax + SOCKET.Number]
DEBUGF 1,"num=%u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "num=%u\n", eax
ret ret
.error: .error:
DEBUGF 1,"not found\n", eax DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_ptr_to_num: not found\n", eax
ret ret
@ -2054,7 +2054,7 @@ SOCKET_ptr_to_num:
align 4 align 4
SOCKET_check: SOCKET_check:
DEBUGF 1,"SOCKET_check: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check: %x\n", eax
push ebx push ebx
mov ebx, net_sockets mov ebx, net_sockets
@ -2088,7 +2088,7 @@ SOCKET_check:
align 4 align 4
SOCKET_check_owner: SOCKET_check_owner:
DEBUGF 1,"SOCKET_check_owner: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_check_owner: %x\n", eax
push ebx push ebx
mov ebx, [TASK_BASE] mov ebx, [TASK_BASE]
@ -2116,7 +2116,7 @@ SOCKET_check_owner:
align 4 align 4
SOCKET_process_end: SOCKET_process_end:
DEBUGF 1, "SOCKET_process_end: %x\n", edx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_process_end: %x\n", edx
push ebx push ebx
mov ebx, net_sockets mov ebx, net_sockets
@ -2130,7 +2130,7 @@ SOCKET_process_end:
cmp [ebx + SOCKET.PID], edx cmp [ebx + SOCKET.PID], edx
jne .next_socket jne .next_socket
DEBUGF 1, "SOCKET_process_end: killing socket %x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_process_end: killing socket %x\n", ebx
mov [ebx + SOCKET.PID], 0 mov [ebx + SOCKET.PID], 0
mov eax, ebx mov eax, ebx
@ -2160,7 +2160,7 @@ SOCKET_process_end:
align 4 align 4
SOCKET_is_connecting: SOCKET_is_connecting:
DEBUGF 1,"SOCKET_is_connecting: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_connecting: %x\n", eax
and [eax + SOCKET.options], not (SS_ISCONNECTED + SS_ISDISCONNECTING + SS_ISCONFIRMING) and [eax + SOCKET.options], not (SS_ISCONNECTED + SS_ISDISCONNECTING + SS_ISCONFIRMING)
or [eax + SOCKET.options], SS_ISCONNECTING or [eax + SOCKET.options], SS_ISCONNECTING
@ -2181,7 +2181,7 @@ SOCKET_is_connecting:
align 4 align 4
SOCKET_is_connected: SOCKET_is_connected:
DEBUGF 1,"SOCKET_is_connected: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_connected: %x\n", eax
and [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISDISCONNECTING + SS_ISCONFIRMING) and [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISDISCONNECTING + SS_ISCONFIRMING)
or [eax + SOCKET.options], SS_ISCONNECTED or [eax + SOCKET.options], SS_ISCONNECTED
@ -2203,7 +2203,7 @@ SOCKET_is_connected:
align 4 align 4
SOCKET_is_disconnecting: SOCKET_is_disconnecting:
DEBUGF 1,"SOCKET_is_disconnecting: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnecting: %x\n", eax
and [eax + SOCKET.options], not (SS_ISCONNECTING) and [eax + SOCKET.options], not (SS_ISCONNECTING)
or [eax + SOCKET.options], SS_ISDISCONNECTING + SS_CANTRCVMORE + SS_CANTSENDMORE or [eax + SOCKET.options], SS_ISDISCONNECTING + SS_CANTRCVMORE + SS_CANTSENDMORE
@ -2224,7 +2224,7 @@ SOCKET_is_disconnecting:
align 4 align 4
SOCKET_is_disconnected: SOCKET_is_disconnected:
DEBUGF 1,"SOCKET_is_disconnected: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_is_disconnected: %x\n", eax
and [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING) and [eax + SOCKET.options], not (SS_ISCONNECTING + SS_ISCONNECTED + SS_ISDISCONNECTING)
or [eax + SOCKET.options], SS_CANTRCVMORE + SS_CANTSENDMORE or [eax + SOCKET.options], SS_CANTRCVMORE + SS_CANTSENDMORE
@ -2257,7 +2257,7 @@ SOCKET_is_disconnected:
align 4 align 4
SOCKET_cant_recv_more: SOCKET_cant_recv_more:
DEBUGF 1,"SOCKET_cant_recv_more: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_recv_more: %x\n", eax
or [eax + SOCKET.options], SS_CANTRCVMORE or [eax + SOCKET.options], SS_CANTRCVMORE
@ -2277,7 +2277,7 @@ SOCKET_cant_recv_more:
align 4 align 4
SOCKET_cant_send_more: SOCKET_cant_send_more:
DEBUGF 1,"SOCKET_cant_send_more: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_cant_send_more: %x\n", eax
or [eax + SOCKET.options], SS_CANTSENDMORE or [eax + SOCKET.options], SS_CANTSENDMORE

View File

@ -28,6 +28,9 @@ uglobal
net_tmr_count dw ? net_tmr_count dw ?
endg endg
DEBUG_NETWORK_ERROR = 1
DEBUG_NETWORK_VERBOSE = 0
MAX_NET_DEVICES = 16 MAX_NET_DEVICES = 16
ARP_BLOCK = 1 ; true or false ARP_BLOCK = 1 ; true or false
@ -305,12 +308,12 @@ stack_handler:
align 4 align 4
NET_link_changed: NET_link_changed:
DEBUGF 1,"NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.state] DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.state]
align 4 align 4
NET_send_event: NET_send_event:
DEBUGF 1,"NET_send_event\n" DEBUGF DEBUG_NETWORK_VERBOSE, "NET_send_event\n"
; Send event to all applications ; Send event to all applications
push edi ecx push edi ecx
@ -340,7 +343,7 @@ NET_send_event:
align 4 align 4
NET_add_device: NET_add_device:
DEBUGF 1,"NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list DEBUGF DEBUG_NETWORK_VERBOSE, "NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
cmp [NET_RUNNING], MAX_NET_DEVICES cmp [NET_RUNNING], MAX_NET_DEVICES
jae .error jae .error
@ -384,12 +387,12 @@ NET_add_device:
call NET_send_event call NET_send_event
DEBUGF 1,"Device number: %u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
ret ret
.error: .error:
or eax, -1 or eax, -1
DEBUGF 2,"Adding network device failed\n" DEBUGF DEBUG_NETWORK_ERROR, "Adding network device failed\n"
ret ret
@ -407,7 +410,7 @@ NET_add_device:
align 4 align 4
NET_set_default: NET_set_default:
DEBUGF 1,"NET_set_default: device=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "NET_set_default: device=%x\n", eax
cmp eax, MAX_NET_DEVICES cmp eax, MAX_NET_DEVICES
jae .error jae .error
@ -417,12 +420,12 @@ NET_set_default:
mov [NET_DEFAULT], eax mov [NET_DEFAULT], eax
DEBUGF 1,"NET_set_default: succes\n" DEBUGF DEBUG_NETWORK_VERBOSE, "NET_set_default: succes\n"
ret ret
.error: .error:
or eax, -1 or eax, -1
DEBUGF 1,"NET_set_default: failed\n" DEBUGF DEBUG_NETWORK_ERROR, "NET_set_default: failed\n"
ret ret
@ -634,7 +637,7 @@ checksum_2:
.not_zero: .not_zero:
xchg dl, dh xchg dl, dh
DEBUGF 1,"Checksum: %x\n", dx DEBUGF DEBUG_NETWORK_VERBOSE, "Checksum: %x\n", dx
ret ret

View File

@ -60,7 +60,7 @@ TCP_input:
.fail: .fail:
popf popf
DEBUGF 2, "TCP incoming queue is full, discarding packet!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
inc [TCP_segments_missed] ; FIXME: use correct interface inc [TCP_segments_missed] ; FIXME: use correct interface
@ -97,7 +97,7 @@ TCP_process_input:
mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 source address, followed by ipv4 destination address mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 source address, followed by ipv4 destination address
mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last
DEBUGF 1,"TCP_input: size=%u time=%d\n", ecx, [timer_ticks] DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
mov edx, esi mov edx, esi
@ -127,7 +127,7 @@ TCP_process_input:
movzx eax, [edx + TCP_header.DataOffset] movzx eax, [edx + TCP_header.DataOffset]
sub ecx, eax ; substract TCP header size from total segment size sub ecx, eax ; substract TCP header size from total segment size
jb .drop_no_socket ; If total segment size is less then the advertised header size, drop packet jb .drop_no_socket ; If total segment size is less then the advertised header size, drop packet
DEBUGF 1,"TCP_input: %u bytes of data\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes of data\n", ecx
;------------------------------------------- ;-------------------------------------------
; Convert Big-endian values to little endian ; Convert Big-endian values to little endian
@ -176,7 +176,7 @@ TCP_process_input:
test ax, ax test ax, ax
jnz .socket_loop jnz .socket_loop
.found_socket: ; ebx now contains the socketpointer .found_socket: ; ebx now contains the socketpointer
DEBUGF 1,"TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2 DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2
;------------- ;-------------
; update stats ; update stats
@ -197,7 +197,7 @@ TCP_process_input:
call mutex_lock call mutex_lock
popa popa
DEBUGF 1,"TCP_input: socket locked\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: socket locked\n"
;--------------------------- ;---------------------------
; disable all temporary bits ; disable all temporary bits
@ -220,7 +220,7 @@ TCP_process_input:
test [ebx + SOCKET.options], SO_ACCEPTCON test [ebx + SOCKET.options], SO_ACCEPTCON
jz .no_accept jz .no_accept
DEBUGF 1,"TCP_input: Accepting new connection\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Accepting new connection\n"
pusha pusha
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -263,7 +263,7 @@ TCP_process_input:
cmp ecx, sizeof.TCP_header ; Does header contain any options? cmp ecx, sizeof.TCP_header ; Does header contain any options?
je .no_options je .no_options
DEBUGF 1,"TCP_input: Segment has options\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Segment has options\n"
;;; FIXME: for LISTEN, options should be called after we determined route, we need it for MSS ;;; FIXME: for LISTEN, options should be called after we determined route, we need it for MSS
;;; cmp [ebx + TCP_SOCKET.t_state], TCPS_LISTEN ; no options when in listen state ;;; cmp [ebx + TCP_SOCKET.t_state], TCPS_LISTEN ; no options when in listen state
@ -290,7 +290,7 @@ TCP_process_input:
; je .opt_sack ; je .opt_sack
cmp al, TCP_OPT_TIMESTAMP cmp al, TCP_OPT_TIMESTAMP
je .opt_timestamp je .opt_timestamp
DEBUGF 1,"TCP_input: unknown option:%u\n", al DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: unknown option:%u\n", al
jmp .no_options ; If we reach here, some unknown options were received, skip them all! jmp .no_options ; If we reach here, some unknown options were received, skip them all!
.opt_maxseg: .opt_maxseg:
@ -303,7 +303,7 @@ TCP_process_input:
lodsw lodsw
rol ax, 8 rol ax, 8
DEBUGF 1,"TCP_input: Maxseg=%u\n", ax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", ax
call TCP_mss call TCP_mss
@@: @@:
jmp .opt_loop jmp .opt_loop
@ -317,7 +317,7 @@ TCP_process_input:
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
DEBUGF 1,"TCP_input: Got window scale option\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got window scale option\n"
or [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE or [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE
lodsb lodsb
@ -336,7 +336,7 @@ TCP_process_input:
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
DEBUGF 1,"TCP_input: Selective Acknowledgement permitted\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Selective Acknowledgement permitted\n"
or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
@@: @@:
@ -348,7 +348,7 @@ TCP_process_input:
cmp al, 10 ; length must be 10 cmp al, 10 ; length must be 10
jne .no_options jne .no_options
DEBUGF 1,"TCP_input: Got timestamp option\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got timestamp option\n"
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
@ -372,7 +372,7 @@ TCP_process_input:
cmp eax, [ebx + TCP_SOCKET.ts_val] cmp eax, [ebx + TCP_SOCKET.ts_val]
jge .no_paws jge .no_paws
DEBUGF 1,"TCP_input: PAWS: detected an old segment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: PAWS: detected an old segment\n"
mov eax, [esp+4+4] ; tcp_now mov eax, [esp+4+4] ; tcp_now
sub eax, [ebx + TCP_SOCKET.ts_recent_age] sub eax, [ebx + TCP_SOCKET.ts_recent_age]
@ -450,7 +450,7 @@ TCP_process_input:
sub eax, [ebx + TCP_SOCKET.SND_UNA] sub eax, [ebx + TCP_SOCKET.SND_UNA]
jbe .not_uni_xfer jbe .not_uni_xfer
DEBUGF 1,"TCP_input: Header prediction: we are sender\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are sender\n"
;--------------------------------- ;---------------------------------
; Packet is a pure ACK, process it ; Packet is a pure ACK, process it
@ -524,7 +524,7 @@ TCP_process_input:
; Complete processing of received data ; Complete processing of received data
DEBUGF 1,"TCP_input: Header prediction: we are receiving %u bytes\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
@ -545,7 +545,7 @@ TCP_process_input:
.not_uni_xfer: .not_uni_xfer:
DEBUGF 1,"TCP_input: Header prediction failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction failed\n"
; Calculate receive window size ; Calculate receive window size
@ -558,7 +558,7 @@ TCP_process_input:
jg @f jg @f
mov eax, edx mov eax, edx
@@: @@:
DEBUGF 1,"Receive window size=%d\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "Receive window size=%d\n", eax
mov [ebx + TCP_SOCKET.RCV_WND], eax mov [ebx + TCP_SOCKET.RCV_WND], eax
pop edx pop edx
@ -579,12 +579,12 @@ TCP_process_input:
sub eax, [edx + TCP_header.SequenceNumber] sub eax, [edx + TCP_header.SequenceNumber]
jle .no_duplicate jle .no_duplicate
DEBUGF 1,"TCP_input: %u bytes duplicate data!\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes duplicate data!\n", eax
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz .no_dup_syn jz .no_dup_syn
DEBUGF 1,"TCP_input: got duplicate syn\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: got duplicate syn\n"
and [edx + TCP_header.Flags], not (TH_SYN) and [edx + TCP_header.Flags], not (TH_SYN)
inc [edx + TCP_header.SequenceNumber] inc [edx + TCP_header.SequenceNumber]
@ -613,7 +613,7 @@ TCP_process_input:
; send an ACK and resynchronize and drop any data. ; send an ACK and resynchronize and drop any data.
; But keep on processing for RST or ACK ; But keep on processing for RST or ACK
DEBUGF 1, "616\n" DEBUGF DEBUG_NETWORK_VERBOSE, "616\n"
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
mov eax, ecx mov eax, ecx
;TODO: update stats ;TODO: update stats
@ -658,7 +658,7 @@ TCP_process_input:
sub eax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop sub eax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop
jle .no_excess_data jle .no_excess_data
DEBUGF 1,"%d bytes beyond right edge of window\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "%d bytes beyond right edge of window\n", eax
;;; TODO: update stats ;;; TODO: update stats
cmp eax, ecx cmp eax, ecx
@ -687,7 +687,7 @@ TCP_process_input:
cmp eax, [ebx + TCP_SOCKET.RCV_NXT] cmp eax, [ebx + TCP_SOCKET.RCV_NXT]
jne .drop_after_ack jne .drop_after_ack
DEBUGF 1, "690\n" DEBUGF DEBUG_NETWORK_VERBOSE, "690\n"
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
;;; TODO: update stats ;;; TODO: update stats
jmp .no_excess_data jmp .no_excess_data
@ -715,7 +715,7 @@ TCP_process_input:
sub eax, ecx sub eax, ecx
jae .no_timestamp jae .no_timestamp
DEBUGF 1,"Recording timestamp\n" DEBUGF DEBUG_NETWORK_VERBOSE, "Recording timestamp\n"
mov eax, [esp + 4] ; tcp_now mov eax, [esp + 4] ; tcp_now
mov [ebx + TCP_SOCKET.ts_recent_age], eax mov [ebx + TCP_SOCKET.ts_recent_age], eax
@ -729,7 +729,7 @@ TCP_process_input:
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jz .no_rst jz .no_rst
DEBUGF 1,"TCP_input: Got an RST flag\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got an RST flag\n"
mov eax, [ebx + TCP_SOCKET.t_state] mov eax, [ebx + TCP_SOCKET.t_state]
shl eax, 2 shl eax, 2
@ -749,18 +749,18 @@ TCP_process_input:
dd .rst_close ; TCPS_TIMED_WAIT dd .rst_close ; TCPS_TIMED_WAIT
.econnrefused: .econnrefused:
DEBUGF 1,"TCP_input: Connection refused\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection refused\n"
mov [ebx + SOCKET.errorcode], ECONNREFUSED mov [ebx + SOCKET.errorcode], ECONNREFUSED
jmp .close jmp .close
.econnreset: .econnreset:
DEBUGF 1,"TCP_input: Connection reset\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection reset\n"
mov [ebx + SOCKET.errorcode], ECONNRESET mov [ebx + SOCKET.errorcode], ECONNRESET
.close: .close:
DEBUGF 1,"TCP_input: Closing connection\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing connection\n"
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
;;; TODO: update stats (tcp drops) ;;; TODO: update stats (tcp drops)
@ -769,7 +769,7 @@ TCP_process_input:
jmp .drop_no_socket jmp .drop_no_socket
.rst_close: .rst_close:
DEBUGF 1,"TCP_input: Closing with reset\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
mov eax, ebx mov eax, ebx
call TCP_close call TCP_close
@ -799,7 +799,7 @@ TCP_process_input:
jb .ack_processed ; states: closed, listen, syn_sent jb .ack_processed ; states: closed, listen, syn_sent
ja .no_syn_rcv ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait ja .no_syn_rcv ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait
DEBUGF 1,"TCP_input: state=syn_received\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_received\n"
mov eax, [edx + TCP_header.AckNumber] mov eax, [edx + TCP_header.AckNumber]
cmp [ebx + TCP_SOCKET.SND_UNA], eax cmp [ebx + TCP_SOCKET.SND_UNA], eax
@ -846,7 +846,7 @@ TCP_process_input:
cmp eax, [ebx + TCP_SOCKET.SND_WND] cmp eax, [ebx + TCP_SOCKET.SND_WND]
jne .reset_dupacks jne .reset_dupacks
DEBUGF 1,"TCP_input: Processing duplicate ACK\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Processing duplicate ACK\n"
; If we have outstanding data, other than a window probe, this is a completely duplicate ACK ; If we have outstanding data, other than a window probe, this is a completely duplicate ACK
; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them, ; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them,
@ -927,7 +927,7 @@ TCP_process_input:
.no_re_xmit: .no_re_xmit:
jbe .not_dup_ack jbe .not_dup_ack
DEBUGF 1,"TCP_input: Increasing congestion window\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Increasing congestion window\n"
mov eax, [ebx + TCP_SOCKET.t_maxseg] mov eax, [ebx + TCP_SOCKET.t_maxseg]
add [ebx + TCP_SOCKET.SND_CWND], eax add [ebx + TCP_SOCKET.SND_CWND], eax
@ -980,7 +980,7 @@ TCP_process_input:
;;; TODO: update stats ;;; TODO: update stats
DEBUGF 1,"TCP_input: acceptable ACK for %u bytes\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
;------------------------------------------ ;------------------------------------------
; RTT measurements and retransmission timer (912-926) ; RTT measurements and retransmission timer (912-926)
@ -1073,7 +1073,7 @@ TCP_process_input:
call SOCKET_ring_free call SOCKET_ring_free
pop ebx edx ecx pop ebx edx ecx
DEBUGF 1,"TCP_input: our FIN is acked\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
stc stc
jmp .wakeup jmp .wakeup
@ -1088,7 +1088,7 @@ TCP_process_input:
sub [ebx + TCP_SOCKET.SND_WND], ecx sub [ebx + TCP_SOCKET.SND_WND], ecx
pop edx ecx pop edx ecx
DEBUGF 1,"TCP_input: our FIN is not acked\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is not acked\n"
clc clc
;---------------------------------------- ;----------------------------------------
@ -1176,7 +1176,7 @@ TCP_process_input:
align 4 align 4
.LISTEN: .LISTEN:
DEBUGF 1,"TCP_input: state=listen\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=listen\n"
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jnz .drop jnz .drop
@ -1228,7 +1228,7 @@ align 4
align 4 align 4
.SYN_SENT: .SYN_SENT:
DEBUGF 1,"TCP_input: state=syn_sent\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_sent\n"
test [edx + TCP_header.Flags], TH_ACK test [edx + TCP_header.Flags], TH_ACK
jz @f jz @f
@ -1288,7 +1288,7 @@ align 4
test [edx + TCP_header.Flags], TH_ACK test [edx + TCP_header.Flags], TH_ACK
jz .simultaneous_open jz .simultaneous_open
DEBUGF 1,"TCP_input: active open\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: active open\n"
;;; TODO: update stats ;;; TODO: update stats
@ -1316,7 +1316,7 @@ align 4
.simultaneous_open: .simultaneous_open:
DEBUGF 1,"TCP_input: simultaneous open\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: simultaneous open\n"
; We have received a syn but no ACK, so we are having a simultaneous open.. ; We have received a syn but no ACK, so we are having a simultaneous open..
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
@ -1339,7 +1339,7 @@ align 4
.ack_processed: .ack_processed:
DEBUGF 1,"TCP_input: ACK processed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n"
;---------------------------------------------- ;----------------------------------------------
; check if we need to update window information ; check if we need to update window information
@ -1373,7 +1373,7 @@ align 4
@@: @@:
mov [ebx + TCP_SOCKET.SND_WND], eax mov [ebx + TCP_SOCKET.SND_WND], eax
DEBUGF 1,"TCP_input: Updating window to %u\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Updating window to %u\n", eax
push [edx + TCP_header.SequenceNumber] push [edx + TCP_header.SequenceNumber]
pop [ebx + TCP_SOCKET.SND_WL1] pop [ebx + TCP_SOCKET.SND_WL1]
@ -1467,7 +1467,7 @@ align 4
call TCP_reassemble call TCP_reassemble
DEBUGF 1, "1470\n" DEBUGF DEBUG_NETWORK_VERBOSE, "1470\n"
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
.data_done: .data_done:
@ -1478,12 +1478,12 @@ align 4
test [edx + TCP_header.Flags], TH_FIN test [edx + TCP_header.Flags], TH_FIN
jz .final_processing jz .final_processing
DEBUGF 1,"TCP_input: Processing FIN\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Processing FIN\n"
cmp [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT cmp [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
jae .not_first_fin jae .not_first_fin
DEBUGF 1,"TCP_input: First FIN for this connection\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
mov eax, ebx mov eax, ebx
call SOCKET_cant_recv_more call SOCKET_cant_recv_more
@ -1534,7 +1534,7 @@ align 4
.drop_after_ack: .drop_after_ack:
DEBUGF 1,"TCP_input: Drop after ACK\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop after ACK\n"
push edx ebx push edx ebx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1548,7 +1548,7 @@ align 4
jmp .need_output jmp .need_output
.drop_with_reset: .drop_with_reset:
DEBUGF 1,"TCP_input: Drop with reset\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop with reset\n"
push ebx edx push ebx edx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1571,7 +1571,7 @@ align 4
; Final processing ; Final processing
.final_processing: .final_processing:
DEBUGF 1,"TCP_input: Final processing\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Final processing\n"
push ebx push ebx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1583,14 +1583,14 @@ align 4
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jz .dumpit jz .dumpit
DEBUGF 1,"TCP_input: ACK now!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n"
.need_output: .need_output:
DEBUGF 1,"TCP_input: need output\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
call TCP_output call TCP_output
.dumpit: .dumpit:
DEBUGF 1,"TCP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4
@ -1641,7 +1641,7 @@ align 4
; Drop ; Drop
.drop: .drop:
DEBUGF 1,"TCP_input: Dropping segment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n"
pusha pusha
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1656,7 +1656,7 @@ align 4
call SOCKET_free call SOCKET_free
.drop_no_socket: .drop_no_socket:
DEBUGF 1,"TCP_input: Drop (no socket)\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
call kernel_free call kernel_free
add esp, 4 add esp, 4

View File

@ -28,7 +28,7 @@ $Revision: 3289 $
align 4 align 4
TCP_output: TCP_output:
DEBUGF 1,"TCP_output: socket=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: socket=%x\n", eax
push eax push eax
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
@ -78,7 +78,7 @@ TCP_output:
cmp [eax + TCP_SOCKET.t_force], 0 cmp [eax + TCP_SOCKET.t_force], 0
je .no_force je .no_force
DEBUGF 1,"TCP_output: forcing data out\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: forcing data out\n"
test ecx, ecx test ecx, ecx
jnz .no_zero_window jnz .no_zero_window
@ -202,7 +202,7 @@ TCP_output:
;---------------------------------------- ;----------------------------------------
; Check if a window update should be sent (154) ; Check if a window update should be sent (154)
DEBUGF 1,"TCP_output: window=%d\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: window=%d\n", ecx
; Compare available window to amount of window known to peer (as advertised window less next expected input) ; Compare available window to amount of window known to peer (as advertised window less next expected input)
; If the difference is at least two max size segments, or at least 50% of the maximum possible window, ; If the difference is at least two max size segments, or at least 50% of the maximum possible window,
@ -237,7 +237,7 @@ TCP_output:
;-------------------------- ;--------------------------
; Should a segment be sent? (174) ; Should a segment be sent? (174)
DEBUGF 1,"TCP_output: 174\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: 174\n"
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW ; we need to ACK test [eax + TCP_SOCKET.t_flags], TF_ACKNOW ; we need to ACK
jnz TCP_send jnz TCP_send
@ -273,7 +273,7 @@ TCP_output:
cmp [eax + TCP_SOCKET.timer_persist], 0 ; Persist timer already expired? cmp [eax + TCP_SOCKET.timer_persist], 0 ; Persist timer already expired?
jne @f jne @f
DEBUGF 1,"TCP_output: Entering persist state\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
mov [eax + TCP_SOCKET.t_rxtshift], 0 mov [eax + TCP_SOCKET.t_rxtshift], 0
call TCP_set_persist call TCP_set_persist
@ -282,7 +282,7 @@ TCP_output:
;---------------------------- ;----------------------------
; No reason to send a segment (219) ; No reason to send a segment (219)
DEBUGF 1,"TCP_output: No reason to send a segment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: No reason to send a segment\n"
pusha pusha
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
@ -313,7 +313,7 @@ TCP_output:
align 4 align 4
TCP_send: TCP_send:
DEBUGF 1,"TCP_send: socket=%x length=%u flags=%x\n", eax, esi, dl DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: socket=%x length=%u flags=%x\n", eax, esi, dl
push eax ; save socket ptr push eax ; save socket ptr
push esi ; and data length too push esi ; and data length too
@ -337,7 +337,7 @@ TCP_send:
push ecx push ecx
add di, 4 add di, 4
DEBUGF 1,"TCP_send: added maxseg option\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: added maxseg option\n"
test [eax + TCP_SOCKET.t_flags], TF_REQ_SCALE test [eax + TCP_SOCKET.t_flags], TF_REQ_SCALE
jz .no_scale jz .no_scale
@ -355,7 +355,7 @@ TCP_send:
pushw TCP_OPT_WINDOW + 3 shl 8 pushw TCP_OPT_WINDOW + 3 shl 8
add di, 4 add di, 4
DEBUGF 1,"TCP_send: added scale option\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: added scale option\n"
.no_scale: .no_scale:
.no_syn: .no_syn:
@ -381,7 +381,7 @@ TCP_send:
pushd TCP_OPT_NOP + TCP_OPT_NOP shl 8 + TCP_OPT_TIMESTAMP shl 16 + 10 shl 24 pushd TCP_OPT_NOP + TCP_OPT_NOP shl 8 + TCP_OPT_TIMESTAMP shl 16 + 10 shl 24
add di, 12 add di, 12
DEBUGF 1,"TCP_send: added timestamp\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: added timestamp\n"
.no_timestamp: .no_timestamp:
@ -538,7 +538,7 @@ TCP_send:
;---------------- ;----------------
; Send the packet ; Send the packet
DEBUGF 1,"TCP_send: Sending with device %x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: Sending with device %x\n", ebx
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
jnz .send_error jnz .send_error
@ -580,7 +580,7 @@ TCP_send:
test [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT test [eax + TCP_SOCKET.temp_bits], TCP_BIT_SENDALOT
jnz TCP_output.again jnz TCP_output.again
DEBUGF 1,"TCP_send: success!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
xor eax, eax xor eax, eax
ret ret
@ -597,7 +597,7 @@ TCP_send:
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock
DEBUGF 1,"TCP_send: IP error\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: IP error\n"
or eax, -1 or eax, -1
ret ret
@ -609,7 +609,7 @@ TCP_send:
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock
DEBUGF 1,"TCP_send: sending failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: sending failed\n"
or eax, -2 or eax, -2
ret ret

View File

@ -119,7 +119,7 @@ macro TCP_init_socket socket {
align 4 align 4
TCP_pull_out_of_band: TCP_pull_out_of_band:
DEBUGF 1,"TCP_pull_out_of_band\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_pull_out_of_band\n"
;;;; 1282-1305 ;;;; 1282-1305
@ -145,7 +145,7 @@ TCP_pull_out_of_band:
align 4 align 4
TCP_drop: TCP_drop:
DEBUGF 1,"TCP_drop: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
jb .no_syn_received jb .no_syn_received
@ -184,7 +184,7 @@ TCP_drop:
align 4 align 4
TCP_close: TCP_close:
DEBUGF 1,"TCP_close: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_close: %x\n", eax
;;; TODO: update RTT and mean deviation ;;; TODO: update RTT and mean deviation
;;; TODO: update slow start threshold ;;; TODO: update slow start threshold
@ -212,7 +212,7 @@ TCP_outflags:
mov edx, [eax + TCP_SOCKET.t_state] mov edx, [eax + TCP_SOCKET.t_state]
movzx edx, byte [edx + .flaglist] movzx edx, byte [edx + .flaglist]
DEBUGF 1,"TCP_outflags: socket=%x flags=%x\n", eax, dl DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_outflags: socket=%x flags=%x\n", eax, dl
ret ret
@ -248,7 +248,7 @@ TCP_outflags:
align 4 align 4
TCP_respond: TCP_respond:
DEBUGF 1,"TCP_respond_socket: socket=%x flags=%x\n", ebx, cl DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: socket=%x flags=%x\n", ebx, cl
;--------------------- ;---------------------
; Create the IP packet ; Create the IP packet
@ -305,7 +305,7 @@ TCP_respond:
ret ret
.error: .error:
DEBUGF 1,"TCP_respond_socket: failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: failed\n"
add esp, 2 + 4 add esp, 2 + 4
ret ret
@ -327,7 +327,7 @@ TCP_respond:
align 4 align 4
TCP_respond_segment: TCP_respond_segment:
DEBUGF 1,"TCP_respond_segment: frame=%x flags=%x\n", edx, cl DEBUGF DEBUG_NETWORK_VERBOSE,"TCP_respond_segment: frame=%x flags=%x\n", edx, cl
;--------------------- ;---------------------
; Create the IP packet ; Create the IP packet
@ -381,7 +381,7 @@ TCP_respond_segment:
ret ret
.error: .error:
DEBUGF 1,"TCP_respond_segment: failed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: failed\n"
add esp, 2+4 add esp, 2+4
ret ret
@ -416,7 +416,7 @@ local .done
align 4 align 4
TCP_set_persist: TCP_set_persist:
DEBUGF 1,"TCP_set_persist\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_set_persist\n"
; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive ; First, check if retransmit timer is not set, retransmit and persist are mutually exclusive
@ -454,7 +454,7 @@ TCP_set_persist:
align 4 align 4
TCP_xmit_timer: TCP_xmit_timer:
DEBUGF 1,"TCP_xmit_timer: socket=%x rtt=%d0ms\n", ebx, eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=%x rtt=%d0ms\n", ebx, eax
;TODO: update stats ;TODO: update stats

View File

@ -87,7 +87,7 @@ local .exit
dec [eax + TCP_SOCKET.timer_retransmission] dec [eax + TCP_SOCKET.timer_retransmission]
jnz .check_more2 jnz .check_more2
DEBUGF 1,"socket %x: Retransmission timer expired\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
push eax push eax
call TCP_output call TCP_output
@ -97,7 +97,7 @@ local .exit
dec [eax + TCP_SOCKET.timer_keepalive] dec [eax + TCP_SOCKET.timer_keepalive]
jnz .check_more3 jnz .check_more3
DEBUGF 1,"socket %x: Keepalive expired\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
cmp [eax + TCP_SOCKET.state], TCPS_ESTABLISHED cmp [eax + TCP_SOCKET.state], TCPS_ESTABLISHED
ja .dont_kill ja .dont_kill
@ -126,13 +126,13 @@ local .exit
dec [eax + TCP_SOCKET.timer_timed_wait] dec [eax + TCP_SOCKET.timer_timed_wait]
jnz .check_more5 jnz .check_more5
DEBUGF 1,"socket %x: 2MSL timer expired\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
.check_more5: .check_more5:
dec [eax + TCP_SOCKET.timer_persist] dec [eax + TCP_SOCKET.timer_persist]
jnz .loop jnz .loop
DEBUGF 1,"socket %x: persist timer expired\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
call TCP_set_persist call TCP_set_persist
mov [eax + TCP_SOCKET.t_force], 1 mov [eax + TCP_SOCKET.t_force], 1

View File

@ -27,7 +27,7 @@
align 4 align 4
TCP_usrclosed: TCP_usrclosed:
DEBUGF 1,"TCP_usrclosed: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_usrclosed: %x\n", eax
push ebx push ebx
mov ebx, [eax + TCP_SOCKET.t_state] mov ebx, [eax + TCP_SOCKET.t_state]
@ -87,7 +87,7 @@ TCP_usrclosed:
align 4 align 4
TCP_disconnect: TCP_disconnect:
DEBUGF 1,"TCP_disconnect: %x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_disconnect: %x\n", eax
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
jb TCP_close jb TCP_close

View File

@ -116,7 +116,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
align 4 align 4
UDP_input: UDP_input:
DEBUGF 1,"UDP_input: size=%u\n", ecx DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
; First validate, checksum ; First validate, checksum
@ -129,7 +129,7 @@ UDP_input:
jnz .checksum_mismatch jnz .checksum_mismatch
.no_checksum: .no_checksum:
DEBUGF 1,"UDP_input: checksum ok\n" DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: checksum ok\n"
; Convert length to little endian ; Convert length to little endian
@ -158,7 +158,7 @@ UDP_input:
cmp [eax + UDP_SOCKET.LocalPort], dx cmp [eax + UDP_SOCKET.LocalPort], dx
jne .next_socket jne .next_socket
DEBUGF 1,"UDP_input: socket=%x\n", eax DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: socket=%x\n", eax
;;; TODO: when packet is processed, check more sockets! ;;; TODO: when packet is processed, check more sockets!
@ -196,7 +196,7 @@ UDP_input:
call mutex_lock call mutex_lock
popa popa
DEBUGF 1,"UDP_input: new remote port=%x\n", cx ; FIXME: find a way to print big endian values with debugf DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: new remote port=%x\n", cx ; FIXME: find a way to print big endian values with debugf
mov [eax + UDP_SOCKET.RemotePort], cx mov [eax + UDP_SOCKET.RemotePort], cx
inc [eax + UDP_SOCKET.firstpacket] inc [eax + UDP_SOCKET.firstpacket]
@ -204,12 +204,12 @@ UDP_input:
.checksum_mismatch: .checksum_mismatch:
DEBUGF 2,"UDP_input: checksum mismatch\n" DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: checksum mismatch\n"
.dump: .dump:
call kernel_free call kernel_free
add esp, 4 ; pop (balance stack) add esp, 4 ; pop (balance stack)
DEBUGF 2,"UDP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE,"UDP_input: dumping\n"
ret ret
@ -229,13 +229,13 @@ UDP_input:
align 4 align 4
UDP_output: UDP_output:
DEBUGF 1,"UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
mov dx, [eax + UDP_SOCKET.RemotePort] mov dx, [eax + UDP_SOCKET.RemotePort]
DEBUGF 1,"UDP_output: remote port=%x, ", dx ; FIXME: find a way to print big endian values with debugf DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: remote port=%x, ", dx ; FIXME: find a way to print big endian values with debugf
rol edx, 16 rol edx, 16
mov dx, [eax + UDP_SOCKET.LocalPort] mov dx, [eax + UDP_SOCKET.LocalPort]
DEBUGF 1,"local port=%x\n", dx DEBUGF DEBUG_NETWORK_VERBOSE, "local port=%x\n", dx
sub esp, 8 ; Data ptr and data size will be placed here sub esp, 8 ; Data ptr and data size will be placed here
push edx esi push edx esi
@ -270,7 +270,7 @@ UDP_output:
mov [edi + UDP_header.Checksum], 0 mov [edi + UDP_header.Checksum], 0
UDP_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options.. UDP_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options..
DEBUGF 1,"UDP_output: sending with device %x\n", ebx DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: sending with device %x\n", ebx
call [ebx + NET_DEVICE.transmit] call [ebx + NET_DEVICE.transmit]
test eax, eax test eax, eax
jnz @f jnz @f
@ -280,7 +280,7 @@ UDP_output:
ret ret
.fail: .fail:
DEBUGF 1,"UDP_output: failed\n" DEBUGF DEBUG_NETWORK_ERROR, "UDP_output: failed\n"
add esp, 4+4+8 add esp, 4+4+8
or eax, -1 or eax, -1
ret ret