forked from KolibriOS/kolibrios
kolibri-acpi: update
git-svn-id: svn://kolibrios.org@6078 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
5d4667748a
commit
a6e137e674
@ -178,7 +178,7 @@ bd_read:
|
|||||||
ja .notread
|
ja .notread
|
||||||
sub eax, [bios_cur_sector]
|
sub eax, [bios_cur_sector]
|
||||||
shl eax, 9
|
shl eax, 9
|
||||||
add eax, (OS_BASE+0x9A000)
|
add eax, (OS_BASE+0x99000)
|
||||||
push ecx esi
|
push ecx esi
|
||||||
mov esi, eax
|
mov esi, eax
|
||||||
mov ecx, 512/4
|
mov ecx, 512/4
|
||||||
@ -207,12 +207,14 @@ bd_read:
|
|||||||
jmp bd_read
|
jmp bd_read
|
||||||
.readerr:
|
.readerr:
|
||||||
.v86err:
|
.v86err:
|
||||||
|
pop edx
|
||||||
|
pop eax
|
||||||
mov [hd_error], 1
|
mov [hd_error], 1
|
||||||
jmp hd_read_error
|
jmp hd_read_error
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
bd_write_cache_chain:
|
bd_write_cache_chain:
|
||||||
pusha
|
pusha
|
||||||
mov edi, OS_BASE + 0x9A000
|
mov edi, OS_BASE + 0x99000
|
||||||
movzx ecx, [cache_chain_size]
|
movzx ecx, [cache_chain_size]
|
||||||
push ecx
|
push ecx
|
||||||
shl ecx, 9-2
|
shl ecx, 9-2
|
||||||
@ -240,7 +242,7 @@ int13_call:
|
|||||||
; In current implementation it is protected by common mutex 'ide_status'
|
; In current implementation it is protected by common mutex 'ide_status'
|
||||||
mov word [OS_BASE + 510h], 10h ; packet length
|
mov word [OS_BASE + 510h], 10h ; packet length
|
||||||
mov word [OS_BASE + 512h], cx ; number of sectors
|
mov word [OS_BASE + 512h], cx ; number of sectors
|
||||||
mov dword [OS_BASE + 514h], 9A000000h ; buffer 9A00:0000
|
mov dword [OS_BASE + 514h], 99000000h ; buffer 9900:0000
|
||||||
mov dword [OS_BASE + 518h], eax
|
mov dword [OS_BASE + 518h], eax
|
||||||
and dword [OS_BASE + 51Ch], 0
|
and dword [OS_BASE + 51Ch], 0
|
||||||
push ebx ecx esi edi
|
push ebx ecx esi edi
|
||||||
@ -267,7 +269,7 @@ int13_call:
|
|||||||
@@:
|
@@:
|
||||||
mov word [ebx+v86_regs.esi], 510h
|
mov word [ebx+v86_regs.esi], 510h
|
||||||
mov word [ebx+v86_regs.ss], 9000h
|
mov word [ebx+v86_regs.ss], 9000h
|
||||||
mov word [ebx+v86_regs.esp], 0A000h
|
mov word [ebx+v86_regs.esp], 09000h
|
||||||
mov word [ebx+v86_regs.eip], 500h
|
mov word [ebx+v86_regs.eip], 500h
|
||||||
mov [ebx+v86_regs.eflags], 20200h
|
mov [ebx+v86_regs.eflags], 20200h
|
||||||
mov esi, [sys_v86_machine]
|
mov esi, [sys_v86_machine]
|
||||||
|
@ -504,81 +504,66 @@ align 4
|
|||||||
IDE_irq_14_handler:
|
IDE_irq_14_handler:
|
||||||
IDE_irq_15_handler:
|
IDE_irq_15_handler:
|
||||||
IDE_common_irq_handler:
|
IDE_common_irq_handler:
|
||||||
|
; Most of the time, we are here because we have requested
|
||||||
|
; a DMA transfer for the corresponding drive.
|
||||||
|
; However,
|
||||||
|
; a) we can be here because IDE IRQ is shared with some other device,
|
||||||
|
; that device has actually raised IRQ,
|
||||||
|
; it has nothing to do with IDE;
|
||||||
|
; b) we can be here because IDE controller just does not want
|
||||||
|
; to be silent and reacts to something even though
|
||||||
|
; we have, in theory, disabled IRQs.
|
||||||
|
; If the interrupt corresponds to our current request,
|
||||||
|
; remove the interrupt request and raise the event for the waiting code.
|
||||||
|
; In the case a), just return zero - not our interrupt.
|
||||||
|
; In the case b), remove the interrupt request and hope for the best.
|
||||||
; DEBUGF 1, 'K : IDE_irq_handler %x\n', [IDE_common_irq_param]:2
|
; DEBUGF 1, 'K : IDE_irq_handler %x\n', [IDE_common_irq_param]:2
|
||||||
cmp [IDE_common_irq_param], 0
|
mov ecx, [esp+4]
|
||||||
jz .exit
|
|
||||||
pushfd
|
|
||||||
cli
|
|
||||||
pushad
|
|
||||||
mov ecx, [IDE_controller_pointer]
|
|
||||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||||
cmp [IDE_common_irq_param], 14
|
|
||||||
jz @f
|
|
||||||
add dx, 8
|
|
||||||
@@:
|
|
||||||
add edx, 2 ; Bus Master IDE Status register
|
add edx, 2 ; Bus Master IDE Status register
|
||||||
in al, dx
|
in al, dx
|
||||||
test al, 4
|
test al, 4
|
||||||
jz @f
|
jnz .interrupt_from_primary
|
||||||
mov [IDE_common_irq_param], 0
|
add edx, 8
|
||||||
|
in al, dx
|
||||||
|
test al, 4
|
||||||
|
jnz .interrupt_from_secondary
|
||||||
|
.exit_notour:
|
||||||
|
xor eax, eax ; not our interrupt
|
||||||
|
ret
|
||||||
|
.interrupt_from_primary:
|
||||||
out dx, al ; clear Interrupt bit
|
out dx, al ; clear Interrupt bit
|
||||||
sub edx, 2
|
sub edx, 2
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
out dx, al ; clear Bus Master IDE Command register
|
out dx, al ; clear Bus Master IDE Command register
|
||||||
mov edx, [hdbase]
|
mov dx, [ecx+IDE_DATA.BAR0_val]
|
||||||
add edx, 7
|
add edx, 7
|
||||||
in al, dx ; read status register
|
in al, dx ; read status register
|
||||||
|
cmp [IDE_common_irq_param], 14
|
||||||
|
jz .raise
|
||||||
|
.exit_our:
|
||||||
|
mov al, 1
|
||||||
|
ret
|
||||||
|
.interrupt_from_secondary:
|
||||||
|
out dx, al ; clear Interrupt bit
|
||||||
|
sub edx, 2
|
||||||
|
xor eax, eax
|
||||||
|
out dx, al ; clear Bus Master IDE Command register
|
||||||
|
mov dx, [ecx+IDE_DATA.BAR2_val]
|
||||||
|
add edx, 7
|
||||||
|
in al, dx ; read status register
|
||||||
|
cmp [IDE_common_irq_param], 15
|
||||||
|
jnz .exit_our
|
||||||
|
.raise:
|
||||||
|
cmp ecx, [IDE_controller_pointer]
|
||||||
|
jnz .exit_our
|
||||||
|
pushad
|
||||||
mov eax, [eventPointer]
|
mov eax, [eventPointer]
|
||||||
mov ebx, [eventID]
|
mov ebx, [eventID]
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
call raise_event
|
call raise_event
|
||||||
popad
|
popad
|
||||||
popfd
|
|
||||||
mov al, 1 ; remove the interrupt request
|
mov al, 1 ; remove the interrupt request
|
||||||
ret
|
ret
|
||||||
@@:
|
|
||||||
popad
|
|
||||||
popfd
|
|
||||||
.exit:
|
|
||||||
xor eax, eax ; not our interrupt
|
|
||||||
ret
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------
|
||||||
proc clear_pci_ide_interrupts
|
|
||||||
mov esi, pcidev_list
|
|
||||||
align 4
|
|
||||||
.loop:
|
|
||||||
mov esi, [esi+PCIDEV.fd]
|
|
||||||
cmp esi, pcidev_list
|
|
||||||
jz .done
|
|
||||||
|
|
||||||
; cmp [esi+PCIDEV.class], 0x01018F
|
|
||||||
mov eax, [esi+PCIDEV.class]
|
|
||||||
shr eax, 4
|
|
||||||
cmp eax, 0x01018
|
|
||||||
jnz .loop
|
|
||||||
|
|
||||||
mov ah, [esi+PCIDEV.bus]
|
|
||||||
mov al, 2
|
|
||||||
mov bh, [esi+PCIDEV.devfn]
|
|
||||||
mov bl, 0x20
|
|
||||||
call pci_read_reg
|
|
||||||
|
|
||||||
and eax, 0FFFCh
|
|
||||||
mov edx, eax
|
|
||||||
add edx, 2
|
|
||||||
in al, dx
|
|
||||||
DEBUGF 1,'K : clear_pci_ide_interrupts: port[%x] = %x ',dx,al
|
|
||||||
out dx, al
|
|
||||||
in al, dx
|
|
||||||
DEBUGF 1,'-> %x; ',al
|
|
||||||
add edx, 8
|
|
||||||
in al, dx
|
|
||||||
DEBUGF 1,'port[%x] = %x ',dx,al
|
|
||||||
out dx, al
|
|
||||||
in al, dx
|
|
||||||
DEBUGF 1,'-> %x\n',al
|
|
||||||
jmp .loop
|
|
||||||
.done:
|
|
||||||
ret
|
|
||||||
endp
|
|
||||||
|
@ -747,12 +747,13 @@ proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @F
|
jnz @F
|
||||||
|
|
||||||
mov esi, msg_unresolved
|
; disable debug msg
|
||||||
call sys_msg_board_str
|
;mov esi, msg_unresolved
|
||||||
mov esi, edi
|
;call sys_msg_board_str
|
||||||
call sys_msg_board_str
|
;mov esi, edi
|
||||||
mov esi, msg_CR
|
;call sys_msg_board_str
|
||||||
call sys_msg_board_str
|
;mov esi, msg_CR
|
||||||
|
;call sys_msg_board_str
|
||||||
|
|
||||||
mov [retval], 0
|
mov [retval], 0
|
||||||
@@:
|
@@:
|
||||||
|
@ -119,13 +119,13 @@ __exports:
|
|||||||
usb_get_param, 'USBGetParam', \
|
usb_get_param, 'USBGetParam', \
|
||||||
usb_hc_func, 'USBHCFunc', \
|
usb_hc_func, 'USBHCFunc', \
|
||||||
\
|
\
|
||||||
NET_add_device, 'NetRegDev', \
|
net_add_device, 'NetRegDev', \
|
||||||
NET_remove_device, 'NetUnRegDev', \
|
net_remove_device, 'NetUnRegDev', \
|
||||||
NET_ptr_to_num, 'NetPtrToNum', \
|
net_ptr_to_num, 'NetPtrToNum', \
|
||||||
NET_link_changed, 'NetLinkChanged', \
|
net_link_changed, 'NetLinkChanged', \
|
||||||
ETH_input, 'EthInput', \
|
eth_input, 'EthInput', \
|
||||||
NET_BUFF_alloc, 'NetAlloc', \
|
net_buff_alloc, 'NetAlloc', \
|
||||||
NET_BUFF_free, 'NetFree', \
|
net_buff_free, 'NetFree', \
|
||||||
\
|
\
|
||||||
get_pcidev_list, 'GetPCIList', \
|
get_pcidev_list, 'GetPCIList', \
|
||||||
\
|
\
|
||||||
|
@ -203,6 +203,8 @@ align 16
|
|||||||
; Note: this still isn't 100% correct, because two IRQs can fire simultaneously,
|
; Note: this still isn't 100% correct, because two IRQs can fire simultaneously,
|
||||||
; the better way would be to find the correct IRQ, but I don't know how to do
|
; the better way would be to find the correct IRQ, but I don't know how to do
|
||||||
; this in that case.
|
; this in that case.
|
||||||
|
cmp ebp, 1
|
||||||
|
jz .fail
|
||||||
push ebp
|
push ebp
|
||||||
xor ebp, ebp
|
xor ebp, ebp
|
||||||
.try_other_irqs:
|
.try_other_irqs:
|
||||||
|
@ -144,13 +144,13 @@ align 4
|
|||||||
|
|
||||||
sub esp, sizeof.MUTEX_WAITER
|
sub esp, sizeof.MUTEX_WAITER
|
||||||
mov ebx, [TASK_BASE]
|
mov ebx, [TASK_BASE]
|
||||||
mov [ebx+TASKDATA.state], 1
|
|
||||||
mov [esp+MUTEX_WAITER.task], ebx
|
mov [esp+MUTEX_WAITER.task], ebx
|
||||||
lea esi, [ebp+FUTEX.wait_list]
|
lea esi, [ebp+FUTEX.wait_list]
|
||||||
|
|
||||||
list_add_tail esp, esi ;esp= new waiter, esi= list head
|
list_add_tail esp, esi ;esp= new waiter, esi= list head
|
||||||
|
|
||||||
.again:
|
.again:
|
||||||
|
mov [ebx+TASKDATA.state], 1
|
||||||
call change_task
|
call change_task
|
||||||
|
|
||||||
lock cmpxchg [ecx], edx
|
lock cmpxchg [ecx], edx
|
||||||
@ -199,7 +199,7 @@ align 4
|
|||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
mov [eax+TASKDATA.state], 5
|
mov [eax+TASKDATA.state], 5
|
||||||
|
|
||||||
mov [esp+MUTEX_WAITER.task], ebx
|
mov [esp+MUTEX_WAITER.task], eax
|
||||||
lea esi, [ebp+FUTEX.wait_list]
|
lea esi, [ebp+FUTEX.wait_list]
|
||||||
|
|
||||||
list_add_tail esp, esi ;esp= new waiter, esi= list head
|
list_add_tail esp, esi ;esp= new waiter, esi= list head
|
||||||
|
@ -89,10 +89,10 @@ v86_create:
|
|||||||
mov byte [0x504], 0x10
|
mov byte [0x504], 0x10
|
||||||
mov byte [0x505], 0xF4
|
mov byte [0x505], 0xF4
|
||||||
|
|
||||||
mov eax, 0x99000+PG_UWR
|
mov eax, 0x98000+PG_UWR
|
||||||
mov edi, page_tabs+0x99*4
|
mov edi, page_tabs+0x98*4
|
||||||
mov edx, 0x1000
|
mov edx, 0x1000
|
||||||
mov ecx, 7
|
mov ecx, 8
|
||||||
@@:
|
@@:
|
||||||
stosd
|
stosd
|
||||||
add eax, edx
|
add eax, edx
|
||||||
|
@ -378,9 +378,11 @@ Init_IDE_ATA_controller_2:
|
|||||||
je .end_set_interrupts
|
je .end_set_interrupts
|
||||||
|
|
||||||
push ecx
|
push ecx
|
||||||
stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
|
stdcall attach_int_handler, 14, IDE_irq_14_handler, ecx
|
||||||
|
pop ecx
|
||||||
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
|
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
|
||||||
stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
|
push ecx
|
||||||
|
stdcall attach_int_handler, 15, IDE_irq_15_handler, ecx
|
||||||
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
|
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
|
||||||
pop ecx
|
pop ecx
|
||||||
|
|
||||||
@ -400,20 +402,18 @@ Init_IDE_ATA_controller_2:
|
|||||||
; the IDE controller 01018f. For this reason, the interrupt handler
|
; the IDE controller 01018f. For this reason, the interrupt handler
|
||||||
; does not need to be installed if both channel IDE controller
|
; does not need to be installed if both channel IDE controller
|
||||||
; running in PIO mode.
|
; running in PIO mode.
|
||||||
|
|
||||||
|
; ...unfortunately, PCI interrupt can be shared with other devices
|
||||||
|
; which could enable it without consulting IDE code.
|
||||||
|
; So install the handler anyways and try to process
|
||||||
|
; even those interrupts which we are not expecting.
|
||||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||||
je .end_set_interrupts
|
je .end_set_interrupts
|
||||||
|
|
||||||
cmp [ecx+IDE_DATA.dma_hdd_channel_1], 0
|
|
||||||
jne @f
|
|
||||||
|
|
||||||
cmp [ecx+IDE_DATA.dma_hdd_channel_2], 0
|
|
||||||
je .end_set_interrupts
|
|
||||||
;--------------------------------------
|
|
||||||
@@:
|
|
||||||
mov ax, [ecx+IDE_DATA.Interrupt]
|
mov ax, [ecx+IDE_DATA.Interrupt]
|
||||||
movzx eax, al
|
movzx eax, al
|
||||||
push ecx
|
push ecx
|
||||||
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
|
stdcall attach_int_handler, eax, IDE_common_irq_handler, ecx
|
||||||
pop ecx
|
pop ecx
|
||||||
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [ecx+IDE_DATA.Interrupt]:1, eax
|
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [ecx+IDE_DATA.Interrupt]:1, eax
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1808,6 +1808,8 @@ fat_Read:
|
|||||||
mov ebx, [ebx+16] ; buffer
|
mov ebx, [ebx+16] ; buffer
|
||||||
push ebx
|
push ebx
|
||||||
push 0
|
push 0
|
||||||
|
test ecx, ecx
|
||||||
|
jz .done
|
||||||
mov eax, [edi+28]
|
mov eax, [edi+28]
|
||||||
sub eax, edx
|
sub eax, edx
|
||||||
jb .fileEnd
|
jb .fileEnd
|
||||||
@ -1920,7 +1922,7 @@ fat_Read:
|
|||||||
jnz .noaccess3
|
jnz .noaccess3
|
||||||
pop ecx
|
pop ecx
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
jcxz .done
|
jecxz .done
|
||||||
jmp .alignedCluster
|
jmp .alignedCluster
|
||||||
.readEnd:
|
.readEnd:
|
||||||
add ecx, edi
|
add ecx, edi
|
||||||
|
@ -20,6 +20,7 @@ ERROR_FAT_TABLE = 9 ;deprecated
|
|||||||
ERROR_FS_FAIL = 9
|
ERROR_FS_FAIL = 9
|
||||||
ERROR_ACCESS_DENIED = 10
|
ERROR_ACCESS_DENIED = 10
|
||||||
ERROR_DEVICE = 11
|
ERROR_DEVICE = 11
|
||||||
|
ERROR_OUT_OF_MEMORY = 12
|
||||||
|
|
||||||
image_of_eax EQU esp+32
|
image_of_eax EQU esp+32
|
||||||
image_of_ebx EQU esp+20
|
image_of_ebx EQU esp+20
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
||||||
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
@ -8,10 +8,6 @@
|
|||||||
|
|
||||||
$Revision$
|
$Revision$
|
||||||
|
|
||||||
;==============================================================================
|
|
||||||
;///// public functions ///////////////////////////////////////////////////////
|
|
||||||
;==============================================================================
|
|
||||||
|
|
||||||
button.MAX_BUTTONS = 4095
|
button.MAX_BUTTONS = 4095
|
||||||
|
|
||||||
struct SYS_BUTTON
|
struct SYS_BUTTON
|
||||||
@ -25,12 +21,11 @@ struct SYS_BUTTON
|
|||||||
dw ?
|
dw ?
|
||||||
ends
|
ends
|
||||||
|
|
||||||
align 4
|
;---------------------------------------------------------------
|
||||||
;------------------------------------------------------------------------------
|
syscall_button: ;////////////// system function 8 //////////////
|
||||||
syscall_button: ;///// system function 8 //////////////////////////////////////
|
;---------------------------------------------------------------
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? Define/undefine GUI button object
|
;? Define/undefine GUI button object
|
||||||
;------------------------------------------------------------------------------
|
;---------------------------------------------------------------
|
||||||
;; Define button:
|
;; Define button:
|
||||||
;> ebx = pack[16(x), 16(width)]
|
;> ebx = pack[16(x), 16(width)]
|
||||||
;> ecx = pack[16(y), 16(height)]
|
;> ecx = pack[16(y), 16(height)]
|
||||||
@ -40,12 +35,12 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
;> 6 (30) = don't draw button
|
;> 6 (30) = don't draw button
|
||||||
;> 5 (29) = don't draw button frame when pressed
|
;> 5 (29) = don't draw button frame when pressed
|
||||||
;> esi = button color
|
;> esi = button color
|
||||||
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
;; Undefine button:
|
;; Undefine button:
|
||||||
;> edx = pack[8(flags), 24(button identifier)]
|
;> edx = pack[8(flags), 24(button identifier)]
|
||||||
;> flags bits:
|
;> flags bits:
|
||||||
;> 7 (31) = 1
|
;> 7 (31) = 1
|
||||||
;------------------------------------------------------------------------------
|
;---------------------------------------------------------------
|
||||||
; do we actually need to undefine the button?
|
; do we actually need to undefine the button?
|
||||||
test edx, 0x80000000
|
test edx, 0x80000000
|
||||||
jnz .remove_button
|
jnz .remove_button
|
||||||
@ -74,13 +69,12 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
; basic checks passed, define the button
|
; basic checks passed, define the button
|
||||||
push ebx ecx edx
|
|
||||||
inc eax
|
inc eax
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
shl eax, 4
|
shl eax, 4
|
||||||
add edi, eax
|
add edi, eax
|
||||||
; NOTE: this code doesn't rely on SYS_BUTTON struct, please revise it
|
; NOTE: this code doesn't rely on SYS_BUTTON struct,
|
||||||
; if you change something
|
; please revise it, if you change something.
|
||||||
mov ax, [CURRENT_TASK]
|
mov ax, [CURRENT_TASK]
|
||||||
stosw
|
stosw
|
||||||
mov ax, dx
|
mov ax, dx
|
||||||
@ -94,18 +88,52 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
mov eax, edx
|
mov eax, edx
|
||||||
shr eax, 16
|
shr eax, 16
|
||||||
stosw ; button id number: bits 16-31
|
stosw ; button id number: bits 16-31
|
||||||
pop edx ecx ebx
|
|
||||||
|
|
||||||
; do we also need to draw the button?
|
; do we also need to draw the button?
|
||||||
test edx, 0x40000000
|
test edx, 0x40000000
|
||||||
jnz .exit
|
jnz .exit
|
||||||
|
|
||||||
; draw button body
|
and esi, 0xFFFFFF
|
||||||
|
xor edi, edi
|
||||||
|
push ebx ecx esi
|
||||||
|
dec cx
|
||||||
|
dec cx
|
||||||
|
cmp [buttontype], 1
|
||||||
|
jnz .draw
|
||||||
|
cmp cx, 65
|
||||||
|
jnc .draw
|
||||||
|
|
||||||
pushad
|
; calculate gradient data
|
||||||
|
mov eax, esi
|
||||||
|
shl eax, 8
|
||||||
|
mov edx, 3
|
||||||
|
.calculate:
|
||||||
|
rol eax, 8
|
||||||
|
shl al, 1
|
||||||
|
jnc @f
|
||||||
|
neg al
|
||||||
|
jnz @f
|
||||||
|
mov al, 64
|
||||||
|
@@:
|
||||||
|
cmp al, 65
|
||||||
|
jc @f
|
||||||
|
mov al, 64
|
||||||
|
@@:
|
||||||
|
div cl
|
||||||
|
shl ax, 8
|
||||||
|
dec edx
|
||||||
|
jnz .calculate
|
||||||
|
mov dl, cl
|
||||||
|
dec edx
|
||||||
|
shr edx, 1
|
||||||
|
shr eax, 8
|
||||||
|
mov edi, eax
|
||||||
|
mul edx
|
||||||
|
add esi, eax
|
||||||
|
|
||||||
; calculate window-relative coordinates
|
.draw: ; calculate window-relative coordinates
|
||||||
movzx edi, cx
|
movzx ebp, cx
|
||||||
|
dec ebp
|
||||||
shr ebx, 16
|
shr ebx, 16
|
||||||
shr ecx, 16
|
shr ecx, 16
|
||||||
mov eax, [TASK_BASE]
|
mov eax, [TASK_BASE]
|
||||||
@ -113,110 +141,73 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
|
|||||||
add ecx, [eax - twdw + WDATA.box.top]
|
add ecx, [eax - twdw + WDATA.box.top]
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
inc eax
|
inc eax
|
||||||
shl eax, 16
|
|
||||||
mov ax, bx
|
|
||||||
add ax, word[esp + 16]
|
|
||||||
dec ax
|
|
||||||
mov ebx, ecx
|
|
||||||
shl ebx, 16
|
|
||||||
mov bx, cx
|
|
||||||
|
|
||||||
; calculate initial color
|
|
||||||
mov ecx, esi
|
|
||||||
cmp [buttontype], 0
|
|
||||||
je @f
|
|
||||||
call button._.incecx2
|
|
||||||
|
|
||||||
; set button height counter
|
|
||||||
@@:
|
|
||||||
mov edx, edi
|
|
||||||
add ebx, 0x00010001
|
|
||||||
dec edx
|
|
||||||
|
|
||||||
.next_line:
|
|
||||||
call button._.button_dececx
|
|
||||||
push edi
|
|
||||||
xor edi, edi
|
|
||||||
; call [draw_line]
|
|
||||||
call __sys_draw_line
|
|
||||||
pop edi
|
|
||||||
add ebx, 0x00010001
|
|
||||||
dec edx
|
|
||||||
jnz .next_line
|
|
||||||
|
|
||||||
popad
|
|
||||||
|
|
||||||
; draw button frame
|
|
||||||
|
|
||||||
push ebx ecx
|
|
||||||
|
|
||||||
; calculate window-relative coordinates
|
|
||||||
shr ebx, 16
|
|
||||||
shr ecx, 16
|
|
||||||
mov eax, [TASK_BASE]
|
|
||||||
add ebx, [eax - twdw + WDATA.box.left]
|
|
||||||
add ecx, [eax - twdw + WDATA.box.top]
|
|
||||||
|
|
||||||
; top border
|
|
||||||
mov eax, ebx
|
|
||||||
shl eax, 16
|
|
||||||
mov ax, bx
|
|
||||||
add ax, [esp + 4]
|
|
||||||
mov ebx, ecx
|
|
||||||
shl ebx, 16
|
|
||||||
mov bx, cx
|
|
||||||
push ebx
|
|
||||||
xor edi, edi
|
|
||||||
mov ecx, esi
|
|
||||||
call button._.incecx
|
|
||||||
; call [draw_line]
|
|
||||||
call __sys_draw_line
|
|
||||||
|
|
||||||
; bottom border
|
|
||||||
movzx edx, word[esp + 4 + 0]
|
|
||||||
add ebx, edx
|
|
||||||
shl edx, 16
|
|
||||||
add ebx, edx
|
|
||||||
mov ecx, esi
|
|
||||||
call button._.dececx
|
|
||||||
; call [draw_line]
|
|
||||||
call __sys_draw_line
|
|
||||||
|
|
||||||
; left border
|
|
||||||
pop ebx
|
|
||||||
push edx
|
|
||||||
mov edx, eax
|
|
||||||
shr edx, 16
|
|
||||||
mov ax, dx
|
|
||||||
mov edx, ebx
|
mov edx, ebx
|
||||||
shr edx, 16
|
add dx, [esp+8]
|
||||||
mov bx, dx
|
dec edx
|
||||||
add bx, [esp + 4 + 0]
|
mov ebx, ecx
|
||||||
pop edx
|
|
||||||
mov ecx, esi
|
mov ecx, esi
|
||||||
call button._.incecx
|
shr ecx, 1
|
||||||
; call [draw_line]
|
and cx, 7F7Fh
|
||||||
dec ebx
|
push esi
|
||||||
call __sys_draw_line
|
mov esi, edi
|
||||||
|
xor edi, edi
|
||||||
; right border
|
call hline ; top border
|
||||||
mov dx, [esp + 4]
|
inc ebx
|
||||||
add ax, dx
|
or ecx, 808080h
|
||||||
shl edx, 16
|
call hline ; top light line
|
||||||
add eax, edx
|
pop ecx
|
||||||
add ebx, 0x00010000
|
inc ebx
|
||||||
mov ecx, esi
|
.next_line:
|
||||||
call button._.dececx
|
call hline ; button body
|
||||||
; call [draw_line]
|
inc ebx
|
||||||
call __sys_draw_line
|
sub ecx, esi
|
||||||
|
dec ebp
|
||||||
|
jnz .next_line
|
||||||
|
shr ecx, 2
|
||||||
|
and cx, 3F3Fh
|
||||||
|
mov ebp, ecx
|
||||||
|
shl ecx, 1
|
||||||
|
add ecx, ebp
|
||||||
|
call hline ; bottom dark line
|
||||||
|
inc ebx
|
||||||
|
sub ecx, ebp
|
||||||
|
call hline ; bottom border
|
||||||
|
pop ecx
|
||||||
|
shr ecx, 1
|
||||||
|
inc edx
|
||||||
|
push edx
|
||||||
|
mov edx, ebx
|
||||||
|
sub bx, [esp+4]
|
||||||
|
dec edx
|
||||||
|
inc ebx
|
||||||
|
cmp [buttontype], 0
|
||||||
|
jnz @f
|
||||||
|
dec edx
|
||||||
|
or ecx, 808080h
|
||||||
|
call vline ; left light line
|
||||||
|
inc edx
|
||||||
|
@@:
|
||||||
|
and ecx, 7F7F7Fh
|
||||||
|
dec eax
|
||||||
|
call vline ; left border
|
||||||
|
pop eax
|
||||||
|
call vline ; right border
|
||||||
|
cmp [buttontype], 0
|
||||||
|
jnz @f
|
||||||
|
mov ebp, ecx
|
||||||
|
shr ecx, 1
|
||||||
|
and cx, 7F7Fh
|
||||||
|
add ecx, ebp
|
||||||
|
dec eax
|
||||||
|
inc ebx
|
||||||
|
call vline ; right dark line
|
||||||
|
@@:
|
||||||
pop ecx ebx
|
pop ecx ebx
|
||||||
|
.exit:
|
||||||
.exit:
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; FIXME: mutex needed
|
; FIXME: mutex needed
|
||||||
syscall_button.remove_button:
|
.remove_button:
|
||||||
and edx, 0x00ffffff
|
and edx, 0x00ffffff
|
||||||
mov edi, [BTN_ADDR]
|
mov edi, [BTN_ADDR]
|
||||||
mov ebx, [edi]
|
mov ebx, [edi]
|
||||||
@ -227,7 +218,7 @@ syscall_button.remove_button:
|
|||||||
add ecx, -sizeof.SYS_BUTTON
|
add ecx, -sizeof.SYS_BUTTON
|
||||||
add esi, sizeof.SYS_BUTTON
|
add esi, sizeof.SYS_BUTTON
|
||||||
|
|
||||||
.next_button:
|
.next_button:
|
||||||
dec ebx
|
dec ebx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
@ -256,98 +247,28 @@ syscall_button.remove_button:
|
|||||||
pop ebx
|
pop ebx
|
||||||
jmp .next_button
|
jmp .next_button
|
||||||
|
|
||||||
.exit:
|
;---------------------------------------------------------------
|
||||||
ret
|
sys_button_activate_handler:
|
||||||
|
sys_button_deactivate_handler:
|
||||||
align 4
|
;---------------------------------------------------------------
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
sys_button_activate_handler: ;/////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;> eax = pack[8(process slot), 24(button id)]
|
;> eax = pack[8(process slot), 24(button id)]
|
||||||
;> ebx = pack[16(button x coord), 16(button y coord)]
|
;> ebx = pack[16(button x coord), 16(button y coord)]
|
||||||
;> cl = mouse button mask this system button was pressed with
|
;> cl = mouse button mask this system button was pressed with
|
||||||
;------------------------------------------------------------------------------
|
;---------------------------------------------------------------
|
||||||
call button._.find_button
|
; find system button by specified process slot, id and coordinates
|
||||||
or eax, eax
|
|
||||||
jz .exit
|
|
||||||
|
|
||||||
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
|
||||||
call button._.negative_button
|
|
||||||
|
|
||||||
.exit:
|
|
||||||
ret
|
|
||||||
|
|
||||||
align 4
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
sys_button_deactivate_handler: ;///////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;> eax = pack[8(process slot), 24(button id)]
|
|
||||||
;> ebx = pack[16(button x coord), 16(button y coord)]
|
|
||||||
;> cl = mouse button mask this system button was pressed with
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
call button._.find_button
|
|
||||||
or eax, eax
|
|
||||||
jz .exit
|
|
||||||
|
|
||||||
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
|
||||||
call button._.negative_button
|
|
||||||
|
|
||||||
.exit:
|
|
||||||
ret
|
|
||||||
|
|
||||||
align 4
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
sys_button_perform_handler: ;//////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;> eax = pack[8(process slot), 24(button id)]
|
|
||||||
;> ebx = pack[16(button x coord), 16(button y coord)]
|
|
||||||
;> cl = mouse button mask this system button was pressed with
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
shl eax, 8
|
|
||||||
mov al, cl
|
|
||||||
movzx ebx, byte[BTN_COUNT]
|
|
||||||
mov [BTN_BUFF + ebx * 4], eax
|
|
||||||
inc bl
|
|
||||||
mov [BTN_COUNT], bl
|
|
||||||
ret
|
|
||||||
|
|
||||||
;==============================================================================
|
|
||||||
;///// private functions //////////////////////////////////////////////////////
|
|
||||||
;==============================================================================
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
button._.find_button: ;////////////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? Find system button by specified process slot, id and coordinates
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;> eax = pack[8(process slot), 24(button id)] or 0
|
|
||||||
;> ebx = pack[16(button x coord), 16(button y coord)]
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;< eax = pointer to SYS_BUTTON struct or 0
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
push ecx edx esi edi
|
push ecx edx esi edi
|
||||||
|
|
||||||
mov edx, eax
|
mov edx, eax
|
||||||
shr edx, 24
|
shr edx, 24
|
||||||
and eax, 0x0ffffff
|
and eax, 0x0ffffff
|
||||||
|
|
||||||
mov edi, [BTN_ADDR]
|
mov edi, [BTN_ADDR]
|
||||||
mov ecx, [edi]
|
mov ecx, [edi]
|
||||||
imul esi, ecx, sizeof.SYS_BUTTON
|
imul esi, ecx, sizeof.SYS_BUTTON
|
||||||
add esi, edi
|
add esi, edi
|
||||||
inc ecx
|
inc ecx
|
||||||
add esi, sizeof.SYS_BUTTON
|
add esi, sizeof.SYS_BUTTON
|
||||||
|
.next_button:
|
||||||
.next_button:
|
|
||||||
dec ecx
|
dec ecx
|
||||||
jz .not_found
|
jz .popexit
|
||||||
|
|
||||||
add esi, -sizeof.SYS_BUTTON
|
add esi, -sizeof.SYS_BUTTON
|
||||||
|
|
||||||
; does it belong to our process?
|
; does it belong to our process?
|
||||||
@ -367,147 +288,58 @@ button._.find_button: ;////////////////////////////////////////////////////////
|
|||||||
cmp ebx, edi
|
cmp ebx, edi
|
||||||
jne .next_button
|
jne .next_button
|
||||||
|
|
||||||
; okay, return it
|
|
||||||
mov eax, esi
|
mov eax, esi
|
||||||
jmp .exit
|
|
||||||
|
|
||||||
.not_found:
|
|
||||||
xor eax, eax
|
|
||||||
|
|
||||||
.exit:
|
|
||||||
pop edi esi edx ecx
|
pop edi esi edx ecx
|
||||||
ret
|
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
; display button border on press?
|
||||||
button._.dececx: ;/////////////////////////////////////////////////////////////
|
bt ebx, 29
|
||||||
;------------------------------------------------------------------------------
|
jc .exit
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
sub cl, 0x20
|
|
||||||
jnc @f
|
|
||||||
xor cl, cl
|
|
||||||
@@:
|
|
||||||
sub ch, 0x20
|
|
||||||
jnc @f
|
|
||||||
xor ch, ch
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
sub cl, 0x20
|
|
||||||
jnc @f
|
|
||||||
xor cl, cl
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
ret
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
button._.incecx: ;/////////////////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
add cl, 0x20
|
|
||||||
jnc @f
|
|
||||||
or cl, -1
|
|
||||||
@@:
|
|
||||||
add ch, 0x20
|
|
||||||
jnc @f
|
|
||||||
or ch, -1
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
add cl, 0x20
|
|
||||||
jnc @f
|
|
||||||
or cl, -1
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
ret
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
button._.incecx2: ;////////////////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
add cl, 0x14
|
|
||||||
jnc @f
|
|
||||||
or cl, -1
|
|
||||||
@@:
|
|
||||||
add ch, 0x14
|
|
||||||
jnc @f
|
|
||||||
or ch, -1
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
add cl, 0x14
|
|
||||||
jnc @f
|
|
||||||
or cl, -1
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
ret
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
button._.button_dececx: ;//////////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? <description>
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
cmp [buttontype], 1
|
|
||||||
jne .finish
|
|
||||||
|
|
||||||
push eax
|
|
||||||
mov al, 1
|
|
||||||
cmp edi, 20
|
|
||||||
jg @f
|
|
||||||
mov al, 2
|
|
||||||
|
|
||||||
@@:
|
|
||||||
sub cl, al
|
|
||||||
jnc @f
|
|
||||||
xor cl, cl
|
|
||||||
@@:
|
|
||||||
sub ch, al
|
|
||||||
jnc @f
|
|
||||||
xor ch, ch
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
sub cl, al
|
|
||||||
jnc @f
|
|
||||||
xor cl, cl
|
|
||||||
@@:
|
|
||||||
rol ecx, 16
|
|
||||||
|
|
||||||
pop eax
|
|
||||||
|
|
||||||
.finish:
|
|
||||||
ret
|
|
||||||
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
button._.negative_button: ;////////////////////////////////////////////////////
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
;? Invert system button border
|
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
; if requested, do not display button border on press.
|
|
||||||
test ebx, 0x20000000
|
|
||||||
jnz .exit
|
|
||||||
|
|
||||||
|
; invert system button border
|
||||||
pushad
|
pushad
|
||||||
|
mov esi, eax
|
||||||
xchg esi, eax
|
mov edi, ebx
|
||||||
|
|
||||||
movzx ecx, [esi + SYS_BUTTON.pslot]
|
movzx ecx, [esi + SYS_BUTTON.pslot]
|
||||||
shl ecx, 5
|
shl ecx, 5
|
||||||
add ecx, window_data
|
add ecx, window_data
|
||||||
|
|
||||||
mov eax, dword[esi + SYS_BUTTON.left]
|
mov eax, dword[esi + SYS_BUTTON.left]
|
||||||
mov ebx, dword[esi + SYS_BUTTON.top]
|
mov ebx, dword[esi + SYS_BUTTON.top]
|
||||||
add eax, [ecx + WDATA.box.left]
|
add eax, [ecx + WDATA.box.left]
|
||||||
add ebx, [ecx + WDATA.box.top]
|
add ebx, [ecx + WDATA.box.top]
|
||||||
push eax ebx
|
mov ecx, eax
|
||||||
pop edx ecx
|
mov edx, ebx
|
||||||
|
bt edi, 30
|
||||||
|
jc @f
|
||||||
|
inc ax
|
||||||
|
inc bx
|
||||||
|
dec cx
|
||||||
|
dec dx
|
||||||
|
@@:
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
rol ebx, 16
|
rol ebx, 16
|
||||||
add ax, cx
|
add ax, cx
|
||||||
add bx, dx
|
add bx, dx
|
||||||
|
mov esi, 1000000h
|
||||||
mov esi, 0x01000000
|
|
||||||
call draw_rectangle.forced
|
call draw_rectangle.forced
|
||||||
|
|
||||||
popad
|
popad
|
||||||
|
.exit:
|
||||||
.exit:
|
ret
|
||||||
|
.popexit:
|
||||||
|
pop edi esi edx ecx
|
||||||
|
ret
|
||||||
|
|
||||||
|
;---------------------------------------------------------------
|
||||||
|
sys_button_perform_handler:
|
||||||
|
;---------------------------------------------------------------
|
||||||
|
;> eax = pack[8(process slot), 24(button id)]
|
||||||
|
;> ebx = pack[16(button x coord), 16(button y coord)]
|
||||||
|
;> cl = mouse button mask this system button was pressed with
|
||||||
|
;---------------------------------------------------------------
|
||||||
|
shl eax, 8
|
||||||
|
mov al, cl
|
||||||
|
movzx ebx, byte[BTN_COUNT]
|
||||||
|
mov [BTN_BUFF + ebx * 4], eax
|
||||||
|
inc bl
|
||||||
|
mov [BTN_COUNT], bl
|
||||||
ret
|
ret
|
||||||
|
@ -241,7 +241,7 @@ deltaToScreen = 28
|
|||||||
.drawPicture:
|
.drawPicture:
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
repz scasd
|
repz scasd
|
||||||
jcxz @f
|
jecxz @f
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
sub eax, ecx
|
sub eax, ecx
|
||||||
push ecx
|
push ecx
|
||||||
|
@ -101,7 +101,6 @@ parse_skin_data:
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
cld
|
cld
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
mov ebx, [ebp+SKIN_HEADER.params]
|
mov ebx, [ebp+SKIN_HEADER.params]
|
||||||
add ebx, [skin_data]
|
add ebx, [skin_data]
|
||||||
mov eax, [ebx+SKIN_PARAMS.skin_height]
|
mov eax, [ebx+SKIN_PARAMS.skin_height]
|
||||||
@ -127,11 +126,8 @@ parse_skin_data:
|
|||||||
mov dword[_skinmargins+0], eax
|
mov dword[_skinmargins+0], eax
|
||||||
mov eax, dword[ebx+SKIN_PARAMS.margin.bottom]
|
mov eax, dword[ebx+SKIN_PARAMS.margin.bottom]
|
||||||
mov dword[_skinmargins+4], eax
|
mov dword[_skinmargins+4], eax
|
||||||
|
|
||||||
mov ebx, [ebp+SKIN_HEADER.bitmaps]
|
mov ebx, [ebp+SKIN_HEADER.bitmaps]
|
||||||
add ebx, [skin_data]
|
add ebx, [skin_data]
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
.lp1:
|
.lp1:
|
||||||
cmp dword[ebx], 0
|
cmp dword[ebx], 0
|
||||||
je .end_bitmaps
|
je .end_bitmaps
|
||||||
@ -142,11 +138,8 @@ align 4
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edx, skin_active.left.data
|
mov edx, skin_active.left.data
|
||||||
or ecx, ecx
|
or ecx, ecx
|
||||||
jnz @f
|
jnz .next_bitmap
|
||||||
mov edx, skin_inactive.left.data
|
mov edx, skin_inactive.left.data
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
|
||||||
jmp .next_bitmap
|
jmp .next_bitmap
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -159,11 +152,8 @@ align 4
|
|||||||
neg eax
|
neg eax
|
||||||
mov edx, skin_active.oper.data
|
mov edx, skin_active.oper.data
|
||||||
or ecx, ecx
|
or ecx, ecx
|
||||||
jnz @f
|
jnz .next_bitmap
|
||||||
mov edx, skin_inactive.oper.data
|
mov edx, skin_inactive.oper.data
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
|
||||||
jmp .next_bitmap
|
jmp .next_bitmap
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -173,12 +163,9 @@ align 4
|
|||||||
mov eax, [skin_active.left.width]
|
mov eax, [skin_active.left.width]
|
||||||
mov edx, skin_active.base.data
|
mov edx, skin_active.base.data
|
||||||
or ecx, ecx
|
or ecx, ecx
|
||||||
jnz @f
|
jnz .next_bitmap
|
||||||
mov eax, [skin_inactive.left.width]
|
mov eax, [skin_inactive.left.width]
|
||||||
mov edx, skin_inactive.base.data
|
mov edx, skin_inactive.base.data
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
|
||||||
jmp .next_bitmap
|
jmp .next_bitmap
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
align 4
|
align 4
|
||||||
@ -202,8 +189,6 @@ align 4
|
|||||||
.end_bitmaps:
|
.end_bitmaps:
|
||||||
mov ebx, [ebp+SKIN_HEADER.buttons]
|
mov ebx, [ebp+SKIN_HEADER.buttons]
|
||||||
add ebx, [skin_data]
|
add ebx, [skin_data]
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
.lp2:
|
.lp2:
|
||||||
cmp dword[ebx], 0
|
cmp dword[ebx], 0
|
||||||
je .end_buttons
|
je .end_buttons
|
||||||
@ -245,13 +230,10 @@ align 4
|
|||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
align 4
|
align 4
|
||||||
drawwindow_IV_caption:
|
drawwindow_IV_caption:
|
||||||
|
|
||||||
mov ebp, skin_active
|
mov ebp, skin_active
|
||||||
or al, al
|
or al, al
|
||||||
jnz @f
|
jnz @f
|
||||||
mov ebp, skin_inactive
|
mov ebp, skin_inactive
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
mov esi, [esp+4]
|
mov esi, [esp+4]
|
||||||
mov eax, [esi+WDATA.box.width] ; window width
|
mov eax, [esi+WDATA.box.width] ; window width
|
||||||
@ -260,13 +242,10 @@ align 4
|
|||||||
mov ecx, [ebp+SKIN_DATA.left.width]
|
mov ecx, [ebp+SKIN_DATA.left.width]
|
||||||
shl ecx, 16
|
shl ecx, 16
|
||||||
add ecx, [_skinh]
|
add ecx, [_skinh]
|
||||||
|
|
||||||
mov ebx, [ebp+SKIN_DATA.left.data]
|
mov ebx, [ebp+SKIN_DATA.left.data]
|
||||||
or ebx, ebx
|
or ebx, ebx
|
||||||
jz @f
|
jz @f
|
||||||
call sys_putimage.forced
|
call sys_putimage.forced
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
mov esi, [esp+4]
|
mov esi, [esp+4]
|
||||||
mov eax, [esi+WDATA.box.width]
|
mov eax, [esi+WDATA.box.width]
|
||||||
@ -278,9 +257,7 @@ align 4
|
|||||||
mov ecx, [ebp+SKIN_DATA.base.width]
|
mov ecx, [ebp+SKIN_DATA.base.width]
|
||||||
jecxz .non_base
|
jecxz .non_base
|
||||||
div ecx
|
div ecx
|
||||||
|
|
||||||
inc eax
|
inc eax
|
||||||
|
|
||||||
mov ebx, [ebp+SKIN_DATA.base.data]
|
mov ebx, [ebp+SKIN_DATA.base.data]
|
||||||
mov ecx, [ebp+SKIN_DATA.base.width]
|
mov ecx, [ebp+SKIN_DATA.base.width]
|
||||||
shl ecx, 16
|
shl ecx, 16
|
||||||
@ -288,45 +265,33 @@ align 4
|
|||||||
mov edx, [ebp+SKIN_DATA.base.left]
|
mov edx, [ebp+SKIN_DATA.base.left]
|
||||||
sub edx, [ebp+SKIN_DATA.base.width]
|
sub edx, [ebp+SKIN_DATA.base.width]
|
||||||
shl edx, 16
|
shl edx, 16
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
.baseskinloop:
|
.baseskinloop:
|
||||||
shr edx, 16
|
shr edx, 16
|
||||||
add edx, [ebp+SKIN_DATA.base.width]
|
add edx, [ebp+SKIN_DATA.base.width]
|
||||||
shl edx, 16
|
shl edx, 16
|
||||||
|
|
||||||
push eax ebx ecx edx
|
push eax ebx ecx edx
|
||||||
|
|
||||||
or ebx, ebx
|
or ebx, ebx
|
||||||
jz @f
|
jz @f
|
||||||
call sys_putimage.forced
|
call sys_putimage.forced
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
pop edx ecx ebx eax
|
pop edx ecx ebx eax
|
||||||
|
|
||||||
dec eax
|
dec eax
|
||||||
jnz .baseskinloop
|
jnz .baseskinloop
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
.non_base:
|
.non_base:
|
||||||
|
|
||||||
mov esi, [esp+4]
|
mov esi, [esp+4]
|
||||||
mov edx, [esi+WDATA.box.width]
|
mov edx, [esi+WDATA.box.width]
|
||||||
sub edx, [ebp+SKIN_DATA.oper.width]
|
sub edx, [ebp+SKIN_DATA.oper.width]
|
||||||
inc edx
|
inc edx
|
||||||
shl edx, 16
|
shl edx, 16
|
||||||
mov ebx, [ebp+SKIN_DATA.oper.data]
|
mov ebx, [ebp+SKIN_DATA.oper.data]
|
||||||
|
|
||||||
mov ecx, [ebp+SKIN_DATA.oper.width]
|
mov ecx, [ebp+SKIN_DATA.oper.width]
|
||||||
shl ecx, 16
|
shl ecx, 16
|
||||||
add ecx, [_skinh]
|
add ecx, [_skinh]
|
||||||
|
|
||||||
or ebx, ebx
|
or ebx, ebx
|
||||||
jz @f
|
jz @f
|
||||||
call sys_putimage.forced
|
call sys_putimage.forced
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
;------------------------------------------------------------------------------
|
;------------------------------------------------------------------------------
|
||||||
@ -334,17 +299,12 @@ align 4
|
|||||||
drawwindow_IV:
|
drawwindow_IV:
|
||||||
;param1 - aw_yes
|
;param1 - aw_yes
|
||||||
pusha
|
pusha
|
||||||
|
|
||||||
push edx
|
push edx
|
||||||
|
|
||||||
mov edi, edx
|
mov edi, edx
|
||||||
|
|
||||||
mov ebp, skin_active
|
mov ebp, skin_active
|
||||||
cmp byte [esp+32+4+4], 0
|
cmp byte [esp+32+4+4], 0
|
||||||
jne @f
|
jne @f
|
||||||
mov ebp, skin_inactive
|
mov ebp, skin_inactive
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
mov eax, [edi+WDATA.box.left]
|
mov eax, [edi+WDATA.box.left]
|
||||||
shl eax, 16
|
shl eax, 16
|
||||||
@ -362,8 +322,6 @@ align 4
|
|||||||
rol ebx, 16
|
rol ebx, 16
|
||||||
call draw_rectangle
|
call draw_rectangle
|
||||||
mov ecx, 3
|
mov ecx, 3
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
_dw3l:
|
_dw3l:
|
||||||
add eax, 1*65536-1
|
add eax, 1*65536-1
|
||||||
add ebx, 0*65536-1
|
add ebx, 0*65536-1
|
||||||
@ -387,8 +345,6 @@ _dw3l:
|
|||||||
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
|
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
|
||||||
jnz @f
|
jnz @f
|
||||||
call draw_rectangle
|
call draw_rectangle
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
@@:
|
@@:
|
||||||
mov eax, [skin_data]
|
mov eax, [skin_data]
|
||||||
cmp [eax], dword 'SKIN'
|
cmp [eax], dword 'SKIN'
|
||||||
@ -400,7 +356,6 @@ align 4
|
|||||||
inc ecx
|
inc ecx
|
||||||
mov edx, [_skinh]
|
mov edx, [_skinh]
|
||||||
mov edi, [common_colours+4]; standard grab color
|
mov edi, [common_colours+4]; standard grab color
|
||||||
; call [drawbar]
|
|
||||||
call vesa20_drawbar
|
call vesa20_drawbar
|
||||||
jmp draw_clientbar
|
jmp draw_clientbar
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
@ -408,11 +363,8 @@ align 4
|
|||||||
@@:
|
@@:
|
||||||
mov al, [esp+32+4+4]
|
mov al, [esp+32+4+4]
|
||||||
call drawwindow_IV_caption
|
call drawwindow_IV_caption
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
draw_clientbar:
|
draw_clientbar:
|
||||||
mov esi, [esp]
|
mov esi, [esp]
|
||||||
|
|
||||||
mov edx, [esi+WDATA.box.top] ; WORK AREA
|
mov edx, [esi+WDATA.box.top] ; WORK AREA
|
||||||
add edx, 21+5
|
add edx, 21+5
|
||||||
mov ebx, [esi+WDATA.box.top]
|
mov ebx, [esi+WDATA.box.top]
|
||||||
@ -428,10 +380,7 @@ draw_clientbar:
|
|||||||
mov edi, [esi+WDATA.cl_workarea]
|
mov edi, [esi+WDATA.cl_workarea]
|
||||||
test edi, 0x40000000
|
test edi, 0x40000000
|
||||||
jnz _noinside2
|
jnz _noinside2
|
||||||
; call [drawbar]
|
|
||||||
call vesa20_drawbar
|
call vesa20_drawbar
|
||||||
;--------------------------------------
|
|
||||||
align 4
|
|
||||||
_noinside2:
|
_noinside2:
|
||||||
mov eax, [skin_data]
|
mov eax, [skin_data]
|
||||||
cmp [eax], dword 'SKIN'
|
cmp [eax], dword 'SKIN'
|
||||||
@ -443,39 +392,30 @@ _noinside2:
|
|||||||
jge no_skin_add_button
|
jge no_skin_add_button
|
||||||
inc eax
|
inc eax
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
|
|
||||||
shl eax, 4
|
shl eax, 4
|
||||||
add eax, edi
|
add eax, edi
|
||||||
|
|
||||||
mov bx, [CURRENT_TASK]
|
mov bx, [CURRENT_TASK]
|
||||||
mov [eax], bx
|
mov [eax], bx
|
||||||
|
mov word [eax+2], 1 ; button id
|
||||||
add eax, 2 ; save button id number
|
|
||||||
mov bx, 1
|
|
||||||
mov [eax], bx
|
|
||||||
add eax, 2 ; x start
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
cmp [skin_btn_close.left], 0
|
cmp [skin_btn_close.left], 0
|
||||||
jge _bCx_at_right
|
jge @f
|
||||||
mov ebx, [esp]
|
mov ebx, [esp]
|
||||||
mov ebx, [ebx+WDATA.box.width]
|
mov ebx, [ebx+WDATA.box.width]
|
||||||
inc ebx
|
inc ebx
|
||||||
;--------------------------------------
|
@@:
|
||||||
align 4
|
|
||||||
_bCx_at_right:
|
|
||||||
add ebx, [skin_btn_close.left]
|
add ebx, [skin_btn_close.left]
|
||||||
mov [eax], bx
|
mov word [eax+4], bx ; x start
|
||||||
add eax, 2 ; x size
|
|
||||||
mov ebx, [skin_btn_close.width]
|
mov ebx, [skin_btn_close.width]
|
||||||
dec ebx
|
dec ebx
|
||||||
mov [eax], bx
|
mov word [eax+6], bx ; x size
|
||||||
add eax, 2 ; y start
|
|
||||||
mov ebx, [skin_btn_close.top]
|
mov ebx, [skin_btn_close.top]
|
||||||
mov [eax], bx
|
mov word [eax+8], bx ; y start
|
||||||
add eax, 2 ; y size
|
|
||||||
mov ebx, [skin_btn_close.height]
|
mov ebx, [skin_btn_close.height]
|
||||||
dec ebx
|
dec ebx
|
||||||
mov [eax], bx
|
mov word [eax+10], bx ; y size
|
||||||
|
bts word [eax+12], 14
|
||||||
;* minimize button
|
;* minimize button
|
||||||
mov edi, [BTN_ADDR]
|
mov edi, [BTN_ADDR]
|
||||||
movzx eax, word [edi]
|
movzx eax, word [edi]
|
||||||
@ -483,43 +423,31 @@ _bCx_at_right:
|
|||||||
jge no_skin_add_button
|
jge no_skin_add_button
|
||||||
inc eax
|
inc eax
|
||||||
mov [edi], ax
|
mov [edi], ax
|
||||||
|
|
||||||
shl eax, 4
|
shl eax, 4
|
||||||
add eax, edi
|
add eax, edi
|
||||||
|
|
||||||
mov bx, [CURRENT_TASK]
|
mov bx, [CURRENT_TASK]
|
||||||
mov [eax], bx
|
mov [eax], bx
|
||||||
|
mov word [eax+2], -1 ; button id
|
||||||
add eax, 2 ; save button id number
|
|
||||||
mov bx, 65535;999
|
|
||||||
mov [eax], bx
|
|
||||||
add eax, 2 ; x start
|
|
||||||
xor ebx, ebx
|
xor ebx, ebx
|
||||||
cmp [skin_btn_minimize.left], 0
|
cmp [skin_btn_minimize.left], 0
|
||||||
jge _bMx_at_right
|
jge @f
|
||||||
mov ebx, [esp]
|
mov ebx, [esp]
|
||||||
mov ebx, [ebx+WDATA.box.width]
|
mov ebx, [ebx+WDATA.box.width]
|
||||||
inc ebx
|
inc ebx
|
||||||
;--------------------------------------
|
@@:
|
||||||
align 4
|
|
||||||
_bMx_at_right:
|
|
||||||
add ebx, [skin_btn_minimize.left]
|
add ebx, [skin_btn_minimize.left]
|
||||||
mov [eax], bx
|
mov word [eax+4], bx ; x start
|
||||||
add eax, 2 ; x size
|
|
||||||
mov ebx, [skin_btn_minimize.width]
|
mov ebx, [skin_btn_minimize.width]
|
||||||
dec ebx
|
dec ebx
|
||||||
mov [eax], bx
|
mov word [eax+6], bx ; x size
|
||||||
add eax, 2 ; y start
|
|
||||||
mov ebx, [skin_btn_minimize.top]
|
mov ebx, [skin_btn_minimize.top]
|
||||||
mov [eax], bx
|
mov word [eax+8], bx ; y start
|
||||||
add eax, 2 ; y size
|
|
||||||
mov ebx, [skin_btn_minimize.height]
|
mov ebx, [skin_btn_minimize.height]
|
||||||
dec ebx
|
dec ebx
|
||||||
mov [eax], bx
|
mov word [eax+10], bx ; y size
|
||||||
;--------------------------------------
|
bts word [eax+12], 14
|
||||||
align 4
|
|
||||||
no_skin_add_button:
|
no_skin_add_button:
|
||||||
pop edi
|
pop edi
|
||||||
popa
|
popa
|
||||||
ret 4
|
ret 4
|
||||||
;------------------------------------------------------------------------------
|
|
||||||
|
@ -551,9 +551,9 @@ proc set_mouse_data stdcall uses edx, BtnState:dword, XMoving:dword, YMoving:dwo
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
; 3 = x^2 /2
|
; 3 = (x+1)^2 /4
|
||||||
; 2 = (x+1)^2 /4
|
; 2 = (x+2)^2 /8
|
||||||
; 1 = (x+2)^2 /8
|
; 1 = (x+3)^2 /16
|
||||||
align 4
|
align 4
|
||||||
mouse_acceleration:
|
mouse_acceleration:
|
||||||
cmp [mouse_delay], 0
|
cmp [mouse_delay], 0
|
||||||
@ -562,13 +562,13 @@ mouse_acceleration:
|
|||||||
@@:
|
@@:
|
||||||
neg eax
|
neg eax
|
||||||
jl @b
|
jl @b
|
||||||
|
inc eax
|
||||||
cmp [mouse_delay], 3
|
cmp [mouse_delay], 3
|
||||||
adc eax, 0
|
adc eax, 0
|
||||||
cmp [mouse_delay], 2
|
cmp [mouse_delay], 2
|
||||||
adc eax, 0
|
adc eax, 0
|
||||||
mul al
|
mul al
|
||||||
shr eax, 1
|
shr eax, 2
|
||||||
adc eax, 0
|
|
||||||
cmp [mouse_delay], 2
|
cmp [mouse_delay], 2
|
||||||
jz .2
|
jz .2
|
||||||
jnc .3
|
jnc .3
|
||||||
|
@ -996,8 +996,6 @@ end if
|
|||||||
; mov esi, boot_devices
|
; mov esi, boot_devices
|
||||||
; call boot_log
|
; call boot_log
|
||||||
|
|
||||||
call clear_pci_ide_interrupts
|
|
||||||
|
|
||||||
include "detect/vortex86.inc" ; Vortex86 SoC detection code
|
include "detect/vortex86.inc" ; Vortex86 SoC detection code
|
||||||
|
|
||||||
stdcall load_pe_driver, szVidintel, 0
|
stdcall load_pe_driver, szVidintel, 0
|
||||||
@ -2167,7 +2165,7 @@ sys_end:
|
|||||||
pusha
|
pusha
|
||||||
mov edx, [TASK_BASE]
|
mov edx, [TASK_BASE]
|
||||||
mov edx, [edx+TASKDATA.pid]
|
mov edx, [edx+TASKDATA.pid]
|
||||||
call SOCKET_process_end
|
call socket_process_end
|
||||||
popa
|
popa
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
mov ecx, [current_slot]
|
mov ecx, [current_slot]
|
||||||
@ -2297,7 +2295,7 @@ sysfn_terminate: ; 18.2 = TERMINATE
|
|||||||
; terminate all network sockets it used
|
; terminate all network sockets it used
|
||||||
pusha
|
pusha
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
call SOCKET_process_end
|
call socket_process_end
|
||||||
popa
|
popa
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
cmp [_display.select_cursor], 0
|
cmp [_display.select_cursor], 0
|
||||||
|
@ -70,14 +70,12 @@ endg
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_init
|
; arp_init: Resets all ARP variables. ;
|
||||||
;
|
; ;
|
||||||
; This function resets all ARP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro arp_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro ARP_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ARP_entries_num
|
mov edi, ARP_entries_num
|
||||||
@ -86,13 +84,12 @@ macro ARP_init {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_decrease_entry_ttls
|
; arp_decrease_entry_ttls ;
|
||||||
;
|
; ;
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
macro arp_decrease_entry_ttls {
|
||||||
macro ARP_decrease_entry_ttls {
|
|
||||||
|
|
||||||
local .loop
|
local .loop
|
||||||
local .exit
|
local .exit
|
||||||
@ -135,7 +132,7 @@ local .exit
|
|||||||
je .response_timeout
|
je .response_timeout
|
||||||
|
|
||||||
push esi edi ecx
|
push esi edi ecx
|
||||||
call ARP_del_entry
|
call arp_del_entry
|
||||||
pop ecx edi esi
|
pop ecx edi esi
|
||||||
|
|
||||||
jmp .next
|
jmp .next
|
||||||
@ -154,20 +151,21 @@ local .exit
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_input
|
; arp_input ;
|
||||||
;
|
; ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; IN: [esp] = Pointer to buffer ;
|
||||||
; size of buffer in [esp+4]
|
; [esp+4] = size of buffer ;
|
||||||
; packet size (without ethernet header) in ecx
|
; ecx = packet size (without ethernet header) ;
|
||||||
; packet ptr in edx
|
; edx = packet ptr ;
|
||||||
; device ptr in ebx
|
; ebx = device ptr ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_input:
|
arp_input:
|
||||||
|
|
||||||
;-----------------------------------------
|
;-----------------------------------------
|
||||||
; Check validity and print some debug info
|
; Check validity and print some debug info
|
||||||
@ -175,7 +173,7 @@ ARP_input:
|
|||||||
cmp ecx, sizeof.ARP_header
|
cmp ecx, sizeof.ARP_header
|
||||||
jb .exit
|
jb .exit
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
@ -294,21 +292,21 @@ ARP_input:
|
|||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: exiting\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: exiting\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_output_request
|
; arp_output_request ;
|
||||||
;
|
; ;
|
||||||
; IN: ebx = device ptr
|
; IN: ebx = device ptr ;
|
||||||
; eax = IP
|
; eax = IP ;
|
||||||
; OUT: /
|
; ;
|
||||||
; scratched: probably everything
|
; OUT: scratched: probably everything ;
|
||||||
;
|
; ;
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_output_request:
|
arp_output_request:
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
|
|
||||||
@ -318,7 +316,7 @@ ARP_output_request:
|
|||||||
mov ax, ETHER_PROTO_ARP
|
mov ax, ETHER_PROTO_ARP
|
||||||
mov ecx, sizeof.ARP_header
|
mov ecx, sizeof.ARP_header
|
||||||
mov edx, ETH_BROADCAST ; broadcast mac
|
mov edx, ETH_BROADCAST ; broadcast mac
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
|
||||||
@ -333,7 +331,7 @@ ARP_output_request:
|
|||||||
movsd ;
|
movsd ;
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
||||||
lea esi, [IP_LIST + edi] ; SenderIP
|
lea esi, [IP_LIST + edi] ; SenderIP
|
||||||
pop edi
|
pop edi
|
||||||
@ -354,18 +352,22 @@ ARP_output_request:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_add_entry (or update)
|
; arp_add_entry: Add or update an entry in the ARP table. ;
|
||||||
;
|
; ;
|
||||||
; IN: esi = ptr to entry (can easily be made on the stack)
|
; IN: esi = ptr to entry (can easily be made on the stack) ;
|
||||||
; edi = device num*4
|
; edi = device num*4 ;
|
||||||
; OUT: eax = entry #, -1 on error
|
; ;
|
||||||
; esi = ptr to newly created entry
|
; OUT: eax = entry number on success ;
|
||||||
;
|
; eax = -1 on error ;
|
||||||
;----------------------------------------------------------------- ; TODO: use a mutex
|
; esi = ptr to newly created entry ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_add_entry:
|
arp_add_entry:
|
||||||
|
|
||||||
|
; TODO: use a mutex to lock ARP table
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
||||||
|
|
||||||
@ -421,19 +423,22 @@ ARP_add_entry:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_del_entry
|
; arp_del_entry: Remove an entry from the ARP table. ;
|
||||||
;
|
; ;
|
||||||
; IN: esi = ptr to arp entry
|
; IN: esi = ptr to arp entry ;
|
||||||
; edi = device number
|
; edi = device number ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_del_entry:
|
arp_del_entry:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
|
; TODO: use a mutex to lock ARP table
|
||||||
|
|
||||||
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=0x%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
|
||||||
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
|
||||||
|
|
||||||
@ -463,22 +468,22 @@ ARP_del_entry:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_IP_to_MAC
|
; arp_ip_to_mac: Translate an IP address to a MAC address. ;
|
||||||
;
|
; ;
|
||||||
; This function translates an IP address to a MAC address
|
; IN: eax = IPv4 address ;
|
||||||
;
|
; edi = device number * 4 ;
|
||||||
; IN: eax = IPv4 address
|
; ;
|
||||||
; edi = device number * 4
|
; OUT: eax = -1 on error ;
|
||||||
; OUT: eax = -1 on error, -2 means request send
|
; eax = -2 when request send ;
|
||||||
; else, ax = first two bytes of mac (high 16 bits of eax will be 0)
|
; eax = first two bytes of mac on success ;
|
||||||
; ebx = last four bytes of mac
|
; ebx = last four bytes of mac on success ;
|
||||||
; edi = unchanged
|
; edi = unchanged ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ARP_IP_to_MAC:
|
arp_ip_to_mac:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
|
||||||
rol eax, 16
|
rol eax, 16
|
||||||
@ -513,11 +518,11 @@ ARP_IP_to_MAC:
|
|||||||
pushw ARP_AWAITING_RESPONSE ; status
|
pushw ARP_AWAITING_RESPONSE ; status
|
||||||
pushd 0 ; mac
|
pushd 0 ; mac
|
||||||
pushw 0
|
pushw 0
|
||||||
pushd eax ; ip
|
pushd eax ; IP
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
; Add it to the list
|
; Add it to the list
|
||||||
call ARP_add_entry
|
call arp_add_entry
|
||||||
|
|
||||||
; Delete the temporary entry
|
; Delete the temporary entry
|
||||||
add esp, sizeof.ARP_entry ; clear the entry from stack
|
add esp, sizeof.ARP_entry ; clear the entry from stack
|
||||||
@ -534,7 +539,7 @@ ARP_IP_to_MAC:
|
|||||||
|
|
||||||
push esi edi
|
push esi edi
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [NET_DRV_LIST + edi]
|
||||||
call ARP_output_request
|
call arp_output_request
|
||||||
pop edi esi
|
pop edi esi
|
||||||
.found_it:
|
.found_it:
|
||||||
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
||||||
@ -576,21 +581,19 @@ end if
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ARP_API
|
; arp_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 76
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT: ?
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ARP_api:
|
arp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -650,7 +653,7 @@ ARP_api:
|
|||||||
.write:
|
.write:
|
||||||
; esi = pointer to buffer
|
; esi = pointer to buffer
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
call ARP_add_entry ; out: eax = entry number, -1 on error
|
call arp_add_entry ; out: eax = entry number, -1 on error
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.remove:
|
.remove:
|
||||||
@ -661,12 +664,12 @@ ARP_api:
|
|||||||
lea esi, [ARP_table + ecx]
|
lea esi, [ARP_table + ecx]
|
||||||
mov edi, eax
|
mov edi, eax
|
||||||
shr edi, 2
|
shr edi, 2
|
||||||
call ARP_del_entry
|
call arp_del_entry
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.send_announce:
|
.send_announce:
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call arp_output_request ; now send a gratuitous ARP
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5842 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
IPv4_MAX_FRAGMENTS = 64
|
IPv4_MAX_FRAGMENTS = 64
|
||||||
IPv4_MAX_ROUTES = 64
|
IPv4_MAX_ROUTES = 64
|
||||||
@ -92,14 +92,12 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_init
|
; ipv4_init: Resets all IPv4 variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro ipv4_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro IPv4_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IP_LIST
|
mov edi, IP_LIST
|
||||||
@ -109,12 +107,12 @@ macro IPv4_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; Decrease TimeToLive of all fragment slots
|
; Decrease TimeToLive of all fragment slots ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
macro IPv4_decrease_fragment_ttls {
|
macro ipv4_decrease_fragment_ttls {
|
||||||
|
|
||||||
local .loop, .next
|
local .loop, .next
|
||||||
|
|
||||||
@ -141,7 +139,7 @@ local .loop, .next
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro IPv4_checksum ptr {
|
macro ipv4_checksum ptr {
|
||||||
|
|
||||||
; This is the fast procedure to create or check an IP header without options
|
; This is the fast procedure to create or check an IP header without options
|
||||||
; To create a new checksum, the checksum field must be set to 0 before computation
|
; To create a new checksum, the checksum field must be set to 0 before computation
|
||||||
@ -205,24 +203,22 @@ macro IPv4_checksum ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_input:
|
; ipv4_input: Check if IPv4 Packet isnt damaged and call ;
|
||||||
;
|
; appropriate handler. (TCP/UDP/ICMP/..) ;
|
||||||
; Will check if IPv4 Packet isnt damaged
|
; We will also re-construct fragmented packets. ;
|
||||||
; and call appropriate handler. (TCP/UDP/ICMP/..)
|
; ;
|
||||||
;
|
; IN: Pointer to buffer in [esp] ;
|
||||||
; It will also re-construct fragmented packets
|
; pointer to device struct in ebx ;
|
||||||
;
|
; pointer to IPv4 header in edx ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; size of IPv4 packet in ecx ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to IPv4 header in edx
|
; OUT: / ;
|
||||||
; size of IPv4 packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv4_input:
|
ipv4_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: packet from %u.%u.%u.%u ",\
|
||||||
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
|
[edx + IPv4_header.SourceAddress + 0]:1,[edx + IPv4_header.SourceAddress + 1]:1,\
|
||||||
@ -231,14 +227,14 @@ IPv4_input:
|
|||||||
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
|
[edx + IPv4_header.DestinationAddress + 0]:1,[edx + IPv4_header.DestinationAddress + 1]:1,\
|
||||||
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
|
[edx + IPv4_header.DestinationAddress + 2]:1,[edx + IPv4_header.DestinationAddress + 3]:1
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
je .invalid_device
|
je .invalid_device
|
||||||
|
|
||||||
;-------------------------------
|
;-------------------------------
|
||||||
; re-calculate the checksum
|
; re-calculate the checksum
|
||||||
|
|
||||||
IPv4_checksum edx
|
ipv4_checksum edx
|
||||||
jnz .dump ; if checksum isn't valid then dump packet
|
jnz .dump ; if checksum isn't valid then dump packet
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Checksum ok\n"
|
||||||
@ -304,13 +300,13 @@ IPv4_input:
|
|||||||
add esi, edx ; make esi ptr to data
|
add esi, edx ; make esi ptr to data
|
||||||
|
|
||||||
cmp al, IP_PROTO_TCP
|
cmp al, IP_PROTO_TCP
|
||||||
je TCP_input
|
je tcp_input
|
||||||
|
|
||||||
cmp al, IP_PROTO_UDP
|
cmp al, IP_PROTO_UDP
|
||||||
je UDP_input
|
je udp_input
|
||||||
|
|
||||||
cmp al, IP_PROTO_ICMP
|
cmp al, IP_PROTO_ICMP
|
||||||
je ICMP_input
|
je icmp_input
|
||||||
|
|
||||||
;-------------------------------
|
;-------------------------------
|
||||||
; Look for a matching RAW socket
|
; Look for a matching RAW socket
|
||||||
@ -347,7 +343,7 @@ IPv4_input:
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.dump_unlock:
|
.dump_unlock:
|
||||||
|
|
||||||
@ -361,12 +357,12 @@ IPv4_input:
|
|||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: dumping\n"
|
||||||
inc [IPv4_packets_dumped + edi]
|
inc [IPv4_packets_dumped + edi]
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.invalid_device:
|
.invalid_device:
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_input: packet originated from invalid device\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -390,7 +386,7 @@ IPv4_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Middle fragment packet received!\n"
|
||||||
|
|
||||||
call IPv4_find_fragment_slot
|
call ipv4_find_fragment_slot
|
||||||
cmp esi, -1
|
cmp esi, -1
|
||||||
je .dump
|
je .dump
|
||||||
|
|
||||||
@ -455,7 +451,7 @@ IPv4_input:
|
|||||||
.is_last_fragment:
|
.is_last_fragment:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Last fragment packet received!\n"
|
||||||
|
|
||||||
call IPv4_find_fragment_slot
|
call ipv4_find_fragment_slot
|
||||||
cmp esi, -1
|
cmp esi, -1
|
||||||
je .dump
|
je .dump
|
||||||
|
|
||||||
@ -546,7 +542,7 @@ IPv4_input:
|
|||||||
push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer
|
push [edx + IPv4_FRAGMENT_entry.NextPtr] ; Set edx to the next pointer
|
||||||
push edx ; Push pointer to fragment onto stack
|
push edx ; Push pointer to fragment onto stack
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: Next Fragment: 0x%x\n", edx
|
||||||
call NET_BUFF_free ; free the previous fragment buffer (this uses the value from stack)
|
call net_buff_free ; free the previous fragment buffer (this uses the value from stack)
|
||||||
pop edx ebx eax
|
pop edx ebx eax
|
||||||
cmp edx, -1 ; Check if it is last fragment in chain
|
cmp edx, -1 ; Check if it is last fragment in chain
|
||||||
jne .rebuild_packet_loop
|
jne .rebuild_packet_loop
|
||||||
@ -571,16 +567,17 @@ IPv4_input:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; find fragment slot
|
; ipv4_find_fragment_slot ;
|
||||||
;
|
; ;
|
||||||
; IN: pointer to fragmented packet in edx
|
; IN: pointer to fragmented packet in edx ;
|
||||||
; OUT: pointer to slot in esi, -1 on error
|
; ;
|
||||||
;
|
; OUT: pointer to slot in esi, -1 on error ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_find_fragment_slot:
|
ipv4_find_fragment_slot:
|
||||||
|
|
||||||
;;; TODO: the RFC says we should check protocol number too
|
;;; TODO: the RFC says we should check protocol number too
|
||||||
|
|
||||||
@ -607,26 +604,27 @@ IPv4_find_fragment_slot:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_output
|
; ipv4_output ;
|
||||||
;
|
; ;
|
||||||
; IN: al = protocol
|
; IN: al = protocol ;
|
||||||
; ah = TTL
|
; ah = TTL ;
|
||||||
; ebx = device ptr (or 0 to let IP layer decide)
|
; ebx = device ptr (or 0 to let IP layer decide) ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = Source IP
|
; edx = Source IP ;
|
||||||
; edi = Destination IP
|
; edi = Destination IP ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = pointer to buffer start / 0 on error
|
; OUT: eax = pointer to buffer start ;
|
||||||
; ebx = device ptr (send packet through this device)
|
; eax = 0 on error ;
|
||||||
; ecx = data length
|
; ebx = device ptr (send packet through this device) ;
|
||||||
; edx = size of complete frame
|
; ecx = data length ;
|
||||||
; edi = start of IPv4 payload
|
; edx = size of complete frame ;
|
||||||
;
|
; edi = start of IPv4 payload ;
|
||||||
;------------------------------------------------------------------
|
; ;
|
||||||
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_output:
|
ipv4_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
|
||||||
|
|
||||||
@ -635,12 +633,12 @@ IPv4_output:
|
|||||||
|
|
||||||
push ecx ax edi
|
push ecx ax edi
|
||||||
mov eax, edi
|
mov eax, edi
|
||||||
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
|
call ipv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
|
||||||
push edx
|
push edx
|
||||||
test edi, edi
|
test edi, edi
|
||||||
jz .loopback
|
jz .loopback
|
||||||
|
|
||||||
call ARP_IP_to_MAC
|
call arp_ip_to_mac
|
||||||
test eax, 0xffff0000 ; error bits
|
test eax, 0xffff0000 ; error bits
|
||||||
jnz .arp_error
|
jnz .arp_error
|
||||||
push ebx ; push the mac onto the stack
|
push ebx ; push the mac onto the stack
|
||||||
@ -653,7 +651,7 @@ IPv4_output:
|
|||||||
mov ecx, [esp + 6 + 8 + 2]
|
mov ecx, [esp + 6 + 8 + 2]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
add esp, 6 ; pop the mac out of the stack
|
add esp, 6 ; pop the mac out of the stack
|
||||||
|
|
||||||
@ -674,7 +672,7 @@ IPv4_output:
|
|||||||
|
|
||||||
pop ecx
|
pop ecx
|
||||||
|
|
||||||
IPv4_checksum edi
|
ipv4_checksum edi
|
||||||
add edi, sizeof.IPv4_header
|
add edi, sizeof.IPv4_header
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: success!\n"
|
||||||
ret
|
ret
|
||||||
@ -704,33 +702,33 @@ IPv4_output:
|
|||||||
mov ecx, [esp + 10]
|
mov ecx, [esp + 10]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edi, AF_INET4
|
mov edi, AF_INET4
|
||||||
call LOOP_output
|
call loop_output
|
||||||
jmp .continue
|
jmp .continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_output_raw
|
; ipv4_output_raw ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket ptr
|
; IN: eax = socket ptr ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; esi = data ptr
|
; esi = data ptr ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = -1 on error
|
; OUT: eax = -1 on error ;
|
||||||
;
|
; ;
|
||||||
;------------------------------------------------------------------
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_output_raw:
|
ipv4_output_raw:
|
||||||
|
|
||||||
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
|
DEBUGF 1,"IPv4_output_raw: size=%u ptr=%x socket=%x\n", ecx, esi, eax
|
||||||
|
|
||||||
sub esp, 8
|
sub esp, 8
|
||||||
push esi eax
|
push esi eax
|
||||||
|
|
||||||
call IPv4_route
|
call ipv4_route
|
||||||
call ARP_IP_to_MAC
|
call arp_ip_to_mac
|
||||||
|
|
||||||
test eax, 0xffff0000 ; error bits
|
test eax, 0xffff0000 ; error bits
|
||||||
jnz .arp_error
|
jnz .arp_error
|
||||||
@ -744,7 +742,7 @@ IPv4_output_raw:
|
|||||||
mov ecx, [esp + 6 + 4]
|
mov ecx, [esp + 6 + 4]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .error
|
jz .error
|
||||||
add esp, 6 ; pop the mac
|
add esp, 6 ; pop the mac
|
||||||
|
|
||||||
@ -772,7 +770,7 @@ IPv4_output_raw:
|
|||||||
; [edi + IPv4_header.SourceAddress]
|
; [edi + IPv4_header.SourceAddress]
|
||||||
; [edi + IPv4_header.DestinationAddress]
|
; [edi + IPv4_header.DestinationAddress]
|
||||||
|
|
||||||
IPv4_checksum edi ;;;; todo: checksum for IP packet with options!
|
ipv4_checksum edi ;;;; todo: checksum for IP packet with options!
|
||||||
add edi, sizeof.IPv4_header
|
add edi, sizeof.IPv4_header
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output_raw: device=%x\n", ebx
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
@ -791,17 +789,18 @@ IPv4_output_raw:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;--------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
;
|
; ipv4_fragment ;
|
||||||
; IN: [esp] = pointer to buffer containing ipv4 packet to be fragmented
|
; ;
|
||||||
; edi = pointer to ip header in that buffer
|
; IN: [esp] = ptr to packet buffer to fragment ;
|
||||||
; ebx = device ptr
|
; edi = ptrr to ip header in that buffer ;
|
||||||
;
|
; ebx = device ptr ;
|
||||||
; OUT: /
|
; ;
|
||||||
;
|
; OUT: / ;
|
||||||
;--------------------------------------------------------
|
; ;
|
||||||
proc IPv4_fragment stdcall buffer
|
;-----------------------------------------------------------------;
|
||||||
|
proc ipv4_fragment stdcall buffer
|
||||||
|
|
||||||
locals
|
locals
|
||||||
offset dd ?
|
offset dd ?
|
||||||
@ -910,22 +909,24 @@ endp
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_route
|
; ipv4_route ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = Destination IP
|
; IN: eax = Destination IP ;
|
||||||
; ebx = outgoing device / 0
|
; ebx = outgoing device / 0 ;
|
||||||
; edx = Source IP
|
; edx = Source IP ;
|
||||||
; OUT: eax = Destination IP (or gateway IP)
|
; ;
|
||||||
; edx = Source IP
|
; OUT: eax = Destination IP (or gateway IP) ;
|
||||||
; edi = device number*4
|
; edx = Source IP ;
|
||||||
; DESTROYED:
|
; edi = device number*4 ;
|
||||||
; ecx
|
; ;
|
||||||
;
|
; DESTROYED: ;
|
||||||
;---------------------------------------------------------------------------
|
; ecx ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_route: ; TODO: return error if no valid route found
|
ipv4_route: ; TODO: return error if no valid route found
|
||||||
|
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jnz .got_device
|
jnz .got_device
|
||||||
@ -961,7 +962,7 @@ IPv4_route: ; TODO: return error if no valid route found
|
|||||||
|
|
||||||
.got_device:
|
.got_device:
|
||||||
; Validate device ptr and convert to device number
|
; Validate device ptr and convert to device number
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
je .fail
|
je .fail
|
||||||
|
|
||||||
@ -982,32 +983,35 @@ IPv4_route: ; TODO: return error if no valid route found
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_get_frgmnt_num
|
; ipv4_get_frgmnt_num ;
|
||||||
;
|
; ;
|
||||||
; IN: /
|
; IN: / ;
|
||||||
; OUT: fragment number in ax
|
; ;
|
||||||
;
|
; OUT: ax = fragment number ;
|
||||||
;---------------------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_get_frgmnt_num:
|
ipv4_get_frgmnt_num:
|
||||||
xor ax, ax ;;; TODO: replace this with real code
|
xor ax, ax ;;; TODO: replace this with real code
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_connect
|
; ipv4_connect ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket pointer
|
; IN: eax = socket pointer ;
|
||||||
; OUT: eax = 0 ok / -1 error
|
; ;
|
||||||
; ebx = error code
|
; OUT: eax = 0 on success ;
|
||||||
;
|
; eax = -1 on error ;
|
||||||
;-------------------------
|
; ebx = error code on error ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
IPv4_connect:
|
ipv4_connect:
|
||||||
|
|
||||||
push eax edx
|
push eax edx
|
||||||
lea ecx, [eax + SOCKET.mutex]
|
lea ecx, [eax + SOCKET.mutex]
|
||||||
@ -1031,21 +1035,19 @@ IPv4_connect:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv4_API
|
; ipv4_API: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv4_api:
|
ipv4_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -1096,9 +1098,9 @@ IPv4_api:
|
|||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [NET_DRV_LIST + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IP_LIST + eax]
|
||||||
call ARP_output_request ; now send a gratuitous ARP
|
call arp_output_request ; now send a gratuitous ARP
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1108,7 +1110,7 @@ IPv4_api:
|
|||||||
|
|
||||||
.write_dns:
|
.write_dns:
|
||||||
mov [DNS_LIST + eax], ecx
|
mov [DNS_LIST + eax], ecx
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1125,7 +1127,7 @@ IPv4_api:
|
|||||||
or ecx, ebx
|
or ecx, ebx
|
||||||
mov [BROADCAST_LIST + eax], ecx
|
mov [BROADCAST_LIST + eax], ecx
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -1136,6 +1138,6 @@ IPv4_api:
|
|||||||
.write_gateway:
|
.write_gateway:
|
||||||
mov [GATEWAY_LIST + eax], ecx
|
mov [GATEWAY_LIST + eax], ecx
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5522 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
|
|
||||||
struct IPv6_header
|
struct IPv6_header
|
||||||
@ -45,14 +45,12 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_init
|
; ipv6_init: Resets all IPv6 variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro ipv6_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro IPv6_init {
|
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IPv6
|
mov edi, IPv6
|
||||||
@ -63,25 +61,23 @@ macro IPv6_init {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_input:
|
; ipv6_input: Check if IPv6 Packet isnt damaged and call ;
|
||||||
;
|
; appropriate handler. (TCP/UDP/ICMP/..) ;
|
||||||
; Will check if IPv6 Packet isnt damaged
|
; We will also re-construct fragmented packets ;
|
||||||
; and call appropriate handler. (TCP/UDP/ICMP/..)
|
; ;
|
||||||
;
|
; IN: [esp] = ptr to buffer ;
|
||||||
; It will also re-construct fragmented packets
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; edx = ptr to IPv6 header ;
|
||||||
; size of buffer in [esp+4]
|
; ecx = size of IPv6 packet ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to IPv6 header in edx
|
; OUT: / ;
|
||||||
; size of IPv6 packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv6_input:
|
ipv6_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input from: %x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x:%x%x\n",\
|
||||||
[edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\
|
[edx + IPv6_header.SourceAddress + 0]:2,[edx + IPv6_header.SourceAddress + 1]:2,\
|
||||||
@ -147,7 +143,7 @@ IPv6_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv6_input - dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.dump_options:
|
.dump_options:
|
||||||
@ -245,21 +241,19 @@ IPv6_input:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IPv6_API
|
; ipv6_api: Part of system function 76 ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
IPv6_api:
|
ipv6_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5522 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
|
|
||||||
struct PPPoE_frame
|
struct PPPoE_frame
|
||||||
@ -33,37 +33,33 @@ align 4
|
|||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE_init
|
; pppoe_init: Reset all pppoe variables ;
|
||||||
;
|
; ;
|
||||||
; This function resets all IP variables
|
;-----------------------------------------------------------------;
|
||||||
;
|
macro pppoe_init {
|
||||||
;-----------------------------------------------------------------
|
|
||||||
macro PPPoE_init {
|
|
||||||
|
|
||||||
call PPPoE_stop_connection
|
call pppoe_stop_connection
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE discovery input
|
; pppoe_discovery_input ;
|
||||||
;
|
; ;
|
||||||
; Handler of received Ethernet packet with type = Discovery
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; ecx = size of PPP packet ;
|
||||||
; size of buffer in [esp+4]
|
; edx = ptr to PPP header ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to PPP header in edx
|
; OUT: / ;
|
||||||
; size of PPP packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_discovery_input:
|
pppoe_discovery_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_input\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_input\n"
|
||||||
|
|
||||||
@ -97,7 +93,7 @@ PPPoE_discovery_input:
|
|||||||
mov ecx, [esp + 4]
|
mov ecx, [esp + 4]
|
||||||
mov esi, [esp]
|
mov esi, [esp]
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
pusha
|
pusha
|
||||||
@ -106,22 +102,21 @@ PPPoE_discovery_input:
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
|
DEBUGF DEBUG_NETWORK_VERBOSE, 'PPPoE_discovery_input: dumping\n'
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;--------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; Send discovery packet
|
; pppoe_discovery_output ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket pointer
|
; IN: eax = socket pointer ;
|
||||||
; ecx = number of bytes to send
|
; ecx = number of bytes to send ;
|
||||||
; esi = pointer to data
|
; esi = pointer to data ;
|
||||||
;
|
; ;
|
||||||
;--------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_discovery_output:
|
pppoe_discovery_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: socket=%x buffer=%x size=%d\n", eax, esi, ecx
|
||||||
|
|
||||||
@ -147,7 +142,7 @@ PPPoE_discovery_output:
|
|||||||
|
|
||||||
; Create packet.
|
; Create packet.
|
||||||
push ecx esi
|
push ecx esi
|
||||||
stdcall kernel_alloc, 1500
|
;;;; FIXME stdcall kernel_alloc, 1500
|
||||||
pop esi ecx
|
pop esi ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .bad
|
jz .bad
|
||||||
@ -185,23 +180,21 @@ PPPoE_discovery_output:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE session input
|
; pppoe_session_input ;
|
||||||
;
|
; ;
|
||||||
; Handler of received Ethernet packet with type = Session
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; [esp+4] = size of buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; edx = ptr to PPP header ;
|
||||||
; size of buffer in [esp+4]
|
; ecx = size of PPP packet ;
|
||||||
; pointer to device struct in ebx
|
; ;
|
||||||
; pointer to PPP header in edx
|
; OUT: / ;
|
||||||
; size of PPP packet in ecx
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_session_input:
|
pppoe_session_input:
|
||||||
|
|
||||||
cmp [edx + PPPoE_frame.VersionAndType], 0x11
|
cmp [edx + PPPoE_frame.VersionAndType], 0x11
|
||||||
jne .dump
|
jne .dump
|
||||||
@ -221,38 +214,39 @@ PPPoE_session_input:
|
|||||||
add edx, PPPoE_frame.Payload + 2
|
add edx, PPPoE_frame.Payload + 2
|
||||||
|
|
||||||
cmp ax, PPP_PROTO_IPv4
|
cmp ax, PPP_PROTO_IPv4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
; cmp ax, PPP_PROTO_IPv6
|
; cmp ax, PPP_PROTO_IPv6
|
||||||
; je IPv6_input
|
; je ipv6_input
|
||||||
|
|
||||||
jmp PPPoE_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
jmp pppoe_discovery_input ; Send LCP,CHAP,CBCP,... packets to the PPP dialer
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: Unknown protocol=%x\n", ax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE_output
|
; pppoe_output ;
|
||||||
;
|
; ;
|
||||||
; IN: ax = protocol
|
; IN: ax = protocol ;
|
||||||
; ebx = device ptr
|
; ebx = device ptr ;
|
||||||
; ecx = packet size
|
; ecx = packet size ;
|
||||||
;
|
; ;
|
||||||
; OUT: eax = buffer start / 0 on error
|
; OUT: eax = buffer start ;
|
||||||
; ebx = device ptr
|
; eax = 0 on error ;
|
||||||
; ecx = packet size
|
; ebx = device ptr ;
|
||||||
; edx = size of complete buffer
|
; ecx = packet size ;
|
||||||
; edi = start of PPP payload
|
; edx = size of complete buffer ;
|
||||||
;
|
; edi = start of PPP payload ;
|
||||||
;-----------------------------------------------------------------
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
PPPoE_output:
|
pppoe_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
|
||||||
|
|
||||||
@ -262,7 +256,7 @@ PPPoE_output:
|
|||||||
mov ax, ETHER_PROTO_PPP_SESSION
|
mov ax, ETHER_PROTO_PPP_SESSION
|
||||||
add ecx, PPPoE_frame.Payload + 2
|
add ecx, PPPoE_frame.Payload + 2
|
||||||
lea edx, [PPPoE_MAC]
|
lea edx, [PPPoE_MAC]
|
||||||
call ETH_output
|
call eth_output
|
||||||
jz .eth_error
|
jz .eth_error
|
||||||
|
|
||||||
sub ecx, PPPoE_frame.Payload
|
sub ecx, PPPoE_frame.Payload
|
||||||
@ -287,8 +281,8 @@ PPPoE_output:
|
|||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
align 4
|
||||||
PPPoE_start_connection:
|
pppoe_start_connection:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_start_connection: %x\n", cx
|
||||||
|
|
||||||
@ -308,7 +302,7 @@ PPPoE_start_connection:
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_stop_connection:
|
pppoe_stop_connection:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_stop_connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_stop_connection\n"
|
||||||
|
|
||||||
@ -320,21 +314,19 @@ PPPoE_stop_connection:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;---------------------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; PPPoE API
|
; pppoe_api: Part of system function 76 ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: subfunction number in bl ;
|
||||||
;
|
; device number in bh ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;---------------------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
PPPoE_api:
|
pppoe_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
@ -345,8 +337,8 @@ PPPoE_api:
|
|||||||
jmp dword [.table + 4*ebx]
|
jmp dword [.table + 4*ebx]
|
||||||
|
|
||||||
.table:
|
.table:
|
||||||
dd PPPoE_start_connection ; 0
|
dd pppoe_start_connection ; 0
|
||||||
dd PPPoE_stop_connection ; 1
|
dd pppoe_stop_connection ; 1
|
||||||
.number = ($ - .table) / 4 - 1
|
.number = ($ - .table) / 4 - 1
|
||||||
|
|
||||||
.error:
|
.error:
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5522 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
ETH_FRAME_MINIMUM = 60
|
ETH_FRAME_MINIMUM = 60
|
||||||
ETH_QUEUE_SIZE = 255
|
ETH_QUEUE_SIZE = 255
|
||||||
@ -50,10 +50,10 @@ align 4
|
|||||||
ETH_input_event dd ?
|
ETH_input_event dd ?
|
||||||
endg
|
endg
|
||||||
|
|
||||||
macro ETH_init {
|
macro eth_init {
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, ETH_process_input
|
mov ecx, eth_process_input
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -62,20 +62,18 @@ macro ETH_init {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ETH_input
|
; eth_input: This function is called by ethernet drivers. ;
|
||||||
;
|
; Push the received ethernet packet onto the ethernet input queue.;
|
||||||
; This function is called by ethernet drivers,
|
; ;
|
||||||
; It pushes the received ethernet packets onto the ethernet input queue
|
; IN: [esp] = Pointer to buffer ;
|
||||||
;
|
; ;
|
||||||
; IN: [esp] = Pointer to buffer
|
; OUT: / ;
|
||||||
;
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ETH_input:
|
eth_input:
|
||||||
|
|
||||||
pop eax
|
pop eax
|
||||||
pushf
|
pushf
|
||||||
@ -109,14 +107,22 @@ ETH_input:
|
|||||||
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "ETH incoming queue is full, discarding packet!\n"
|
||||||
popf
|
popf
|
||||||
push eax
|
push eax
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
|
; ;
|
||||||
|
; eth_process_input: Process packets from ethernet input queue. ;
|
||||||
|
; ;
|
||||||
|
; IN: / ;
|
||||||
|
; ;
|
||||||
|
; OUT: / ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ETH_process_input:
|
eth_process_input:
|
||||||
|
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
mov ecx, MANUAL_DESTROY
|
mov ecx, MANUAL_DESTROY
|
||||||
@ -163,44 +169,46 @@ ETH_process_input:
|
|||||||
|
|
||||||
; Place protocol handlers here
|
; Place protocol handlers here
|
||||||
cmp ax, ETHER_PROTO_IPv4
|
cmp ax, ETHER_PROTO_IPv4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
cmp ax, ETHER_PROTO_ARP
|
cmp ax, ETHER_PROTO_ARP
|
||||||
je ARP_input
|
je arp_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_IPv6
|
; cmp ax, ETHER_PROTO_IPv6
|
||||||
; je IPv6_input
|
; je ipv6_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_PPP_DISCOVERY
|
; cmp ax, ETHER_PROTO_PPP_DISCOVERY
|
||||||
; je PPPoE_discovery_input
|
; je pppoe_discovery_input
|
||||||
|
|
||||||
; cmp ax, ETHER_PROTO_PPP_SESSION
|
; cmp ax, ETHER_PROTO_PPP_SESSION
|
||||||
; je PPPoE_session_input
|
; je pppoe_session_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: Unknown packet type=%x\n", ax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
;
|
|
||||||
; ETH_output
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; IN: ax = protocol
|
; eth_output ;
|
||||||
; ebx = device ptr
|
; ;
|
||||||
; ecx = payload size
|
; IN: ax = protocol ;
|
||||||
; edx = pointer to destination mac
|
; ebx = device ptr ;
|
||||||
;
|
; ecx = payload size ;
|
||||||
; OUT: eax = start of net frame / 0 on error
|
; edx = pointer to destination mac ;
|
||||||
; ebx = device ptr
|
; ;
|
||||||
; ecx = payload size
|
; OUT: eax = start of net frame / 0 on error ;
|
||||||
; edi = start of payload
|
; ebx = device ptr ;
|
||||||
;
|
; ecx = payload size ;
|
||||||
;-----------------------------------------------------------------
|
; edi = start of payload ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ETH_output:
|
eth_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
|
||||||
|
|
||||||
@ -211,7 +219,7 @@ ETH_output:
|
|||||||
push ax edx
|
push ax edx
|
||||||
|
|
||||||
add ecx, sizeof.ETH_header + NET_BUFF.data
|
add ecx, sizeof.ETH_header + NET_BUFF.data
|
||||||
stdcall NET_BUFF_alloc, ecx
|
stdcall net_buff_alloc, ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .out_of_ram
|
jz .out_of_ram
|
||||||
mov [eax + NET_BUFF.type], NET_BUFF_ETH
|
mov [eax + NET_BUFF.type], NET_BUFF_ETH
|
||||||
@ -257,21 +265,19 @@ ETH_output:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ETH_API
|
; eth_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 76
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ETH_api:
|
eth_api:
|
||||||
|
|
||||||
cmp bh, NET_DEVICES_MAX
|
cmp bh, NET_DEVICES_MAX
|
||||||
ja .error
|
ja .error
|
||||||
|
@ -85,7 +85,6 @@ ICMP_PHOTURIS_AUTH_FAILED = 2 ; auth failed
|
|||||||
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
|
ICMP_PHOTURIS_DECRYPT_FAILED = 3 ; decrypt failed
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct ICMP_header
|
struct ICMP_header
|
||||||
|
|
||||||
Type db ?
|
Type db ?
|
||||||
@ -107,13 +106,13 @@ endg
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_init
|
; ICMP_init ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
macro ICMP_init {
|
macro icmp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ICMP_PACKETS_TX
|
mov edi, ICMP_PACKETS_TX
|
||||||
@ -123,25 +122,23 @@ macro ICMP_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_input:
|
; icmp_input: Send a reply's to an ICMP echo or insert packets ;
|
||||||
;
|
; into socket. ;
|
||||||
; This procedure will send reply's to ICMP echo's
|
; ;
|
||||||
; and insert packets into sockets when needed
|
; IN: [esp] = ptr to buffer ;
|
||||||
;
|
; ebx = ptr to device struct ;
|
||||||
; IN: Pointer to buffer in [esp]
|
; ecx = ICMP Packet size ;
|
||||||
; ebx = pointer to device struct
|
; edx = ptr to IPv4 header ;
|
||||||
; ecx = ICMP Packet size
|
; esi = ptr to ICMP Packet data ;
|
||||||
; edx = ptr to IPv4 header
|
; edi = interface number*4 ;
|
||||||
; esi = ptr to ICMP Packet data
|
; ;
|
||||||
; edi = interface number*4
|
; OUT: / ;
|
||||||
;
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ICMP_input:
|
icmp_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
||||||
|
|
||||||
@ -204,7 +201,7 @@ ICMP_input:
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -274,7 +271,7 @@ ICMP_input:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -293,26 +290,26 @@ ICMP_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
if 0
|
if 0
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_output
|
; icmp_output ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = dest ip
|
; IN: eax = dest ip ;
|
||||||
; bh = type
|
; bh = type ;
|
||||||
; bl = code
|
; bl = code ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = source ip
|
; edx = source ip ;
|
||||||
; esi = data offset
|
; esi = data offset ;
|
||||||
; edi = identifier shl 16 + sequence number
|
; edi = identifier shl 16 + sequence number ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ICMP_output:
|
icmp_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet\n"
|
||||||
|
|
||||||
@ -364,17 +361,17 @@ end if
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_output_raw
|
; icmp_output_raw ;
|
||||||
;
|
; ;
|
||||||
; IN: eax = socket ptr
|
; IN: eax = socket ptr ;
|
||||||
; ecx = data length
|
; ecx = data length ;
|
||||||
; edx = data pointer
|
; edx = data pointer ;
|
||||||
;
|
; ;
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
ICMP_output_raw:
|
icmp_output_raw:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Creating ICMP Packet for socket %x, data ptr=%x\n", eax, edx
|
||||||
|
|
||||||
@ -384,7 +381,7 @@ ICMP_output_raw:
|
|||||||
mov edi, [eax + IP_SOCKET.RemoteIP]
|
mov edi, [eax + IP_SOCKET.RemoteIP]
|
||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_ICMP
|
mov ah, IP_PROTO_ICMP
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
@ -407,7 +404,7 @@ ICMP_output_raw:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -422,21 +419,19 @@ ICMP_output_raw:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; ICMP_API
|
; icmp_api: Part of system function 76. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by system function 75
|
; IN: bl = subfunction number ;
|
||||||
;
|
; bh = device number ;
|
||||||
; IN: subfunction number in bl
|
; ecx, edx, .. depends on subfunction ;
|
||||||
; device number in bh
|
; ;
|
||||||
; ecx, edx, .. depends on subfunction
|
; OUT: depends on subfunction ;
|
||||||
;
|
; ;
|
||||||
; OUT:
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
ICMP_api:
|
icmp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5976 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
iglobal
|
iglobal
|
||||||
align 4
|
align 4
|
||||||
@ -27,7 +27,7 @@ LOOPBACK_DEVICE:
|
|||||||
|
|
||||||
.unload dd .dummy_fn
|
.unload dd .dummy_fn
|
||||||
.reset dd .dummy_fn
|
.reset dd .dummy_fn
|
||||||
.transmit dd LOOP_input
|
.transmit dd loop_input
|
||||||
|
|
||||||
.bytes_tx dq 0
|
.bytes_tx dq 0
|
||||||
.bytes_rx dq 0
|
.bytes_rx dq 0
|
||||||
@ -45,11 +45,11 @@ LOOPBACK_DEVICE:
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
macro LOOP_init {
|
macro loop_init {
|
||||||
local .fail
|
local .fail
|
||||||
|
|
||||||
mov ebx, LOOPBACK_DEVICE
|
mov ebx, LOOPBACK_DEVICE
|
||||||
call NET_add_device
|
call net_add_device
|
||||||
|
|
||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .fail
|
je .fail
|
||||||
@ -63,7 +63,7 @@ local .fail
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; LOOP_input ;
|
; loop_input ;
|
||||||
; ;
|
; ;
|
||||||
; IN: [esp+4] = Pointer to buffer ;
|
; IN: [esp+4] = Pointer to buffer ;
|
||||||
; ;
|
; ;
|
||||||
@ -71,7 +71,7 @@ local .fail
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
LOOP_input:
|
loop_input:
|
||||||
|
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
|
|
||||||
@ -95,19 +95,19 @@ LOOP_input:
|
|||||||
|
|
||||||
; Place protocol handlers here
|
; Place protocol handlers here
|
||||||
cmp eax, AF_INET4
|
cmp eax, AF_INET4
|
||||||
je IPv4_input
|
je ipv4_input
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", eax
|
||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; LOOP_output ;
|
; loop_output ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ecx = packet size ;
|
; IN: ecx = packet size ;
|
||||||
; edi = address family ;
|
; edi = address family ;
|
||||||
@ -119,7 +119,7 @@ LOOP_input:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
LOOP_output:
|
loop_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ LOOP_output:
|
|||||||
|
|
||||||
push ecx edi
|
push ecx edi
|
||||||
add ecx, NET_BUFF.data
|
add ecx, NET_BUFF.data
|
||||||
stdcall NET_BUFF_alloc, ecx
|
stdcall net_buff_alloc, ecx
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .out_of_ram
|
jz .out_of_ram
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -258,16 +258,14 @@ align 4
|
|||||||
endg
|
endg
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; stack_init
|
; stack_init: Initialize all network variables ;
|
||||||
;
|
; ;
|
||||||
; This function calls all network init procedures
|
; IN: / ;
|
||||||
;
|
; OUT: / ;
|
||||||
; IN: /
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
stack_init:
|
stack_init:
|
||||||
|
|
||||||
@ -294,21 +292,21 @@ stack_init:
|
|||||||
mov ecx, (NET_DEVICES_MAX + 1)
|
mov ecx, (NET_DEVICES_MAX + 1)
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
ETH_init
|
eth_init
|
||||||
|
|
||||||
PPPoE_init
|
pppoe_init
|
||||||
|
|
||||||
IPv4_init
|
ipv4_init
|
||||||
; IPv6_init
|
; ipv6_init
|
||||||
ICMP_init
|
icmp_init
|
||||||
|
|
||||||
ARP_init
|
arp_init
|
||||||
UDP_init
|
udp_init
|
||||||
TCP_init
|
tcp_init
|
||||||
|
|
||||||
SOCKET_init
|
socket_init
|
||||||
|
|
||||||
LOOP_init
|
loop_init
|
||||||
|
|
||||||
mov [net_tmr_count], 0
|
mov [net_tmr_count], 0
|
||||||
ret
|
ret
|
||||||
@ -329,16 +327,14 @@ proc stack_handler_has_work?
|
|||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; stack_handler
|
; stack_handler: Network handlers called from os_loop. ;
|
||||||
;
|
; ;
|
||||||
; This function is called in kernel loop
|
; IN: / ;
|
||||||
;
|
; OUT: / ;
|
||||||
; IN: /
|
; ;
|
||||||
; OUT: /
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
stack_handler:
|
stack_handler:
|
||||||
|
|
||||||
@ -354,13 +350,13 @@ stack_handler:
|
|||||||
test [net_10ms], 0x0f ; 160ms
|
test [net_10ms], 0x0f ; 160ms
|
||||||
jnz .exit
|
jnz .exit
|
||||||
|
|
||||||
TCP_timer_160ms
|
tcp_timer_160ms
|
||||||
|
|
||||||
test [net_10ms], 0x3f ; 640ms
|
test [net_10ms], 0x3f ; 640ms
|
||||||
jnz .exit
|
jnz .exit
|
||||||
|
|
||||||
ARP_decrease_entry_ttls
|
arp_decrease_entry_ttls
|
||||||
IPv4_decrease_fragment_ttls
|
ipv4_decrease_fragment_ttls
|
||||||
|
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
mov eax, [TCP_timer1_event]
|
mov eax, [TCP_timer1_event]
|
||||||
@ -373,7 +369,8 @@ stack_handler:
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc NET_BUFF_alloc stdcall, buffersize
|
proc net_buff_alloc stdcall, buffersize
|
||||||
|
|
||||||
cmp [buffersize], NET_BUFFER_SIZE
|
cmp [buffersize], NET_BUFFER_SIZE
|
||||||
ja .too_large
|
ja .too_large
|
||||||
|
|
||||||
@ -387,27 +384,27 @@ proc NET_BUFF_alloc stdcall, buffersize
|
|||||||
|
|
||||||
spin_unlock_irqrestore
|
spin_unlock_irqrestore
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "net alloc: 0x%x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_alloc: 0x%x\n", eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.out_of_mem:
|
.out_of_mem:
|
||||||
spin_unlock_irqrestore
|
spin_unlock_irqrestore
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "NET_BUFF_alloc: out of mem!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: out of mem!\n"
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.too_large:
|
.too_large:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "NET_BUFF_alloc: too large!\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "net_buff_alloc: too large!\n"
|
||||||
ret
|
ret
|
||||||
endp
|
endp
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc NET_BUFF_free stdcall, buffer
|
proc net_buff_free stdcall, buffer
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "net free: 0x%x\n", [buffer]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_buff_free: 0x%x\n", [buffer]
|
||||||
|
|
||||||
spin_lock_irqsave
|
spin_lock_irqsave
|
||||||
|
|
||||||
@ -423,14 +420,14 @@ endp
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_link_changed:
|
net_link_changed:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_send_event:
|
net_send_event:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_send_event\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_send_event\n"
|
||||||
|
|
||||||
; Send event to all applications
|
; Send event to all applications
|
||||||
push edi ecx
|
push edi ecx
|
||||||
@ -446,21 +443,20 @@ NET_send_event:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_add_device:
|
; net_add_device: Called by network driver to register interface. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by the network drivers,
|
; IN: ebx = ptr to device structure ;
|
||||||
; to register each running NIC to the kernel
|
; ;
|
||||||
;
|
; OUT: eax = device num on success ;
|
||||||
; IN: Pointer to device structure in ebx
|
; eax = -1 on error ;
|
||||||
; OUT: Device num in eax, -1 on error
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
NET_add_device:
|
net_add_device:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_Add_Device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
DEBUGF DEBUG_NETWORK_VERBOSE, "net_add_device: %x\n", ebx ;;; TODO: use mutex to lock net device list
|
||||||
|
|
||||||
cmp [NET_RUNNING], NET_DEVICES_MAX
|
cmp [NET_RUNNING], NET_DEVICES_MAX
|
||||||
jae .error
|
jae .error
|
||||||
@ -495,7 +491,7 @@ NET_add_device:
|
|||||||
|
|
||||||
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "Device number: %u\n", eax
|
||||||
ret
|
ret
|
||||||
@ -507,19 +503,17 @@ NET_add_device:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_Remove_Device:
|
; net_remove_device: Called by network driver to unregister dev. ;
|
||||||
;
|
; ;
|
||||||
; This function is called by network drivers,
|
; IN: ebx = ptr to device ;
|
||||||
; to unregister network devices from the kernel
|
; ;
|
||||||
;
|
; OUT: eax: -1 on error ;
|
||||||
; IN: Pointer to device structure in ebx
|
; ;
|
||||||
; OUT: eax: -1 on error
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
NET_remove_device:
|
net_remove_device:
|
||||||
|
|
||||||
cmp [NET_RUNNING], 0
|
cmp [NET_RUNNING], 0
|
||||||
je .error
|
je .error
|
||||||
@ -541,7 +535,7 @@ NET_remove_device:
|
|||||||
mov dword [edi-4], eax
|
mov dword [edi-4], eax
|
||||||
dec [NET_RUNNING]
|
dec [NET_RUNNING]
|
||||||
|
|
||||||
call NET_send_event
|
call net_send_event
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -552,25 +546,27 @@ NET_remove_device:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; NET_ptr_to_num
|
; net_ptr_to_num ;
|
||||||
;
|
; ;
|
||||||
; IN: ebx = ptr to device struct
|
; IN: ebx = ptr to device struct ;
|
||||||
; OUT: edi = -1 on error, device number otherwise
|
; ;
|
||||||
;
|
; OUT: edi = device number ;
|
||||||
;-----------------------------------------------------------------
|
; edi = -1 on error ;
|
||||||
|
; ;
|
||||||
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
NET_ptr_to_num:
|
net_ptr_to_num:
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
ror edi, 2 ; If -1, stay -1
|
ror edi, 2 ; If -1, stay -1
|
||||||
; valid device numbers have last two bits 0, so do just shr
|
; valid device numbers have last two bits 0, so do just shr
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
NET_ptr_to_num4: ; Todo, place number in device structure so we only need to verify?
|
net_ptr_to_num4: ; Todo, place number in device structure so we only need to verify?
|
||||||
|
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jz .fail
|
jz .fail
|
||||||
@ -595,21 +591,17 @@ NET_ptr_to_num4: ; Todo, place number in device structure so we o
|
|||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; checksum_1
|
; checksum_1: Calculate semi-checksum for network packets. ;
|
||||||
;
|
; ;
|
||||||
; This is the first of two functions needed to calculate a checksum.
|
; IN: edx = start offset for semi-checksum ;
|
||||||
;
|
; esi = pointer to data ;
|
||||||
; IN: edx = start offset for semi-checksum
|
; ecx = data size ;
|
||||||
; esi = pointer to data
|
; ;
|
||||||
; ecx = data size
|
; OUT: edx = semi-checksum ;
|
||||||
; OUT: edx = semi-checksum
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;
|
|
||||||
; Code was optimized by diamond
|
|
||||||
;
|
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
checksum_1:
|
checksum_1:
|
||||||
|
|
||||||
@ -679,16 +671,15 @@ checksum_1:
|
|||||||
.end:
|
.end:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
;-----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; checksum_2
|
; checksum_2: Calculate the final ip/tcp/udp checksum. ;
|
||||||
;
|
; ;
|
||||||
; This function calculates the final ip/tcp/udp checksum for you
|
; IN: edx = semi-checksum ;
|
||||||
;
|
; ;
|
||||||
; IN: edx = semi-checksum
|
; OUT: dx = checksum (in INET byte order) ;
|
||||||
; OUT: dx = checksum (in INET byte order)
|
; ;
|
||||||
;
|
;-----------------------------------------------------------------;
|
||||||
;-----------------------------------------------------------------
|
|
||||||
align 4
|
align 4
|
||||||
checksum_2:
|
checksum_2:
|
||||||
|
|
||||||
@ -713,11 +704,11 @@ checksum_2:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; System function to work with network devices (74)
|
; System function 74: Low level access to network devices. ;
|
||||||
;
|
; ;
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
sys_network:
|
sys_network:
|
||||||
|
|
||||||
@ -736,7 +727,7 @@ sys_network:
|
|||||||
and esi, 0x0000ff00
|
and esi, 0x0000ff00
|
||||||
shr esi, 6
|
shr esi, 6
|
||||||
|
|
||||||
cmp dword [esi + NET_DRV_LIST], 0 ; check if driver is running
|
cmp dword[esi + NET_DRV_LIST], 0 ; check if driver is running
|
||||||
je .doesnt_exist
|
je .doesnt_exist
|
||||||
|
|
||||||
mov eax, [esi + NET_DRV_LIST]
|
mov eax, [esi + NET_DRV_LIST]
|
||||||
@ -809,16 +800,16 @@ sys_network:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.bytes_tx:
|
.bytes_tx:
|
||||||
mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
|
mov ebx, dword[eax + NET_DEVICE.bytes_tx + 4]
|
||||||
mov [esp+20], ebx
|
mov [esp+20], ebx
|
||||||
mov eax, dword [eax + NET_DEVICE.bytes_tx]
|
mov eax, dword[eax + NET_DEVICE.bytes_tx]
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.bytes_rx:
|
.bytes_rx:
|
||||||
mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
|
mov ebx, dword[eax + NET_DEVICE.bytes_rx + 4]
|
||||||
mov [esp+20], ebx
|
mov [esp+20], ebx
|
||||||
mov eax, dword [eax + NET_DEVICE.bytes_rx]
|
mov eax, dword[eax + NET_DEVICE.bytes_rx]
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -834,11 +825,11 @@ sys_network:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
;
|
; ;
|
||||||
; System function to work with protocols (76)
|
; System function 76: Low level access to protocol handlers. ;
|
||||||
;
|
; ;
|
||||||
;----------------------------------------------------------------
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
sys_protocols:
|
sys_protocols:
|
||||||
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
cmp bh, NET_DEVICES_MAX ; Check if device number exists
|
||||||
@ -856,28 +847,28 @@ sys_protocols:
|
|||||||
shr eax, 16 ;
|
shr eax, 16 ;
|
||||||
|
|
||||||
cmp ax, API_ETH
|
cmp ax, API_ETH
|
||||||
je ETH_api
|
je eth_api
|
||||||
|
|
||||||
cmp ax, API_IPv4
|
cmp ax, API_IPv4
|
||||||
je IPv4_api
|
je ipv4_api
|
||||||
|
|
||||||
cmp ax, API_ICMP
|
cmp ax, API_ICMP
|
||||||
je ICMP_api
|
je icmp_api
|
||||||
|
|
||||||
cmp ax, API_UDP
|
cmp ax, API_UDP
|
||||||
je UDP_api
|
je udp_api
|
||||||
|
|
||||||
cmp ax, API_TCP
|
cmp ax, API_TCP
|
||||||
je TCP_api
|
je tcp_api
|
||||||
|
|
||||||
cmp ax, API_ARP
|
cmp ax, API_ARP
|
||||||
je ARP_api
|
je arp_api
|
||||||
|
|
||||||
cmp ax, API_PPPOE
|
cmp ax, API_PPPOE
|
||||||
je PPPoE_api
|
je pppoe_api
|
||||||
|
|
||||||
cmp ax, API_IPv6
|
cmp ax, API_IPv6
|
||||||
je IPv6_api
|
je ipv6_api
|
||||||
|
|
||||||
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
add esp, 4 ; if we reached here, no function was called, so we need to balance stack
|
||||||
|
|
||||||
|
@ -206,7 +206,7 @@ endg
|
|||||||
; TCP_init: Resets all TCP variables. ;
|
; TCP_init: Resets all TCP variables. ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
macro TCP_init {
|
macro tcp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, TCP_segments_tx
|
mov edi, TCP_segments_tx
|
||||||
@ -219,7 +219,7 @@ macro TCP_init {
|
|||||||
init_queue TCP_queue
|
init_queue TCP_queue
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, TCP_process_input
|
mov ecx, tcp_process_input
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -227,7 +227,7 @@ macro TCP_init {
|
|||||||
@@:
|
@@:
|
||||||
|
|
||||||
movi ebx, 1
|
movi ebx, 1
|
||||||
mov ecx, TCP_timer_640ms
|
mov ecx, tcp_timer_640ms
|
||||||
call new_sys_threads
|
call new_sys_threads
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jns @f
|
jns @f
|
||||||
@ -246,7 +246,7 @@ include 'tcp_output.inc'
|
|||||||
|
|
||||||
;------------------------------------------------------------------;
|
;------------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_api: This function is called by system function 76 ;
|
; tcp_api: Part of system function 76 ;
|
||||||
; ;
|
; ;
|
||||||
; IN: bl = subfunction number ;
|
; IN: bl = subfunction number ;
|
||||||
; bh = device number ;
|
; bh = device number ;
|
||||||
@ -256,7 +256,7 @@ include 'tcp_output.inc'
|
|||||||
; ;
|
; ;
|
||||||
;------------------------------------------------------------------;
|
;------------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_api:
|
tcp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5976 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
@ -31,7 +31,7 @@ $Revision: 5976 $
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_input:
|
tcp_input:
|
||||||
|
|
||||||
; record the current time
|
; record the current time
|
||||||
push [timer_ticks] ; in 1/100 seconds
|
push [timer_ticks] ; in 1/100 seconds
|
||||||
@ -57,17 +57,17 @@ TCP_input:
|
|||||||
pop edi
|
pop edi
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP incoming queue is full, discarding packet!\n"
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_missed + edi]
|
inc [TCP_segments_missed + edi]
|
||||||
|
|
||||||
add esp, sizeof.TCP_queue_entry - 4
|
add esp, sizeof.TCP_queue_entry - 4
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc TCP_process_input
|
proc tcp_process_input
|
||||||
|
|
||||||
locals
|
locals
|
||||||
dataoffset dd ?
|
dataoffset dd ?
|
||||||
@ -111,7 +111,7 @@ endl
|
|||||||
push ecx esi
|
push ecx esi
|
||||||
pushw [esi + TCP_header.Checksum]
|
pushw [esi + TCP_header.Checksum]
|
||||||
mov [esi + TCP_header.Checksum], 0
|
mov [esi + TCP_header.Checksum], 0
|
||||||
TCP_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
|
tcp_checksum (edi+IPv4_header.SourceAddress), (edi+IPv4_header.DestinationAddress)
|
||||||
pop cx ; previous checksum
|
pop cx ; previous checksum
|
||||||
cmp cx, dx
|
cmp cx, dx
|
||||||
pop edx ecx
|
pop edx ecx
|
||||||
@ -234,7 +234,7 @@ endl
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
push ecx edx esi edi
|
push ecx edx esi edi
|
||||||
call SOCKET_fork
|
call socket_fork
|
||||||
pop edi esi edx ecx
|
pop edi esi edx ecx
|
||||||
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
@ -312,7 +312,7 @@ endl
|
|||||||
lodsw
|
lodsw
|
||||||
rol ax, 8
|
rol ax, 8
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Maxseg=%u\n", eax
|
||||||
call TCP_mss
|
call tcp_mss
|
||||||
@@:
|
@@:
|
||||||
jmp .opt_loop
|
jmp .opt_loop
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ endl
|
|||||||
pusha
|
pusha
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
popa
|
popa
|
||||||
|
|
||||||
; Update RTT estimators
|
; Update RTT estimators
|
||||||
@ -483,7 +483,7 @@ endl
|
|||||||
mov eax, [timestamp]
|
mov eax, [timestamp]
|
||||||
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
||||||
inc eax
|
inc eax
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .rtt_done
|
jmp .rtt_done
|
||||||
.no_timestamp_rtt:
|
.no_timestamp_rtt:
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ endl
|
|||||||
cmp eax, [ebx + TCP_SOCKET.t_rtseq]
|
cmp eax, [ebx + TCP_SOCKET.t_rtseq]
|
||||||
jbe .rtt_done
|
jbe .rtt_done
|
||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
.rtt_done:
|
.rtt_done:
|
||||||
|
|
||||||
; update window pointers
|
; update window pointers
|
||||||
@ -511,10 +511,10 @@ endl
|
|||||||
|
|
||||||
; Awaken waiting processes
|
; Awaken waiting processes
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
; Generate more output
|
; Generate more output
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
@ -540,11 +540,11 @@ endl
|
|||||||
mov esi, [dataoffset]
|
mov esi, [dataoffset]
|
||||||
add esi, edx
|
add esi, edx
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_write ; Add the data to the socket buffer
|
call socket_ring_write ; Add the data to the socket buffer
|
||||||
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag
|
or [ebx + TCP_SOCKET.t_flags], TF_DELACK ; Set delayed ack flag
|
||||||
|
|
||||||
@ -661,7 +661,7 @@ endl
|
|||||||
jz .not_terminated
|
jz .not_terminated
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
inc [TCPS_rcvafterclose]
|
inc [TCPS_rcvafterclose]
|
||||||
jmp .respond_seg_reset
|
jmp .respond_seg_reset
|
||||||
|
|
||||||
@ -691,7 +691,7 @@ endl
|
|||||||
; cmp edx, [edx + TCP_header.SequenceNumber]
|
; cmp edx, [edx + TCP_header.SequenceNumber]
|
||||||
; add edx, 64000 ; TCP_ISSINCR FIXME
|
; add edx, 64000 ; TCP_ISSINCR FIXME
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .findpcb ; FIXME: skip code for unscaling window, ...
|
jmp .findpcb ; FIXME: skip code for unscaling window, ...
|
||||||
.no_new_request:
|
.no_new_request:
|
||||||
|
|
||||||
@ -779,14 +779,14 @@ endl
|
|||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
;;; TODO: update stats (tcp drops)
|
;;; TODO: update stats (tcp drops)
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.rst_close:
|
.rst_close:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Closing with reset\n"
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.no_rst:
|
.no_rst:
|
||||||
@ -799,7 +799,7 @@ endl
|
|||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ebx, ECONNRESET
|
mov ebx, ECONNRESET
|
||||||
call TCP_drop
|
call tcp_drop
|
||||||
jmp .drop_with_reset
|
jmp .drop_with_reset
|
||||||
.not_syn_full:
|
.not_syn_full:
|
||||||
|
|
||||||
@ -824,7 +824,7 @@ endl
|
|||||||
;;; TODO: update stats
|
;;; TODO: update stats
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
|
|
||||||
; Do window scaling?
|
; Do window scaling?
|
||||||
@ -838,7 +838,7 @@ endl
|
|||||||
pop word [ebx + TCP_SOCKET.SND_SCALE]
|
pop word [ebx + TCP_SOCKET.SND_SCALE]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
call TCP_reassemble
|
call tcp_reassemble
|
||||||
|
|
||||||
mov eax, [edx + TCP_header.SequenceNumber]
|
mov eax, [edx + TCP_header.SequenceNumber]
|
||||||
dec eax
|
dec eax
|
||||||
@ -916,7 +916,7 @@ endl
|
|||||||
|
|
||||||
; retransmit missing segment
|
; retransmit missing segment
|
||||||
mov eax, [esp]
|
mov eax, [esp]
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
; Lock the socket again
|
; Lock the socket again
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
@ -955,7 +955,7 @@ endl
|
|||||||
|
|
||||||
; retransmit missing segment
|
; retransmit missing segment
|
||||||
mov eax, [esp]
|
mov eax, [esp]
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
; Lock the socket again
|
; Lock the socket again
|
||||||
mov ecx, [esp]
|
mov ecx, [esp]
|
||||||
@ -1005,7 +1005,7 @@ endl
|
|||||||
mov eax, [timestamp]
|
mov eax, [timestamp]
|
||||||
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
sub eax, [ebx + TCP_SOCKET.ts_ecr]
|
||||||
inc eax
|
inc eax
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .rtt_done_
|
jmp .rtt_done_
|
||||||
|
|
||||||
; If no timestamp but transmit timer is running and timed sequence number was acked,
|
; If no timestamp but transmit timer is running and timed sequence number was acked,
|
||||||
@ -1020,7 +1020,7 @@ endl
|
|||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .rtt_done_
|
jz .rtt_done_
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
|
|
||||||
.rtt_done_:
|
.rtt_done_:
|
||||||
|
|
||||||
@ -1085,7 +1085,7 @@ endl
|
|||||||
mov ecx, [ebx + STREAM_SOCKET.snd.size]
|
mov ecx, [ebx + STREAM_SOCKET.snd.size]
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
pop ebx edx ecx
|
pop ebx edx ecx
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: our FIN is acked\n"
|
||||||
@ -1097,7 +1097,7 @@ endl
|
|||||||
push ecx edx ebx
|
push ecx edx ebx
|
||||||
mov ecx, edi
|
mov ecx, edi
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_free
|
call socket_ring_free
|
||||||
pop ebx
|
pop ebx
|
||||||
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
sub [ebx + TCP_SOCKET.SND_WND], ecx
|
||||||
pop edx ecx
|
pop edx ecx
|
||||||
@ -1109,7 +1109,7 @@ endl
|
|||||||
|
|
||||||
.wakeup:
|
.wakeup:
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
; Update TCPS
|
; Update TCPS
|
||||||
mov eax, [edx + TCP_header.AckNumber]
|
mov eax, [edx + TCP_header.AckNumber]
|
||||||
@ -1147,7 +1147,7 @@ endl
|
|||||||
test [ebx + SOCKET.state], SS_CANTRCVMORE
|
test [ebx + SOCKET.state], SS_CANTRCVMORE
|
||||||
jnz @f
|
jnz @f
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
mov [ebx + TCP_SOCKET.timer_timed_wait], TCP_time_max_idle
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
@@:
|
@@:
|
||||||
@ -1160,11 +1160,11 @@ endl
|
|||||||
|
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call tcp_cancel_timers
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
jmp .ack_processed
|
jmp .ack_processed
|
||||||
|
|
||||||
.ack_la:
|
.ack_la:
|
||||||
@ -1177,7 +1177,7 @@ endl
|
|||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_close
|
call tcp_close
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.ack_tw:
|
.ack_tw:
|
||||||
@ -1224,8 +1224,8 @@ align 4
|
|||||||
mov [ebx + TCP_SOCKET.ISS], eax
|
mov [ebx + TCP_SOCKET.ISS], eax
|
||||||
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
mov [ebx + TCP_SOCKET.SND_NXT], eax
|
||||||
|
|
||||||
TCP_sendseqinit ebx
|
tcp_sendseqinit ebx
|
||||||
TCP_rcvseqinit ebx
|
tcp_rcvseqinit ebx
|
||||||
|
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
@ -1233,12 +1233,12 @@ align 4
|
|||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .drop
|
jz .drop
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .drop
|
jz .drop
|
||||||
|
|
||||||
@ -1246,7 +1246,7 @@ align 4
|
|||||||
|
|
||||||
pusha
|
pusha
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
popa
|
popa
|
||||||
|
|
||||||
jmp .trim
|
jmp .trim
|
||||||
@ -1278,7 +1278,7 @@ align 4
|
|||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ebx, ECONNREFUSED
|
mov ebx, ECONNREFUSED
|
||||||
call TCP_drop
|
call tcp_drop
|
||||||
|
|
||||||
jmp .drop
|
jmp .drop
|
||||||
@@:
|
@@:
|
||||||
@ -1306,7 +1306,7 @@ align 4
|
|||||||
push [edx + TCP_header.SequenceNumber]
|
push [edx + TCP_header.SequenceNumber]
|
||||||
pop [ebx + TCP_SOCKET.IRS]
|
pop [ebx + TCP_SOCKET.IRS]
|
||||||
|
|
||||||
TCP_rcvseqinit ebx
|
tcp_rcvseqinit ebx
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
|
|
||||||
@ -1324,7 +1324,7 @@ align 4
|
|||||||
; set socket state to connected
|
; set socket state to connected
|
||||||
push eax
|
push eax
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
pop eax
|
pop eax
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
mov [ebx + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
|
|
||||||
@ -1334,8 +1334,8 @@ align 4
|
|||||||
cmp eax, TF_REQ_SCALE or TF_RCVD_SCALE
|
cmp eax, TF_REQ_SCALE or TF_RCVD_SCALE
|
||||||
jne .no_scaling
|
jne .no_scaling
|
||||||
|
|
||||||
mov ax, word [ebx + TCP_SOCKET.requested_s_scale]
|
mov ax, word[ebx + TCP_SOCKET.requested_s_scale]
|
||||||
mov word [ebx + TCP_SOCKET.SND_SCALE], ax
|
mov word[ebx + TCP_SOCKET.SND_SCALE], ax
|
||||||
.no_scaling:
|
.no_scaling:
|
||||||
|
|
||||||
;;; TODO: reassemble packets queue
|
;;; TODO: reassemble packets queue
|
||||||
@ -1343,7 +1343,7 @@ align 4
|
|||||||
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
mov eax, [ebx + TCP_SOCKET.t_rtt]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
je .trim
|
je .trim
|
||||||
call TCP_xmit_timer
|
call tcp_xmit_timer
|
||||||
jmp .trim
|
jmp .trim
|
||||||
|
|
||||||
.simultaneous_open:
|
.simultaneous_open:
|
||||||
@ -1485,13 +1485,13 @@ align 4
|
|||||||
mov esi, [dataoffset]
|
mov esi, [dataoffset]
|
||||||
add esi, edx
|
add esi, edx
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_write ; Add the data to the socket buffer
|
call socket_ring_write ; Add the data to the socket buffer
|
||||||
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
add [ebx + TCP_SOCKET.RCV_NXT], ecx ; Update sequence number with number of bytes we have copied
|
||||||
popa
|
popa
|
||||||
|
|
||||||
; Wake up the sleeping process
|
; Wake up the sleeping process
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
|
|
||||||
jmp .data_done
|
jmp .data_done
|
||||||
|
|
||||||
@ -1501,7 +1501,7 @@ align 4
|
|||||||
|
|
||||||
; Uh-oh, some data is out of order, lets call TCP reassemble for help
|
; Uh-oh, some data is out of order, lets call TCP reassemble for help
|
||||||
|
|
||||||
call TCP_reassemble
|
call tcp_reassemble
|
||||||
|
|
||||||
; Generate ACK immediately, to let the other end know that a segment was received out of order,
|
; Generate ACK immediately, to let the other end know that a segment was received out of order,
|
||||||
; and to tell it what sequence number is expected. This aids the fast-retransmit algorithm.
|
; and to tell it what sequence number is expected. This aids the fast-retransmit algorithm.
|
||||||
@ -1522,7 +1522,7 @@ align 4
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: First FIN for this connection\n"
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_cant_recv_more
|
call socket_cant_recv_more
|
||||||
|
|
||||||
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
or [ebx + TCP_SOCKET.t_flags], TF_ACKNOW
|
||||||
inc [ebx + TCP_SOCKET.RCV_NXT]
|
inc [ebx + TCP_SOCKET.RCV_NXT]
|
||||||
@ -1556,8 +1556,8 @@ align 4
|
|||||||
.fin_wait2:
|
.fin_wait2:
|
||||||
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
mov [ebx + TCP_SOCKET.t_state], TCPS_TIMED_WAIT
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call TCP_cancel_timers
|
call tcp_cancel_timers
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
|
|
||||||
.fin_timed:
|
.fin_timed:
|
||||||
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
mov [ebx + TCP_SOCKET.timer_timed_wait], 2 * TCP_time_MSL
|
||||||
@ -1583,12 +1583,12 @@ align 4
|
|||||||
|
|
||||||
.need_output:
|
.need_output:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: need output\n"
|
||||||
call TCP_output
|
call tcp_output
|
||||||
|
|
||||||
.done:
|
.done:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: dumping\n"
|
||||||
|
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
|
|
||||||
@ -1621,7 +1621,7 @@ align 4
|
|||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jnz .done
|
jnz .done
|
||||||
|
|
||||||
;;; if its a multicast/broadcast, also drop
|
; TODO: if its a multicast/broadcast, also drop
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jnz .respond_ack
|
jnz .respond_ack
|
||||||
@ -1636,14 +1636,14 @@ align 4
|
|||||||
.respond_ack:
|
.respond_ack:
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_RST
|
mov cl, TH_RST
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
pop ebx
|
pop ebx
|
||||||
jmp .destroy_new_socket
|
jmp .destroy_new_socket
|
||||||
|
|
||||||
.respond_syn:
|
.respond_syn:
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_RST + TH_ACK
|
mov cl, TH_RST + TH_ACK
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
pop ebx
|
pop ebx
|
||||||
jmp .destroy_new_socket
|
jmp .destroy_new_socket
|
||||||
|
|
||||||
@ -1660,7 +1660,7 @@ align 4
|
|||||||
test [edx + TCP_header.Flags], TH_RST
|
test [edx + TCP_header.Flags], TH_RST
|
||||||
jnz .drop_no_socket
|
jnz .drop_no_socket
|
||||||
|
|
||||||
;;; TODO: if its a multicast/broadcast, also drop
|
; TODO: if its a multicast/broadcast, also drop
|
||||||
|
|
||||||
test [edx + TCP_header.Flags], TH_ACK
|
test [edx + TCP_header.Flags], TH_ACK
|
||||||
jnz .respond_seg_ack
|
jnz .respond_seg_ack
|
||||||
@ -1673,13 +1673,13 @@ align 4
|
|||||||
.respond_seg_ack:
|
.respond_seg_ack:
|
||||||
mov cl, TH_RST
|
mov cl, TH_RST
|
||||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||||
call TCP_respond_segment
|
call tcp_respond_segment
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
.respond_seg_syn:
|
.respond_seg_syn:
|
||||||
mov cl, TH_RST + TH_ACK
|
mov cl, TH_RST + TH_ACK
|
||||||
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
xor ebx, ebx ; FIXME: find a way to get the receiving device ptr
|
||||||
call TCP_respond_segment
|
call tcp_respond_segment
|
||||||
jmp .drop_no_socket
|
jmp .drop_no_socket
|
||||||
|
|
||||||
;------------------------------------------------
|
;------------------------------------------------
|
||||||
@ -1701,7 +1701,7 @@ align 4
|
|||||||
jz .drop_no_socket
|
jz .drop_no_socket
|
||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
call SOCKET_free
|
call socket_free
|
||||||
|
|
||||||
;------------------
|
;------------------
|
||||||
; Drop the segment
|
; Drop the segment
|
||||||
@ -1709,7 +1709,7 @@ align 4
|
|||||||
.drop_no_socket:
|
.drop_no_socket:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_input: Drop (no socket)\n"
|
||||||
|
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
endp
|
endp
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5584 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_output ;
|
; tcp_output ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ;
|
; ;
|
||||||
@ -26,7 +26,7 @@ $Revision: 5584 $
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
proc TCP_output
|
proc tcp_output
|
||||||
|
|
||||||
locals
|
locals
|
||||||
temp_bits db ?
|
temp_bits db ?
|
||||||
@ -72,7 +72,7 @@ endl
|
|||||||
mov ecx, [eax + TCP_SOCKET.SND_CWND] ;
|
mov ecx, [eax + TCP_SOCKET.SND_CWND] ;
|
||||||
@@: ;
|
@@: ;
|
||||||
|
|
||||||
call TCP_outflags ; flags in dl
|
call tcp_outflags ; flags in dl
|
||||||
|
|
||||||
;------------------------
|
;------------------------
|
||||||
; data being forced out ?
|
; data being forced out ?
|
||||||
@ -279,7 +279,7 @@ endl
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_output: Entering persist state\n"
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
mov [eax + TCP_SOCKET.t_rxtshift], 0
|
||||||
call TCP_set_persist
|
call tcp_set_persist
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
@ -509,7 +509,7 @@ endl
|
|||||||
mov edi, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
mov edi, [eax + IP_SOCKET.RemoteIP] ; dest ip
|
||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_TCP
|
mov ah, IP_PROTO_TCP
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .ip_error
|
jz .ip_error
|
||||||
|
|
||||||
;------------------------------------------
|
;------------------------------------------
|
||||||
@ -549,7 +549,7 @@ endl
|
|||||||
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
add [eax + TCP_SOCKET.SND_NXT], ecx ; update sequence number
|
||||||
sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset
|
sub edx, [eax + TCP_SOCKET.SND_UNA] ; offset
|
||||||
add eax, STREAM_SOCKET.snd
|
add eax, STREAM_SOCKET.snd
|
||||||
call SOCKET_ring_read
|
call socket_ring_read
|
||||||
.nodata:
|
.nodata:
|
||||||
pop edi
|
pop edi
|
||||||
pop esi ; begin of data
|
pop esi ; begin of data
|
||||||
@ -606,7 +606,7 @@ endl
|
|||||||
test [ebx + NET_DEVICE.hwacc], NET_HWACC_TCP_IPv4_OUT
|
test [ebx + NET_DEVICE.hwacc], NET_HWACC_TCP_IPv4_OUT
|
||||||
jnz .checksum_ok
|
jnz .checksum_ok
|
||||||
|
|
||||||
TCP_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
|
tcp_checksum (eax + IP_SOCKET.LocalIP), (eax + IP_SOCKET.RemoteIP)
|
||||||
|
|
||||||
.checksum_ok:
|
.checksum_ok:
|
||||||
mov [esi + TCP_header.Checksum], dx
|
mov [esi + TCP_header.Checksum], dx
|
||||||
@ -624,7 +624,7 @@ endl
|
|||||||
pop ecx
|
pop ecx
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
inc [TCPS_sndtotal]
|
inc [TCPS_sndtotal]
|
||||||
|
|
||||||
@ -658,7 +658,7 @@ endl
|
|||||||
; Check if we need more output
|
; Check if we need more output
|
||||||
|
|
||||||
test [temp_bits], TCP_BIT_SENDALOT
|
test [temp_bits], TCP_BIT_SENDALOT
|
||||||
jnz TCP_output.again
|
jnz tcp_output.again
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_send: success!\n"
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5584 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
iglobal
|
iglobal
|
||||||
TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6
|
TCP_backoff db 0,1,2,3,4,5,6,6,6,6,6,6,6
|
||||||
endg
|
endg
|
||||||
|
|
||||||
macro TCP_checksum IP1, IP2 {
|
macro tcp_checksum IP1, IP2 {
|
||||||
|
|
||||||
;-------------
|
;-------------
|
||||||
; Pseudoheader
|
; Pseudoheader
|
||||||
@ -60,9 +60,9 @@ macro TCP_checksum IP1, IP2 {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_sendseqinit ptr {
|
macro tcp_sendseqinit ptr {
|
||||||
|
|
||||||
push edi ;;;; i dont like this static use of edi
|
push edi ;;;; FIXME: i dont like this static use of edi
|
||||||
mov edi, [ptr + TCP_SOCKET.ISS]
|
mov edi, [ptr + TCP_SOCKET.ISS]
|
||||||
mov [ptr + TCP_SOCKET.SND_UP], edi
|
mov [ptr + TCP_SOCKET.SND_UP], edi
|
||||||
mov [ptr + TCP_SOCKET.SND_MAX], edi
|
mov [ptr + TCP_SOCKET.SND_MAX], edi
|
||||||
@ -74,7 +74,7 @@ macro TCP_sendseqinit ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_rcvseqinit ptr {
|
macro tcp_rcvseqinit ptr {
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
mov edi, [ptr + TCP_SOCKET.IRS]
|
mov edi, [ptr + TCP_SOCKET.IRS]
|
||||||
@ -87,7 +87,7 @@ macro TCP_rcvseqinit ptr {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
macro TCP_init_socket socket {
|
macro tcp_init_socket socket {
|
||||||
|
|
||||||
mov [socket + TCP_SOCKET.t_maxseg], TCP_mss_default
|
mov [socket + TCP_SOCKET.t_maxseg], TCP_mss_default
|
||||||
mov [socket + TCP_SOCKET.t_flags], TF_REQ_SCALE or TF_REQ_TSTMP
|
mov [socket + TCP_SOCKET.t_flags], TF_REQ_SCALE or TF_REQ_TSTMP
|
||||||
@ -106,7 +106,7 @@ macro TCP_init_socket socket {
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_pull_out_of_band ;
|
; tcp_pull_out_of_band ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = ? ;
|
; IN: eax = ? ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -116,9 +116,9 @@ macro TCP_init_socket socket {
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_pull_out_of_band:
|
tcp_pull_out_of_band:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_pull_out_of_band\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_pull_out_of_band\n"
|
||||||
|
|
||||||
;;;; 1282-1305
|
;;;; 1282-1305
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ TCP_pull_out_of_band:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_drop ;
|
; tcp_drop ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ebx = error number ;
|
; ebx = error number ;
|
||||||
@ -137,9 +137,9 @@ TCP_pull_out_of_band:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_drop: ; FIXME CHECKME TODO
|
tcp_drop: ; FIXME CHECKME TODO
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "tcp_drop: %x\n", eax
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_RECEIVED
|
||||||
jb .no_syn_received
|
jb .no_syn_received
|
||||||
@ -147,12 +147,12 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
;;; TODO: update stats
|
;;; TODO: update stats
|
||||||
|
|
||||||
jmp TCP_close
|
jmp tcp_close
|
||||||
|
|
||||||
.no_syn_received:
|
.no_syn_received:
|
||||||
|
|
||||||
@ -167,7 +167,7 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_disconnect ;
|
; tcp_disconnect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -175,22 +175,22 @@ TCP_drop: ; FIXME CHECKME TODO
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_disconnect:
|
tcp_disconnect:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_disconnect: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_disconnect: %x\n", eax
|
||||||
|
|
||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
jb TCP_close ; Connection not yet synchronised, just get rid of the socket
|
jb tcp_close ; Connection not yet synchronised, just get rid of the socket
|
||||||
|
|
||||||
; TODO: implement LINGER
|
; TODO: implement LINGER
|
||||||
|
|
||||||
call SOCKET_is_disconnecting
|
call socket_is_disconnecting
|
||||||
call TCP_usrclosed
|
call tcp_usrclosed
|
||||||
|
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz @f
|
jz @f
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -198,7 +198,7 @@ TCP_disconnect:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_close ;
|
; tcp_close ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -206,15 +206,15 @@ TCP_disconnect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_close:
|
tcp_close:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_close: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_close: %x\n", eax
|
||||||
|
|
||||||
;;; TODO: update RTT and mean deviation
|
;;; TODO: update RTT and mean deviation
|
||||||
;;; TODO: update slow start threshold
|
;;; TODO: update slow start threshold
|
||||||
|
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
call SOCKET_free
|
call socket_free
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -223,7 +223,7 @@ TCP_close:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_outflags ;
|
; tcp_outflags ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -231,10 +231,10 @@ TCP_close:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_outflags:
|
tcp_outflags:
|
||||||
|
|
||||||
mov edx, [eax + TCP_SOCKET.t_state]
|
mov edx, [eax + TCP_SOCKET.t_state]
|
||||||
movzx edx, byte [edx + .flaglist]
|
movzx edx, byte[edx + .flaglist]
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_outflags: socket=%x flags=%x\n", eax, dl
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_outflags: socket=%x flags=%x\n", eax, dl
|
||||||
|
|
||||||
@ -270,7 +270,7 @@ TCP_outflags:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_respond:
|
tcp_respond:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: socket=%x flags=%x\n", ebx, cl
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_socket: socket=%x flags=%x\n", ebx, cl
|
||||||
|
|
||||||
@ -284,7 +284,7 @@ TCP_respond:
|
|||||||
mov ah, IP_PROTO_TCP
|
mov ah, IP_PROTO_TCP
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov ebx, [ebx + IP_SOCKET.device]
|
mov ebx, [ebx + IP_SOCKET.device]
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .error
|
jz .error
|
||||||
pop esi cx
|
pop esi cx
|
||||||
push eax
|
push eax
|
||||||
@ -320,7 +320,7 @@ TCP_respond:
|
|||||||
sub edi, sizeof.TCP_header
|
sub edi, sizeof.TCP_header
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
xchg esi, edi
|
xchg esi, edi
|
||||||
TCP_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
|
tcp_checksum (edi + IP_SOCKET.LocalIP), (edi + IP_SOCKET.RemoteIP)
|
||||||
mov [esi+TCP_header.Checksum], dx
|
mov [esi+TCP_header.Checksum], dx
|
||||||
|
|
||||||
;--------------------
|
;--------------------
|
||||||
@ -329,7 +329,7 @@ TCP_respond:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -343,7 +343,7 @@ TCP_respond:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_respond_segment ;
|
; tcp_respond_segment ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ebx = device ptr ;
|
; IN: ebx = device ptr ;
|
||||||
; edx = segment ptr (a previously received segment) ;
|
; edx = segment ptr (a previously received segment) ;
|
||||||
@ -354,7 +354,7 @@ TCP_respond:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_respond_segment:
|
tcp_respond_segment:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: frame=%x flags=%x\n", edx, cl
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_respond_segment: frame=%x flags=%x\n", edx, cl
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ TCP_respond_segment:
|
|||||||
mov edi, [edi + IPv4_header.SourceAddress]
|
mov edi, [edi + IPv4_header.SourceAddress]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
mov ax, IP_PROTO_TCP shl 8 + 128
|
mov ax, IP_PROTO_TCP shl 8 + 128
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .error
|
jz .error
|
||||||
pop esi cx
|
pop esi cx
|
||||||
|
|
||||||
@ -399,7 +399,7 @@ TCP_respond_segment:
|
|||||||
|
|
||||||
lea esi, [edi - sizeof.TCP_header]
|
lea esi, [edi - sizeof.TCP_header]
|
||||||
mov ecx, sizeof.TCP_header
|
mov ecx, sizeof.TCP_header
|
||||||
TCP_checksum (esi - sizeof.IPv4_header + IPv4_header.DestinationAddress),\ ; FIXME
|
tcp_checksum (esi - sizeof.IPv4_header + IPv4_header.DestinationAddress),\ ; FIXME
|
||||||
(esi - sizeof.IPv4_header + IPv4_header.SourceAddress)
|
(esi - sizeof.IPv4_header + IPv4_header.SourceAddress)
|
||||||
mov [esi + TCP_header.Checksum], dx
|
mov [esi + TCP_header.Checksum], dx
|
||||||
|
|
||||||
@ -409,7 +409,7 @@ TCP_respond_segment:
|
|||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [TCP_segments_tx + edi]
|
inc [TCP_segments_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
@ -421,7 +421,7 @@ TCP_respond_segment:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
macro TCPT_RANGESET timer, value, min, max {
|
macro tcpt_rangeset timer, value, min, max {
|
||||||
|
|
||||||
local .min
|
local .min
|
||||||
local .max
|
local .max
|
||||||
@ -448,11 +448,11 @@ local .done
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_set_persist ;
|
; tcp_set_persist ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_set_persist:
|
tcp_set_persist:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_set_persist\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_set_persist\n"
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ TCP_set_persist:
|
|||||||
|
|
||||||
; Start/restart persistance timer.
|
; Start/restart persistance timer.
|
||||||
|
|
||||||
TCPT_RANGESET [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
tcpt_rangeset [eax + TCP_SOCKET.timer_persist], ebx, TCP_time_pers_min, TCP_time_pers_max
|
||||||
or [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
or [ebx + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ TCP_set_persist:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_xmit_timer: Calculate new smoothed RTT. ;
|
; tcp_xmit_timer: Calculate new smoothed RTT. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = rtt ;
|
; IN: eax = rtt ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -498,7 +498,7 @@ TCP_set_persist:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_xmit_timer:
|
tcp_xmit_timer:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=0x%x rtt=%d0ms\n", ebx, eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_xmit_timer: socket=0x%x rtt=%d0ms\n", ebx, eax
|
||||||
|
|
||||||
@ -563,7 +563,7 @@ TCP_xmit_timer:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_mss: Update maximum segment size ;
|
; tcp_mss: Update maximum segment size ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = max segment size ;
|
; IN: eax = max segment size ;
|
||||||
; ebx = socket ptr ;
|
; ebx = socket ptr ;
|
||||||
@ -572,7 +572,7 @@ TCP_xmit_timer:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_mss:
|
tcp_mss:
|
||||||
|
|
||||||
cmp eax, 1420 ; FIXME
|
cmp eax, 1420 ; FIXME
|
||||||
jbe @f
|
jbe @f
|
||||||
@ -587,7 +587,7 @@ TCP_mss:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_reassemble ;
|
; tcp_reassemble ;
|
||||||
; ;
|
; ;
|
||||||
; IN: ebx = socket ptr ;
|
; IN: ebx = socket ptr ;
|
||||||
; edx = segment ptr ;
|
; edx = segment ptr ;
|
||||||
@ -596,7 +596,7 @@ TCP_mss:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_reassemble:
|
tcp_reassemble:
|
||||||
|
|
||||||
;;;;; TODO
|
;;;;; TODO
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5442 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
timer_flag_retransmission = 1 shl 0
|
timer_flag_retransmission = 1 shl 0
|
||||||
timer_flag_keepalive = 1 shl 1
|
timer_flag_keepalive = 1 shl 1
|
||||||
@ -23,7 +23,7 @@ timer_flag_persist = 1 shl 3
|
|||||||
timer_flag_wait = 1 shl 4
|
timer_flag_wait = 1 shl 4
|
||||||
|
|
||||||
|
|
||||||
macro TCP_timer_160ms {
|
macro tcp_timer_160ms {
|
||||||
|
|
||||||
local .loop
|
local .loop
|
||||||
local .exit
|
local .exit
|
||||||
@ -45,10 +45,7 @@ local .exit
|
|||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
mov cl, TH_ACK
|
mov cl, TH_ACK
|
||||||
call TCP_respond
|
call tcp_respond
|
||||||
; and [ebx + TCP_SOCKET.t_flags], TF_ACKNOW ;;
|
|
||||||
; mov eax, ebx ;;
|
|
||||||
; call TCP_output ;;
|
|
||||||
pop ebx
|
pop ebx
|
||||||
|
|
||||||
inc [TCPS_delack] ; update stats
|
inc [TCPS_delack] ; update stats
|
||||||
@ -61,7 +58,7 @@ local .exit
|
|||||||
|
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
proc tcp_timer_640ms
|
||||||
|
|
||||||
xor esi, esi
|
xor esi, esi
|
||||||
mov ecx, MANUAL_DESTROY
|
mov ecx, MANUAL_DESTROY
|
||||||
@ -77,8 +74,8 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
|
|
||||||
add [TCP_sequence_num], 64000
|
add [TCP_sequence_num], 64000
|
||||||
|
|
||||||
; scan through all the active TCP sockets, decrementing ALL timers
|
; Scan through all the active TCP sockets, decrementing all active timers
|
||||||
; When a timer reaches zero, we'll check wheter it was active or not
|
; When a timer reaches zero, run its handler.
|
||||||
|
|
||||||
mov eax, net_sockets
|
mov eax, net_sockets
|
||||||
.loop:
|
.loop:
|
||||||
@ -95,22 +92,22 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
|
|
||||||
inc [eax + TCP_SOCKET.t_idle]
|
inc [eax + TCP_SOCKET.t_idle]
|
||||||
|
|
||||||
dec [eax + TCP_SOCKET.timer_retransmission]
|
|
||||||
jnz .check_more2
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_retransmission
|
||||||
jz .check_more2
|
jz .check_more2
|
||||||
|
dec [eax + TCP_SOCKET.timer_retransmission]
|
||||||
|
jnz .check_more2
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Retransmission timer expired\n", eax
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
.check_more2:
|
.check_more2:
|
||||||
dec [eax + TCP_SOCKET.timer_keepalive]
|
|
||||||
jnz .check_more3
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_keepalive
|
||||||
jz .check_more3
|
jz .check_more3
|
||||||
|
dec [eax + TCP_SOCKET.timer_keepalive]
|
||||||
|
jnz .check_more3
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: Keepalive expired\n", eax
|
||||||
|
|
||||||
@ -118,7 +115,7 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
ja .dont_kill
|
ja .dont_kill
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
call TCP_disconnect
|
call tcp_disconnect
|
||||||
pop eax
|
pop eax
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
@ -129,7 +126,7 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
push eax
|
push eax
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
xor cl, cl
|
xor cl, cl
|
||||||
call TCP_respond ; send keepalive
|
call tcp_respond ; send keepalive
|
||||||
pop eax
|
pop eax
|
||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_interval
|
||||||
jmp .check_more3
|
jmp .check_more3
|
||||||
@ -138,38 +135,38 @@ proc TCP_timer_640ms ; TODO: implement timed wait timer!
|
|||||||
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
mov [eax + TCP_SOCKET.timer_keepalive], TCP_time_keep_idle
|
||||||
|
|
||||||
.check_more3:
|
.check_more3:
|
||||||
dec [eax + TCP_SOCKET.timer_timed_wait]
|
|
||||||
jnz .check_more5
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_2msl
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_2msl
|
||||||
jz .check_more5
|
jz .check_more5
|
||||||
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
||||||
|
jnz .check_more5
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: 2MSL timer expired\n", eax
|
||||||
|
|
||||||
.check_more5:
|
.check_more5:
|
||||||
dec [eax + TCP_SOCKET.timer_persist]
|
|
||||||
jnz .check_more6
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_persist
|
||||||
jz .check_more6
|
jz .check_more6
|
||||||
|
dec [eax + TCP_SOCKET.timer_persist]
|
||||||
|
jnz .check_more6
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: persist timer expired\n", eax
|
||||||
|
|
||||||
call TCP_set_persist
|
call tcp_set_persist
|
||||||
mov [eax + TCP_SOCKET.t_force], 1
|
mov [eax + TCP_SOCKET.t_force], 1
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
mov [eax + TCP_SOCKET.t_force], 0
|
mov [eax + TCP_SOCKET.t_force], 0
|
||||||
|
|
||||||
.check_more6:
|
.check_more6:
|
||||||
dec [eax + TCP_SOCKET.timer_timed_wait]
|
|
||||||
jnz .loop
|
|
||||||
test [eax + TCP_SOCKET.timer_flags], timer_flag_wait
|
test [eax + TCP_SOCKET.timer_flags], timer_flag_wait
|
||||||
jz .loop
|
jz .loop
|
||||||
|
dec [eax + TCP_SOCKET.timer_timed_wait]
|
||||||
|
jnz .loop
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: timed wait timer expired\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "socket %x: timed wait timer expired\n", eax
|
||||||
|
|
||||||
push [eax + SOCKET.NextPtr]
|
push [eax + SOCKET.NextPtr]
|
||||||
call TCP_close
|
call tcp_close
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
jmp .check_only
|
jmp .check_only
|
||||||
@ -187,7 +184,7 @@ endp
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_cancel_timers:
|
tcp_cancel_timers:
|
||||||
|
|
||||||
mov [eax + TCP_SOCKET.timer_flags], 0
|
mov [eax + TCP_SOCKET.timer_flags], 0
|
||||||
|
|
||||||
|
@ -14,12 +14,12 @@
|
|||||||
;; ;;
|
;; ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
$Revision: 5442 $
|
$Revision: 6011 $
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_usrclosed ;
|
; tcp_usrclosed ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -27,7 +27,7 @@ $Revision: 5442 $
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_usrclosed:
|
tcp_usrclosed:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_usrclosed: %x\n", eax
|
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_usrclosed: %x\n", eax
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ TCP_usrclosed:
|
|||||||
|
|
||||||
.close:
|
.close:
|
||||||
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
mov [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||||
call TCP_close
|
call tcp_close
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ TCP_usrclosed:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.disc:
|
.disc:
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
.ret:
|
.ret:
|
||||||
pop ebx
|
pop ebx
|
||||||
ret
|
ret
|
||||||
@ -74,7 +74,7 @@ TCP_usrclosed:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; TCP_connect ;
|
; tcp_connect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket ptr ;
|
; IN: eax = socket ptr ;
|
||||||
; ;
|
; ;
|
||||||
@ -84,7 +84,7 @@ TCP_usrclosed:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
TCP_connect:
|
tcp_connect:
|
||||||
|
|
||||||
test [eax + SOCKET.state], SS_ISCONNECTED
|
test [eax + SOCKET.state], SS_ISCONNECTED
|
||||||
jnz .eisconn
|
jnz .eisconn
|
||||||
@ -112,7 +112,7 @@ TCP_connect:
|
|||||||
; Find a local port, if user didnt define one
|
; Find a local port, if user didnt define one
|
||||||
cmp [eax + TCP_SOCKET.LocalPort], 0
|
cmp [eax + TCP_SOCKET.LocalPort], 0
|
||||||
jne @f
|
jne @f
|
||||||
call SOCKET_find_port
|
call socket_find_port
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
; Start the TCP sequence
|
; Start the TCP sequence
|
||||||
@ -124,16 +124,16 @@ TCP_connect:
|
|||||||
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
|
||||||
|
|
||||||
TCP_sendseqinit eax
|
tcp_sendseqinit eax
|
||||||
|
|
||||||
mov ebx, eax
|
mov ebx, eax
|
||||||
lea eax, [ebx + STREAM_SOCKET.snd]
|
lea eax, [ebx + STREAM_SOCKET.snd]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nomem
|
jz .nomem
|
||||||
|
|
||||||
lea eax, [ebx + STREAM_SOCKET.rcv]
|
lea eax, [ebx + STREAM_SOCKET.rcv]
|
||||||
call SOCKET_ring_create
|
call socket_ring_create
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jz .nomem
|
jz .nomem
|
||||||
|
|
||||||
@ -142,11 +142,11 @@ TCP_connect:
|
|||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call SOCKET_is_connecting
|
call socket_is_connecting
|
||||||
|
|
||||||
; Now send the SYN packet to remote end
|
; Now send the SYN packet to remote end
|
||||||
push eax
|
push eax
|
||||||
call TCP_output
|
call tcp_output
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
.block:
|
.block:
|
||||||
@ -183,14 +183,14 @@ TCP_connect:
|
|||||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||||
je .established
|
je .established
|
||||||
|
|
||||||
call SOCKET_block
|
call socket_block
|
||||||
jmp .loop
|
jmp .loop
|
||||||
|
|
||||||
.timeout:
|
.timeout:
|
||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
mov [eax + SOCKET.errorcode], ETIMEDOUT
|
mov [eax + SOCKET.errorcode], ETIMEDOUT
|
||||||
and [eax + SOCKET.state], not SS_ISCONNECTING
|
and [eax + SOCKET.state], not SS_ISCONNECTING
|
||||||
call SOCKET_notify
|
call socket_notify
|
||||||
ret 4
|
ret 4
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
|
@ -38,10 +38,10 @@ endg
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_init: This function resets all UDP variables ;
|
; udp_init: This function resets all UDP variables ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
macro UDP_init {
|
macro udp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, UDP_PACKETS_TX
|
mov edi, UDP_PACKETS_TX
|
||||||
@ -50,7 +50,7 @@ macro UDP_init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size, destroys: ecx, edx
|
macro udp_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size, destroys: ecx, edx
|
||||||
|
|
||||||
; Pseudoheader
|
; Pseudoheader
|
||||||
mov edx, IP_PROTO_UDP
|
mov edx, IP_PROTO_UDP
|
||||||
@ -98,7 +98,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_input: Inject the UDP data in the application sockets. ;
|
; udp_input: Inject the UDP data in the application sockets. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: [esp] = ptr to buffer ;
|
; IN: [esp] = ptr to buffer ;
|
||||||
; ebx = ptr to device struct ;
|
; ebx = ptr to device struct ;
|
||||||
@ -111,7 +111,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_input:
|
udp_input:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ UDP_input:
|
|||||||
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
|
; otherwise, we will re-calculate the checksum and add it to this value, thus creating 0 when it is correct
|
||||||
|
|
||||||
mov eax, edx
|
mov eax, edx
|
||||||
UDP_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress)
|
udp_checksum (eax+IPv4_header.SourceAddress), (eax+IPv4_header.DestinationAddress)
|
||||||
jnz .checksum_mismatch
|
jnz .checksum_mismatch
|
||||||
|
|
||||||
.no_checksum:
|
.no_checksum:
|
||||||
@ -194,7 +194,7 @@ UDP_input:
|
|||||||
sub ecx, sizeof.UDP_header
|
sub ecx, sizeof.UDP_header
|
||||||
add esi, sizeof.UDP_header
|
add esi, sizeof.UDP_header
|
||||||
|
|
||||||
jmp SOCKET_input
|
jmp socket_input
|
||||||
|
|
||||||
.updateport:
|
.updateport:
|
||||||
pusha
|
pusha
|
||||||
@ -220,14 +220,14 @@ UDP_input:
|
|||||||
|
|
||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: dumping\n"
|
||||||
call NET_BUFF_free
|
call net_buff_free
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_output: Create an UDP packet. ;
|
; udp_output: Create an UDP packet. ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ecx = number of bytes to send ;
|
; ecx = number of bytes to send ;
|
||||||
@ -238,7 +238,7 @@ UDP_input:
|
|||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
|
|
||||||
align 4
|
align 4
|
||||||
UDP_output:
|
udp_output:
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: socket=%x bytes=%u data_ptr=%x\n", eax, ecx, esi
|
||||||
|
|
||||||
@ -256,7 +256,7 @@ UDP_output:
|
|||||||
mov al, [eax + IP_SOCKET.ttl]
|
mov al, [eax + IP_SOCKET.ttl]
|
||||||
mov ah, IP_PROTO_UDP
|
mov ah, IP_PROTO_UDP
|
||||||
add ecx, sizeof.UDP_header
|
add ecx, sizeof.UDP_header
|
||||||
call IPv4_output
|
call ipv4_output
|
||||||
jz .fail
|
jz .fail
|
||||||
mov [esp + 8], eax ; pointer to buffer start
|
mov [esp + 8], eax ; pointer to buffer start
|
||||||
|
|
||||||
@ -279,13 +279,13 @@ UDP_output:
|
|||||||
; Checksum
|
; Checksum
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
mov [edi + UDP_header.Checksum], 0
|
mov [edi + UDP_header.Checksum], 0
|
||||||
UDP_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options..
|
udp_checksum (edi-4), (edi-8) ; FIXME: IPv4 packet could have options..
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: sending with device %x\n", ebx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_output: sending with device %x\n", ebx
|
||||||
call [ebx + NET_DEVICE.transmit]
|
call [ebx + NET_DEVICE.transmit]
|
||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call NET_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [UDP_PACKETS_TX + edi]
|
inc [UDP_PACKETS_TX + edi]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -302,7 +302,7 @@ UDP_output:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_connect ;
|
; udp_connect ;
|
||||||
; ;
|
; ;
|
||||||
; IN: eax = socket pointer ;
|
; IN: eax = socket pointer ;
|
||||||
; ;
|
; ;
|
||||||
@ -312,11 +312,11 @@ UDP_output:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_connect:
|
udp_connect:
|
||||||
|
|
||||||
test [eax + SOCKET.state], SS_ISCONNECTED
|
test [eax + SOCKET.state], SS_ISCONNECTED
|
||||||
jz @f
|
jz @f
|
||||||
call UDP_disconnect
|
call udp_disconnect
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
push eax edx
|
push eax edx
|
||||||
@ -340,7 +340,7 @@ UDP_connect:
|
|||||||
; Find a local port, if user didnt define one
|
; Find a local port, if user didnt define one
|
||||||
cmp [eax + UDP_SOCKET.LocalPort], 0
|
cmp [eax + UDP_SOCKET.LocalPort], 0
|
||||||
jne @f
|
jne @f
|
||||||
call SOCKET_find_port
|
call socket_find_port
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
push eax
|
push eax
|
||||||
@ -348,7 +348,7 @@ UDP_connect:
|
|||||||
call mutex_unlock
|
call mutex_unlock
|
||||||
pop eax
|
pop eax
|
||||||
|
|
||||||
call SOCKET_is_connected
|
call socket_is_connected
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
@ -364,11 +364,11 @@ UDP_connect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_disconnect:
|
udp_disconnect:
|
||||||
|
|
||||||
; TODO: remove the pending received data
|
; TODO: remove the pending received data
|
||||||
|
|
||||||
call SOCKET_is_disconnected
|
call socket_is_disconnected
|
||||||
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ UDP_disconnect:
|
|||||||
|
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
; ;
|
; ;
|
||||||
; UDP_api: This function is called by system function 76 ;
|
; UDP_api: Part of system function 76 ;
|
||||||
; ;
|
; ;
|
||||||
; IN: bl = subfunction number in bl ;
|
; IN: bl = subfunction number in bl ;
|
||||||
; bh = device number in bh ;
|
; bh = device number in bh ;
|
||||||
@ -388,7 +388,7 @@ UDP_disconnect:
|
|||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
UDP_api:
|
udp_api:
|
||||||
|
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
shl eax, 2
|
shl eax, 2
|
||||||
|
Loading…
Reference in New Issue
Block a user