forked from KolibriOS/kolibrios
Net branch:
-Updates in TCP code: accepting connections now works. (TCPserv is able to send 'hello world!' to telnet client) git-svn-id: svn://kolibrios.org@1838 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
1510d5d932
commit
08596896d2
@ -594,7 +594,7 @@ IPv4_find_fragment_slot:
|
|||||||
align 4
|
align 4
|
||||||
IPv4_output:
|
IPv4_output:
|
||||||
|
|
||||||
DEBUGF 1,"IPv4_create_packet: size=%u\n", ecx
|
DEBUGF 1,"IPv4_create_packet: size=%u\n", ecx
|
||||||
|
|
||||||
cmp ecx, 65500 ; Max IPv4 packet size
|
cmp ecx, 65500 ; Max IPv4 packet size
|
||||||
jg .too_large
|
jg .too_large
|
||||||
|
@ -335,6 +335,9 @@ align 4
|
|||||||
mov [eax + SOCKET.Protocol], IP_PROTO_TCP
|
mov [eax + SOCKET.Protocol], IP_PROTO_TCP
|
||||||
mov [eax + SOCKET.snd_proc], SOCKET_send_tcp
|
mov [eax + SOCKET.snd_proc], SOCKET_send_tcp
|
||||||
mov [eax + SOCKET.rcv_proc], SOCKET_receive_tcp
|
mov [eax + SOCKET.rcv_proc], SOCKET_receive_tcp
|
||||||
|
|
||||||
|
|
||||||
|
mov [eax + TCP_SOCKET.t_maxseg], 1480 ;;;;; FIXME
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -507,8 +510,6 @@ align 4
|
|||||||
pop [eax + TCP_SOCKET.ISS]
|
pop [eax + TCP_SOCKET.ISS]
|
||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_init
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_maxseg], 1480 ;;;;;
|
|
||||||
|
|
||||||
TCP_sendseqinit eax
|
TCP_sendseqinit eax
|
||||||
|
|
||||||
; mov [ebx + TCP_SOCKET.timer_retransmission], ;; todo: create macro to set retransmission timer
|
; mov [ebx + TCP_SOCKET.timer_retransmission], ;; todo: create macro to set retransmission timer
|
||||||
@ -1491,7 +1492,7 @@ SOCKET_fork:
|
|||||||
|
|
||||||
and [eax + SOCKET.options], not SO_ACCEPTCON
|
and [eax + SOCKET.options], not SO_ACCEPTCON
|
||||||
|
|
||||||
call SOCKET_notify_owner
|
;;;;; call SOCKET_notify_owner
|
||||||
pop edi ecx esi
|
pop edi ecx esi
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
@ -181,21 +181,26 @@ TCP_input:
|
|||||||
test [ebx + SOCKET.options], SO_ACCEPTCON
|
test [ebx + SOCKET.options], SO_ACCEPTCON
|
||||||
jz .no_listening_socket
|
jz .no_listening_socket
|
||||||
|
|
||||||
call SOCKET_fork
|
DEBUGF 1,"Accepting new connection\n"
|
||||||
jz .drop
|
|
||||||
|
|
||||||
push [edx + TCP_segment.DestinationPort]
|
mov [ebx + SOCKET.lock], 0
|
||||||
pop [eax + TCP_SOCKET.LocalPort]
|
call SOCKET_fork
|
||||||
|
|
||||||
|
test eax, eax
|
||||||
|
jz .drop
|
||||||
|
|
||||||
push [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress] ;;; FIXME
|
push [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.DestinationAddress] ;;; FIXME
|
||||||
pop [eax + IP_SOCKET.LocalIP]
|
pop [eax + IP_SOCKET.LocalIP]
|
||||||
|
|
||||||
push [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress] ;;; FIXME
|
push [edx + TCP_segment.DestinationPort]
|
||||||
pop [eax + IP_SOCKET.RemoteIP]
|
pop [eax + TCP_SOCKET.LocalPort]
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_state], TCPS_LISTEN
|
mov [eax + TCP_SOCKET.t_state], TCPS_LISTEN
|
||||||
|
|
||||||
jmp .not_uni_xfer
|
; mov [ebx + SOCKET.lock], 0
|
||||||
|
mov ebx, eax
|
||||||
|
|
||||||
|
jmp .LISTEN
|
||||||
|
|
||||||
.no_listening_socket:
|
.no_listening_socket:
|
||||||
|
|
||||||
@ -467,32 +472,36 @@ align 4
|
|||||||
|
|
||||||
;;; TODO: check if it's a broadcast or multicast, and drop if so
|
;;; TODO: check if it's a broadcast or multicast, and drop if so
|
||||||
|
|
||||||
add [TCP_sequence_num], 64000
|
push [edx - IPv4_Packet.DataOrOptional + IPv4_Packet.SourceAddress] ;;; FIXME
|
||||||
|
pop [ebx + IP_SOCKET.RemoteIP]
|
||||||
|
|
||||||
push [edx + TCP_segment.SourcePort]
|
push [edx + TCP_segment.SourcePort]
|
||||||
pop [eax + TCP_SOCKET.RemotePort]
|
pop [ebx + TCP_SOCKET.RemotePort]
|
||||||
|
|
||||||
push [edx + TCP_segment.SequenceNumber]
|
push [edx + TCP_segment.SequenceNumber]
|
||||||
pop [eax + TCP_SOCKET.IRS]
|
pop [ebx + TCP_SOCKET.IRS]
|
||||||
|
|
||||||
push [eax + TCP_SOCKET.ISS]
|
push [TCP_sequence_num] ;;;;;
|
||||||
pop [eax + TCP_SOCKET.SND_NXT]
|
add [TCP_sequence_num], 64000 / 2
|
||||||
|
pop [ebx + TCP_SOCKET.ISS]
|
||||||
|
|
||||||
TCP_sendseqinit eax
|
push [ebx + TCP_SOCKET.ISS]
|
||||||
TCP_rcvseqinit eax
|
pop [ebx + TCP_SOCKET.SND_NXT]
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
TCP_sendseqinit ebx
|
||||||
mov [eax + TCP_SOCKET.t_flags], TF_ACKNOW
|
TCP_rcvseqinit ebx
|
||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval ;;;; macro
|
|
||||||
|
|
||||||
add eax, STREAM_SOCKET.snd
|
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
|
mov [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
|
mov [ebx + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval ;;;; macro
|
||||||
|
|
||||||
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call SOCKET_ring_create
|
||||||
|
|
||||||
add eax, STREAM_SOCKET.rcv - STREAM_SOCKET.snd
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_create
|
call SOCKET_ring_create
|
||||||
|
|
||||||
lea ebx, [eax - STREAM_SOCKET.rcv]
|
;;; call SOCKET_notify_owner
|
||||||
mov [ebx + SOCKET.lock], 0
|
|
||||||
|
|
||||||
jmp .trim_then_step6
|
jmp .trim_then_step6
|
||||||
|
|
||||||
@ -503,6 +512,8 @@ align 4
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;------------
|
;------------
|
||||||
; Active Open
|
; Active Open
|
||||||
|
|
||||||
@ -662,16 +673,13 @@ align 4
|
|||||||
inc [edx + TCP_segment.SequenceNumber]
|
inc [edx + TCP_segment.SequenceNumber]
|
||||||
|
|
||||||
cmp [edx + TCP_segment.UrgentPointer], 1
|
cmp [edx + TCP_segment.UrgentPointer], 1
|
||||||
jl @f
|
jle @f
|
||||||
|
|
||||||
dec [edx + TCP_segment.UrgentPointer]
|
dec [edx + TCP_segment.UrgentPointer]
|
||||||
|
jmp .dup_syn
|
||||||
jmp .no_dup_syn
|
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
and [edx + TCP_segment.Flags], not (TH_URG)
|
and [edx + TCP_segment.Flags], not (TH_URG)
|
||||||
|
.dup_syn:
|
||||||
dec eax
|
dec eax
|
||||||
jz .no_duplicate
|
|
||||||
.no_dup_syn:
|
.no_dup_syn:
|
||||||
|
|
||||||
; eax holds number of bytes to drop
|
; eax holds number of bytes to drop
|
||||||
@ -889,11 +897,11 @@ align 4
|
|||||||
DEBUGF 1,"TCP state = syn received\n"
|
DEBUGF 1,"TCP state = syn received\n"
|
||||||
|
|
||||||
mov eax, [edx + TCP_segment.AckNumber]
|
mov eax, [edx + TCP_segment.AckNumber]
|
||||||
cmp eax, [ebx + TCP_SOCKET.SND_UNA]
|
cmp [ebx + TCP_SOCKET.SND_UNA], eax
|
||||||
|
jg .drop_with_reset
|
||||||
|
cmp eax, [ebx + TCP_SOCKET.SND_MAX]
|
||||||
jg .drop_with_reset
|
jg .drop_with_reset
|
||||||
|
|
||||||
cmp [ebx + TCP_SOCKET.SND_MAX], eax
|
|
||||||
jg .drop_with_reset
|
|
||||||
;;; update stats
|
;;; update stats
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_connected
|
call SOCKET_is_connected
|
||||||
@ -1487,8 +1495,10 @@ align 4
|
|||||||
mov [ebx + SOCKET.lock], 0
|
mov [ebx + SOCKET.lock], 0
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_ACK
|
; mov cl, TH_ACK
|
||||||
call TCP_respond_socket
|
; call TCP_respond_socket
|
||||||
|
mov eax, ebx
|
||||||
|
call TCP_output
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
call kernel_free
|
call kernel_free
|
||||||
|
@ -492,7 +492,8 @@ TCP_output:
|
|||||||
.fail:
|
.fail:
|
||||||
pop ecx
|
pop ecx
|
||||||
add esp, ecx
|
add esp, ecx
|
||||||
add esp, 4+8
|
pop eax
|
||||||
|
add esp, 8
|
||||||
mov [eax + SOCKET.lock], 0
|
mov [eax + SOCKET.lock], 0
|
||||||
DEBUGF 1,"TCP_output: failed\n"
|
DEBUGF 1,"TCP_output: failed\n"
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user