Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3275 → Rev 3274

/kernel/branches/net/network/tcp_input.inc
54,8 → 54,6
.fail:
DEBUGF 2, "TCP incoming queue is full, discarding packet!\n"
 
inc [TCP_segments_missed] ; FIXME: use correct interface
 
add esp, sizeof.TCP_queue_entry - 8
call kernel_free
add esp, 4
142,7 → 140,7
.socket_loop:
mov ebx, [ebx + SOCKET.NextPtr]
or ebx, ebx
jz .respond_seg_reset
jz .drop_with_reset_no_socket
 
cmp [ebx + SOCKET.Domain], AF_INET4
jne .socket_loop
247,7 → 245,7
;--------------------
; Process TCP options
 
push ecx
push ecx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
movzx ecx, [edx + TCP_header.DataOffset]
cmp ecx, sizeof.TCP_header ; Does header contain any options?
378,7 → 376,7
 
.no_options:
 
pop ecx
pop ecx;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
;-----------------------------------------------------------------------
; Time to do some header prediction (Original Principle by Van Jacobson)
480,13 → 478,12
; Stop retransmit timer
mov [ebx + TCP_SOCKET.timer_retransmission], 0
 
; Unlock the socket
; Awaken waiting processes
pusha
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
popa
 
; Awaken waiting processes
mov eax, ebx
call SOCKET_notify
 
530,6 → 527,11
 
jmp .drop
 
 
 
 
 
 
;--------------------------------------------------
; Header prediction failed, do it the slow way
 
552,7 → 554,7
mov [ebx + TCP_SOCKET.RCV_WND], eax
pop edx
 
; If we are in listen or syn_sent state, go to that specific code right away
; If listen or Syn sent, go to that specific code right away
 
cmp [ebx + TCP_SOCKET.t_state], TCPS_LISTEN
je .LISTEN
560,6 → 562,8
cmp [ebx + TCP_SOCKET.t_state], TCPS_SYN_SENT
je .SYN_SENT
 
DEBUGF 1,"TCP_input: state is not listen or syn_sent\n"
 
;----------------------------
; trim any data not in window
 
635,7 → 639,7
mov eax, ebx
call TCP_close
;;;TODO: update stats
jmp .respond_seg_reset
jmp .drop_with_reset_no_socket
 
;----------------------------------------
; Remove data beyond right edge of window (700-736)
893,25 → 897,14
mov eax, [ebx + TCP_SOCKET.t_maxseg]
mov [ebx + TCP_SOCKET.SND_CWND], eax
 
; Unlock the socket
push ebx
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
mov eax, ebx
call TCP_output ; retransmit missing segment
 
; retransmit missing segment
mov eax, [esp]
call TCP_output
 
; Lock the socket again
mov ecx, [esp]
add ecx, SOCKET.mutex
call mutex_lock
pop ebx
 
; Continue processing
push edx
xor edx, edx
mov eax, [ebx + TCP_SOCKET.t_maxseg]
mul [ebx + TCP_SOCKET.t_dupacks]
pop edx
add eax, [ebx + TCP_SOCKET.SND_SSTHRESH]
mov [ebx + TCP_SOCKET.SND_CWND], eax
 
932,21 → 925,9
mov eax, [ebx + TCP_SOCKET.t_maxseg]
add [ebx + TCP_SOCKET.SND_CWND], eax
 
; Unlock the socket
push ebx
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
 
; retransmit missing segment
mov eax, [esp]
mov eax, ebx
call TCP_output
 
; Lock the socket again
mov ecx, [esp]
add ecx, SOCKET.mutex
call mutex_lock
pop ebx
 
jmp .drop
 
 
1096,7 → 1077,7
 
.wakeup:
 
pushf ; Keep the flags (Carry flag)
pushf ; Why?
mov eax, ebx
call SOCKET_notify
 
1113,7 → 1094,6
 
; General ACK handling complete
; Now do the state-specific ones
; Carry flag is set when our FIN is acked
 
mov eax, [ebx + TCP_SOCKET.t_state]
jmp dword [eax*4 + .ACK_sw_list]
1170,10 → 1150,11
mov [ebx + TCP_SOCKET.t_dupacks], 0
jmp .ack_processed
 
;-------
; LISTEN
 
align 4
 
 
 
 
.LISTEN:
 
DEBUGF 1,"TCP_input: state=listen\n"
1222,6 → 1203,15
 
jmp .trim_then_step6
 
 
 
 
 
 
 
 
 
 
;------------
; Active Open
 
1334,11 → 1324,10
dec eax
mov [ebx + TCP_SOCKET.SND_WL1], eax
 
;-------
; step 6
 
.ack_processed:
 
.ack_processed: ; (step 6)
 
DEBUGF 1,"TCP_input: ACK processed\n"
 
;----------------------------------------------
1507,6 → 1496,8
or [eax + TCP_SOCKET.t_flags], TF_ACKNOW
jmp .need_output
 
 
 
.drop_with_reset:
DEBUGF 1,"TCP_input: Drop with reset\n"
 
1547,6 → 1538,7
 
.need_output:
DEBUGF 1,"TCP_input: need output\n"
 
call TCP_output
 
.dumpit:
1554,10 → 1546,9
 
call kernel_free
add esp, 4
 
ret
 
;---------
; Respond
 
.respond_ack:
push ebx
1566,6 → 1557,7
pop ebx
jmp .destroy_new_socket
 
 
.respond_syn:
push ebx
mov cl, TH_RST + TH_ACK
1573,36 → 1565,15
pop ebx
jmp .destroy_new_socket
 
