572,8 → 572,7 |
mov eax, [edx + TCP_segment.SequenceNumber] |
cmp eax, [ebx + TCP_SOCKET.RCV_NXT] |
jne .not_uni_xfer |
DEBUGF 1,"TCP_segment.window=%u\n", [edx + TCP_segment.Window]:4 |
DEBUGF 1,"TCP_SOCKET.SND_WND=%u\n", [ebx + TCP_SOCKET.SND_WND]:4 |
|
mov eax, dword [edx + TCP_segment.Window] |
cmp eax, [ebx + TCP_SOCKET.SND_WND] |
jne .not_uni_xfer |
614,11 → 613,9 |
; Update RTT estimators |
|
; Delete acknowledged bytes from send buffer |
pusha |
mov ecx, eax |
lea eax, [ebx + STREAM_SOCKET.snd] |
call SOCKET_ring_free |
popa |
|
; update window pointers |
mov eax, [edx + TCP_segment.AckNumber] |
632,12 → 629,12 |
mov eax, ebx |
call SOCKET_notify_owner |
|
;; Generate more output FIXME |
;; Generate more output |
;; mov eax, ebx |
;; call TCP_output |
;; |
;; jmp .drop |
jmp .ack_processed |
jmp .step6 |
|
;------------------------------------------------- |
; maybe we are the receiver in the uni-xfer then.. |
650,10 → 647,8 |
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 (seg_next equals tp). ;;;;;;; |
|
;;;;;;; TODO |
|
jnz .not_uni_xfer |
|
;------------------------------------- |
661,7 → 656,6 |
|
DEBUGF 1,"header prediction: we are receiver\nreceiving %u bytes of data\n", ecx |
|
pusha |
add esi, edx |
lea eax, [ebx + STREAM_SOCKET.rcv] |
call SOCKET_ring_write ; Add the data to the socket buffer |
668,7 → 662,6 |
|
mov eax, ebx |
call SOCKET_notify_owner |
popa |
|
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied |
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag |
774,6 → 767,8 |
mov eax, [edx + TCP_segment.AckNumber] |
cmp eax, [ebx + TCP_SOCKET.ISS] |
jle .drop_with_reset |
|
; mov eax, [edx + TCP_segment.AckNumber] |
cmp eax, [ebx + TCP_SOCKET.SND_MAX] |
jg .drop_with_reset |
@@: |
784,7 → 779,6 |
test [edx + TCP_segment.Flags], TH_ACK |
jz .drop |
|
mov eax, ebx |
mov ebx, ECONNREFUSED |
call TCP_drop |
|
861,7 → 855,7 |
; TODO... |
@@: |
;;;;; |
jmp .ack_processed |
jmp .step6 |
|
|
.trim_then_step6: |
873,6 → 867,8 |
|
mov eax, [ebx + TCP_SOCKET.RCV_NXT] |
sub eax, [edx + TCP_segment.SequenceNumber] |
|
test eax, eax |
jz .no_duplicate |
|
test [edx + TCP_segment.Flags], TH_SYN |
1068,7 → 1064,6 |
test [edx + TCP_segment.Flags], TH_SYN |
jz @f |
|
mov eax, ebx |
mov ebx, ECONNRESET |
call TCP_drop |
|
1077,49 → 1072,30 |
test [edx + TCP_segment.Flags], TH_ACK |
jz .drop |
@@: |
;---------------- |
; Process the ACK |
|
;--------------- |
; ACK processing |
|
cmp [ebx + TCP_SOCKET.t_state], TCB_SYN_RECEIVED |
jnz .no_syn_rcv |
jg .ack_dup |
jl .ack_nodup |
|
DEBUGF 1,"TCP state = syn received\n" |
|
;;;;; 801-815 |
;;;;; |
|
.no_syn_rcv: |
.ack_nodup: |
|
; check for duplicate ACK |
DEBUGF 1,"New ACK\n" |
|
mov eax, [edx + TCP_segment.AckNumber] |
cmp eax, [ebx + TCP_SOCKET.SND_UNA] |
jg .not_dup_ack |
|
DEBUGF 1,"Duplicate ACK\n" |
|
test ecx, ecx |
jnz .ack_processed |
.ack_dup: |
|
mov eax, dword [edx + TCP_segment.Window] |
cmp eax, [ebx + TCP_SOCKET.SND_WND] |
jne .ack_processed |
;;;; |
|
; Process the duplicate ACK |
|
;;;;; 833 - 878 |
|
;;; call TCP_output |
jmp .drop |
|
.not_dup_ack: |
|
DEBUGF 1,"new ACK\n" |
|
|
;------------------------------------------------- |
; If the congestion window was inflated to account |
; for the other side's cached packets, retract it |
; for the other side's cached packets, retrace it |
|
;;;; 888 - 902 |
|
1147,21 → 1123,18 |
; Remove acknowledged data from send buffer |
|
pusha |
; Delete acknowledged bytes from send buffer |
mov ecx, [edx + TCP_segment.AckNumber] |
sub ecx, [ebx + TCP_SOCKET.SND_UNA] ; ecx now holds number of bytes acked |
|
sub ecx, [ebx + TCP_SOCKET.SND_UNA] |
lea eax, [ebx + STREAM_SOCKET.snd] |
call SOCKET_ring_free |
popa |
|
;--------------------------------------- |
; Wake up process waiting on send buffer |
|
mov eax, ebx |
call SOCKET_notify_owner |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; code missing (943?) |
|
; Update TCB |
|
|
mov eax, [edx + TCP_segment.AckNumber] |
mov [ebx + TCP_SOCKET.SND_UNA], eax |
|
1170,56 → 1143,55 |
mov [ebx + TCP_SOCKET.SND_NXT], eax |
@@: |
|
; General ACK handling complete |
; Now do the state-specific ones |
|
;--------------------------------------- |
; Wake up process waiting on send buffer |
|
mov eax, ebx |
call SOCKET_notify_owner |
|
mov eax, [ebx + TCP_SOCKET.t_state] |
jmp dword [eax*4 + .ACK_sw_list] |
shl eax, 2 |
jmp dword [eax + .ACK_sw_list] |
|
.ACK_sw_list: |
dd .ack_processed ;TCB_CLOSED |
dd .ack_processed ;TCB_LISTEN |
dd .ack_processed ;TCB_SYN_SENT |
dd .ack_processed ;TCB_SYN_RECEIVED |
dd .ack_processed ;TCB_ESTABLISHED |
dd .ack_processed ;TCB_CLOSE_WAIT |
dd .ack_fw1 ;TCB_FIN_WAIT_1 |
dd .ack_c ;TCB_CLOSING |
dd .ack_la ;TCB_LAST_ACK |
dd .ack_processed ;TCB_FIN_WAIT_2 |
dd .ack_tw ;TCB_TIMED_WAIT |
dd .step6 ;TCB_CLOSED |
dd .step6 ;TCB_LISTEN |
dd .step6 ;TCB_SYN_SENT |
dd .step6 ;TCB_SYN_RECEIVED |
dd .step6 ;TCB_ESTABLISHED |
dd .step6 ;TCB_CLOSE_WAIT |
dd ._963 ;TCB_FIN_WAIT_1 |
dd ._958 ;TCB_CLOSING |
dd ._999 ;TCB_LAST_ACK |
dd .step6 ;TCB_FIN_WAIT_2 |
dd ._1010 ;TCB_TIMED_WAIT |
|
|
.ack_fw1: |
._963: |
|
;;; TODO: 963 |
|
jmp .ack_processed |
jmp .step6 |
|
.ack_c: |
|
;;; TODO: 958 |
._958: |
|
jmp .ack_processed |
jmp .step6 |
|
.ack_la: |
._999: |
|
;;; TODO: 999 |
jmp .step6 |
|
jmp .ack_processed |
|
._1010: |
|
.ack_tw: |
jmp .step6 |
|
;;; TODO: 1010 |
|
jmp .ack_processed |
.step6: |
|
DEBUGF 1,"step 6\n" |
|
.ack_processed: |
|
DEBUGF 1,"ack processed\n" |
|
;---------------------------------------------- |
; check if we need to update window information |
|
1411,12 → 1383,18 |
|
;;; if debug enabled, output packet |
|
;test needoutput, needoutput |
;jz .dumpit |
;test ;;;needoutput = 1 |
;jnz .outputnow |
|
test [ebx + TCP_SOCKET.t_flags], TF_ACKNOW |
jz .dumpit |
jnz .ack_now |
|
call kernel_free |
add esp, 4 |
ret |
|
.ack_now: |
|
DEBUGF 1,"ACK now!\n" |
|
push ebx |
1424,8 → 1402,6 |
call TCP_output |
pop ebx |
|
.dumpit: |
|
call kernel_free |
add esp, 4 |
ret |
2034,16 → 2010,10 |
align 4 |
TCP_close: |
|
DEBUGF 1,"TCP_close\n" |
|
;;; TODO: update RTT and mean deviation |
;;; TODO: update slow start threshold |
;;; TODO: release connection resources |
|
; Now, mark the socket as being disconnected |
|
mov [eax + SOCKET.state], 0 ;;; FIXME |
|
ret |
|
|