Small changes in TCP_input

git-svn-id: svn://kolibrios.org@5133 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-09-19 19:02:34 +00:00
parent 7406df89a5
commit c993fd46f8
2 changed files with 40 additions and 43 deletions

View File

@ -96,6 +96,7 @@ TCP_RTTVAR_SHIFT = 2
TCP_BIT_NEEDOUTPUT = 1 shl 0 TCP_BIT_NEEDOUTPUT = 1 shl 0
TCP_BIT_TIMESTAMP = 1 shl 1 TCP_BIT_TIMESTAMP = 1 shl 1
TCP_BIT_DROPSOCKET = 1 shl 2 TCP_BIT_DROPSOCKET = 1 shl 2
TCP_BIT_FIN_IS_ACKED = 1 shl 3
TCP_BIT_SENDALOT = 1 shl 0 TCP_BIT_SENDALOT = 1 shl 0
@ -119,13 +120,13 @@ ends
struct TCP_queue_entry struct TCP_queue_entry
ip_ptr dd ? ip_ptr dd ?
segment_ptr dd ? segment_ptr dd ?
segment_size dd ? segment_size dd ?
device_ptr dd ? device_ptr dd ?
buffer_ptr dd ? buffer_ptr dd ?
timestamp dd ? timestamp dd ?
ends ends

View File

