forked from KolibriOS/kolibrios
UDP fixes for net branch
git-svn-id: svn://kolibrios.org@1335 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7872f73198
commit
3b4749a91b
@ -76,6 +76,7 @@ struct UDP_SOCKET
|
||||
|
||||
.LocalPort dw ? ; In INET byte order
|
||||
.RemotePort dw ? ; In INET byte order
|
||||
.firstpacket db ?
|
||||
|
||||
.end:
|
||||
ends
|
||||
@ -343,6 +344,7 @@ socket_connect:
|
||||
|
||||
mov bx , word [edx + 2]
|
||||
mov word [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.RemotePort], bx
|
||||
mov [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.firstpacket], 0
|
||||
DEBUGF 1,"remote port: %x ",bx
|
||||
|
||||
mov ebx, dword [edx + 4]
|
||||
|
@ -140,11 +140,13 @@ UDP_handler:
|
||||
DEBUGF 1,"Remote Ip matches\n"
|
||||
.ok1:
|
||||
|
||||
mov bx, [edx + UDP_Packet.SourcePort] ; Remote port must be 0, or equal to sourceport of packet
|
||||
lea ebx, [eax + SOCKET_head.lock]
|
||||
call wait_mutex
|
||||
|
||||
cmp [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.RemotePort], 0
|
||||
je .ok2
|
||||
cmp [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.firstpacket], 0
|
||||
jz .updateport
|
||||
|
||||
mov bx, [edx + UDP_Packet.SourcePort]
|
||||
cmp [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.RemotePort], bx
|
||||
jne .dump
|
||||
|
||||
@ -155,13 +157,7 @@ UDP_handler:
|
||||
movzx ecx, [edx + UDP_Packet.Length]
|
||||
rol cx , 8
|
||||
sub cx , UDP_Packet.Data
|
||||
mov dx , bx
|
||||
|
||||
|
||||
lea ebx, [eax + SOCKET_head.lock]
|
||||
call wait_mutex
|
||||
mov [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.RemotePort], dx ; update remote port number
|
||||
mov [eax + SOCKET_head.end + IPv4_SOCKET.RemoteIP], edi
|
||||
inc [UDP_PACKETS_RX]
|
||||
|
||||
pop edi
|
||||
@ -172,6 +168,15 @@ UDP_handler:
|
||||
jmp socket_internal_receiver
|
||||
|
||||
|
||||
.updateport:
|
||||
|
||||
mov bx, [edx + UDP_Packet.SourcePort]
|
||||
DEBUGF 1,"Changing remote port to: %x\n", bx
|
||||
mov [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.RemotePort], bx
|
||||
inc [eax + SOCKET_head.end + IPv4_SOCKET.end + UDP_SOCKET.firstpacket]
|
||||
|
||||
jmp .ok2
|
||||
|
||||
.dump:
|
||||
DEBUGF 1,"Dumping UDP packet\n"
|
||||
call kernel_free
|
||||
@ -247,7 +252,7 @@ UDP_socket_send:
|
||||
mov esi, edi
|
||||
call checksum_1
|
||||
; Checksum for pseudoheader
|
||||
pushd [edi-4] ; destination address ; TODO: fix this, IPv4 packet could have options..
|
||||
pushd [edi-4] ; destination address ; TODO: fix this, IPv4 packet could have options..
|
||||
pushd [edi-8] ; source address
|
||||
mov ecx, 12
|
||||
mov esi, esp
|
||||
|
Loading…
Reference in New Issue
Block a user