diff --git a/kernel/branches/net/network/socket.inc b/kernel/branches/net/network/socket.inc index 7a79e49880..5e762595aa 100644 --- a/kernel/branches/net/network/socket.inc +++ b/kernel/branches/net/network/socket.inc @@ -30,7 +30,7 @@ virtual at 0 .Domain dd ? ; INET/UNIX/.. .Type dd ? ; RAW/STREAM/DGRAP .Protocol dd ? ; ICMP/IPv4/ARP/TCP/UDP -; .errorcode dd ? + .errorcode dd ? .options dd ? .state dd ? diff --git a/kernel/branches/net/network/stack.inc b/kernel/branches/net/network/stack.inc index 3fd96ad0c5..9b594b7e1f 100644 --- a/kernel/branches/net/network/stack.inc +++ b/kernel/branches/net/network/stack.inc @@ -76,6 +76,14 @@ NET_TYPE_SLIP equ 2 MAX_backlog equ 20 ; maximum backlog for stream sockets +; Error Codes +ENOBUFS equ 55 +ECONNREFUSED equ 61 +ECONNRESET equ 52 +ETIMEDOUT equ 60 +ECONNABORTED equ 53 + + virtual at 0 diff --git a/kernel/branches/net/network/tcp.inc b/kernel/branches/net/network/tcp.inc index 70f045ca9d..6e6749b09d 100644 --- a/kernel/branches/net/network/tcp.inc +++ b/kernel/branches/net/network/tcp.inc @@ -779,7 +779,8 @@ align 4 test [edx + TCP_segment.Flags], TH_ACK jz .drop - ;tp = tcp_drop(tp, ECONNREFUSED) + mov ebx, ECONNREFUSED + call TCP_drop jmp .drop @@: @@ -1063,7 +1064,9 @@ align 4 test [edx + TCP_segment.Flags], TH_SYN jz @f - ;;; tcp_drop ( ECONNRESET) + mov ebx, ECONNRESET + call TCP_drop + jmp .drop_with_reset test [edx + TCP_segment.Flags], TH_ACK @@ -1964,8 +1967,9 @@ TCP_outflags: ; TCP_drop ; ; IN: eax = socket ptr +; ebx = error number ; -; OUT: / +; OUT: eax = socket ptr ; ;------------------------- align 4 @@ -1973,21 +1977,48 @@ TCP_drop: DEBUGF 1,"TCP_drop\n" -; cmp [eax + TCP_SOCKET.t_state], TCB_SYN_RECEIVED -; jl .no_syn_received + cmp [eax + TCP_SOCKET.t_state], TCB_SYN_RECEIVED + jl .no_syn_received mov [eax + TCP_SOCKET.t_state], TCB_CLOSED call TCP_output -; .no_syn_received: +;;; TODO: update stats + + jmp TCP_close + + .no_syn_received: + +;;; TODO: update stats + +;;; TODO: check if error code is "Connection timed out' and handle accordingly + + mov [eax + SOCKET.errorcode], ebx + + jmp TCP_close + + +;------------------------- +; +; TCP_close +; +; IN: eax = socket ptr +; OUT: eax = socket ptr +; +;------------------------- +align 4 +TCP_close: + +;;; TODO: update RTT and mean deviation +;;; TODO: update slow start threshold +;;; TODO: release connection resources ret - ;--------------------------------------- ; ; The easy way to send an ACK/RST/keepalive segment