@ -1,13 +1,13 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;; ;; Part of the TCP/IP network stack for KolibriOS ;;
;; ;; ;; ;;
;; Written by hidnplayr@kolibrios.org ;; ;; Written by hidnplayr@kolibrios.org ;;
;; ;; ;; ;;
;; Based on the code of 4.4BSD ;; ;; Based on the algorithms used in 4.4BSD ;;
;; ;; ;; ;;
;; GNU GENERAL PUBLIC LICENSE ;; ;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;; ;; Version 2, June 1991 ;;
@ -531,11 +531,9 @@ endl
cmp eax, [ebx + TCP_SOCKET.SND_UNA] cmp eax, [ebx + TCP_SOCKET.SND_UNA]
jne .not_uni_xfer jne .not_uni_xfer
; - The reassembly list of out-of-order segments for the connection is empty (seg_next equals tp). ; - The reassembly list of out-of-order segments for the connection is empty.
cmp [ebx + TCP_SOCKET.seg_next], 0
;;; TODO jne .not_uni_xfer
; jnz .not_uni_xfer
; Complete processing of received data ; Complete processing of received data
@ -840,7 +838,7 @@ endl
pop word [ebx + TCP_SOCKET.SND_SCALE] pop word [ebx + TCP_SOCKET.SND_SCALE]
@@: @@:
;;; TODO: call TCP_reassemble call TCP_reassemble
mov eax, [edx + TCP_header.SequenceNumber] mov eax, [edx + TCP_header.SequenceNumber]
dec eax dec eax
@ -1094,8 +1092,7 @@ endl
pop ebx edx ecx pop ebx edx ecx
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
stc or [temp_bits], TCP_BIT_FIN_IS_ACKED
jmp .wakeup jmp .wakeup
.finiacked: .finiacked:
@ -1109,19 +1106,15 @@ endl
pop edx ecx pop edx ecx
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is not acked\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is not acked\n"
clc
;---------------------------------------- ;----------------------------------------
; Wake up process waiting on send buffer ; Wake up process waiting on send buffer
.wakeup: .wakeup:
pushf ; Keep the flags (Carry flag)
mov eax, ebx mov eax, ebx
call SOCKET_notify call SOCKET_notify
; Update TCPS ; Update TCPS
mov eax, [edx + TCP_header.AckNumber] mov eax, [edx + TCP_header.AckNumber]
mov [ebx + TCP_SOCKET.SND_UNA], eax mov [ebx + TCP_SOCKET.SND_UNA], eax
cmp eax, [ebx + TCP_SOCKET.SND_NXT] cmp eax, [ebx + TCP_SOCKET.SND_NXT]
@ -1129,8 +1122,6 @@ endl
mov [ebx + TCP_SOCKET.SND_NXT], eax mov [ebx + TCP_SOCKET.SND_NXT], eax
@@: @@:
popf
; General ACK handling complete ; General ACK handling complete
; Now do the state-specific ones ; Now do the state-specific ones
; Carry flag is set when our FIN is acked ; Carry flag is set when our FIN is acked
@ -1153,7 +1144,8 @@ endl
.ack_fw1: .ack_fw1:
jnc .ack_processed test [temp_bits], TCP_BIT_FIN_IS_ACKED
jz .ack_processed
test [ebx + SOCKET.state], SS_CANTRCVMORE test [ebx + SOCKET.state], SS_CANTRCVMORE
jnz @f jnz @f
@ -1166,7 +1158,8 @@ endl
jmp .ack_processed jmp .ack_processed
.ack_c: .ack_c:
jnc .ack_processed test [temp_bits], TCP_BIT_FIN_IS_ACKED
jz .ack_processed
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
mov eax, ebx mov eax, ebx
@ -1178,7 +1171,8 @@ endl
jmp .ack_processed jmp .ack_processed
.ack_la: .ack_la:
jnc .ack_processed test [temp_bits], TCP_BIT_FIN_IS_ACKED
jz .ack_processed
push ebx push ebx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1252,7 +1246,7 @@ align 4
call SOCKET_notify call SOCKET_notify
popa popa
jmp .trim_then_step6 jmp .trim
;------------ ;------------
; Active Open ; Active Open
@ -1345,9 +1339,9 @@ align 4
mov eax, [ebx + TCP_SOCKET.t_rtt] mov eax, [ebx + TCP_SOCKET.t_rtt]
test eax, eax test eax, eax
je .trim_then_step6 je .trim
call TCP_xmit_timer call TCP_xmit_timer
jmp .trim_then_step6 jmp .trim
.simultaneous_open: .simultaneous_open:
@ -1358,8 +1352,7 @@ align 4
;------------------------------------- ;-------------------------------------
; Common processing for receipt of SYN ; Common processing for receipt of SYN
.trim_then_step6: .trim:
inc [edx + TCP_header.SequenceNumber] inc [edx + TCP_header.SequenceNumber]
; Drop any received data that doesnt fit in the receive window. ; Drop any received data that doesnt fit in the receive window.
@ -1372,17 +1365,12 @@ align 4
;;; TODO: update stats ;;; TODO: update stats
.dont_trim: .dont_trim:
mov eax, [edx + TCP_header.SequenceNumber] mov eax, [edx + TCP_header.SequenceNumber]
mov [ebx + TCP_SOCKET.RCV_UP], eax mov [ebx + TCP_SOCKET.RCV_UP], eax
dec eax dec eax
mov [ebx + TCP_SOCKET.SND_WL1], eax mov [ebx + TCP_SOCKET.SND_WL1], eax
;-------
; step 6
.ack_processed: .ack_processed:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n"
;---------------------------------------------- ;----------------------------------------------
@ -1587,14 +1575,14 @@ align 4
jnz .need_output jnz .need_output
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jz .dumpit jz .done
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n"
.need_output: .need_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
call TCP_output call TCP_output
.dumpit: .done:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
call NET_packet_free call NET_packet_free
@ -1614,7 +1602,7 @@ align 4
pop eax edx pop eax edx
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jnz .dumpit jnz .done
or [eax + TCP_SOCKET.t_flags], TF_ACKNOW or [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jmp .need_output jmp .need_output
@ -1628,7 +1616,7 @@ align 4
pop edx ebx pop edx ebx
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jnz .dumpit jnz .done
;;; if its a multicast/broadcast, also drop ;;; if its a multicast/broadcast, also drop
@ -1637,7 +1625,7 @@ align 4
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jnz .respond_syn jnz .respond_syn
jmp .dumpit jmp .done
;--------- ;---------
; Respond ; Respond
@ -1656,8 +1644,10 @@ align 4
pop ebx pop ebx
jmp .destroy_new_socket jmp .destroy_new_socket
.no_socket: ;-----------------------------------------
; The connection has no associated socket
.no_socket:
pusha pusha
mov ecx, socket_mutex mov ecx, socket_mutex
call mutex_unlock call mutex_unlock
@ -1687,8 +1677,8 @@ align 4
call TCP_respond_segment call TCP_respond_segment
jmp .drop_no_socket jmp .drop_no_socket
;----- ;------------------------------------------------
; Drop ; Unlock socket mutex and prepare to drop segment
.drop: .drop:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n"
@ -1698,6 +1688,9 @@ align 4
call mutex_unlock call mutex_unlock
popa popa
;--------------------------------------------
; Destroy the newly created socket if needed
.destroy_new_socket: .destroy_new_socket:
test [temp_bits], TCP_BIT_DROPSOCKET test [temp_bits], TCP_BIT_DROPSOCKET
jz .drop_no_socket jz .drop_no_socket
@ -1705,6 +1698,9 @@ align 4
mov eax, ebx mov eax, ebx
call SOCKET_free call SOCKET_free
;------------------
; Drop the segment
.drop_no_socket: .drop_no_socket:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n" DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"