forked from KolibriOS/kolibrios
Add a build script for Linux
git-svn-id: svn://kolibrios.org@6908 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
03c47f08be
commit
caf7d0c041
20
kernel/trunk/build.sh
Executable file
20
kernel/trunk/build.sh
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Compile the KolibriOS kernel on Linux
|
||||||
|
# 2017, The KolibriOS team
|
||||||
|
|
||||||
|
KERPACK=$HOME/kolibrios/programs/other/kpack/kerpack_linux/kerpack
|
||||||
|
KOLIBRI_IMG=$HOME/nightly/kolibri.img
|
||||||
|
|
||||||
|
replace=0; # Replace kernel in the image file?
|
||||||
|
fasm -m 65536 kernel.asm kernel.mnt
|
||||||
|
$KERPACK kernel.mnt kernel.mnt
|
||||||
|
|
||||||
|
[[ $replace -eq 1 ]] && {
|
||||||
|
mntpt=$(mktemp -d)
|
||||||
|
|
||||||
|
sudo mount -o loop $KOLIBRI_IMG $mntpt
|
||||||
|
sudo mount -o remount,rw $mntpt
|
||||||
|
sudo cp kernel.mnt ${mntpt}/KERNEL.MNT
|
||||||
|
sudo umount $mntpt
|
||||||
|
rmdir $mntpt
|
||||||
|
}
|
@ -220,7 +220,7 @@ macro ipv4_checksum ptr {
|
|||||||
align 4
|
align 4
|
||||||
ipv4_input:
|
ipv4_input:
|
||||||
|
|
||||||
DEBUGF 1, "IPv4_input: packet from %u.%u.%u.%u ",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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",\
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ sys_socket:
|
|||||||
align 4
|
align 4
|
||||||
socket_open:
|
socket_open:
|
||||||
|
|
||||||
DEBUGF 1, "SOCKET_open: domain=%u type=%u protocol=%x\n ", ecx, edx, esi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_open: domain=%u type=%u protocol=%x ", 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,7 +730,6 @@ 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.
|
||||||
|
|
||||||
@ -762,7 +761,6 @@ 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
|
||||||
@ -793,8 +791,6 @@ 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
|
||||||
@ -810,9 +806,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
@ -822,7 +817,6 @@ 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
|
||||||
@ -1831,7 +1825,7 @@ socket_ring_free:
|
|||||||
align 4
|
align 4
|
||||||
socket_block:
|
socket_block:
|
||||||
|
|
||||||
DEBUGF 1, "SOCKET_block: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: %x\n", eax
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
@ -1856,7 +1850,7 @@ socket_block:
|
|||||||
call change_task
|
call change_task
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
DEBUGF 1, "SOCKET_block: continuing: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_block: continuing\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1911,7 +1905,7 @@ socket_notify:
|
|||||||
; Socket and thread exists and socket is of non blocking type.
|
; Socket and thread exists and socket is of non blocking type.
|
||||||
; We'll try to flag an event to the thread.
|
; We'll try to flag an event to the thread.
|
||||||
shl ecx, 8
|
shl ecx, 8
|
||||||
or [SLOT_BASE + ecx + APPDATA.event_mask], EVENT_NETWORK
|
or [SLOT_BASE + ecx + APPDATA.event_mask], EVENT_NETWORK
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: poking thread %u!\n", ebx
|
||||||
pop esi ecx ebx
|
pop esi ecx ebx
|
||||||
@ -1924,7 +1918,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 1, "SOCKET_notify: Unblocked socket!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_notify: Unblocked socket!\n"
|
||||||
pop esi ecx ebx
|
pop esi ecx ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -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,7 +54,6 @@ 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
|
||||||
@ -97,7 +96,6 @@ 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
|
||||||
@ -111,7 +109,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 1, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: size=%u time=%d\n", ecx, [timer_ticks]
|
||||||
|
|
||||||
mov edx, esi
|
mov edx, esi
|
||||||
|
|
||||||
@ -141,7 +139,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 1, "TCP_input: %u bytes of data\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: %u bytes of data\n", ecx
|
||||||
|
|
||||||
;-------------------------------------------
|
;-------------------------------------------
|
||||||
; Convert Big-endian values to little endian
|
; Convert Big-endian values to little endian
|
||||||
@ -203,7 +201,7 @@ endl
|
|||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: socket ptr=%x state=%u flags=%x\n", ebx, [ebx + TCP_SOCKET.t_state], [edx + TCP_header.Flags]:2
|
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
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
; Check if socket isnt closed
|
; Check if socket isnt closed
|
||||||
@ -219,7 +217,7 @@ endl
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: socket locked\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: socket locked\n"
|
||||||
|
|
||||||
;---------------------------
|
;---------------------------
|
||||||
; disable all temporary bits
|
; disable all temporary bits
|
||||||
@ -245,7 +243,7 @@ endl
|
|||||||
test [ebx + SOCKET.options], SO_ACCEPTCON
|
test [ebx + SOCKET.options], SO_ACCEPTCON
|
||||||
jz .no_accept
|
jz .no_accept
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Accepting new connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Accepting new connection\n"
|
||||||
|
|
||||||
; Unlock current socket
|
; Unlock current socket
|
||||||
|
|
||||||
@ -302,7 +300,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 1, "TCP_input: Segment has options\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Segment has options\n"
|
||||||
|
|
||||||
add ecx, edx
|
add ecx, edx
|
||||||
lea esi, [edx + sizeof.TCP_header]
|
lea esi, [edx + sizeof.TCP_header]
|
||||||
@ -325,7 +323,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 1, "TCP_input: unknown option:%u\n", al
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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:
|
||||||
@ -339,7 +337,7 @@ endl
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
lodsw
|
lodsw
|
||||||
rol ax, 8
|
rol ax, 8
|
||||||
DEBUGF 1, "TCP_input: Maxseg=%u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax
|
||||||
call tcp_mss
|
call tcp_mss
|
||||||
@@:
|
@@:
|
||||||
jmp .opt_loop
|
jmp .opt_loop
|
||||||
@ -353,7 +351,7 @@ endl
|
|||||||
test [edx + TCP_header.Flags], TH_SYN
|
test [edx + TCP_header.Flags], TH_SYN
|
||||||
jz @f
|
jz @f
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Got window scale option\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -372,7 +370,7 @@ endl
|
|||||||
test [edx + TCP_header.Flags], TH_SYN
|
test [edx + TCP_header.Flags], TH_SYN
|
||||||
jz @f
|
jz @f
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Selective Acknowledgement permitted\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Selective Acknowledgement permitted\n"
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
|
or [ebx + TCP_SOCKET.t_flags], TF_SACK_PERMIT
|
||||||
|
|
||||||
@@:
|
@@:
|
||||||
@ -384,7 +382,7 @@ endl
|
|||||||
cmp al, 10 ; length must be 10
|
cmp al, 10 ; length must be 10
|
||||||
jne .no_options
|
jne .no_options
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Got timestamp option\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Got timestamp option\n"
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_SYN
|
test [edx + TCP_header.Flags], TH_SYN
|
||||||
jz @f
|
jz @f
|
||||||
@ -409,7 +407,7 @@ endl
|
|||||||
cmp eax, [ebx + TCP_SOCKET.ts_val]
|
cmp eax, [ebx + TCP_SOCKET.ts_val]
|
||||||
jbe .no_paws
|
jbe .no_paws
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: PAWS: detected an old segment\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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]
|
||||||
@ -499,7 +497,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 1, "TCP_input: Header prediction: we are sender\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are sender\n"
|
||||||
|
|
||||||
;---------------------------------
|
;---------------------------------
|
||||||
; Packet is a pure ACK, process it
|
; Packet is a pure ACK, process it
|
||||||
@ -583,7 +581,7 @@ endl
|
|||||||
|
|
||||||
; Complete processing of received data
|
; Complete processing of received data
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Header prediction: we are receiving %u bytes\n", ecx
|
||||||
|
|
||||||
mov esi, [dataoffset]
|
mov esi, [dataoffset]
|
||||||
add esi, edx
|
add esi, edx
|
||||||
@ -592,7 +590,6 @@ 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
|
||||||
@ -607,22 +604,22 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.not_uni_xfer:
|
.not_uni_xfer:
|
||||||
DEBUGF 1, "TCP_input: Header prediction failed\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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 1, "Space in receive buffer=%d\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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 1, "Current advertised window=%d\n", edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Current advertised window=%d\n", edx
|
||||||
cmp eax, edx
|
cmp eax, edx
|
||||||
jg @f
|
jg @f
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
@@:
|
@@:
|
||||||
DEBUGF 1, "Receive window size=%d\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Receive window size=%d\n", eax
|
||||||
mov [ebx + TCP_SOCKET.RCV_WND], eax
|
mov [ebx + TCP_SOCKET.RCV_WND], eax
|
||||||
pop edx
|
pop edx
|
||||||
|
|
||||||
@ -649,14 +646,14 @@ endl
|
|||||||
sub eax, [edx + TCP_header.SequenceNumber]
|
sub eax, [edx + TCP_header.SequenceNumber]
|
||||||
jle .no_duplicate
|
jle .no_duplicate
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: %u bytes duplicate data!\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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 1, "TCP_input: got duplicate syn\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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]
|
||||||
@ -703,7 +700,7 @@ endl
|
|||||||
;-----------------------------------------------
|
;-----------------------------------------------
|
||||||
; Remove duplicate data and update urgent offset
|
; Remove duplicate data and update urgent offset
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: trimming duplicate data\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: trimming duplicate data\n"
|
||||||
|
|
||||||
; Trim data from left side of window
|
; Trim data from left side of window
|
||||||
|
|
||||||
@ -743,7 +740,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 1, "%d bytes beyond right edge of window\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "%d bytes beyond right edge of window\n", eax
|
||||||
|
|
||||||
inc [TCPS_rcvpackafterwin]
|
inc [TCPS_rcvpackafterwin]
|
||||||
|
|
||||||
@ -781,7 +778,7 @@ endl
|
|||||||
inc [TCPS_rcvwinprobe]
|
inc [TCPS_rcvwinprobe]
|
||||||
.dont_drop_all:
|
.dont_drop_all:
|
||||||
add [TCPS_rcvbyteafterwin], eax
|
add [TCPS_rcvbyteafterwin], eax
|
||||||
DEBUGF 1, "Trimming %u bytes from the right of the window\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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)
|
||||||
|
|
||||||
@ -809,7 +806,7 @@ endl
|
|||||||
sub eax, ecx
|
sub eax, ecx
|
||||||
jae .no_timestamp
|
jae .no_timestamp
|
||||||
|
|
||||||
DEBUGF 1, "Recording timestamp\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -826,7 +823,7 @@ endl
|
|||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jz .no_rst
|
jz .no_rst
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Got an RST flag\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -848,16 +845,16 @@ endl
|
|||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
.econnrefused:
|
.econnrefused:
|
||||||
DEBUGF 1, "TCP_input: Connection refused\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection refused\n"
|
||||||
mov [ebx + SOCKET.errorcode], ECONNREFUSED
|
mov [ebx + SOCKET.errorcode], ECONNREFUSED
|
||||||
jmp .close
|
jmp .close
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
.econnreset:
|
.econnreset:
|
||||||
DEBUGF 1, "TCP_input: Connection reset\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Connection reset\n"
|
||||||
mov [ebx + SOCKET.errorcode], ECONNRESET
|
mov [ebx + SOCKET.errorcode], ECONNRESET
|
||||||
.close:
|
.close:
|
||||||
DEBUGF 1, "TCP_input: Closing connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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]
|
||||||
|
|
||||||
@ -866,7 +863,7 @@ endl
|
|||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
.rst_close:
|
.rst_close:
|
||||||
DEBUGF 1, "TCP_input: Closing with reset\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
|
||||||
jmp .unlock_and_close
|
jmp .unlock_and_close
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
@ -904,7 +901,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 1, "TCP_input: state=syn_received\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -957,7 +954,7 @@ endl
|
|||||||
jne .reset_dupacks
|
jne .reset_dupacks
|
||||||
|
|
||||||
inc [TCPS_rcvdupack]
|
inc [TCPS_rcvdupack]
|
||||||
DEBUGF 1, "TCP_input: Processing duplicate ACK\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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,
|
||||||
@ -978,7 +975,7 @@ endl
|
|||||||
jb .dup_ack_complete
|
jb .dup_ack_complete
|
||||||
ja .another_lost
|
ja .another_lost
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Re-transmitting lost segment\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Re-transmitting lost segment\n"
|
||||||
|
|
||||||
push [ebx + TCP_SOCKET.SND_NXT] ; >>>>
|
push [ebx + TCP_SOCKET.SND_NXT] ; >>>>
|
||||||
|
|
||||||
@ -1041,7 +1038,7 @@ endl
|
|||||||
jmp .drop
|
jmp .drop
|
||||||
|
|
||||||
.another_lost:
|
.another_lost:
|
||||||
DEBUGF 1, "TCP_input: Increasing congestion window\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -1099,7 +1096,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 1, "TCP_input: acceptable ACK for %u bytes\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: acceptable ACK for %u bytes\n", edi
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
@ -1208,7 +1205,7 @@ endl
|
|||||||
call socket_ring_free
|
call socket_ring_free
|
||||||
pop ebx edx ecx
|
pop ebx edx ecx
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: our FIN is acked\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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:
|
||||||
@ -1334,7 +1331,7 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.state_listen:
|
.state_listen:
|
||||||
DEBUGF 1, "TCP_input: state=listen\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=listen\n"
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jnz .drop
|
jnz .drop
|
||||||
@ -1400,7 +1397,7 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.state_syn_sent:
|
.state_syn_sent:
|
||||||
DEBUGF 1, "TCP_input: state=syn_sent\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: state=syn_sent\n"
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jz @f
|
jz @f
|
||||||
@ -1460,7 +1457,7 @@ endl
|
|||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jz .simultaneous_open
|
jz .simultaneous_open
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: active open\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: active open\n"
|
||||||
|
|
||||||
inc [TCPS_connects]
|
inc [TCPS_connects]
|
||||||
|
|
||||||
@ -1501,7 +1498,7 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.simultaneous_open:
|
.simultaneous_open:
|
||||||
DEBUGF 1, "TCP_input: simultaneous open\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: simultaneous open\n"
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
@ -1521,7 +1518,7 @@ endl
|
|||||||
cmp ecx, [ebx + TCP_SOCKET.RCV_WND]
|
cmp ecx, [ebx + TCP_SOCKET.RCV_WND]
|
||||||
jbe .dont_trim
|
jbe .dont_trim
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: received data does not fit in window, trimming %u bytes\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -1542,7 +1539,7 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.ack_processed:
|
.ack_processed:
|
||||||
DEBUGF 1, "TCP_input: ACK processed\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK processed\n"
|
||||||
|
|
||||||
; dont look at window if no ACK
|
; dont look at window if no ACK
|
||||||
|
|
||||||
@ -1594,7 +1591,7 @@ endl
|
|||||||
mov [ebx + TCP_SOCKET.max_sndwnd], eax
|
mov [ebx + TCP_SOCKET.max_sndwnd], eax
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Updating window to %u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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]
|
||||||
@ -1690,7 +1687,7 @@ endl
|
|||||||
jmp .data_done
|
jmp .data_done
|
||||||
|
|
||||||
.out_of_order:
|
.out_of_order:
|
||||||
DEBUGF 1, "TCP data is out of order!\nSequencenumber is %u, we expected %u.\n", \
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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
|
||||||
@ -1712,12 +1709,12 @@ endl
|
|||||||
test [edx + TCP_header.Flags], TH_FIN
|
test [edx + TCP_header.Flags], TH_FIN
|
||||||
jz .final_processing
|
jz .final_processing
|
||||||
|
|
||||||
DEBUGF 1, "TCP_input: Processing FIN\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "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 1, "TCP_input: First FIN for this connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call socket_cant_recv_more
|
call socket_cant_recv_more
|
||||||
@ -1778,7 +1775,7 @@ endl
|
|||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
.final_processing:
|
.final_processing:
|
||||||
DEBUGF 1, "TCP_input: Final processing\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Final processing\n"
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
lea ecx, [ebx + SOCKET.mutex]
|
lea ecx, [ebx + SOCKET.mutex]
|
||||||
@ -1790,14 +1787,14 @@ endl
|
|||||||
|
|
||||||
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
|
test [eax + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
jz .done
|
jz .done
|
||||||
DEBUGF 1, "TCP_input: ACK now!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: ACK now!\n"
|
||||||
|
|
||||||
.need_output:
|
.need_output:
|
||||||
DEBUGF 1, "TCP_input: need output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
|
||||||
call tcp_output
|
call tcp_output
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
DEBUGF 1, "TCP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
|
||||||
|
|
||||||
call net_buff_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
@ -1810,7 +1807,7 @@ endl
|
|||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
.drop_after_ack:
|
.drop_after_ack:
|
||||||
DEBUGF 1, "TCP_input: Drop after ACK\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop after ACK\n"
|
||||||
|
|
||||||
push edx ebx
|
push edx ebx
|
||||||
lea ecx, [ebx + SOCKET.mutex]
|
lea ecx, [ebx + SOCKET.mutex]
|
||||||
@ -1825,7 +1822,7 @@ endl
|
|||||||
|
|
||||||
;-----------------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------------
|
||||||
.drop_with_reset:
|
.drop_with_reset:
|
||||||
DEBUGF 1, "TCP_input: Drop with reset\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop with reset\n"
|
||||||
|
|
||||||
push ebx edx
|
push ebx edx
|
||||||
lea ecx, [ebx + SOCKET.mutex]
|
lea ecx, [ebx + SOCKET.mutex]
|
||||||
@ -1897,7 +1894,7 @@ endl
|
|||||||
; Unlock socket mutex and prepare to drop segment
|
; Unlock socket mutex and prepare to drop segment
|
||||||
|
|
||||||
.drop:
|
.drop:
|
||||||
DEBUGF 1, "TCP_input: Dropping segment\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Dropping segment\n"
|
||||||
|
|
||||||
pusha
|
pusha
|
||||||
lea ecx, [ebx + SOCKET.mutex]
|
lea ecx, [ebx + SOCKET.mutex]
|
||||||
@ -1918,7 +1915,7 @@ endl
|
|||||||
; Drop the segment
|
; Drop the segment
|
||||||
|
|
||||||
.drop_no_socket:
|
.drop_no_socket:
|
||||||
DEBUGF 1, "TCP_input: Drop (no socket)\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
|
||||||
|
|
||||||
call net_buff_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
Loading…
Reference in New Issue
Block a user