Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1368 → Rev 1369

/kernel/trunk/network/stack.inc
361,27 → 361,48
; It provides application access to the network interface layer
;
;***************************************************************************
iglobal
align 4
f52call:
dd app_stack_handler.00
dd app_stack_handler.01
dd app_stack_handler.02
dd app_stack_handler.03
dd app_stack_handler.fail ;04
dd app_stack_handler.fail ;05
dd stack_insert_packet ;app_stack_handler.06
dd app_stack_handler.fail ;07
dd stack_get_packet ;app_stack_handler.08
dd app_stack_handler.09
dd app_stack_handler.10
dd app_stack_handler.11
dd app_stack_handler.12
dd app_stack_handler.13
dd app_stack_handler.14
dd app_stack_handler.15
endg
app_stack_handler:
cmp eax, 0
jnz not0
;in ebx,ecx
;out eax
cmp ebx,15
ja .fail ;if more than 15 then exit
 
jmp dword [f52call+ebx*4]
 
 
.00:
; Read the configuration word
mov eax, [stack_config]
ret
 
not0:
cmp eax, 1
jnz not1
.01:
; read the IP address
 
mov eax, [stack_ip]
ret
 
not1:
cmp eax, 2
jnz not2
 
.02:
; write the configuration word
mov [stack_config], ebx
mov [stack_config], ecx
 
; <Slip shouldn't be active anyway - thats an operational issue.>
; If ethernet now enabled, probe for the card, reset it and empty
391,155 → 412,90
; empty the tcpip data area too.
 
; ethernet interface is '3' in ls 7 bits
and bl, 0x7f
cmp bl, 3
 
and cl, 0x7f
cmp cl, 3
je ash_eth_enable
; Ethernet isn't enabled, so make sure that the card is disabled
mov [ethernet_active], byte 0
 
ret
 
ash_eth_enable:
; Probe for the card. This will reset it and enable the interface
; if found
call eth_probe
cmp eax, 0
je ash_eth_done ; Abort if no hardware found
 
mov [ethernet_active], byte 1
 
ash_eth_done:
ret
 
not2:
cmp eax, 3
jnz not3
.03:
; write the IP Address
mov [stack_ip], ebx
mov [stack_ip], ecx
ret
 
;old functions was deleted
 
not3:
cmp eax, 6
jnz not6
 
;.06:
; Insert an IP packet into the stacks received packet queue
call stack_insert_packet
ret
; call stack_insert_packet
; ret
 
not6:
cmp eax, 7
jnz not7
 
; Test for any packets queued for transmission over the network
 
not7:
cmp eax, 8
jnz not8
 
call stack_get_packet
;.08:
; call stack_get_packet
; Extract a packet queued for transmission by the network
ret
; ret
 
not8:
cmp eax, 9
jnz not9
 
.09:
; read the gateway IP address
 
mov eax, [gateway_ip]
ret
 
not9:
cmp eax, 10
jnz not10
 
.10:
; read the subnet mask
 
mov eax, [subnet_mask]
ret
 
not10:
cmp eax, 11
jnz not11
 
.11:
; write the gateway IP Address
mov [gateway_ip], ebx
 
mov [gateway_ip], ecx
ret
 
not11:
cmp eax, 12
jnz not12
 
.12:
; write the subnet mask
mov [subnet_mask], ebx
mov [subnet_mask], ecx
ret
 
 
not12:
cmp eax, 13
jnz not13
 
.13:
; read the dns
 
mov eax, [dns_ip]
ret
 
not13:
cmp eax, 14
jnz not14
 
.14:
; write the dns IP Address
mov [dns_ip], ebx
 
mov [dns_ip], ecx
ret
 
.15:
;<added by Frank Sommer>
not14:
cmp eax, 15
jnz not15
 
; in ebx we need 4 to read the last 2 bytes
cmp ebx, dword 4
je read
 
; in ecx we need 4 to read the last 2 bytes
; or we need 0 to read the first 4 bytes
cmp ebx, dword 0
jnz param_error
cmp ecx,4
ja .param_error
 
; read MAC, returned (in mirrored byte order) in eax
read:
mov eax, [node_addr + ebx]
jmp @f
mov eax, [node_addr + ecx]
ret
 
param_error:
mov eax, -1 ; params not accepted
@@:
.param_error:
or eax, -1 ; params not accepted
ret
 
 
.16:
; 0 -> arp_probe
; 1 -> arp_announce
; 2 -> arp_responce (not supported yet)
 
not15: ; ARP stuff
cmp eax, 16
jnz not16
 
cmp ebx, 0
test ecx,ecx
je a_probe
 
cmp ebx, 1
je a_ann ; arp announce
dec ebx
jz a_ann ; arp announce
.fail:
or eax, -1
ret
 
; cmp ebx,2
; jne a_resp ; arp response
 
