Some markup changes in network stack.

git-svn-id: svn://kolibrios.org@2924 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2012-08-15 16:15:57 +00:00
parent a31be47dbc
commit 8140e5df69
7 changed files with 46 additions and 47 deletions

View File

@ -60,7 +60,7 @@ uglobal
NumARP dd ? NumARP dd ?
ARP_table rb ARP_TABLE_SIZE * sizeof.ARP_entry ARP_table rb ARP_TABLE_SIZE * sizeof.ARP_entry ; TODO: separate ARP table and stats per interface
ARP_PACKETS_TX rd MAX_NET_DEVICES ARP_PACKETS_TX rd MAX_NET_DEVICES
ARP_PACKETS_RX rd MAX_NET_DEVICES ARP_PACKETS_RX rd MAX_NET_DEVICES

View File

@ -19,8 +19,6 @@
$Revision$ $Revision$
MAX_FRAGMENTS = 64 MAX_FRAGMENTS = 64
MAX_IP = MAX_NET_DEVICES
IP_MAX_INTERFACES = MAX_IP
struct IPv4_header struct IPv4_header
@ -60,14 +58,14 @@ ends
align 4 align 4
uglobal uglobal
IP_LIST rd MAX_IP IP_LIST rd MAX_NET_DEVICES
SUBNET_LIST rd MAX_IP SUBNET_LIST rd MAX_NET_DEVICES
DNS_LIST rd MAX_IP DNS_LIST rd MAX_NET_DEVICES
GATEWAY_LIST rd MAX_IP GATEWAY_LIST rd MAX_NET_DEVICES
BROADCAST_LIST rd MAX_IP BROADCAST_LIST rd MAX_NET_DEVICES
IP_PACKETS_TX rd MAX_IP IP_PACKETS_TX rd MAX_NET_DEVICES
IP_PACKETS_RX rd MAX_IP IP_PACKETS_RX rd MAX_NET_DEVICES
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
endg endg
@ -84,7 +82,7 @@ macro IPv4_init {
xor eax, eax xor eax, eax
mov edi, IP_LIST mov edi, IP_LIST
mov ecx, 7*MAX_IP + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4 mov ecx, 7*MAX_NET_DEVICES + (sizeof.FRAGMENT_slot*MAX_FRAGMENTS)/4
rep stosd rep stosd
} }
@ -317,12 +315,12 @@ IPv4_input: ; TODO: add IPv4
.has_fragments: .has_fragments:
movzx eax, [edx + IPv4_header.FlagsAndFragmentOffset] movzx eax, [edx + IPv4_header.FlagsAndFragmentOffset]
xchg al , ah xchg al, ah
shl ax , 3 shl ax, 3
DEBUGF 1,"IPv4_input: fragmented packet offset=%u id=%x\n", ax, [edx + IPv4_header.Identification]:4 DEBUGF 1,"IPv4_input: fragmented packet offset=%u id=%x\n", ax, [edx + IPv4_header.Identification]:4
test ax , ax ; Is this the first packet of the fragment? test ax, ax ; Is this the first packet of the fragment?
jz .is_first_fragment jz .is_first_fragment
@ -375,7 +373,7 @@ IPv4_input: ; TODO: add IPv4
.found_free_slot: ; We found a free slot, let's fill in the FRAGMENT_slot structure .found_free_slot: ; We found a free slot, let's fill in the FRAGMENT_slot structure
mov [esi + FRAGMENT_slot.ttl], 15 ; RFC recommends 15 secs as ttl mov [esi + FRAGMENT_slot.ttl], 15 ; RFC recommends 15 secs as ttl
mov ax , [edx + IPv4_header.Identification] mov ax, [edx + IPv4_header.Identification]
mov [esi + FRAGMENT_slot.id], ax mov [esi + FRAGMENT_slot.id], ax
mov eax,[edx + IPv4_header.SourceAddress] mov eax,[edx + IPv4_header.SourceAddress]
mov [esi + FRAGMENT_slot.SrcIP], eax mov [esi + FRAGMENT_slot.SrcIP], eax
@ -431,16 +429,16 @@ IPv4_input: ; TODO: add IPv4
mov [esi + FRAGMENT_entry.Owner], ebx mov [esi + FRAGMENT_entry.Owner], ebx
mov cx, [edx + IPv4_header.TotalLength] ; Note: This time we dont substract Header length mov cx, [edx + IPv4_header.TotalLength] ; Note: This time we dont substract Header length
xchg cl , ch xchg cl, ch
DEBUGF 1,"IPv4_input: Packet size=%u\n", cx DEBUGF 1,"IPv4_input: Packet size=%u\n", cx
add ax , cx add ax, cx
DEBUGF 1,"IPv4_input: Total Received data size=%u\n", eax DEBUGF 1,"IPv4_input: Total Received data size=%u\n", eax
push eax push eax
mov ax , [edx + IPv4_header.FlagsAndFragmentOffset] mov ax, [edx + IPv4_header.FlagsAndFragmentOffset]
xchg al , ah xchg al, ah
shl ax , 3 shl ax, 3
add cx , ax add cx, ax
pop eax pop eax
DEBUGF 1,"IPv4_input: Total Fragment size=%u\n", ecx DEBUGF 1,"IPv4_input: Total Fragment size=%u\n", ecx
@ -456,14 +454,14 @@ IPv4_input: ; TODO: add IPv4
.rebuild_packet_loop: .rebuild_packet_loop:
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset
xchg cl , ch ; intel byte order xchg cl, ch ; intel byte order
shl cx , 3 ; multiply by 8 and clear first 3 bits shl cx, 3 ; multiply by 8 and clear first 3 bits
DEBUGF 1,"IPv4_input: Fragment offset=%u\n", cx DEBUGF 1,"IPv4_input: Fragment offset=%u\n", cx
lea edi, [eax + ecx] ; Notice that edi will be equal to eax for first fragment lea edi, [eax + ecx] ; Notice that edi will be equal to eax for first fragment
movzx ebx, [edx + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Find header size (in ebx) of fragment movzx ebx, [edx + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Find header size (in ebx) of fragment
and bx , 0x000F ; and bx, 0x000F ;
shl bx , 2 ; shl bx, 2 ;
lea esi, [edx + sizeof.FRAGMENT_entry] ; Set esi to the correct begin of fragment lea esi, [edx + sizeof.FRAGMENT_entry] ; Set esi to the correct begin of fragment
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.TotalLength] ; Calculate total length of fragment movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.TotalLength] ; Calculate total length of fragment
@ -527,7 +525,7 @@ IPv4_find_fragment_slot:
;;; TODO: the RFC says we should check protocol number too ;;; TODO: the RFC says we should check protocol number too
push eax ebx ecx edx push eax ebx ecx edx
mov ax , [edx + IPv4_header.Identification] mov ax, [edx + IPv4_header.Identification]
mov ecx, MAX_FRAGMENTS mov ecx, MAX_FRAGMENTS
mov esi, FRAGMENT_LIST mov esi, FRAGMENT_LIST
mov ebx, [edx + IPv4_header.SourceAddress] mov ebx, [edx + IPv4_header.SourceAddress]
@ -542,10 +540,8 @@ IPv4_find_fragment_slot:
.try_next: .try_next:
add esi, sizeof.FRAGMENT_slot add esi, sizeof.FRAGMENT_slot
loop .find_slot loop .find_slot
; pop edx ebx
or esi, -1
; ret
or esi, -1
.found_slot: .found_slot:
pop edx ecx ebx eax pop edx ecx ebx eax
ret ret
@ -869,7 +865,7 @@ IPv4_dest_to_dev:
je .broadcast je .broadcast
xor edi, edi xor edi, edi
mov ecx, MAX_IP mov ecx, MAX_NET_DEVICES
.loop: .loop:
mov ebx, [IP_LIST+edi] mov ebx, [IP_LIST+edi]
and ebx, [SUBNET_LIST+edi] and ebx, [SUBNET_LIST+edi]

