Build script for linux

git-svn-id: svn://kolibrios.org@6907 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
ashmew2 2017-05-26 18:43:39 +00:00
parent 0715c316ef
commit 03c47f08be
4 changed files with 72 additions and 63 deletions

View File

@ -220,7 +220,7 @@ macro ipv4_checksum ptr {
align 4 align 4
ipv4_input: ipv4_input:
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\ DEBUGF 1, "IPv4_input: packet from %u.%u.%u.%u ",\
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\ [edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
[edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1 [edx + IPv4_header.SourceAddress + 2]:1,[edx + IPv4_header.SourceAddress + 3]:1
DEBUGF DEBUG_NETWORK_VERBOSE, "to %u.%u.%u.%u\n",\ DEBUGF DEBUG_NETWORK_VERBOSE, "to %u.%u.%u.%u\n",\

View File

@ -50,7 +50,7 @@ local .ok, .no_wrap
cmp [ptr + queue.size], size ; Check if queue isnt full cmp [ptr + queue.size], size ; Check if queue isnt full
jb .ok jb .ok
DEBUGF 1, "--- Queue is FULL!\n"
spin_unlock_irqrestore spin_unlock_irqrestore
jmp failaddr jmp failaddr

View File

@ -293,7 +293,7 @@ sys_socket:
align 4 align 4
socket_open: socket_open:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", ecx, edx, esi DEBUGF 1, "SOCKET_open: domain=%u type=%u protocol=%x\n ", ecx, edx, esi
push ecx edx esi push ecx edx esi
call socket_alloc call socket_alloc
@ -692,7 +692,7 @@ socket_accept:
.block: .block:
test [eax + SOCKET.options], SO_NONBLOCK test [eax + SOCKET.options], SO_NONBLOCK
jnz .wouldblock jnz .wouldblock
DEBUGF 1, "Calling socket_block at 695\n"
call socket_block call socket_block
jmp .loop jmp .loop
@ -730,6 +730,7 @@ socket_close:
call socket_num_to_ptr call socket_num_to_ptr
test eax, eax test eax, eax
jz .invalid jz .invalid
DEBUGF 1, "SOCKET_close: socknum=%x\n", eax
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.
@ -761,6 +762,7 @@ socket_close:
.invalid: .invalid:
DEBUGF 1, "SOCKET_close: INVALID!\n"
mov dword[esp+20], EINVAL mov dword[esp+20], EINVAL
mov dword[esp+32], -1 mov dword[esp+32], -1
ret ret
@ -791,6 +793,8 @@ socket_receive:
jz .invalid jz .invalid
.loop: .loop:
pushf
cli
push edi push edi
call [eax + SOCKET.rcv_proc] call [eax + SOCKET.rcv_proc]
pop edi pop edi
@ -806,8 +810,9 @@ socket_receive:
test [eax + SOCKET.options], SO_NONBLOCK test [eax + SOCKET.options], SO_NONBLOCK
jnz .return_err jnz .return_err
DEBUGF 1, "Calling socket_block at 813\n"
call socket_block call socket_block
popf
jmp .loop jmp .loop
@ -817,6 +822,7 @@ socket_receive:
.return_err: .return_err:
mov ecx, -1 mov ecx, -1
.return: .return:
popf
mov [esp+20], ebx mov [esp+20], ebx
mov [esp+32], ecx mov [esp+32], ecx
ret ret
@ -1825,7 +1831,7 @@ socket_ring_free:
align 4 align 4
socket_block: socket_block:
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax DEBUGF 1, "SOCKET_block: %x\n", eax
push eax push eax
@ -1850,7 +1856,7 @@ socket_block:
call change_task call change_task
pop eax pop eax
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: continuing\n" DEBUGF 1, "SOCKET_block: continuing: %x\n", eax
ret ret
@ -1918,7 +1924,7 @@ socket_notify:
and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag and [eax + SOCKET.state], not SS_BLOCKED ; Clear the 'socket is blocked' flag
mov [esi + TASKDATA.state], 0 ; Run the thread mov [esi + TASKDATA.state], 0 ; Run the thread
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n" DEBUGF 1, "SOCKET_notify: Unblocked socket!\n"
pop esi ecx ebx pop esi ecx ebx
ret ret

View File

@ -37,7 +37,7 @@ TCP_BIT_FIN_IS_ACKED = 1 shl 3
;-----------------------------------------------------------------; ;-----------------------------------------------------------------;
align 4 align 4
tcp_input: tcp_input:
DEBUGF 1, "tcp_input!\n"
; record the current time ; record the current time
push [timer_ticks] ; in 1/100 seconds push [timer_ticks] ; in 1/100 seconds
push ebx ecx esi edx ; mind the order (see TCP_queue_entry struct) push ebx ecx esi edx ; mind the order (see TCP_queue_entry struct)
@ -54,6 +54,7 @@ tcp_input:
mov eax, [TCP_input_event] mov eax, [TCP_input_event]
mov ebx, [eax + EVENT.id] mov ebx, [eax + EVENT.id]
xor esi, esi xor esi, esi
; DEBUGF 1, "Raising Event on TCP input\n"
call raise_event call raise_event
ret ret
@ -96,6 +97,7 @@ endl
mov eax, [TCP_input_event] mov eax, [TCP_input_event]
mov ebx, [eax + EVENT.id] mov ebx, [eax + EVENT.id]
call wait_event call wait_event
DEBUGF 1, "Woke up with tcp_input_event\n"
.loop: .loop:
get_from_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .wait get_from_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .wait
@ -109,7 +111,7 @@ endl
mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 header mov edi, [esi + TCP_queue_entry.ip_ptr] ; ptr to ipv4 header
mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last mov esi, [esi + TCP_queue_entry.segment_ptr] ; change esi last
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks] DEBUGF 1, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
mov edx, esi mov edx, esi
@ -139,7 +141,7 @@ endl
sub ecx, eax ; substract TCP header size from total segment size sub ecx, eax ; substract TCP header size from total segment size
jb .drop_no_socket ; If total segment size is less then the advertised header size, drop packet jb .drop_no_socket ; If total segment size is less then the advertised header size, drop packet
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes of data\n", ecx DEBUGF 1, "TCP_input: %u bytes of data\n", ecx
;------------------------------------------- ;-------------------------------------------
; Convert Big-endian values to little endian ; Convert Big-endian values to little endian
@ -201,7 +203,7 @@ endl
call mutex_unlock call mutex_unlock
popa popa
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2 DEBUGF 1, "TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2
;---------------------------- ;----------------------------
; Check if socket isnt closed ; Check if socket isnt closed
@ -217,7 +219,7 @@ endl
call mutex_lock call mutex_lock
popa popa
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: socket locked\n" DEBUGF 1, "TCP_input: socket locked\n"
;--------------------------- ;---------------------------
; disable all temporary bits ; disable all temporary bits
@ -243,7 +245,7 @@ endl
test [ebx + SOCKET.options], SO_ACCEPTCON test [ebx + SOCKET.options], SO_ACCEPTCON
jz .no_accept jz .no_accept
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Accepting new connection\n" DEBUGF 1, "TCP_input: Accepting new connection\n"
; Unlock current socket ; Unlock current socket
@ -300,7 +302,7 @@ endl
cmp ecx, sizeof.TCP_header ; Does header contain any options? cmp ecx, sizeof.TCP_header ; Does header contain any options?
je .no_options je .no_options
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Segment has options\n" DEBUGF 1, "TCP_input: Segment has options\n"
add ecx, edx add ecx, edx
lea esi, [edx + sizeof.TCP_header] lea esi, [edx + sizeof.TCP_header]
@ -323,7 +325,7 @@ endl
; je .opt_sack ; je .opt_sack
cmp al, TCP_OPT_TIMESTAMP cmp al, TCP_OPT_TIMESTAMP
je .opt_timestamp je .opt_timestamp
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: unknown option:%u\n", al DEBUGF 1, "TCP_input: unknown option:%u\n", al
jmp .no_options ; If we reach here, some unknown options were received, skip them all! jmp .no_options ; If we reach here, some unknown options were received, skip them all!
.opt_maxseg: .opt_maxseg:
@ -337,7 +339,7 @@ endl
xor eax, eax xor eax, eax
lodsw lodsw
rol ax, 8 rol ax, 8
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax DEBUGF 1, "TCP_input: Maxseg=%u\n", eax
call tcp_mss call tcp_mss
@@: @@:
jmp .opt_loop jmp .opt_loop
@ -351,7 +353,7 @@ endl
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got window scale option\n" DEBUGF 1, "TCP_input: Got window scale option\n"
or [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE or [ebx + TCP_SOCKET.t_flags], TF_RCVD_SCALE
lodsb lodsb
@ -370,7 +372,7 @@ endl
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Selective Acknowledgement permitted\n" DEBUGF 1, "TCP_input: Selective Acknowledgement permitted\n"
or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
@@: @@:
@ -382,7 +384,7 @@ endl
cmp al, 10 ; length must be 10 cmp al, 10 ; length must be 10
jne .no_options jne .no_options
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got timestamp option\n" DEBUGF 1, "TCP_input: Got timestamp option\n"
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz @f jz @f
@ -407,7 +409,7 @@ endl
cmp eax, [ebx + TCP_SOCKET.ts_val] cmp eax, [ebx + TCP_SOCKET.ts_val]
jbe .no_paws jbe .no_paws
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: PAWS: detected an old segment\n" DEBUGF 1, "TCP_input: PAWS: detected an old segment\n"
mov eax, [timestamp] mov eax, [timestamp]
sub eax, [ebx + TCP_SOCKET.ts_recent_age] sub eax, [ebx + TCP_SOCKET.ts_recent_age]
@ -497,7 +499,7 @@ endl
sub eax, [ebx + TCP_SOCKET.SND_UNA] sub eax, [ebx + TCP_SOCKET.SND_UNA]
jbe .not_uni_xfer jbe .not_uni_xfer
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are sender\n" DEBUGF 1, "TCP_input: Header prediction: we are sender\n"
;--------------------------------- ;---------------------------------
; Packet is a pure ACK, process it ; Packet is a pure ACK, process it
@ -581,7 +583,7 @@ endl
; Complete processing of received data ; Complete processing of received data
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx DEBUGF 1, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
mov esi, [dataoffset] mov esi, [dataoffset]
add esi, edx add esi, edx
@ -590,6 +592,7 @@ endl
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
mov eax, ebx mov eax, ebx
DEBUGF 1, "-- Call socket_notify for data.\n"
call socket_notify call socket_notify
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag
@ -604,22 +607,22 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.not_uni_xfer: .not_uni_xfer:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction failed\n" DEBUGF 1, "TCP_input: Header prediction failed\n"
; Calculate receive window size ; Calculate receive window size
push edx push edx
mov eax, SOCKET_BUFFER_SIZE mov eax, SOCKET_BUFFER_SIZE
sub eax, [ebx + STREAM_SOCKET.rcv.size] sub eax, [ebx + STREAM_SOCKET.rcv.size]
DEBUGF DEBUG_NETWORK_VERBOSE, "Space in receive buffer=%d\n", eax DEBUGF 1, "Space in receive buffer=%d\n", eax
mov edx, [ebx + TCP_SOCKET.RCV_ADV] mov edx, [ebx + TCP_SOCKET.RCV_ADV]
sub edx, [ebx + TCP_SOCKET.RCV_NXT] sub edx, [ebx + TCP_SOCKET.RCV_NXT]
DEBUGF DEBUG_NETWORK_VERBOSE, "Current advertised window=%d\n", edx DEBUGF 1, "Current advertised window=%d\n", edx
cmp eax, edx cmp eax, edx
jg @f jg @f
mov eax, edx mov eax, edx
@@: @@:
DEBUGF DEBUG_NETWORK_VERBOSE, "Receive window size=%d\n", eax DEBUGF 1, "Receive window size=%d\n", eax
mov [ebx + TCP_SOCKET.RCV_WND], eax mov [ebx + TCP_SOCKET.RCV_WND], eax
pop edx pop edx
@ -646,14 +649,14 @@ endl
sub eax, [edx + TCP_header.SequenceNumber] sub eax, [edx + TCP_header.SequenceNumber]
jle .no_duplicate jle .no_duplicate
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes duplicate data!\n", eax DEBUGF 1, "TCP_input: %u bytes duplicate data!\n", eax
; Check for duplicate SYN ; Check for duplicate SYN
test [edx + TCP_header.Flags], TH_SYN test [edx + TCP_header.Flags], TH_SYN
jz .no_dup_syn jz .no_dup_syn
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: got duplicate syn\n" DEBUGF 1, "TCP_input: got duplicate syn\n"
and [edx + TCP_header.Flags], not (TH_SYN) and [edx + TCP_header.Flags], not (TH_SYN)
inc [edx + TCP_header.SequenceNumber] inc [edx + TCP_header.SequenceNumber]
@ -700,7 +703,7 @@ endl
;----------------------------------------------- ;-----------------------------------------------
; Remove duplicate data and update urgent offset ; Remove duplicate data and update urgent offset
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: trimming duplicate data\n" DEBUGF 1, "TCP_input: trimming duplicate data\n"
; Trim data from left side of window ; Trim data from left side of window
@ -740,7 +743,7 @@ endl
sub eax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop sub eax, [ebx + TCP_SOCKET.RCV_WND] ; eax now holds the number of bytes to drop
jle .no_excess_data jle .no_excess_data
DEBUGF DEBUG_NETWORK_VERBOSE, "%d bytes beyond right edge of window\n", eax DEBUGF 1, "%d bytes beyond right edge of window\n", eax
inc [TCPS_rcvpackafterwin] inc [TCPS_rcvpackafterwin]
@ -778,7 +781,7 @@ endl
inc [TCPS_rcvwinprobe] inc [TCPS_rcvwinprobe]
.dont_drop_all: .dont_drop_all:
add [TCPS_rcvbyteafterwin], eax add [TCPS_rcvbyteafterwin], eax
DEBUGF DEBUG_NETWORK_VERBOSE, "Trimming %u bytes from the right of the window\n" DEBUGF 1, "Trimming %u bytes from the right of the window\n"
; remove data from the right side of window (decrease data length) ; remove data from the right side of window (decrease data length)
@ -806,7 +809,7 @@ endl
sub eax, ecx sub eax, ecx
jae .no_timestamp jae .no_timestamp
DEBUGF DEBUG_NETWORK_VERBOSE, "Recording timestamp\n" DEBUGF 1, "Recording timestamp\n"
mov eax, [timestamp] mov eax, [timestamp]
mov [ebx + TCP_SOCKET.ts_recent_age], eax mov [ebx + TCP_SOCKET.ts_recent_age], eax
@ -823,7 +826,7 @@ endl
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jz .no_rst jz .no_rst
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got an RST flag\n" DEBUGF 1, "TCP_input: Got an RST flag\n"
mov eax, [ebx + TCP_SOCKET.t_state] mov eax, [ebx + TCP_SOCKET.t_state]
shl eax, 2 shl eax, 2
@ -845,16 +848,16 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.econnrefused: .econnrefused:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection refused\n" DEBUGF 1, "TCP_input: Connection refused\n"
mov [ebx + SOCKET.errorcode], ECONNREFUSED mov [ebx + SOCKET.errorcode], ECONNREFUSED
jmp .close jmp .close
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.econnreset: .econnreset:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection reset\n" DEBUGF 1, "TCP_input: Connection reset\n"
mov [ebx + SOCKET.errorcode], ECONNRESET mov [ebx + SOCKET.errorcode], ECONNRESET
.close: .close:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing connection\n" DEBUGF 1, "TCP_input: Closing connection\n"
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
inc [TCPS_drops] inc [TCPS_drops]
@ -863,7 +866,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.rst_close: .rst_close:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n" DEBUGF 1, "TCP_input: Closing with reset\n"
jmp .unlock_and_close jmp .unlock_and_close
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
@ -901,7 +904,7 @@ endl
jb .ack_processed ; states: closed, listen, syn_sent jb .ack_processed ; states: closed, listen, syn_sent
ja .no_syn_rcv ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait ja .no_syn_rcv ; established, fin_wait_1, fin_wait_2, close_wait, closing, last_ack, time_wait
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_received\n" DEBUGF 1, "TCP_input: state=syn_received\n"
mov eax, [edx + TCP_header.AckNumber] mov eax, [edx + TCP_header.AckNumber]
cmp [ebx + TCP_SOCKET.SND_UNA], eax cmp [ebx + TCP_SOCKET.SND_UNA], eax
@ -954,7 +957,7 @@ endl
jne .reset_dupacks jne .reset_dupacks
inc [TCPS_rcvdupack] inc [TCPS_rcvdupack]
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Processing duplicate ACK\n" DEBUGF 1, "TCP_input: Processing duplicate ACK\n"
; If we have outstanding data, other than a window probe, this is a completely duplicate ACK ; If we have outstanding data, other than a window probe, this is a completely duplicate ACK
; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them, ; (window info didnt change) The ACK is the biggest we've seen and we've seen exactly our rexmt threshold of them,
@ -975,7 +978,7 @@ endl
jb .dup_ack_complete jb .dup_ack_complete
ja .another_lost ja .another_lost
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Re-transmitting lost segment\n" DEBUGF 1, "TCP_input: Re-transmitting lost segment\n"
push [ebx + TCP_SOCKET.SND_NXT] ; >>>> push [ebx + TCP_SOCKET.SND_NXT] ; >>>>
@ -1038,7 +1041,7 @@ endl
jmp .drop jmp .drop
.another_lost: .another_lost:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Increasing congestion window\n" DEBUGF 1, "TCP_input: Increasing congestion window\n"
mov eax, [ebx + TCP_SOCKET.t_maxseg] mov eax, [ebx + TCP_SOCKET.t_maxseg]
add [ebx + TCP_SOCKET.SND_CWND], eax add [ebx + TCP_SOCKET.SND_CWND], eax
@ -1096,7 +1099,7 @@ endl
sub edi, [ebx + TCP_SOCKET.SND_UNA] ; now we got the number of acked bytes in edi sub edi, [ebx + TCP_SOCKET.SND_UNA] ; now we got the number of acked bytes in edi
inc [TCPS_rcvackpack] inc [TCPS_rcvackpack]
add [TCPS_rcvackbyte], edi add [TCPS_rcvackbyte], edi
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi DEBUGF 1, "TCP_input: acceptable ACK for %u bytes\n", edi
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
; ;
@ -1205,7 +1208,7 @@ endl
call socket_ring_free call socket_ring_free
pop ebx edx ecx pop ebx edx ecx
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n" DEBUGF 1, "TCP_input: our FIN is acked\n"
or [temp_bits], TCP_BIT_FIN_IS_ACKED or [temp_bits], TCP_BIT_FIN_IS_ACKED
jmp .ack_complete jmp .ack_complete
.no_fin_ack: .no_fin_ack:
@ -1331,7 +1334,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.state_listen: .state_listen:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=listen\n" DEBUGF 1, "TCP_input: state=listen\n"
test [edx + TCP_header.Flags], TH_RST test [edx + TCP_header.Flags], TH_RST
jnz .drop jnz .drop
@ -1397,7 +1400,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.state_syn_sent: .state_syn_sent:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_sent\n" DEBUGF 1, "TCP_input: state=syn_sent\n"
test [edx + TCP_header.Flags], TH_ACK test [edx + TCP_header.Flags], TH_ACK
jz @f jz @f
@ -1457,7 +1460,7 @@ endl
test [edx + TCP_header.Flags], TH_ACK test [edx + TCP_header.Flags], TH_ACK
jz .simultaneous_open jz .simultaneous_open
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: active open\n" DEBUGF 1, "TCP_input: active open\n"
inc [TCPS_connects] inc [TCPS_connects]
@ -1498,7 +1501,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.simultaneous_open: .simultaneous_open:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: simultaneous open\n" DEBUGF 1, "TCP_input: simultaneous open\n"
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
@ -1518,7 +1521,7 @@ endl
cmp ecx, [ebx + TCP_SOCKET.RCV_WND] cmp ecx, [ebx + TCP_SOCKET.RCV_WND]
jbe .dont_trim jbe .dont_trim
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: received data does not fit in window, trimming %u bytes\n", eax DEBUGF 1, "TCP_input: received data does not fit in window, trimming %u bytes\n", eax
inc [TCPS_rcvpackafterwin] inc [TCPS_rcvpackafterwin]
sub ecx, [ebx + TCP_SOCKET.RCV_WND] sub ecx, [ebx + TCP_SOCKET.RCV_WND]
add [TCPS_rcvbyteafterwin], ecx add [TCPS_rcvbyteafterwin], ecx
@ -1539,7 +1542,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.ack_processed: .ack_processed:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n" DEBUGF 1, "TCP_input: ACK processed\n"
; dont look at window if no ACK ; dont look at window if no ACK
@ -1591,7 +1594,7 @@ endl
mov [ebx + TCP_SOCKET.max_sndwnd], eax mov [ebx + TCP_SOCKET.max_sndwnd], eax
@@: @@:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Updating window to %u\n", eax DEBUGF 1, "TCP_input: Updating window to %u\n", eax
push [edx + TCP_header.SequenceNumber] push [edx + TCP_header.SequenceNumber]
pop [ebx + TCP_SOCKET.SND_WL1] pop [ebx + TCP_SOCKET.SND_WL1]
@ -1687,7 +1690,7 @@ endl
jmp .data_done jmp .data_done
.out_of_order: .out_of_order:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP data is out of order!\nSequencenumber is %u, we expected %u.\n", \ DEBUGF 1, "TCP data is out of order!\nSequencenumber is %u, we expected %u.\n", \
[edx + TCP_header.SequenceNumber], [ebx + TCP_SOCKET.RCV_NXT] [edx + TCP_header.SequenceNumber], [ebx + TCP_SOCKET.RCV_NXT]
; Uh-oh, some data is out of order, lets call TCP reassemble for help ; Uh-oh, some data is out of order, lets call TCP reassemble for help
@ -1709,12 +1712,12 @@ endl
test [edx + TCP_header.Flags], TH_FIN test [edx + TCP_header.Flags], TH_FIN
jz .final_processing jz .final_processing
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Processing FIN\n" DEBUGF 1, "TCP_input: Processing FIN\n"
cmp [ebx + TCP_SOCKET.t_state], TCPS_TIME_WAIT cmp [ebx + TCP_SOCKET.t_state], TCPS_TIME_WAIT
jae .not_first_fin jae .not_first_fin
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n" DEBUGF 1, "TCP_input: First FIN for this connection\n"
mov eax, ebx mov eax, ebx
call socket_cant_recv_more call socket_cant_recv_more
@ -1775,7 +1778,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.final_processing: .final_processing:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Final processing\n" DEBUGF 1, "TCP_input: Final processing\n"
push ebx push ebx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1787,14 +1790,14 @@ endl
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jz .done jz .done
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n" DEBUGF 1, "TCP_input: ACK now!\n"
.need_output: .need_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n" DEBUGF 1, "TCP_input: need output\n"
call tcp_output call tcp_output
.done: .done:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n" DEBUGF 1, "TCP_input: dumping\n"
call net_buff_free call net_buff_free
jmp .loop jmp .loop
@ -1807,7 +1810,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.drop_after_ack: .drop_after_ack:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop after ACK\n" DEBUGF 1, "TCP_input: Drop after ACK\n"
push edx ebx push edx ebx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1822,7 +1825,7 @@ endl
;----------------------------------------------------------------------------------- ;-----------------------------------------------------------------------------------
.drop_with_reset: .drop_with_reset:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop with reset\n" DEBUGF 1, "TCP_input: Drop with reset\n"
push ebx edx push ebx edx
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1894,7 +1897,7 @@ endl
; Unlock socket mutex and prepare to drop segment ; Unlock socket mutex and prepare to drop segment
.drop: .drop:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n" DEBUGF 1, "TCP_input: Dropping segment\n"
pusha pusha
lea ecx, [ebx + SOCKET.mutex] lea ecx, [ebx + SOCKET.mutex]
@ -1915,7 +1918,7 @@ endl
; Drop the segment ; Drop the segment
.drop_no_socket: .drop_no_socket:
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n" DEBUGF 1, "TCP_input: Drop (no socket)\n"
call net_buff_free call net_buff_free
jmp .loop jmp .loop