jmp param15_error
 
 
; arp probe, sender IP must be set to 0.0.0.0, target IP is set to address being probed
; ecx: pointer to target MAC, MAC should set to 0 by application
; edx: target IP
547,12 → 503,12
push dword [stack_ip]
 
mov edx, [stack_ip]
mov [stack_ip], dword 0
and [stack_ip], dword 0
mov esi, ecx ; pointer to target MAC address
call arp_request
 
pop dword [stack_ip]
jmp @f
ret
 
; arp announce, sender IP must be set to target IP
; ecx: pointer to target MAC
560,33 → 516,30
mov edx, [stack_ip]
mov esi, ecx ; pointer to target MAC address
call arp_request
jmp @f
ret
 
param15_error:
mov eax, -1
 
@@:
ret
.17:
;</added by Frank Sommer>
; modified by [smb]
 
;<added by Johnny_B>
; ARPTable manager interface
not16:
cmp eax, 17
jnz stack_driver_end
 
;see "proc arp_table_manager" for more details
stdcall arp_table_manager,ebx,ecx,edx ;Opcode,Index,Extra
 
stdcall arp_table_manager,ecx,edx,esi ;Opcode,Index,Extra
ret
;</added by Johnny_B>
 
stack_driver_end:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ash_eth_enable:
; Probe for the card. This will reset it and enable the interface
; if found
call eth_probe
test eax,eax
jz ash_eth_done ; Abort if no hardware found
 
mov [ethernet_active], byte 1
ash_eth_done:
ret
 
 
 
;***************************************************************************
; Function
; app_socket_handler
597,110 → 550,65
; such as opening sockets
;
;***************************************************************************
iglobal
align 4
f53call:
dd socket_open ;00
dd socket_close ;01
dd socket_poll ;02
dd socket_read ;03
dd socket_write ;04
dd socket_open_tcp ;05
dd socket_status ;06
dd socket_write_tcp ;07
dd socket_close_tcp ;08
dd is_localport_unused ;09
dd app_socket_handler.10
dd socket_read_packet ;11
endg
 
app_socket_handler:
cmp eax, 0
jnz nots0
;in ebx,ecx,edx,wsi
;out eax
cmp eax,255
je stack_internal_status
 
call socket_open
ret
cmp eax,11
ja .fail ;if more than 15 then exit
 
nots0:
cmp eax, 1
jnz nots1
jmp dword [f53call+eax*4]
 
call socket_close
ret
 
nots1:
cmp eax, 2
jnz nots2
 
call socket_poll
ret
 
nots2:
cmp eax, 3
jnz nots3
 
call socket_read
ret
 
nots3:
cmp eax, 4
jnz nots4
 
call socket_write
ret
 
nots4:
cmp eax, 5
jnz nots5
 
call socket_open_tcp
ret
 
nots5:
cmp eax, 6
jnz nots6
 
call socket_status
ret
 
nots6:
cmp eax, 7
jnz nots7
 
call socket_write_tcp
ret
 
nots7:
cmp eax, 8
jnz nots8
 
call socket_close_tcp
ret
 
nots8:
cmp eax, 9
jnz nots9
 
call is_localport_unused
ret
 
nots9:
cmp eax, 10
jnz nots10
 
.10:
mov eax,dword[drvr_cable]
test eax,eax
jnz @f ; if function is not implented, return -1
mov al,-1
or al,-1
ret
 
@@:
call dword[drvr_cable]
ret
jmp dword[drvr_cable]
 
 
nots10:
cmp eax, 11
jnz nots11
 
call socket_read_packet
.fail:
or eax,-1
ret
uglobal
ARPTmp:
times 14 db 0
endg
 
nots11:
cmp eax, 254
jnz notdump
 
ret
 
notdump:
cmp eax, 255
jnz notsdebug
 
;***************************************************************************
; Function
; stack_internal_status
;
; Description
; Returns information about the internal status of the stack
; This is only useful for debugging
; It works with the ethernet driver
; sub function in ebx
; return requested data in eax
;
;***************************************************************************
; This sub function allows access to debugging information on the stack
; ebx holds the request:
; ecx holds the request:
; 100 : return length of empty queue
; 101 : return length of IPOUT QUEUE
; 102 : return length of IPIN QUEUE
722,31 → 630,7
; 6 : return status of packet driver
; ( 0 == not active, FFFFFFFF = successful )
 
call stack_internal_status
ret
 
notsdebug:
; Invalid Option
ret
 
 
uglobal
ARPTmp:
times 14 db 0
endg
 
;***************************************************************************
; Function
; stack_internal_status
;
; Description
; Returns information about the internal status of the stack
; This is only useful for debugging
; It works with the ethernet driver
; sub function in ebx
; return requested data in eax
;
;***************************************************************************
stack_internal_status:
cmp ebx, 100
jnz notsis100