From 4fe36c585345296fb138c2d443deb01c198b99bd Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sun, 24 Feb 2013 17:12:10 +0000 Subject: [PATCH] Fixed bugs in TCP (crash when closing socket, crash when responding to segment that has no socket) git-svn-id: svn://kolibrios.org@3270 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/branches/net/network/tcp_input.inc | 9 ++++----- kernel/branches/net/network/tcp_subr.inc | 9 ++++----- kernel/branches/net/network/tcp_usreq.inc | 2 ++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/branches/net/network/tcp_input.inc b/kernel/branches/net/network/tcp_input.inc index 914ec93d24..23777a1875 100644 --- a/kernel/branches/net/network/tcp_input.inc +++ b/kernel/branches/net/network/tcp_input.inc @@ -639,7 +639,7 @@ TCP_process_input: mov eax, ebx call TCP_close ;;;TODO: update stats - jmp .drop_with_reset + jmp .drop_with_reset_no_socket ;---------------------------------------- ; Remove data beyond right edge of window (700-736) @@ -770,14 +770,14 @@ TCP_process_input: ;;; TODO: update stats (tcp drops) mov eax, ebx call TCP_close - jmp .drop + jmp .drop_no_socket .rst_close: DEBUGF 1,"TCP_input: Closing with reset\n" mov eax, ebx call TCP_close - jmp .drop + jmp .drop_no_socket .no_rst: @@ -1596,13 +1596,12 @@ align 4 ret .drop_with_reset_no_socket: - DEBUGF 1,"TCP_input: Drop with reset (no socket)\n" test [edx + TCP_header.Flags], TH_RST jnz .drop_no_socket - ;;; if its a multicast/broadcast, also drop + ;;; TODO: if its a multicast/broadcast, also drop test [edx + TCP_header.Flags], TH_ACK jnz .respond_seg_ack diff --git a/kernel/branches/net/network/tcp_subr.inc b/kernel/branches/net/network/tcp_subr.inc index 33dd5f4d9f..73572c40c1 100644 --- a/kernel/branches/net/network/tcp_subr.inc +++ b/kernel/branches/net/network/tcp_subr.inc @@ -318,7 +318,7 @@ TCP_respond: ;------------------------- -; TCP_respond.segment: +; TCP_respond_segment: ; ; IN: edx = segment ptr (a previously received segment) ; edi = ptr to dest and src IPv4 addresses @@ -327,7 +327,7 @@ TCP_respond: align 4 TCP_respond_segment: - DEBUGF 1,"TCP_respond_segment: frame=%x flags=%c\n", edx, cl + DEBUGF 1,"TCP_respond_segment: frame=%x flags=%x\n", edx, cl ;--------------------- ; Create the IP packet @@ -336,7 +336,7 @@ TCP_respond_segment: mov ebx, [edi + 4] mov eax, [edi] mov ecx, sizeof.TCP_header - mov di , IP_PROTO_TCP shl 8 + 128 + mov di, IP_PROTO_TCP shl 8 + 128 call IPv4_output jz .error pop esi cx @@ -368,12 +368,11 @@ TCP_respond_segment: ;--------------------- ; Fill in the checksum - .checksum: lea esi, [edi - sizeof.TCP_header] mov ecx, sizeof.TCP_header TCP_checksum (esi - sizeof.IPv4_header + IPv4_header.DestinationAddress),\ ; FIXME (esi - sizeof.IPv4_header + IPv4_header.SourceAddress) - mov [esi+TCP_header.Checksum], dx + mov [esi + TCP_header.Checksum], dx ;-------------------- ; And send the segment diff --git a/kernel/branches/net/network/tcp_usreq.inc b/kernel/branches/net/network/tcp_usreq.inc index 24b2a5c09d..737dda6e38 100644 --- a/kernel/branches/net/network/tcp_usreq.inc +++ b/kernel/branches/net/network/tcp_usreq.inc @@ -57,6 +57,7 @@ TCP_usrclosed: .wait1: mov [eax + TCP_SOCKET.t_state], TCPS_FIN_WAIT_1 + ; TODO: set timer? pop ebx ret @@ -67,6 +68,7 @@ TCP_usrclosed: .disc: call SOCKET_is_disconnected + ; TODO: set timer? .ret: pop ebx ret