Bugfixes to bind socket to device.
git-svn-id: svn://kolibrios.org@5584 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
2a0abd0133
commit
47d756fe2f
@ -569,6 +569,7 @@ IPv4_find_fragment_slot:
|
||||
; IPv4_output
|
||||
;
|
||||
; IN: eax = Destination IP
|
||||
; ebx = device ptr (or 0 to let IP layer decide)
|
||||
; ecx = data length
|
||||
; edx = Source IP
|
||||
; di = TTL shl 8 + protocol
|
||||
@ -863,6 +864,7 @@ IPv4_fragment:
|
||||
; IPv4_route
|
||||
;
|
||||
; IN: eax = Destination IP
|
||||
; ebx = outgoing device / 0
|
||||
; edx = Source IP
|
||||
; OUT: eax = Destination IP (or gateway IP)
|
||||
; edx = Source IP
|
||||
@ -874,6 +876,9 @@ IPv4_fragment:
|
||||
align 4
|
||||
IPv4_route: ; TODO: return error if no valid route found
|
||||
|
||||
test ebx, ebx
|
||||
jnz .got_device
|
||||
|
||||
cmp eax, 0xffffffff
|
||||
je .broadcast
|
||||
|
||||
@ -903,6 +908,27 @@ IPv4_route: ; TODO: return error if no valid route found
|
||||
|
||||
ret
|
||||
|
||||
.got_device:
|
||||
; Validate device ptr and convert to device number
|
||||
call NET_ptr_to_num4
|
||||
cmp edi, -1
|
||||
je .fail
|
||||
|
||||
mov edx, [IP_LIST + edi] ; Source IP
|
||||
|
||||
; Check if we should route to gateway or not
|
||||
mov ebx, [IP_LIST + edi]
|
||||
and ebx, [SUBNET_LIST + edi]
|
||||
mov ecx, eax
|
||||
and ecx, [SUBNET_LIST + edi]
|
||||
je @f
|
||||
mov eax, [GATEWAY_LIST + edi]
|
||||
@@:
|
||||
ret
|
||||
|
||||
.fail:
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;---------------------------------------------------------------------------
|
||||
|
@ -388,6 +388,7 @@ ICMP_output_raw:
|
||||
|
||||
mov di, IP_PROTO_ICMP SHL 8 + 128 ; TTL
|
||||
mov edx, [eax + IP_SOCKET.LocalIP]
|
||||
mov ebx, [eax + IP_SOCKET.device]
|
||||
mov eax, [eax + IP_SOCKET.RemoteIP]
|
||||
call IPv4_output
|
||||
jz .exit
|
||||
|
@ -1160,7 +1160,7 @@ SOCKET_set_opt:
|
||||
cmp dword[edx+8], 0
|
||||
je .unbind
|
||||
|
||||
movzx edx, byte[edx + 9]
|
||||
movzx edx, byte[edx + 12]
|
||||
cmp edx, NET_DEVICES_MAX
|
||||
ja .invalid
|
||||
|
||||
@ -1169,7 +1169,7 @@ SOCKET_set_opt:
|
||||
jz .already
|
||||
mov [eax + SOCKET.device], edx
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "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!
|
||||
ret
|
||||
|
@ -504,6 +504,7 @@ endl
|
||||
|
||||
mov ecx, esi
|
||||
mov edx, [eax + IP_SOCKET.LocalIP] ; source ip
|
||||
mov ebx, [eax + IP_SOCKET.device]
|
||||
mov eax, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
||||
mov di, IP_PROTO_TCP shl 8 + 128
|
||||
call IPv4_output
|
||||
|
@ -287,6 +287,7 @@ TCP_respond:
|
||||
push cx ebx
|
||||
mov eax, [ebx + IP_SOCKET.RemoteIP]
|
||||
mov edx, [ebx + IP_SOCKET.LocalIP]
|
||||
mov ebx, [ebx + IP_SOCKET.device]
|
||||
mov ecx, sizeof.TCP_header
|
||||
mov di, IP_PROTO_TCP shl 8 + 128
|
||||
call IPv4_output
|
||||
@ -372,6 +373,7 @@ TCP_respond_segment:
|
||||
mov eax, [edi]
|
||||
mov ecx, sizeof.TCP_header
|
||||
mov di, IP_PROTO_TCP shl 8 + 128
|
||||
xor ebx, ebx ;;; fixme
|
||||
call IPv4_output
|
||||
jz .error
|
||||
pop esi cx
|
||||
|
@ -258,6 +258,7 @@ UDP_output:
|
||||
sub esp, 4 ; Data ptr will be placed here
|
||||
push edx esi
|
||||
mov edx, [eax + IP_SOCKET.LocalIP]
|
||||
mov ebx, [eax + IP_SOCKET.device]
|
||||
mov eax, [eax + IP_SOCKET.RemoteIP]
|
||||
mov di, IP_PROTO_UDP shl 8 + 128
|
||||
add ecx, sizeof.UDP_header
|
||||
|
Loading…
Reference in New Issue
Block a user