some socket functions now return error codes in ebx.

git-svn-id: svn://kolibrios.org@3658 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2013-06-14 20:14:35 +00:00
parent 6447636270
commit 0192ef785b

View File

@ -17,6 +17,16 @@
$Revision: 3514 $ $Revision: 3514 $
ENOBUFS = 1
EOPNOTSUPP = 4
EWOULDBLOCK = 6
ENOTCONN = 9
EALREADY = 10
EINVAL = 11
EMSGSIZE = 12
ENOMEM = 18
EADDRINUSE = 20
struct SOCKET struct SOCKET
@ -250,7 +260,7 @@ sys_socket:
jz SOCKET_debug jz SOCKET_debug
cmp ebx, .number cmp ebx, .number
ja s_error ja .error
jmp dword [.table + 4*ebx] jmp dword [.table + 4*ebx]
.table: .table:
@ -267,9 +277,9 @@ sys_socket:
dd SOCKET_pair ; 10 dd SOCKET_pair ; 10
.number = ($ - .table) / 4 - 1 .number = ($ - .table) / 4 - 1
s_error: .error:
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET: error\n" mov dword[esp+32], -1
mov dword [esp+32], -1 mov dword[esp+24], EINVAL
ret ret
@ -291,7 +301,7 @@ SOCKET_open:
push ecx edx esi push ecx edx esi
call SOCKET_alloc call SOCKET_alloc
pop esi edx ecx pop esi edx ecx
jz s_error jz .nobuffs
mov [esp+32], edi ; return socketnumber mov [esp+32], edi ; return socketnumber
DEBUGF DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi DEBUGF DEBUG_NETWORK_VERBOSE, "socknum=%u\n", edi
@ -326,24 +336,27 @@ SOCKET_open:
je .pppoe je .pppoe
.no_ppp: .no_ppp:
DEBUGF DEBUG_NETWORK_ERROR, "SOCKET_open: Unknown socket family/protocol\n" .unsupported:
push eax
call SOCKET_free
pop eax
mov dword[esp+24], EOPNOTSUPP
mov dword[esp+32], -1
ret
.nobuffs:
mov dword[esp+24], ENOBUFS
mov dword[esp+32], -1
ret ret
align 4
.raw: .raw:
test esi, esi ; IP_PROTO_IP test esi, esi ; IP_PROTO_IP
jz .ip jz .raw_ip
cmp esi, IP_PROTO_ICMP cmp esi, IP_PROTO_ICMP
je .icmp je .raw_icmp
cmp esi, IP_PROTO_UDP jmp .unsupported
je .udp
cmp esi, IP_PROTO_TCP
je .tcp
ret
align 4 align 4
.udp: .udp:
@ -363,14 +376,14 @@ align 4
align 4 align 4
.ip: .raw_ip:
mov [eax + SOCKET.snd_proc], SOCKET_send_ip mov [eax + SOCKET.snd_proc], SOCKET_send_ip
mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram
ret ret
align 4 align 4
.icmp: .raw_icmp:
mov [eax + SOCKET.snd_proc], SOCKET_send_icmp mov [eax + SOCKET.snd_proc], SOCKET_send_icmp
mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram mov [eax + SOCKET.rcv_proc], SOCKET_receive_dgram
ret ret
@ -402,10 +415,10 @@ SOCKET_bind:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
cmp esi, 2 cmp esi, 2
jb s_error jb .invalid
cmp word [edx], AF_INET4 cmp word [edx], AF_INET4
je .af_inet4 je .af_inet4
@ -413,18 +426,24 @@ SOCKET_bind:
cmp word [edx], AF_LOCAL cmp word [edx], AF_LOCAL
je .af_local je .af_local
jmp s_error .notsupp:
mov dword[esp+24], EOPNOTSUPP
mov dword[esp+32], -1
ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
.af_local: .af_local:
; TODO: write code here ; TODO: write code here
mov dword[esp+32], 0
mov dword [esp+32], 0
ret ret
.af_inet4: .af_inet4:
cmp esi, 6 cmp esi, 6
jb s_error jb .invalid
cmp [eax + SOCKET.Protocol], IP_PROTO_UDP cmp [eax + SOCKET.Protocol], IP_PROTO_UDP
je .udp je .udp
@ -432,11 +451,10 @@ SOCKET_bind:
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
je .tcp je .tcp
jmp s_error jmp .notsupp
.tcp: .tcp:
.udp: .udp:
mov ebx, [edx + 4] ; First, fill in the IP mov ebx, [edx + 4] ; First, fill in the IP
test ebx, ebx ; If IP is 0, use default test ebx, ebx ; If IP is 0, use default
jnz @f jnz @f
@ -446,13 +464,18 @@ SOCKET_bind:
mov bx, [edx + 2] ; Now fill in the local port if it's still available mov bx, [edx + 2] ; Now fill in the local port if it's still available
call SOCKET_check_port call SOCKET_check_port
jz s_error ; ZF is set by socket_check_port, on error jz .addrinuse ; ZF is set by socket_check_port, on error
DEBUGF DEBUG_NETWORK_VERBOSE, "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
mov dword [esp+32], 0 mov dword[esp+32], 0
ret
.addrinuse:
mov dword[esp+32], -1
mov dword[esp+24], EADDRINUSE
ret ret
@ -474,15 +497,23 @@ SOCKET_connect:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
cmp esi, 8 cmp esi, 8
jb s_error jb .invalid
cmp word [edx], AF_INET4 cmp word [edx], AF_INET4
je .af_inet4 je .af_inet4
jmp s_error .notsupp:
mov dword[esp+24], EOPNOTSUPP
mov dword[esp+32], -1
ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
.af_inet4: .af_inet4:
cmp [eax + IP_SOCKET.LocalIP], 0 cmp [eax + IP_SOCKET.LocalIP], 0
@ -503,7 +534,7 @@ SOCKET_connect:
cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP cmp [eax + SOCKET.Protocol], IP_PROTO_ICMP
je .ip je .ip
jmp s_error jmp .notsupp
align 4 align 4
.udp: .udp:
@ -532,7 +563,7 @@ align 4
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock
mov dword [esp+32], 0 mov dword[esp+32], 0
ret ret
align 4 align 4
@ -569,10 +600,10 @@ align 4
mov ebx, eax mov ebx, eax
lea eax, [ebx + STREAM_SOCKET.snd] lea eax, [ebx + STREAM_SOCKET.snd]
call SOCKET_ring_create call SOCKET_ring_create ; TODO: check if memory was available or not
lea eax, [ebx + STREAM_SOCKET.rcv] lea eax, [ebx + STREAM_SOCKET.rcv]
call SOCKET_ring_create call SOCKET_ring_create ; TODO: same here
pusha pusha
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -584,7 +615,7 @@ align 4
;;; TODO: wait for successfull connection if blocking socket ;;; TODO: wait for successfull connection if blocking socket
mov dword [esp+32], 0 mov dword[esp+32], 0
ret ret
align 4 align 4
@ -604,7 +635,7 @@ align 4
lea ecx, [eax + SOCKET.mutex] lea ecx, [eax + SOCKET.mutex]
call mutex_unlock call mutex_unlock
mov dword [esp+32], 0 mov dword[esp+32], 0
ret ret
@ -623,16 +654,16 @@ SOCKET_listen:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
cmp [eax + SOCKET.Domain], AF_INET4 cmp [eax + SOCKET.Domain], AF_INET4
jne s_error jne .notsupp
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
jne s_error jne .invalid
cmp [eax + TCP_SOCKET.LocalPort], 0 cmp [eax + TCP_SOCKET.LocalPort], 0
je s_error je .already
cmp [eax + IP_SOCKET.LocalIP], 0 cmp [eax + IP_SOCKET.LocalIP], 0
jne @f jne @f
@ -654,8 +685,22 @@ SOCKET_listen:
init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up sockets queue init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up sockets queue
pop eax pop eax
mov dword [esp+32], 0 mov dword[esp+32], 0
ret
.notsupp:
mov dword[esp+24], EOPNOTSUPP
mov dword[esp+32], -1
ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
.already:
mov dword[esp+24], EALREADY
mov dword[esp+32], -1
ret ret
@ -675,16 +720,16 @@ SOCKET_accept:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
test [eax + SOCKET.options], SO_ACCEPTCON test [eax + SOCKET.options], SO_ACCEPTCON
jz s_error jz .invalid
cmp [eax + SOCKET.Domain], AF_INET4 cmp [eax + SOCKET.Domain], AF_INET4
jne s_error jne .notsupp
cmp [eax + SOCKET.Protocol], IP_PROTO_TCP cmp [eax + SOCKET.Protocol], IP_PROTO_TCP
jne s_error jne .invalid
.loop: .loop:
get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .block get_from_queue (eax + SOCKET_QUEUE_LOCATION), MAX_backlog, 4, .block
@ -692,25 +737,41 @@ SOCKET_accept:
; Ok, we got a socket ptr ; Ok, we got a socket ptr
mov eax, [esi] mov eax, [esi]
; Convert it to a socket number
call SOCKET_ptr_to_num
jz .invalid ; FIXME ?
; Change thread ID to that of the current thread ; Change thread ID to that of the current thread
mov ebx, [TASK_BASE] mov ebx, [TASK_BASE]
mov ebx, [ebx + TASKDATA.pid] mov ebx, [ebx + TASKDATA.pid]
mov [eax + SOCKET.TID], ebx mov [eax + SOCKET.TID], ebx
; Convert it to a socket number
call SOCKET_ptr_to_num
jz s_error
; and return it to caller ; and return it to caller
mov [esp+32], eax mov [esp+32], eax
ret ret
.block: .block:
test [eax + SOCKET.options], SO_NONBLOCK test [eax + SOCKET.options], SO_NONBLOCK
jnz s_error jnz .wouldblock
call SOCKET_block call SOCKET_block
jmp .loop jmp .loop
.wouldblock:
mov dword[esp+24], EWOULDBLOCK
mov dword[esp+32], -1
ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
.notsupp:
mov dword[esp+24], EOPNOTSUPP
mov dword[esp+32], -1
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
; SOCKET_close ; SOCKET_close
@ -725,9 +786,9 @@ SOCKET_close:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
mov dword [esp+32], 0 ; The socket exists, so we will succeed in closing it. mov dword[esp+32], 0 ; The socket exists, so we will succeed in closing it.
or [eax + SOCKET.options], SO_NONBLOCK ; Mark the socket as non blocking, we dont want it to block any longer! or [eax + SOCKET.options], SO_NONBLOCK ; Mark the socket as non blocking, we dont want it to block any longer!
@ -757,6 +818,12 @@ SOCKET_close:
ret ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
; SOCKET_receive ; SOCKET_receive
@ -774,17 +841,22 @@ SOCKET_receive:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
call [eax + SOCKET.rcv_proc] call [eax + SOCKET.rcv_proc]
mov [esp+24], ebx
mov [esp+32], eax mov [esp+32], eax
ret ret
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
align 4 align 4
SOCKET_receive_dgram: SOCKET_receive_dgram:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: DGRAM\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: DGRAM\n"
mov ebx, esi mov ebx, esi
@ -820,23 +892,25 @@ SOCKET_receive_dgram:
call kernel_free ; remove the packet call kernel_free ; remove the packet
pop eax pop eax
ret ret
.too_small: .too_small:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_receive: Buffer too small\n"
.fail:
mov eax, -1 mov eax, -1
mov ebx, EMSGSIZE
ret ret
.block: .block:
test [eax + SOCKET.options], SO_NONBLOCK test [eax + SOCKET.options], SO_NONBLOCK
jnz .fail jnz .wouldblock
call SOCKET_block call SOCKET_block
jmp .loop jmp .loop
.wouldblock:
mov eax, -1
mov ebx, EWOULDBLOCK
ret
align 4 align 4
SOCKET_receive_local: SOCKET_receive_local:
@ -886,7 +960,7 @@ SOCKET_receive_stream:
.block: .block:
test [eax + SOCKET.options], SO_NONBLOCK test [eax + SOCKET.options], SO_NONBLOCK
jnz .return0 jnz .wouldblock
call SOCKET_block call SOCKET_block
jmp .loop jmp .loop
@ -903,6 +977,12 @@ SOCKET_receive_stream:
xor eax, eax xor eax, eax
ret ret
.wouldblock:
mov eax, -1
mov ebx, EWOULDBLOCK
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
@ -922,13 +1002,18 @@ SOCKET_send:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
mov ecx, esi mov ecx, esi
mov esi, edx mov esi, edx
jmp [eax + SOCKET.snd_proc] jmp [eax + SOCKET.snd_proc]
.invalid:
mov dword[esp+24], EINVAL
mov dword[esp+32], -1
ret
align 4 align 4
SOCKET_send_udp: SOCKET_send_udp:
@ -938,7 +1023,12 @@ SOCKET_send_udp:
mov [esp+32], ecx mov [esp+32], ecx
call UDP_output call UDP_output
cmp eax, -1 cmp eax, -1
je s_error je .error
ret
.error:
mov dword[esp+32], -1
mov dword[esp+24], EMSGSIZE ; FIXME: UDP_output should return error codes!
ret ret
@ -953,8 +1043,12 @@ SOCKET_send_tcp:
pop eax pop eax
mov [esp+32], ecx mov [esp+32], ecx
mov [eax + SOCKET.errorcode], 0
call TCP_output push eax
call TCP_output ; FIXME: this doesnt look pretty, does it?
pop eax
mov eax, [eax + SOCKET.errorcode]
mov [esp+24], eax
ret ret
@ -964,9 +1058,14 @@ SOCKET_send_ip:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 ; FIXME: IPv4_output_raw should return error codes!
cmp eax, -1 cmp eax, -1
je s_error je .error
ret
.error:
mov dword[esp+32], -1
mov dword[esp+24], EMSGSIZE
ret ret
@ -976,9 +1075,14 @@ SOCKET_send_icmp:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 ; FIXME: errorcodes
cmp eax, -1 cmp eax, -1
je s_error je .error
ret
.error:
mov dword[esp+32], -1
mov dword[esp+24], EMSGSIZE
ret ret
@ -990,9 +1094,14 @@ SOCKET_send_pppoe:
mov [esp+32], ecx mov [esp+32], ecx
mov ebx, [eax + SOCKET.device] mov ebx, [eax + SOCKET.device]
call PPPoE_discovery_output call PPPoE_discovery_output ; FIXME: errorcodes
cmp eax, -1 cmp eax, -1
je s_error je .error
ret
.error:
mov dword[esp+32], -1
mov dword[esp+24], EMSGSIZE
ret ret
@ -1020,7 +1129,7 @@ SOCKET_send_local_:
; 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]
call SOCKET_check call SOCKET_check
jz s_error jz .invalid
; allright, shove in the data! ; allright, shove in the data!
push eax push eax
@ -1036,6 +1145,11 @@ SOCKET_send_local_:
ret ret
.invalid:
mov dword[esp+32], -1
mov dword[esp+24], EINVAL
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
; ;
@ -1057,14 +1171,14 @@ SOCKET_get_opt:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
cmp dword [edx], IP_PROTO_TCP cmp dword [edx], IP_PROTO_TCP
jne s_error jne .invalid
cmp dword [edx+4], -2 cmp dword [edx+4], -2
je @f je @f
cmp dword [edx+4], -3 cmp dword [edx+4], -3
jne s_error jne .invalid
@@: @@:
; mov eax, [edx+12] ; mov eax, [edx+12]
; test eax, eax ; test eax, eax
@ -1089,6 +1203,11 @@ SOCKET_get_opt:
mov dword [esp+32], 0 mov dword [esp+32], 0
ret ret
.invalid:
mov dword[esp+32], -1
mov dword[esp+24], EINVAL
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
@ -1107,10 +1226,10 @@ SOCKET_set_opt:
DEBUGF DEBUG_NETWORK_VERBOSE, "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 .invalid
cmp dword [edx], SOL_SOCKET cmp dword [edx], SOL_SOCKET
jne s_error jne .invalid
cmp dword [edx+4], SO_BINDTODEVICE cmp dword [edx+4], SO_BINDTODEVICE
je .bind je .bind
@ -1118,47 +1237,56 @@ SOCKET_set_opt:
cmp dword [edx+4], SO_BLOCK cmp dword [edx+4], SO_BLOCK
je .block je .block
jmp s_error .invalid:
mov dword[esp+32], -1
mov dword[esp+24], EINVAL
ret
.bind: .bind:
cmp dword [edx+8], 0 cmp dword[edx+8], 0
je .unbind je .unbind
movzx edx, byte [edx + 9] movzx edx, byte[edx + 9]
cmp edx, NET_DEVICES_MAX cmp edx, NET_DEVICES_MAX
ja s_error ja .invalid
mov edx, [NET_DRV_LIST + 4*edx] mov edx, [NET_DRV_LIST + 4*edx]
test edx, edx test edx, edx
jz s_error jz .already
mov [eax + SOCKET.device], edx 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! mov dword[esp+32], 0 ; success!
ret ret
.unbind: .unbind:
mov [eax + SOCKET.device], 0 mov [eax + SOCKET.device], 0
mov dword [esp+32], 0 ; success! mov dword[esp+32], 0 ; success!
ret ret
.block: .block:
cmp dword [edx+8], 0 cmp dword[edx+8], 0
je .unblock je .unblock
and [eax + SOCKET.options], not SO_NONBLOCK and [eax + SOCKET.options], not SO_NONBLOCK
mov dword [esp+32], 0 ; success! mov dword[esp+32], 0 ; success!
ret ret
.unblock: .unblock:
or [eax + SOCKET.options], SO_NONBLOCK or [eax + SOCKET.options], SO_NONBLOCK
mov dword [esp+32], 0 ; success! mov dword[esp+32], 0 ; success!
ret ret
.already:
mov dword[esp+24], EALREADY
mov dword[esp+32], -1
ret
;----------------------------------------------------------------- ;-----------------------------------------------------------------
@ -1178,7 +1306,7 @@ SOCKET_pair:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n" DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_pair\n"
call SOCKET_alloc call SOCKET_alloc
jz s_error jz .nomem1
mov [esp+32], edi ; application's eax mov [esp+32], edi ; application's eax
mov [eax + SOCKET.Domain], AF_LOCAL mov [eax + SOCKET.Domain], AF_LOCAL
@ -1190,7 +1318,7 @@ SOCKET_pair:
mov ebx, eax mov ebx, eax
call SOCKET_alloc call SOCKET_alloc
jz .error jz .nomem2
mov [esp+24], edi ; application's ebx mov [esp+24], edi ; application's ebx
mov [eax + SOCKET.Domain], AF_LOCAL mov [eax + SOCKET.Domain], AF_LOCAL
@ -1213,10 +1341,13 @@ SOCKET_pair:
ret ret
.error: .nomem2:
mov eax, ebx mov eax, ebx
call SOCKET_free call SOCKET_free
jmp s_error .nomem1:
mov dword[esp+32], -1
mov dword[esp+28], ENOMEM
ret
@ -1242,13 +1373,13 @@ SOCKET_debug:
jz .returnall jz .returnall
call SOCKET_num_to_ptr call SOCKET_num_to_ptr
jz s_error jz .invalid
mov esi, eax mov esi, eax
mov ecx, SOCKETBUFFSIZE/4 mov ecx, SOCKETBUFFSIZE/4
rep movsd rep movsd
mov dword [esp+32], 0 mov dword[esp+32], 0
ret ret
.returnall: .returnall:
@ -1263,8 +1394,12 @@ SOCKET_debug:
.done: .done:
xor eax, eax xor eax, eax
stosd stosd
mov dword[esp+32], eax
ret
mov dword [esp+32], 0 .invalid:
mov dword[esp+32], -1
mov dword[esp+28], EINVAL
ret ret
@ -1830,8 +1965,8 @@ SOCKET_alloc:
pop eax pop eax
; set send-and receive procedures to return -1 ; set send-and receive procedures to return -1
mov [eax + SOCKET.snd_proc], s_error mov [eax + SOCKET.snd_proc], .not_yet
mov [eax + SOCKET.rcv_proc], s_error mov [eax + SOCKET.rcv_proc], .not_yet
pusha pusha
mov ecx, socket_mutex mov ecx, socket_mutex
@ -1907,6 +2042,11 @@ SOCKET_alloc:
ret ret
.not_yet:
mov dword[esp+24], ENOTCONN
mov dword[esp+32], -1
ret
;---------------------------------------------------- ;----------------------------------------------------
; ;
@ -2391,8 +2531,13 @@ SOCKET_cant_send_more:
DEBUGF DEBUG_NETWORK_VERBOSE, "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
mov [eax + SOCKET.snd_proc], s_error mov [eax + SOCKET.snd_proc], .notconn
call SOCKET_notify call SOCKET_notify
ret
.notconn:
mov dword[esp+24], ENOTCONN
mov dword[esp+32], -1
ret ret