.respond_seg_reset:
test [edx + TCP_header.Flags], TH_RST
jnz .drop_no_socket
 
;;; TODO: if its a multicast/broadcast, also drop
 
test [edx + TCP_header.Flags], TH_ACK
jnz .respond_seg_ack
 
test [edx + TCP_header.Flags], TH_SYN
jnz .respond_seg_syn
 
jmp .drop_no_socket
 
.respond_seg_ack:
mov cl, TH_RST
call TCP_respond_segment
jmp .drop_no_socket
 
.respond_seg_syn:
mov cl, TH_RST + TH_ACK
call TCP_respond_segment
jmp .drop_no_socket
 
;-----
; Drop
 
.drop:
DEBUGF 1,"TCP_input: Dropping segment\n"
 
DEBUGF 1,"TCP_input: Dropping packet\n"
 
pusha
lea ecx, [ebx + SOCKET.mutex]
call mutex_unlock
1609,6 → 1580,7
popa
 
.destroy_new_socket:
 
test [ebx + TCP_SOCKET.temp_bits], TCP_BIT_DROPSOCKET
jz .drop_no_socket
 
1620,4 → 1592,33
 
call kernel_free
add esp, 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
 
;;; TODO: if its a multicast/broadcast, also drop
 
test [edx + TCP_header.Flags], TH_ACK
jnz .respond_seg_ack
 
test [edx + TCP_header.Flags], TH_SYN
jnz .respond_seg_syn
 
jmp .drop_no_socket
 
.respond_seg_ack:
 
mov cl, TH_RST
call TCP_respond_segment
jmp .drop_no_socket
 
.respond_seg_syn:
 
mov cl, TH_RST + TH_ACK
call TCP_respond_segment
jmp .drop_no_socket
/kernel/branches/net/network/tcp_subr.inc
355,7 → 355,7
stosd
xor eax, eax
stosd
mov al, 0x50 ; Dataoffset: 20 bytes (sizeof.TCP_header/4 shl 4)
mov al, 0x50 ; Dataoffset: 20 bytes (sizeof.TCP_header)
stosb
mov al, cl
stosb
/kernel/branches/net/network/IPv4.inc
64,9 → 64,8
GATEWAY_LIST rd MAX_NET_DEVICES
BROADCAST_LIST rd MAX_NET_DEVICES
 
IP_packets_tx rd MAX_NET_DEVICES
IP_packets_rx rd MAX_NET_DEVICES
IP_packets_dumped rd MAX_NET_DEVICES
IP_PACKETS_TX rd MAX_NET_DEVICES
IP_PACKETS_RX rd MAX_NET_DEVICES
 
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
endg
263,7 → 262,7
; Now we can update stats
 
.ip_ok:
inc [IP_packets_rx + edi]
inc [IP_PACKETS_RX+edi]
 
;----------------------------------
; Check if the packet is fragmented
304,7 → 303,7
 
.dump:
DEBUGF 1,"IPv4_input: dumping\n"
inc [IP_packets_dumped] ; FIXME: use correct interface
; inc [dumped_rx_count] ;;; TODO
call kernel_free
add esp, 4 ; pop (balance stack)
ret
585,7 → 584,7
push ebx ; push the mac onto the stack
push ax
 
inc [IP_packets_tx + edi] ; update stats
inc [IP_PACKETS_TX + edi] ; update stats
 
mov ebx, [NET_DRV_LIST + edi]
lea eax, [ebx + ETH_DEVICE.mac]
675,7 → 674,7
push ebx ; push the mac
push ax
 
inc [IP_packets_tx + edi]
inc [IP_PACKETS_TX + edi]
mov ebx, [NET_DRV_LIST + edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
952,11 → 951,11
ret
 
.packets_tx:
mov eax, [IP_packets_tx + eax]
mov eax, [IP_PACKETS_TX + eax]
ret
 
.packets_rx:
mov eax, [IP_packets_rx + eax]
mov eax, [IP_PACKETS_RX + eax]
ret
 
.read_ip:
/kernel/branches/net/network/tcp.inc
131,10 → 131,8
uglobal
TCP_segments_tx rd MAX_NET_DEVICES
TCP_segments_rx rd MAX_NET_DEVICES
TCP_segments_missed rd MAX_NET_DEVICES
TCP_segments_dumped rd MAX_NET_DEVICES
; TCP_bytes_rx rq MAX_NET_DEVICES
; TCP_bytes_tx rq MAX_NET_DEVICES
TCP_bytes_rx rq MAX_NET_DEVICES
TCP_bytes_tx rq MAX_NET_DEVICES
TCP_sequence_num dd ?
TCP_queue rd TCP_QUEUE_SIZE*sizeof.TCP_queue_entry/4
endg
192,10 → 190,6
jz .packets_tx ; 0
dec bl
jz .packets_rx ; 1
dec bl
jz .packets_missed ; 2
dec bl
jz .packets_dumped ; 3
 
.error:
mov eax, -1
208,11 → 202,3
.packets_rx:
mov eax, [TCP_segments_rx + eax]
ret
 
.packets_missed:
mov eax, [TCP_segments_missed + eax]
ret
 
.packets_dumped:
mov eax, [TCP_segments_dumped + eax]
ret
/kernel/branches/net/network/tcp_output.inc
30,10 → 30,10
 
DEBUGF 1,"TCP_output: socket=%x\n", eax
 
push eax
pusha
lea ecx, [eax + SOCKET.mutex]
call mutex_lock
pop eax
popa
 
; We'll detect the length of the data to be transmitted, and flags to be used
; If there is some data, or any critical controls to send (SYN / RST), then transmit