Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5200 → Rev 5201

/kernel/branches/Kolibri-acpi/network/tcp_input.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; 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 ;;
;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
7,7 → 7,7
;; ;;
;; Written by hidnplayr@kolibrios.org ;;
;; ;;
;; Based on the code of 4.4BSD ;;
;; Based on the algorithms used in 4.4BSD ;;
;; ;;
;; GNU GENERAL PUBLIC LICENSE ;;
;; Version 2, June 1991 ;;
14,7 → 14,7
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
$Revision: 3407 $
$Revision: 5155 $
 
;-----------------------------------------------------------------
;
43,11 → 43,7
push ebx ecx esi edi ; mind the order
mov esi, esp
 
pushf
cli
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
popf
 
add esp, sizeof.TCP_queue_entry
 
call NET_ptr_to_num4
62,7 → 58,6
ret
 
.fail:
popf
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
 
call NET_ptr_to_num4
536,12 → 531,10
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
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
jne .not_uni_xfer
 
;;; TODO
 
; jnz .not_uni_xfer
 
; Complete processing of received data
 
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
845,7 → 838,7
pop word [ebx + TCP_SOCKET.SND_SCALE]
@@:
 
;;; TODO: call TCP_reassemble
call TCP_reassemble
 
mov eax, [edx + TCP_header.SequenceNumber]
dec eax
1099,8 → 1092,7
pop ebx edx ecx
 
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
stc
 
or [temp_bits], TCP_BIT_FIN_IS_ACKED
jmp .wakeup
 
.finiacked:
1114,19 → 1106,15
pop edx ecx
 
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is not acked\n"
clc
 
;----------------------------------------
; Wake up process waiting on send buffer
 
.wakeup:
 
pushf ; Keep the flags (Carry flag)
mov eax, ebx
call SOCKET_notify
 
; Update TCPS
 
mov eax, [edx + TCP_header.AckNumber]
mov [ebx + TCP_SOCKET.SND_UNA], eax
cmp eax, [ebx + TCP_SOCKET.SND_NXT]
1134,8 → 1122,6
mov [ebx + TCP_SOCKET.SND_NXT], eax
@@:
 
popf
 
; General ACK handling complete
; Now do the state-specific ones
; Carry flag is set when our FIN is acked
1158,7 → 1144,8
 
 
.ack_fw1:
jnc .ack_processed
test [temp_bits], TCP_BIT_FIN_IS_ACKED
jz .ack_processed
 
test [ebx + SOCKET.state], SS_CANTRCVMORE
jnz @f
1171,7 → 1158,8
jmp .ack_processed
 
.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 eax, ebx
1183,7 → 1171,8
jmp .ack_processed
 
.ack_la:
jnc .ack_processed
test [temp_bits], TCP_BIT_FIN_IS_ACKED
jz .ack_processed
 
push ebx
lea ecx, [ebx + SOCKET.mutex]
1246,9 → 1235,13
 
lea eax, [ebx + STREAM_SOCKET.snd]
call SOCKET_ring_create
test eax, eax
jz .drop
 
lea eax, [ebx + STREAM_SOCKET.rcv]
call SOCKET_ring_create
test eax, eax
jz .drop
 
and [temp_bits], not TCP_BIT_DROPSOCKET
 
1257,7 → 1250,7
call SOCKET_notify
popa
 
jmp .trim_then_step6
jmp .trim
 
;------------
; Active Open
1350,9 → 1343,9
 
mov eax, [ebx + TCP_SOCKET.t_rtt]
test eax, eax
je .trim_then_step6
je .trim
call TCP_xmit_timer
jmp .trim_then_step6
jmp .trim
 
.simultaneous_open:
 
1363,8 → 1356,7
;-------------------------------------
; Common processing for receipt of SYN
 
.trim_then_step6:
 
.trim:
inc [edx + TCP_header.SequenceNumber]
 
; Drop any received data that doesnt fit in the receive window.
1377,17 → 1369,12
;;; TODO: update stats
 
.dont_trim:
 
mov eax, [edx + TCP_header.SequenceNumber]
mov [ebx + TCP_SOCKET.RCV_UP], eax
dec eax
mov [ebx + TCP_SOCKET.SND_WL1], eax
 
;-------
; step 6
 
.ack_processed:
 
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n"
 
;----------------------------------------------
1592,7 → 1579,7
jnz .need_output
 
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jz .dumpit
jz .done
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n"
 
.need_output:
1599,7 → 1586,7
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
call TCP_output
 
.dumpit:
.done:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
 
call NET_packet_free
1619,7 → 1606,7
pop eax edx
 
test [edx + TCP_header.Flags], TH_RST
jnz .dumpit
jnz .done
 
or [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jmp .need_output
1633,7 → 1620,7
pop edx ebx
 
test [edx + TCP_header.Flags], TH_RST
jnz .dumpit
jnz .done
 
;;; if its a multicast/broadcast, also drop
 
1642,7 → 1629,7
 
test [edx + TCP_header.Flags], TH_SYN
jnz .respond_syn
jmp .dumpit
jmp .done
 
;---------
; Respond
1661,8 → 1648,10
pop ebx
jmp .destroy_new_socket
 
;-----------------------------------------
; The connection has no associated socket
 
.no_socket:
 
pusha
mov ecx, socket_mutex
call mutex_unlock
1692,8 → 1681,8
call TCP_respond_segment
jmp .drop_no_socket
 
;-----
; Drop
;------------------------------------------------
; Unlock socket mutex and prepare to drop segment
 
.drop:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n"
1703,6 → 1692,9
call mutex_unlock
popa
 
;--------------------------------------------
; Destroy the newly created socket if needed
 
.destroy_new_socket:
test [temp_bits], TCP_BIT_DROPSOCKET
jz .drop_no_socket
1710,6 → 1702,9
mov eax, ebx
call SOCKET_free
 
;------------------
; Drop the segment
 
.drop_no_socket:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"