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