allow query of TCP socket state through getsockopt()

git-svn-id: svn://kolibrios.org@1299 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2009-11-30 11:19:59 +00:00
parent d939ae6ae1
commit 18d56a4087

View File

@ -741,6 +741,7 @@ socket_send:
; ;
; At moment, uses only pseudo-optname -2 for get last_ack_number for TCP. ; At moment, uses only pseudo-optname -2 for get last_ack_number for TCP.
; TODO: find best way to notify that send()'ed data were acknowledged ; TODO: find best way to notify that send()'ed data were acknowledged
; Also pseudo-optname -3 is valid and returns socket state, one of TCB_*.
; ;
;----------------------------------------------------------------- ;-----------------------------------------------------------------
align 4 align 4
@ -749,7 +750,10 @@ socket_get_opt:
cmp dword [edx], IP_PROTO_TCP cmp dword [edx], IP_PROTO_TCP
jnz .unknown jnz .unknown
cmp dword [edx+4], -2 cmp dword [edx+4], -2
jz @f
cmp dword [edx+4], -3
jnz .unknown jnz .unknown
@@:
mov eax, [edx+12] mov eax, [edx+12]
test eax, eax test eax, eax
jz .fail jz .fail
@ -761,6 +765,10 @@ socket_get_opt:
jz .fail jz .fail
; todo: check that eax is really TCP socket ; todo: check that eax is really TCP socket
mov ecx, [eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.last_ack_number] mov ecx, [eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.last_ack_number]
cmp dword [edx+4], -2
jz @f
mov ecx, [eax + SOCKET_head.end + IPv4_SOCKET.end + TCP_SOCKET.state]
@@:
mov eax, [edx+8] mov eax, [edx+8]
test eax, eax test eax, eax
jz @f jz @f