View File

@ -100,8 +100,8 @@ ends
align 4 align 4
uglobal uglobal
ICMP_PACKETS_TX rd MAX_IP ICMP_PACKETS_TX rd MAX_NET_DEVICES
ICMP_PACKETS_RX rd MAX_IP ICMP_PACKETS_RX rd MAX_NET_DEVICES
endg endg
@ -116,7 +116,7 @@ macro ICMP_init {
xor eax, eax xor eax, eax
mov edi, ICMP_PACKETS_TX mov edi, ICMP_PACKETS_TX
mov ecx, 2*MAX_IP mov ecx, 2*MAX_NET_DEVICES
rep stosd rep stosd
} }

View File

@ -118,7 +118,7 @@ struct TCP_SOCKET IP_SOCKET
requested_s_scale db ? requested_s_scale db ?
request_r_scale db ? request_r_scale db ?
ts_recent dd ? ts_recent dd ? ; a copy of the most-recent valid timestamp from the other end
ts_recent_age dd ? ts_recent_age dd ?
last_ack_sent dd ? last_ack_sent dd ?
@ -133,6 +133,7 @@ struct TCP_SOCKET IP_SOCKET
; extra ; extra
sendalot db ? ; also used as 'need output' sendalot db ? ; also used as 'need output'
ts_ecr dd ? ; timestamp echo reply
ends ends

View File

@ -118,6 +118,8 @@ API_TCP = 4
API_ARP = 5 API_ARP = 5
API_PPPOE = 6 API_PPPOE = 6
HWACC_TCP_IPv4 = 1 shl 0
struct NET_DEVICE struct NET_DEVICE
type dd ? ; Type field type dd ? ; Type field

View File

@ -96,10 +96,10 @@ ends
align 4 align 4
uglobal uglobal
TCP_segments_tx rd IP_MAX_INTERFACES TCP_segments_tx rd MAX_NET_DEVICES
TCP_segments_rx rd IP_MAX_INTERFACES TCP_segments_rx rd MAX_NET_DEVICES
TCP_bytes_rx rq IP_MAX_INTERFACES TCP_bytes_rx rq MAX_NET_DEVICES
TCP_bytes_tx rq IP_MAX_INTERFACES TCP_bytes_tx rq MAX_NET_DEVICES
TCP_sequence_num dd ? TCP_sequence_num dd ?
endg endg
@ -115,7 +115,7 @@ macro TCP_init {
xor eax, eax xor eax, eax
mov edi, TCP_segments_tx mov edi, TCP_segments_tx
mov ecx, (6*IP_MAX_INTERFACES) mov ecx, (6*MAX_NET_DEVICES)
rep stosd rep stosd
pseudo_random eax pseudo_random eax

View File

@ -29,8 +29,8 @@ ends
align 4 align 4
uglobal uglobal
UDP_PACKETS_TX rd MAX_IP UDP_PACKETS_TX rd MAX_NET_DEVICES
UDP_PACKETS_RX rd MAX_IP UDP_PACKETS_RX rd MAX_NET_DEVICES
endg endg
@ -45,7 +45,7 @@ macro UDP_init {
xor eax, eax xor eax, eax
mov edi, UDP_PACKETS_TX mov edi, UDP_PACKETS_TX
mov ecx, 2*MAX_IP mov ecx, 2*MAX_NET_DEVICES
rep stosd rep stosd
} }