7,8 → 7,6 |
;; ;; |
;; TCP Processes for Menuet OS TCP/IP stack ;; |
;; ;; |
;; Version 0.6 4th July 2004 ;; |
;; ;; |
;; Copyright 2002 Mike Hibbett, mikeh@oceanfree.net ;; |
;; ;; |
;; See file COPYING for details ;; |
125,7 → 123,7 |
or ebx, ebx |
jz .exit |
|
DEBUGF 1, "K : %x: %x-%x-%x-%u\n", ebx, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] |
DEBUGF 1, "K : %x-%x: %x-%x-%x-%u\n", [ebx + SOCKET.PID]:2, [ebx + SOCKET.Number]:2, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] |
|
cmp [ebx + SOCKET.TCBTimer], 0 |
jne .decrement_tcb |
177,7 → 175,6 |
.next_resendq: |
cmp ecx, NUMRESENDENTRIES |
je .exit ; None left |
;cmp [esi], byte 0xFF ; XTODO: 0xff -> 0 |
cmp dword[esi + 4], 0 |
jne @f ; found one |
inc ecx |
192,7 → 189,6 |
jmp .next_resendq ; Timer not zero, so move on |
|
@@: |
;mov bl, 0xff ; XTODO: bl -> ebx, 0xff -> 0 |
xor ebx, ebx |
; restart timer, and decrement retries |
; After the first resend, back of on next, by a factor of 5 |
201,7 → 197,6 |
jnz @f |
|
; retries now 0, so delete from queue |
;xchg [esi], bl ; XTODO: bl -> ebx |
xchg [esi + 4], ebx |
|
@@: ; resend packet |
213,10 → 208,8 |
jne .tth004z |
|
; TODO - try again in 10ms. |
;cmp bl, 0xff ; XTODO: 0xff -> 0 |
test ebx, ebx |
jnz @f |
;mov [esi], bl ; XTODO: bl -> ebx |
mov [esi + 4], ebx |
|
@@: ; Mark it to expire in 10ms - 1 tick |
310,9 → 303,6 |
or ebx, ebx |
jz .next_socket.1.exit |
|
cmp [ebx + SOCKET.Status], SOCK_OPEN |
jne .next_socket.1 |
|
; DEBUGF 1, "K : tcp_rx - 1.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 |
|
mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get the dest. port from the TCP hdr |
349,9 → 339,6 |
or ebx, ebx |
jz .next_socket.2.exit |
|
cmp [ebx + SOCKET.Status], SOCK_OPEN |
jne .next_socket.2 |
|
; DEBUGF 1, "K : tcp_rx - 2.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 |
|
mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get the dest. port from the TCP hdr |
387,9 → 374,6 |
or ebx, ebx |
jz .next_socket.3.exit |
|
cmp [ebx + SOCKET.Status], SOCK_OPEN |
jne .next_socket.3 |
|
; DEBUGF 1, "K : tcp_rx - 3.dport: %x - %x\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [ebx + SOCKET.LocalPort]:4 |
|
mov ax, [edx + 20 + TCP_PACKET.DestinationPort] ; get destination port from the TCP hdr |
415,16 → 399,7 |
|
DEBUGF 1, "K : tcp_rx - dumped\n" |
DEBUGF 1, "K : --------: %x-%x-%x (flags: %x)\n", [edx + 20 + TCP_PACKET.DestinationPort]:4, [edx + IP_PACKET.SourceAddress], [edx + 20 + TCP_PACKET.SourcePort]:4, [edx + 20 + TCP_PACKET.Flags]:2 |
; mov ebx, net_sockets |
; |
; .next_socket.4: |
; mov ebx, [ebx + SOCKET.NextPtr] |
; or ebx, ebx |
; jz .next_socket.4.exit |
; DEBUGF 1, "K : %x: %x-%x-%x-%u\n", ebx, [ebx + SOCKET.LocalPort]:4, [ebx + SOCKET.RemoteIP], [ebx + SOCKET.RemotePort]:4, [ebx + SOCKET.TCBState] |
; jne .next_socket.4 |
; |
; .next_socket.4.exit: |
|
inc [dumped_rx_count] |
jmp .exit |
|
655,7 → 630,6 |
.next_resendq: |
cmp ecx, NUMRESENDENTRIES |
je .call_handler ; None left |
;cmp [esi], al ; XTODO: al -> eax |
cmp [esi + 4], eax |
je @f ; found one |
inc ecx |
696,7 → 670,6 |
add esi, 8 |
jmp .next_resendq |
|
;@@: mov byte[esi], 0xff ; XTODO: 0xff -> 0 |
@@: mov dword[esi + 4], 0 |
inc ecx |
add esi, 8 |
845,16 → 818,16 |
; For now, if the packet is an ACK, process it, |
; If not, ignore it |
|
test [edx + 20 + TCP_PACKET.Flags], TH_RST ;xxx |
jz .check_ack ;xxx |
test [edx + 20 + TCP_PACKET.Flags], TH_RST |
jz .check_ack |
|
push [ebx + SOCKET.OrigRemotePort] [ebx + SOCKET.OrigRemoteIP] |
pop [ebx + SOCKET.RemoteIP] [ebx + SOCKET.RemotePort] |
|
mov [ebx + SOCKET.TCBState], TCB_LISTEN ;xxx |
jmp .exit ;xxx |
mov [ebx + SOCKET.TCBState], TCB_LISTEN |
jmp .exit |
|
.check_ack: ;xxx |
.check_ack: |
; Look at control flags - expecting an ACK |
test [edx + 20 + TCP_PACKET.Flags], TH_ACK |
jz .exit |
871,10 → 844,8 |
; OR both... |
|
; Did we receive a FIN or RST? |
;xxx test [edx + 20 + TCP_PACKET.Flags], TH_FIN + TH_RST |
;xxx jz .check_ack |
test [edx + 20 + TCP_PACKET.Flags], TH_FIN ;xxx |
jz .check_ack ;xxx |
test [edx + 20 + TCP_PACKET.Flags], TH_FIN |
jz .check_ack |
|
; It was a fin or reset. |
|
890,7 → 861,6 |
.next_resendq: |
cmp ecx, NUMRESENDENTRIES |
je .last_resendq ; None left |
;cmp [esi], al ; XTODO: al -> eax |
cmp [esi + 4], eax |
je @f ; found one |
inc ecx |
897,7 → 867,6 |
add esi, 8 |
jmp .next_resendq |
|
;@@: mov byte[esi], 0xff ; XTODO: 0xff -> 0 |
@@: mov dword[esi + 4], 0 |
inc ecx |
add esi, 8 |
906,13 → 875,6 |
.last_resendq: |
popad |
|
;xxx ; was it a reset? |
;xxx test [edx + 20 + TCP_PACKET.Flags], TH_RST |
;xxx jz @f |
|
;xxx mov [ebx + SOCKET.TCBState], TCB_CLOSED |
;xxx jmp .exit |
|
@@: ; Send an ACK to that fin, and enter closewait state |
|
mov [ebx + SOCKET.TCBState], TCB_CLOSE_WAIT |
1158,11 → 1120,6 |
|
; delete the socket |
stdcall net_socket_free, ebx |
; mov edi, ebx |
; xor eax, eax |
; mov ecx, SOCKETHEADERSIZE |
; cld |
; rep stosb |
|
.exit: |
ret |