forked from KolibriOS/kolibrios
Fixed alignment for data in network stack. Alqo, network queue uses a mutex now.
git-svn-id: svn://kolibrios.org@3698 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a5c3784aca
commit
1ca5fecb5c
@ -55,9 +55,8 @@ struct ARP_header
|
||||
|
||||
ends
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
|
||||
align 4
|
||||
|
||||
ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||
|
||||
|
@ -55,8 +55,8 @@ struct FRAGMENT_entry ; This structure will replace the ethern
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
IP_LIST rd NET_DEVICES_MAX
|
||||
SUBNET_LIST rd NET_DEVICES_MAX
|
||||
@ -69,6 +69,7 @@ uglobal
|
||||
IP_packets_dumped rd NET_DEVICES_MAX
|
||||
|
||||
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
|
||||
|
||||
endg
|
||||
|
||||
|
||||
|
@ -30,8 +30,8 @@ struct IPv6_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
IPv6:
|
||||
.addresses rd 4*NET_DEVICES_MAX
|
||||
|
@ -23,8 +23,11 @@ struct PPPoE_frame
|
||||
ends
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
PPPoE_SID dw ?
|
||||
PPPoE_MAC dp ?
|
||||
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------
|
||||
|
@ -32,8 +32,8 @@ struct ETH_DEVICE NET_DEVICE
|
||||
|
||||
ends
|
||||
|
||||
align 4
|
||||
iglobal
|
||||
align 4
|
||||
|
||||
ETH_BROADCAST dp 0xffffffffffff
|
||||
endg
|
||||
|
@ -97,10 +97,12 @@ struct ICMP_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
ICMP_PACKETS_TX rd NET_DEVICES_MAX
|
||||
ICMP_PACKETS_RX rd NET_DEVICES_MAX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
$Revision: 2891 $
|
||||
|
||||
iglobal
|
||||
align 4
|
||||
|
||||
LOOPBACK_DEVICE:
|
||||
|
||||
|
@ -28,6 +28,7 @@ struct queue
|
||||
size dd ? ; number of queued packets in this queue
|
||||
w_ptr dd ? ; current writing pointer in queue
|
||||
r_ptr dd ? ; current reading pointer
|
||||
mutex MUTEX
|
||||
|
||||
ends
|
||||
|
||||
@ -44,9 +45,23 @@ ends
|
||||
|
||||
macro add_to_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
cmp [ptr + queue.size], size ; Check if queue isnt full
|
||||
jae failaddr
|
||||
local .ok, .no_wrap
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
cmp [ptr + queue.size], size ; Check if queue isnt full
|
||||
jb .ok
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
jmp failaddr
|
||||
|
||||
.ok:
|
||||
inc [ptr + queue.size] ; if not full, queue one more
|
||||
|
||||
mov edi, [ptr + queue.w_ptr] ; Current write pointer (FIFO!)
|
||||
@ -58,19 +73,37 @@ macro add_to_queue ptr, size, entry_size, failaddr {
|
||||
jb .no_wrap
|
||||
|
||||
sub edi, size*entry_size
|
||||
|
||||
.no_wrap:
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
macro get_from_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
cmp [ptr + queue.size], 0 ; any packets queued?
|
||||
je failaddr
|
||||
local .ok, .no_wrap
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_lock
|
||||
popa
|
||||
|
||||
cmp [ptr + queue.size], 0 ; any packets queued?
|
||||
ja .ok
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
jmp failaddr
|
||||
|
||||
.ok:
|
||||
dec [ptr + queue.size] ; if so, dequeue one
|
||||
|
||||
mov esi, [ptr + queue.r_ptr]
|
||||
@ -89,6 +122,11 @@ macro get_from_queue ptr, size, entry_size, failaddr {
|
||||
|
||||
pop esi
|
||||
|
||||
pusha
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_unlock
|
||||
popa
|
||||
|
||||
}
|
||||
|
||||
macro init_queue ptr {
|
||||
@ -97,4 +135,7 @@ macro init_queue ptr {
|
||||
lea edi, [ptr + sizeof.queue]
|
||||
mov [ptr + queue.w_ptr], edi
|
||||
mov [ptr + queue.r_ptr], edi
|
||||
|
||||
lea ecx, [ptr + queue.mutex]
|
||||
call mutex_init
|
||||
}
|
@ -194,11 +194,14 @@ SOCKET_QUEUE_SIZE = 10 ; maximum number of incoming packets queued f
|
||||
SOCKET_QUEUE_LOCATION = (SOCKETBUFFSIZE - SOCKET_QUEUE_SIZE*sizeof.socket_queue_entry - sizeof.queue)
|
||||
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
net_sockets rd 4
|
||||
last_socket_num dd ?
|
||||
last_UDP_port dw ? ; These values give the number of the last used ephemeral port
|
||||
last_TCP_port dw ? ;
|
||||
socket_mutex MUTEX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
@ -614,8 +617,9 @@ align 4
|
||||
.loop:
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_CLOSED
|
||||
je .fail
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_SYN_SENT
|
||||
jne .syn_received
|
||||
cmp [eax + TCP_SOCKET.t_state], TCPS_ESTABLISHED
|
||||
je .established
|
||||
ja .fail
|
||||
|
||||
call SOCKET_block
|
||||
jmp .loop
|
||||
@ -626,7 +630,7 @@ align 4
|
||||
mov dword[esp+32], -1
|
||||
ret
|
||||
|
||||
.syn_received:
|
||||
.established:
|
||||
mov dword[esp+32], 0
|
||||
ret
|
||||
|
||||
|
@ -221,8 +221,8 @@ include "socket.inc"
|
||||
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
NET_RUNNING dd ?
|
||||
NET_DRV_LIST rd NET_DEVICES_MAX
|
||||
|
@ -27,10 +27,12 @@ struct UDP_header
|
||||
ends
|
||||
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
align 4
|
||||
|
||||
UDP_PACKETS_TX rd NET_DEVICES_MAX
|
||||
UDP_PACKETS_RX rd NET_DEVICES_MAX
|
||||
|
||||
endg
|
||||
|
||||
|
||||
@ -114,6 +116,7 @@ macro UDP_checksum IP1, IP2 { ; esi = ptr to udp packet, ecx = packet size
|
||||
;
|
||||
;-----------------------------------------------------------------
|
||||
align 4
|
||||
diff16 "UDP packetgfgfgfgfs", 0, $
|
||||
UDP_input:
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "UDP_input: size=%u\n", ecx
|
||||
|
Loading…
Reference in New Issue
Block a user