More TCP and sockets code

git-svn-id: svn://kolibrios.org@1774 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2011-01-28 23:07:25 +00:00
parent 2ba52e3e4a
commit 8619f93e83
3 changed files with 78 additions and 55 deletions

View File

@ -1724,3 +1724,18 @@ SOCKET_is_disconnected:
or [eax + SOCKET.options], SS_CANTRCVMORE + SS_CANTSENDMORE
jmp SOCKET_notify_owner
;-----------------------------------------------------------------
;
; SOCKET_cant_recv_more
;
; IN: eax = socket ptr
; OUT: /
;
;-----------------------------------------------------------------
align 4
SOCKET_cant_recv_more:
ret

View File

@ -76,7 +76,7 @@ SS_ISDISCONNECTED equ 0x800 ; socket disconnected from peer
SS_ASYNC equ 0x100 ; async i/o notify
SS_ISCONFIRMING equ 0x200 ; deciding to accept connection req
SS_MORETOCOME equ 0x400 ;
SS_MORETOCOME equ 0x400
SOCKET_MAXDATA equ 4096*32 ; must be 4096*(power of 2) where 'power of 2' is at least 8
@ -145,19 +145,6 @@ macro ntohw reg {
}
macro packet_to_debug { ; set esi to packet you want to print, ecx to number of bytes
local .loop
.loop:
lodsb
DEBUGF 1,"%x ", eax:2
loop @r
}
include "queue.inc"
include "ethernet.inc"
@ -263,7 +250,7 @@ stack_handler:
;-----------------------------------------------------------------
;
; NET_Add_Device:
; NET_add_Device:
;
; This function is called by the network drivers,
; to register each running NIC to the kernel

View File

@ -1339,6 +1339,22 @@ align 4
DEBUGF 1,"Processing FIN\n"
cmp [ebx + TCP_SOCKET.t_state], TCB_CLOSE_WAIT
je .not_first_fin
cmp [ebx + TCP_SOCKET.t_state], TCB_CLOSING
je .not_first_fin
cmp [ebx + TCP_SOCKET.t_state], TCB_FIN_WAIT_2
je .not_first_fin
DEBUGF 1,"First FIN for this connection\n"
mov eax, ebx
call SOCKET_cant_recv_more
mov [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
inc [ebx + TCP_SOCKET.RCV_NXT]
.not_first_fin:
mov eax, [ebx + TCP_SOCKET.t_state]
shl eax, 2
jmp dword [eax + .FIN_sw_list]
@ -1356,23 +1372,28 @@ align 4
dd .fin_wait2 ;TCB_FIN_WAIT_2
dd .fin_timed ;TCB_TIMED_WAIT
.fin_syn_est:
jmp .final_processing
mov [ebx + TCP_SOCKET.t_state], TCB_CLOSE_WAIT
jmp .no_fin
.fin_wait1:
jmp .final_processing
mov [ebx + TCP_SOCKET.t_state], TCB_CLOSING
jmp .no_fin
.fin_wait2:
jmp .final_processing
mov [ebx + TCP_SOCKET.t_state], TCB_TIMED_WAIT
mov eax, ebx
call TCP_cancel_timers
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
call SOCKET_is_disconnected
jmp .no_fin
.fin_timed:
jmp .final_processing
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
jmp .no_fin
.no_fin: