forked from KolibriOS/kolibrios
Some markup changes in network stack.
git-svn-id: svn://kolibrios.org@2924 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
a31be47dbc
commit
8140e5df69
@ -60,7 +60,7 @@ uglobal
|
||||
|
||||
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_RX rd MAX_NET_DEVICES
|
||||
|
@ -19,8 +19,6 @@
|
||||
$Revision$
|
||||
|
||||
MAX_FRAGMENTS = 64
|
||||
MAX_IP = MAX_NET_DEVICES
|
||||
IP_MAX_INTERFACES = MAX_IP
|
||||
|
||||
struct IPv4_header
|
||||
|
||||
@ -60,14 +58,14 @@ ends
|
||||
align 4
|
||||
uglobal
|
||||
|
||||
IP_LIST rd MAX_IP
|
||||
SUBNET_LIST rd MAX_IP
|
||||
DNS_LIST rd MAX_IP
|
||||
GATEWAY_LIST rd MAX_IP
|
||||
BROADCAST_LIST rd MAX_IP
|
||||
IP_LIST rd MAX_NET_DEVICES
|
||||
SUBNET_LIST rd MAX_NET_DEVICES
|
||||
DNS_LIST rd MAX_NET_DEVICES
|
||||
GATEWAY_LIST rd MAX_NET_DEVICES
|
||||
BROADCAST_LIST rd MAX_NET_DEVICES
|
||||
|
||||
IP_PACKETS_TX rd MAX_IP
|
||||
IP_PACKETS_RX rd MAX_IP
|
||||
IP_PACKETS_TX rd MAX_NET_DEVICES
|
||||
IP_PACKETS_RX rd MAX_NET_DEVICES
|
||||
|
||||
FRAGMENT_LIST rb MAX_FRAGMENTS * sizeof.FRAGMENT_slot
|
||||
endg
|
||||
@ -84,7 +82,7 @@ macro IPv4_init {
|
||||
|
||||
xor eax, eax
|
||||
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
|
||||
|
||||
}
|
||||
@ -317,12 +315,12 @@ IPv4_input: ; TODO: add IPv4
|
||||
|
||||
.has_fragments:
|
||||
movzx eax, [edx + IPv4_header.FlagsAndFragmentOffset]
|
||||
xchg al , ah
|
||||
shl ax , 3
|
||||
xchg al, ah
|
||||
shl ax, 3
|
||||
|
||||
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
|
||||
|
||||
|
||||
@ -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
|
||||
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 eax,[edx + IPv4_header.SourceAddress]
|
||||
mov [esi + FRAGMENT_slot.SrcIP], eax
|
||||
@ -431,16 +429,16 @@ IPv4_input: ; TODO: add IPv4
|
||||
mov [esi + FRAGMENT_entry.Owner], ebx
|
||||
|
||||
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
|
||||
add ax , cx
|
||||
add ax, cx
|
||||
DEBUGF 1,"IPv4_input: Total Received data size=%u\n", eax
|
||||
|
||||
push eax
|
||||
mov ax , [edx + IPv4_header.FlagsAndFragmentOffset]
|
||||
xchg al , ah
|
||||
shl ax , 3
|
||||
add cx , ax
|
||||
mov ax, [edx + IPv4_header.FlagsAndFragmentOffset]
|
||||
xchg al, ah
|
||||
shl ax, 3
|
||||
add cx, ax
|
||||
pop eax
|
||||
DEBUGF 1,"IPv4_input: Total Fragment size=%u\n", ecx
|
||||
|
||||
@ -455,18 +453,18 @@ IPv4_input: ; TODO: add IPv4
|
||||
mov edx, [esp+4] ; Get pointer to first fragment entry back in edx
|
||||
|
||||
.rebuild_packet_loop:
|
||||
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset
|
||||
xchg cl , ch ; intel byte order
|
||||
shl cx , 3 ; multiply by 8 and clear first 3 bits
|
||||
movzx ecx, [edx + sizeof.FRAGMENT_entry + IPv4_header.FlagsAndFragmentOffset] ; Calculate the fragment offset
|
||||
xchg cl, ch ; intel byte order
|
||||
shl cx, 3 ; multiply by 8 and clear first 3 bits
|
||||
DEBUGF 1,"IPv4_input: Fragment offset=%u\n", cx
|
||||
|
||||
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
|
||||
and bx , 0x000F ;
|
||||
shl bx , 2 ;
|
||||
movzx ebx, [edx + sizeof.FRAGMENT_entry + IPv4_header.VersionAndIHL] ; Find header size (in ebx) of fragment
|
||||
and bx, 0x000F ;
|
||||
shl bx, 2 ;
|
||||
|
||||
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
|
||||
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
|
||||
xchg cl, ch ; intel byte order
|
||||
|
||||
cmp edi, eax ; Is this packet the first fragment ?
|
||||
@ -527,7 +525,7 @@ IPv4_find_fragment_slot:
|
||||
;;; TODO: the RFC says we should check protocol number too
|
||||
|
||||
push eax ebx ecx edx
|
||||
mov ax , [edx + IPv4_header.Identification]
|
||||
mov ax, [edx + IPv4_header.Identification]
|
||||
mov ecx, MAX_FRAGMENTS
|
||||
mov esi, FRAGMENT_LIST
|
||||
mov ebx, [edx + IPv4_header.SourceAddress]
|
||||
@ -542,10 +540,8 @@ IPv4_find_fragment_slot:
|
||||
.try_next:
|
||||
add esi, sizeof.FRAGMENT_slot
|
||||
loop .find_slot
|
||||
; pop edx ebx
|
||||
or esi, -1
|
||||
; ret
|
||||
|
||||
or esi, -1
|
||||
.found_slot:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
@ -869,7 +865,7 @@ IPv4_dest_to_dev:
|
||||
je .broadcast
|
||||
|
||||
xor edi, edi
|
||||
mov ecx, MAX_IP
|
||||
mov ecx, MAX_NET_DEVICES
|
||||
.loop:
|
||||
mov ebx, [IP_LIST+edi]
|
||||
and ebx, [SUBNET_LIST+edi]
|
||||
|
@ -100,8 +100,8 @@ ends
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
ICMP_PACKETS_TX rd MAX_IP
|
||||
ICMP_PACKETS_RX rd MAX_IP
|
||||
ICMP_PACKETS_TX rd MAX_NET_DEVICES
|
||||
ICMP_PACKETS_RX rd MAX_NET_DEVICES
|
||||
endg
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ macro ICMP_init {
|
||||
|
||||
xor eax, eax
|
||||
mov edi, ICMP_PACKETS_TX
|
||||
mov ecx, 2*MAX_IP
|
||||
mov ecx, 2*MAX_NET_DEVICES
|
||||
rep stosd
|
||||
|
||||
}
|
||||
|
@ -111,14 +111,14 @@ struct TCP_SOCKET IP_SOCKET
|
||||
|
||||
|
||||
;---------
|
||||
; RFC 1323 ; the order of next 4 elements may not change
|
||||
; RFC 1323 ; the order of next 4 elements may not change
|
||||
|
||||
SND_SCALE db ?
|
||||
RCV_SCALE db ?
|
||||
requested_s_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 ?
|
||||
last_ack_sent dd ?
|
||||
|
||||
@ -133,6 +133,7 @@ struct TCP_SOCKET IP_SOCKET
|
||||
; extra
|
||||
|
||||
sendalot db ? ; also used as 'need output'
|
||||
ts_ecr dd ? ; timestamp echo reply
|
||||
|
||||
ends
|
||||
|
||||
|
@ -118,6 +118,8 @@ API_TCP = 4
|
||||
API_ARP = 5
|
||||
API_PPPOE = 6
|
||||
|
||||
HWACC_TCP_IPv4 = 1 shl 0
|
||||
|
||||
struct NET_DEVICE
|
||||
|
||||
type dd ? ; Type field
|
||||
|
@ -96,10 +96,10 @@ ends
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
TCP_segments_tx rd IP_MAX_INTERFACES
|
||||
TCP_segments_rx rd IP_MAX_INTERFACES
|
||||
TCP_bytes_rx rq IP_MAX_INTERFACES
|
||||
TCP_bytes_tx rq IP_MAX_INTERFACES
|
||||
TCP_segments_tx rd MAX_NET_DEVICES
|
||||
TCP_segments_rx rd MAX_NET_DEVICES
|
||||
TCP_bytes_rx rq MAX_NET_DEVICES
|
||||
TCP_bytes_tx rq MAX_NET_DEVICES
|
||||
TCP_sequence_num dd ?
|
||||
endg
|
||||
|
||||
@ -115,7 +115,7 @@ macro TCP_init {
|
||||
|
||||
xor eax, eax
|
||||
mov edi, TCP_segments_tx
|
||||
mov ecx, (6*IP_MAX_INTERFACES)
|
||||
mov ecx, (6*MAX_NET_DEVICES)
|
||||
rep stosd
|
||||
|
||||
pseudo_random eax
|
||||
|
@ -29,8 +29,8 @@ ends
|
||||
|
||||
align 4
|
||||
uglobal
|
||||
UDP_PACKETS_TX rd MAX_IP
|
||||
UDP_PACKETS_RX rd MAX_IP
|
||||
UDP_PACKETS_TX rd MAX_NET_DEVICES
|
||||
UDP_PACKETS_RX rd MAX_NET_DEVICES
|
||||
endg
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ macro UDP_init {
|
||||
|
||||
xor eax, eax
|
||||
mov edi, UDP_PACKETS_TX
|
||||
mov ecx, 2*MAX_IP
|
||||
mov ecx, 2*MAX_NET_DEVICES
|
||||
rep stosd
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user