Fix in socket_read (page_fault) and udp_rx (incorrect IP comparison)

git-svn-id: svn://kolibrios.org@915 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Mihail Semenyako (mike.dld) 2008-11-09 18:04:54 +00:00
parent c01a33cfa5
commit c58b0535f6
3 changed files with 13 additions and 16 deletions

View File

@ -608,7 +608,6 @@ proc socket_poll stdcall
ret ret
.error: .error:
;or eax, -1
xor eax, eax xor eax, eax
ret ret
endp endp
@ -633,7 +632,6 @@ proc socket_status stdcall
ret ret
.error: .error:
;or eax, -1
xor eax, eax xor eax, eax
ret ret
endp endp
@ -667,22 +665,22 @@ proc socket_read stdcall
dec eax dec eax
mov esi, ebx ; esi is address of socket mov esi, ebx ; esi is address of socket
mov [ebx + SOCKET.rxDataCount], eax ; store new count mov [ebx + SOCKET.rxDataCount], eax ; store new count
;movzx ebx, byte[ebx + SOCKET.rxData] ; get the byte movzx ebx, byte[ebx + SOCKET.rxData] ; get the byte
movzx ebx, byte[ebx + SOCKETHEADERSIZE] ; get the byte
add esi, SOCKETHEADERSIZE
mov edi, esi
inc esi
mov ecx, (SOCKETBUFFSIZE - SOCKETHEADERSIZE) / 4 mov ecx, SOCKETBUFFSIZE - SOCKET.rxData - 1
lea edi, [ebx + SOCKETHEADERSIZE] lea edi, [esi + SOCKET.rxData]
lea esi, [edi + 1] lea esi, [edi + 1]
cld cld
push ecx
shr ecx, 2
rep movsd rep movsd
pop ecx
and ecx, 3
rep movsb
ret ret
.error: .error:
;or eax, -1
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
ret ret
@ -723,7 +721,7 @@ proc socket_read_packet stdcall
call .start_copy ; copy to the application call .start_copy ; copy to the application
mov esi, ebx ; now we're going to copy the remaining bytes to the beginning mov esi, ebx ; now we're going to copy the remaining bytes to the beginning
add esi, SOCKETHEADERSIZE ; we dont need to copy the header add esi, SOCKET.rxData ; we dont need to copy the header
mov edi, esi ; edi is where we're going to copy to mov edi, esi ; edi is where we're going to copy to
add esi, edx ; esi is from where we copy add esi, edx ; esi is from where we copy
pop ecx ; count of bytes we have left pop ecx ; count of bytes we have left
@ -739,7 +737,6 @@ proc socket_read_packet stdcall
ret ; at last, exit ret ; at last, exit
.error: .error:
;or eax, -1
xor eax, eax xor eax, eax
ret ret
@ -752,7 +749,7 @@ proc socket_read_packet stdcall
.start_copy: .start_copy:
mov edi, ecx mov edi, ecx
mov esi, ebx mov esi, ebx
add esi, SOCKETHEADERSIZE ; we dont need to copy the header add esi, SOCKET.rxData ; we dont need to copy the header
mov ecx, eax ; eax is count of bytes mov ecx, eax ; eax is count of bytes
push ecx push ecx
shr ecx, 2 ; divide eax by 4 shr ecx, 2 ; divide eax by 4

View File

@ -46,7 +46,7 @@ endg
; socket buffers ; socket buffers
SOCKETBUFFSIZE equ 4096 ; state + config + buffer. SOCKETBUFFSIZE equ 4096 ; state + config + buffer.
SOCKETHEADERSIZE equ 76+8+8 ; thus 4096 - SOCKETHEADERSIZE bytes data SOCKETHEADERSIZE equ SOCKET.rxData ; thus 4096 - SOCKETHEADERSIZE bytes data
;NUM_SOCKETS equ 16 ; Number of open sockets supported. Was 20 ;NUM_SOCKETS equ 16 ; Number of open sockets supported. Was 20

View File

@ -102,7 +102,7 @@ proc udp_rx stdcall
je @f je @f
mov eax, [edx + IP_PACKET.SourceAddress] ; get the Source address from the IP packet mov eax, [edx + IP_PACKET.SourceAddress] ; get the Source address from the IP packet
cmp [ebx + SOCKET.RemoteIP], ebx cmp [ebx + SOCKET.RemoteIP], eax
jne .exit ; Quit if the source IP is not valid jne .exit ; Quit if the source IP is not valid
@@: ; OK - we have a valid UDP packet for this socket. @@: ; OK - we have a valid UDP packet for this socket.