forked from KolibriOS/kolibrios
network code cleanup, fix some statistics
git-svn-id: svn://kolibrios.org@7678 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
60a2ed9972
commit
338b57422f
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; ARP.INC ;;
|
;; ARP.INC ;;
|
||||||
@ -60,10 +60,10 @@ align 4
|
|||||||
|
|
||||||
ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry)
|
ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry)
|
||||||
|
|
||||||
ARP_entries_num rd NET_DEVICES_MAX
|
ARP_entries rd NET_DEVICES_MAX
|
||||||
ARP_PACKETS_TX rd NET_DEVICES_MAX
|
ARP_packets_tx rd NET_DEVICES_MAX
|
||||||
ARP_PACKETS_RX rd NET_DEVICES_MAX
|
ARP_packets_rx rd NET_DEVICES_MAX
|
||||||
ARP_CONFLICTS rd NET_DEVICES_MAX
|
ARP_conflicts rd NET_DEVICES_MAX
|
||||||
|
|
||||||
|
|
||||||
endg
|
endg
|
||||||
@ -78,7 +78,7 @@ endg
|
|||||||
macro arp_init {
|
macro arp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ARP_entries_num
|
mov edi, ARP_entries
|
||||||
mov ecx, 4*NET_DEVICES_MAX
|
mov ecx, 4*NET_DEVICES_MAX
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ local .exit
|
|||||||
|
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
.loop_outer:
|
.loop_outer:
|
||||||
mov ecx, [ARP_entries_num + 4*edi]
|
mov ecx, [ARP_entries + 4*edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ arp_input:
|
|||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
inc [ARP_PACKETS_RX + edi] ; update stats
|
inc [ARP_packets_rx + edi] ; update stats
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u (device*4=%u)\n",\
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: got packet from %u.%u.%u.%u (device*4=%u)\n",\
|
||||||
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
|
[edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\
|
||||||
@ -187,7 +187,7 @@ arp_input:
|
|||||||
; First, check for IP collision
|
; First, check for IP collision
|
||||||
|
|
||||||
mov eax, [edx + ARP_header.SenderIP]
|
mov eax, [edx + ARP_header.SenderIP]
|
||||||
cmp eax, [IP_LIST + edi]
|
cmp eax, [IPv4_address + edi]
|
||||||
je .collision
|
je .collision
|
||||||
|
|
||||||
;---------------------
|
;---------------------
|
||||||
@ -198,7 +198,7 @@ arp_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
|
||||||
|
|
||||||
mov ecx, [ARP_entries_num + edi]
|
mov ecx, [ARP_entries + edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .exit
|
jz .exit
|
||||||
|
|
||||||
@ -242,7 +242,7 @@ arp_input:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: its a request\n"
|
||||||
|
|
||||||
mov eax, [IP_LIST + edi]
|
mov eax, [IPv4_address + edi]
|
||||||
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
|
cmp eax, [edx + ARP_header.TargetIP] ; Is it looking for my IP address?
|
||||||
jne .exit
|
jne .exit
|
||||||
|
|
||||||
@ -259,7 +259,7 @@ arp_input:
|
|||||||
movsd ; Move sender IP to Dest IP
|
movsd ; Move sender IP to Dest IP
|
||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
mov esi, [NET_DRV_LIST + esi]
|
mov esi, [net_drv_list + esi]
|
||||||
lea esi, [esi + ETH_DEVICE.mac]
|
lea esi, [esi + ETH_DEVICE.mac]
|
||||||
lea edi, [edx + ARP_header.SenderMAC]
|
lea edi, [edx + ARP_header.SenderMAC]
|
||||||
movsd ; Copy MAC address from in MAC_LIST
|
movsd ; Copy MAC address from in MAC_LIST
|
||||||
@ -288,7 +288,7 @@ arp_input:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.collision:
|
.collision:
|
||||||
inc [ARP_CONFLICTS + edi]
|
inc [ARP_conflicts + edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n"
|
||||||
|
|
||||||
.exit:
|
.exit:
|
||||||
@ -333,8 +333,8 @@ arp_output_request:
|
|||||||
|
|
||||||
push edi
|
push edi
|
||||||
call net_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
|
inc [ARP_packets_tx + edi] ; assume we will succeed
|
||||||
lea esi, [IP_LIST + edi] ; SenderIP
|
lea esi, [IPv4_address + edi] ; SenderIP
|
||||||
pop edi
|
pop edi
|
||||||
movsd
|
movsd
|
||||||
|
|
||||||
@ -372,13 +372,13 @@ arp_add_entry:
|
|||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
|
||||||
|
|
||||||
mov ecx, [ARP_entries_num + edi]
|
mov ecx, [ARP_entries + edi]
|
||||||
cmp ecx, ARP_TABLE_SIZE ; list full ?
|
cmp ecx, ARP_TABLE_SIZE ; list full ?
|
||||||
jae .full
|
jae .full
|
||||||
|
|
||||||
; From this point on, we can only fail if IP has a static entry, or if table is corrupt.
|
; From this point on, we can only fail if IP has a static entry, or if table is corrupt.
|
||||||
|
|
||||||
inc [ARP_entries_num + edi] ; assume we will succeed
|
inc [ARP_entries + edi] ; assume we will succeed
|
||||||
|
|
||||||
push edi
|
push edi
|
||||||
xor ecx, ecx
|
xor ecx, ecx
|
||||||
@ -417,7 +417,7 @@ arp_add_entry:
|
|||||||
|
|
||||||
.error:
|
.error:
|
||||||
pop edi
|
pop edi
|
||||||
dec [ARP_entries_num + edi]
|
dec [ARP_entries + edi]
|
||||||
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n"
|
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n"
|
||||||
.full:
|
.full:
|
||||||
mov eax, -1
|
mov eax, -1
|
||||||
@ -460,7 +460,7 @@ arp_del_entry:
|
|||||||
rep stosw
|
rep stosw
|
||||||
|
|
||||||
pop edi
|
pop edi
|
||||||
dec [ARP_entries_num + 4*edi]
|
dec [ARP_entries + 4*edi]
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -497,7 +497,7 @@ arp_ip_to_mac:
|
|||||||
;--------------------------------
|
;--------------------------------
|
||||||
; Try to find the IP in ARP_table
|
; Try to find the IP in ARP_table
|
||||||
|
|
||||||
mov ecx, [ARP_entries_num + edi]
|
mov ecx, [ARP_entries + edi]
|
||||||
test ecx, ecx
|
test ecx, ecx
|
||||||
jz .not_in_list
|
jz .not_in_list
|
||||||
mov esi, edi
|
mov esi, edi
|
||||||
@ -539,7 +539,7 @@ arp_ip_to_mac:
|
|||||||
pop edi eax ; IP in eax, device number in ebx, for ARP_output_request
|
pop edi eax ; IP in eax, device number in ebx, for ARP_output_request
|
||||||
|
|
||||||
push esi edi
|
push esi edi
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [net_drv_list + edi]
|
||||||
call arp_output_request
|
call arp_output_request
|
||||||
pop edi esi
|
pop edi esi
|
||||||
.found_it:
|
.found_it:
|
||||||
@ -620,23 +620,23 @@ arp_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_tx:
|
.packets_tx:
|
||||||
mov eax, [ARP_PACKETS_TX + eax]
|
mov eax, [ARP_packets_tx + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_rx:
|
.packets_rx:
|
||||||
mov eax, [ARP_PACKETS_RX + eax]
|
mov eax, [ARP_packets_rx + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.conflicts:
|
.conflicts:
|
||||||
mov eax, [ARP_CONFLICTS + eax]
|
mov eax, [ARP_conflicts + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.entries:
|
.entries:
|
||||||
mov eax, [ARP_entries_num + eax]
|
mov eax, [ARP_entries + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.read:
|
.read:
|
||||||
cmp ecx, [ARP_entries_num + eax]
|
cmp ecx, [ARP_entries + eax]
|
||||||
jae .error
|
jae .error
|
||||||
shr eax, 2
|
shr eax, 2
|
||||||
imul eax, sizeof.ARP_entry*ARP_TABLE_SIZE
|
imul eax, sizeof.ARP_entry*ARP_TABLE_SIZE
|
||||||
@ -659,7 +659,7 @@ arp_api:
|
|||||||
|
|
||||||
.remove:
|
.remove:
|
||||||
; ecx = # entry
|
; ecx = # entry
|
||||||
cmp ecx, [ARP_entries_num + eax]
|
cmp ecx, [ARP_entries + eax]
|
||||||
jae .error
|
jae .error
|
||||||
imul ecx, sizeof.ARP_entry
|
imul ecx, sizeof.ARP_entry
|
||||||
lea esi, [ARP_table + ecx]
|
lea esi, [ARP_table + ecx]
|
||||||
@ -669,8 +669,8 @@ arp_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.send_announce:
|
.send_announce:
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [net_drv_list + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IPv4_address + eax]
|
||||||
call arp_output_request ; now send a gratuitous ARP
|
call arp_output_request ; now send a gratuitous ARP
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; IPv4.INC ;;
|
;; IPv4.INC ;;
|
||||||
@ -61,33 +61,32 @@ struct IPv4_FRAGMENT_entry ; This structure will replace the ethern
|
|||||||
; Ip header begins here (we will need the IP header to re-construct the complete packet)
|
; Ip header begins here (we will need the IP header to re-construct the complete packet)
|
||||||
ends
|
ends
|
||||||
|
|
||||||
struct IPv4_ROUTE
|
;struct IPv4_ROUTE
|
||||||
|
;
|
||||||
Destination dd ?
|
; Destination dd ?
|
||||||
Gateway dd ?
|
; Gateway dd ?
|
||||||
Flags dd ?
|
; Flags dd ?
|
||||||
Use dd ?
|
; Use dd ?
|
||||||
Interface dd ?
|
; Interface dd ?
|
||||||
|
;
|
||||||
ends
|
;ends
|
||||||
|
|
||||||
|
|
||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
|
|
||||||
IP_LIST rd NET_DEVICES_MAX
|
IPv4_address rd NET_DEVICES_MAX
|
||||||
SUBNET_LIST rd NET_DEVICES_MAX
|
IPv4_subnet rd NET_DEVICES_MAX
|
||||||
DNS_LIST rd NET_DEVICES_MAX
|
IPv4_nameserver rd NET_DEVICES_MAX
|
||||||
GATEWAY_LIST rd NET_DEVICES_MAX
|
IPv4_gateway rd NET_DEVICES_MAX
|
||||||
BROADCAST_LIST rd NET_DEVICES_MAX
|
IPv4_broadcast rd NET_DEVICES_MAX
|
||||||
|
|
||||||
IPv4_packets_tx rd NET_DEVICES_MAX
|
IPv4_packets_tx rd NET_DEVICES_MAX
|
||||||
IPv4_packets_rx rd NET_DEVICES_MAX
|
IPv4_packets_rx rd NET_DEVICES_MAX
|
||||||
IPv4_packets_dumped rd NET_DEVICES_MAX
|
IPv4_packets_dumped rd NET_DEVICES_MAX
|
||||||
|
|
||||||
IPv4_FRAGMENT_LIST rb IPv4_MAX_FRAGMENTS * sizeof.IPv4_FRAGMENT_slot
|
IPv4_fragments rb IPv4_MAX_FRAGMENTS * sizeof.IPv4_FRAGMENT_slot
|
||||||
|
|
||||||
IPv4_ROUTES rd IPv4_MAX_ROUTES * sizeof.IPv4_ROUTE
|
; IPv4_routes rd IPv4_MAX_ROUTES * sizeof.IPv4_ROUTE
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ endg
|
|||||||
macro ipv4_init {
|
macro ipv4_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, IP_LIST
|
mov edi, IPv4_address
|
||||||
mov ecx, 7*NET_DEVICES_MAX + (sizeof.IPv4_FRAGMENT_slot*IPv4_MAX_FRAGMENTS)/4
|
mov ecx, 7*NET_DEVICES_MAX + (sizeof.IPv4_FRAGMENT_slot*IPv4_MAX_FRAGMENTS)/4
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
@ -116,7 +115,7 @@ macro ipv4_decrease_fragment_ttls {
|
|||||||
|
|
||||||
local .loop, .next
|
local .loop, .next
|
||||||
|
|
||||||
mov esi, IPv4_FRAGMENT_LIST
|
mov esi, IPv4_fragments
|
||||||
mov ecx, IPv4_MAX_FRAGMENTS
|
mov ecx, IPv4_MAX_FRAGMENTS
|
||||||
.loop:
|
.loop:
|
||||||
cmp [esi + IPv4_FRAGMENT_slot.ttl], 0
|
cmp [esi + IPv4_FRAGMENT_slot.ttl], 0
|
||||||
@ -244,11 +243,11 @@ ipv4_input:
|
|||||||
|
|
||||||
; local ip (Using RFC1122 strong end system model)
|
; local ip (Using RFC1122 strong end system model)
|
||||||
mov eax, [edx + IPv4_header.DestinationAddress]
|
mov eax, [edx + IPv4_header.DestinationAddress]
|
||||||
cmp eax, [IP_LIST + edi]
|
cmp eax, [IPv4_address + edi]
|
||||||
je .ip_ok
|
je .ip_ok
|
||||||
|
|
||||||
; network layer broadcast
|
; network layer broadcast
|
||||||
cmp eax, [BROADCAST_LIST + edi]
|
cmp eax, [IPv4_broadcast + edi]
|
||||||
je .ip_ok
|
je .ip_ok
|
||||||
|
|
||||||
; physical layer broadcast (255.255.255.255)
|
; physical layer broadcast (255.255.255.255)
|
||||||
@ -261,7 +260,7 @@ ipv4_input:
|
|||||||
je .ip_ok
|
je .ip_ok
|
||||||
|
|
||||||
; maybe we just dont have an IP yet and should accept everything on the IP level
|
; maybe we just dont have an IP yet and should accept everything on the IP level
|
||||||
cmp [IP_LIST + edi], 0
|
cmp [IPv4_address + edi], 0
|
||||||
je .ip_ok
|
je .ip_ok
|
||||||
|
|
||||||
; or it's just not meant for us.. :(
|
; or it's just not meant for us.. :(
|
||||||
@ -419,7 +418,7 @@ ipv4_input:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: First fragment packet received!\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_input: First fragment packet received!\n"
|
||||||
; try to locate a free slot..
|
; try to locate a free slot..
|
||||||
mov ecx, IPv4_MAX_FRAGMENTS
|
mov ecx, IPv4_MAX_FRAGMENTS
|
||||||
mov esi, IPv4_FRAGMENT_LIST
|
mov esi, IPv4_fragments
|
||||||
.find_free_slot:
|
.find_free_slot:
|
||||||
cmp word [esi + IPv4_FRAGMENT_slot.ttl], 0
|
cmp word [esi + IPv4_FRAGMENT_slot.ttl], 0
|
||||||
je .found_free_slot
|
je .found_free_slot
|
||||||
@ -584,7 +583,7 @@ ipv4_find_fragment_slot:
|
|||||||
push eax ebx ecx edx
|
push eax ebx ecx edx
|
||||||
mov ax, [edx + IPv4_header.Identification]
|
mov ax, [edx + IPv4_header.Identification]
|
||||||
mov ecx, IPv4_MAX_FRAGMENTS
|
mov ecx, IPv4_MAX_FRAGMENTS
|
||||||
mov esi, IPv4_FRAGMENT_LIST
|
mov esi, IPv4_fragments
|
||||||
mov ebx, [edx + IPv4_header.SourceAddress]
|
mov ebx, [edx + IPv4_header.SourceAddress]
|
||||||
mov edx, [edx + IPv4_header.DestinationAddress]
|
mov edx, [edx + IPv4_header.DestinationAddress]
|
||||||
.find_slot:
|
.find_slot:
|
||||||
@ -649,7 +648,7 @@ ipv4_output:
|
|||||||
inc [IPv4_packets_tx + edi] ; update stats
|
inc [IPv4_packets_tx + edi] ; update stats
|
||||||
|
|
||||||
mov ax, ETHER_PROTO_IPv4
|
mov ax, ETHER_PROTO_IPv4
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [net_drv_list + edi]
|
||||||
mov ecx, [esp + 6 + 8 + 2]
|
mov ecx, [esp + 6 + 8 + 2]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
@ -706,6 +705,8 @@ ipv4_output:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.loopback:
|
.loopback:
|
||||||
|
inc [IPv4_packets_tx + edi] ; update stats
|
||||||
|
|
||||||
mov dword [esp], eax ; set source IP to dest IP
|
mov dword [esp], eax ; set source IP to dest IP
|
||||||
mov ecx, [esp + 10]
|
mov ecx, [esp + 10]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
@ -746,7 +747,7 @@ ipv4_output_raw:
|
|||||||
|
|
||||||
inc [IPv4_packets_tx + 4*edi]
|
inc [IPv4_packets_tx + 4*edi]
|
||||||
mov ax, ETHER_PROTO_IPv4
|
mov ax, ETHER_PROTO_IPv4
|
||||||
mov ebx, [NET_DRV_LIST + 4*edi]
|
mov ebx, [net_drv_list + 4*edi]
|
||||||
mov ecx, [esp + 6 + 4]
|
mov ecx, [esp + 6 + 4]
|
||||||
add ecx, sizeof.IPv4_header
|
add ecx, sizeof.IPv4_header
|
||||||
mov edx, esp
|
mov edx, esp
|
||||||
@ -945,11 +946,11 @@ ipv4_route:
|
|||||||
|
|
||||||
xor edi, edi
|
xor edi, edi
|
||||||
.loop:
|
.loop:
|
||||||
mov ebx, [IP_LIST + edi]
|
mov ebx, [IPv4_address + edi]
|
||||||
and ebx, [SUBNET_LIST + edi]
|
and ebx, [IPv4_subnet + edi]
|
||||||
jz .next
|
jz .next
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
and ecx, [SUBNET_LIST + edi]
|
and ecx, [IPv4_subnet + edi]
|
||||||
cmp ebx, ecx
|
cmp ebx, ecx
|
||||||
je .got_it
|
je .got_it
|
||||||
.next:
|
.next:
|
||||||
@ -957,14 +958,14 @@ ipv4_route:
|
|||||||
cmp edi, 4*NET_DEVICES_MAX
|
cmp edi, 4*NET_DEVICES_MAX
|
||||||
jb .loop
|
jb .loop
|
||||||
|
|
||||||
mov eax, [GATEWAY_LIST + 4] ; TODO: let user (or a user space daemon) configure default route
|
mov eax, [IPv4_gateway + 4] ; TODO: let user (or a user space daemon) configure default route
|
||||||
.broadcast:
|
.broadcast:
|
||||||
mov edi, 4 ; TODO: same as above
|
mov edi, 4 ; TODO: same as above
|
||||||
.got_it:
|
.got_it:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jnz @f
|
jnz @f
|
||||||
mov edx, [IP_LIST + edi]
|
mov edx, [IPv4_address + edi]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -975,20 +976,20 @@ ipv4_route:
|
|||||||
cmp edi, -1
|
cmp edi, -1
|
||||||
je .fail
|
je .fail
|
||||||
|
|
||||||
mov edx, [IP_LIST + edi] ; Source IP
|
mov edx, [IPv4_address + edi] ; Source IP
|
||||||
|
|
||||||
; Broadcast does not need gateway
|
; Broadcast does not need gateway
|
||||||
cmp eax, 0xffffffff
|
cmp eax, 0xffffffff
|
||||||
je @f
|
je @f
|
||||||
|
|
||||||
; Check if we should route to gateway or not
|
; Check if we should route to gateway or not
|
||||||
mov ebx, [IP_LIST + edi]
|
mov ebx, [IPv4_address + edi]
|
||||||
and ebx, [SUBNET_LIST + edi]
|
and ebx, [IPv4_subnet + edi]
|
||||||
mov ecx, eax
|
mov ecx, eax
|
||||||
and ecx, [SUBNET_LIST + edi]
|
and ecx, [IPv4_subnet + edi]
|
||||||
cmp ecx, ebx
|
cmp ecx, ebx
|
||||||
je @f
|
je @f
|
||||||
mov eax, [GATEWAY_LIST + edi]
|
mov eax, [IPv4_gateway + edi]
|
||||||
@@:
|
@@:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
||||||
ret
|
ret
|
||||||
@ -1038,7 +1039,7 @@ ipv4_connect:
|
|||||||
; Fill in local IP
|
; Fill in local IP
|
||||||
cmp [eax + IP_SOCKET.LocalIP], 0
|
cmp [eax + IP_SOCKET.LocalIP], 0
|
||||||
jne @f
|
jne @f
|
||||||
push [IP_LIST + 4] ; FIXME: use correct local IP
|
push [IPv4_address + 4] ; FIXME: use correct local IP
|
||||||
pop [eax + IP_SOCKET.LocalIP]
|
pop [eax + IP_SOCKET.LocalIP]
|
||||||
|
|
||||||
; Fill in remote IP
|
; Fill in remote IP
|
||||||
@ -1100,21 +1101,21 @@ ipv4_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.read_ip:
|
.read_ip:
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IPv4_address + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.write_ip:
|
.write_ip:
|
||||||
mov [IP_LIST + eax], ecx
|
mov [IPv4_address + eax], ecx
|
||||||
mov edi, eax ; device number, we'll need it for ARP
|
mov edi, eax ; device number, we'll need it for ARP
|
||||||
|
|
||||||
; pre-calculate the local broadcast address
|
; pre-calculate the local broadcast address
|
||||||
mov ebx, [SUBNET_LIST + eax]
|
mov ebx, [IPv4_subnet + eax]
|
||||||
not ebx
|
not ebx
|
||||||
or ebx, ecx
|
or ebx, ecx
|
||||||
mov [BROADCAST_LIST + eax], ebx
|
mov [IPv4_broadcast + eax], ebx
|
||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + eax]
|
mov ebx, [net_drv_list + eax]
|
||||||
mov eax, [IP_LIST + eax]
|
mov eax, [IPv4_address + 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
|
||||||
@ -1122,38 +1123,38 @@ ipv4_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.read_dns:
|
.read_dns:
|
||||||
mov eax, [DNS_LIST + eax]
|
mov eax, [IPv4_nameserver + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.write_dns:
|
.write_dns:
|
||||||
mov [DNS_LIST + eax], ecx
|
mov [IPv4_nameserver + eax], ecx
|
||||||
call net_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.read_subnet:
|
.read_subnet:
|
||||||
mov eax, [SUBNET_LIST + eax]
|
mov eax, [IPv4_subnet + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.write_subnet:
|
.write_subnet:
|
||||||
mov [SUBNET_LIST + eax], ecx
|
mov [IPv4_subnet + eax], ecx
|
||||||
|
|
||||||
; pre-calculate the local broadcast address
|
; pre-calculate the local broadcast address
|
||||||
mov ebx, [IP_LIST + eax]
|
mov ebx, [IPv4_address + eax]
|
||||||
not ecx
|
not ecx
|
||||||
or ecx, ebx
|
or ecx, ebx
|
||||||
mov [BROADCAST_LIST + eax], ecx
|
mov [IPv4_broadcast + eax], ecx
|
||||||
|
|
||||||
call net_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.read_gateway:
|
.read_gateway:
|
||||||
mov eax, [GATEWAY_LIST + eax]
|
mov eax, [IPv4_gateway + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.write_gateway:
|
.write_gateway:
|
||||||
mov [GATEWAY_LIST + eax], ecx
|
mov [IPv4_gateway + eax], ecx
|
||||||
|
|
||||||
call net_send_event
|
call net_send_event
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2012-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2012-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; PPPoE.INC ;;
|
;; PPPoE.INC ;;
|
||||||
@ -131,7 +131,7 @@ pppoe_discovery_output:
|
|||||||
cmp ebx, NET_DEVICES_MAX
|
cmp ebx, NET_DEVICES_MAX
|
||||||
ja .bad
|
ja .bad
|
||||||
|
|
||||||
mov ebx, [NET_DRV_LIST + 4*ebx]
|
mov ebx, [net_drv_list + 4*ebx]
|
||||||
test ebx, ebx
|
test ebx, ebx
|
||||||
jz .bad
|
jz .bad
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ eth_api:
|
|||||||
cmp bh, NET_DEVICES_MAX
|
cmp bh, NET_DEVICES_MAX
|
||||||
ja .error
|
ja .error
|
||||||
movzx eax, bh
|
movzx eax, bh
|
||||||
mov eax, dword [NET_DRV_LIST + 4*eax]
|
mov eax, dword [net_drv_list + 4*eax]
|
||||||
cmp [eax + NET_DEVICE.device_type], NET_DEVICE_ETH
|
cmp [eax + NET_DEVICE.device_type], NET_DEVICE_ETH
|
||||||
jne .error
|
jne .error
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; ICMP.INC ;;
|
;; ICMP.INC ;;
|
||||||
@ -99,8 +99,8 @@ ends
|
|||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
|
|
||||||
ICMP_PACKETS_TX rd NET_DEVICES_MAX
|
ICMP_packets_tx rd NET_DEVICES_MAX
|
||||||
ICMP_PACKETS_RX rd NET_DEVICES_MAX
|
ICMP_packets_rx rd NET_DEVICES_MAX
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
@ -115,7 +115,7 @@ endg
|
|||||||
macro icmp_init {
|
macro icmp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, ICMP_PACKETS_TX
|
mov edi, ICMP_packets_tx
|
||||||
mov ecx, 2*NET_DEVICES_MAX
|
mov ecx, 2*NET_DEVICES_MAX
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ icmp_input:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n"
|
||||||
|
|
||||||
; Dump all multicasts and broadcasts
|
; Dump all multicasts and broadcasts
|
||||||
mov eax, [IP_LIST + edi]
|
mov eax, [IPv4_address + edi]
|
||||||
cmp eax, [edx + IPv4_header.DestinationAddress]
|
cmp eax, [edx + IPv4_header.DestinationAddress]
|
||||||
jne .dump
|
jne .dump
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ icmp_input:
|
|||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n"
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
inc [ICMP_PACKETS_RX + edi]
|
inc [ICMP_packets_rx + edi]
|
||||||
|
|
||||||
; Is this an echo request?
|
; Is this an echo request?
|
||||||
cmp [esi + ICMP_header.Type], ICMP_ECHO
|
cmp [esi + ICMP_header.Type], ICMP_ECHO
|
||||||
@ -273,7 +273,8 @@ icmp_input:
|
|||||||
jnz @f
|
jnz @f
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n"
|
||||||
call net_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_packets_tx + edi]
|
||||||
|
inc [IPv4_packets_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -406,7 +407,7 @@ icmp_output_raw:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call net_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [ICMP_PACKETS_TX + edi]
|
inc [ICMP_packets_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -447,9 +448,9 @@ icmp_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_tx:
|
.packets_tx:
|
||||||
mov eax, [ICMP_PACKETS_TX + eax]
|
mov eax, [ICMP_packets_tx + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_rx:
|
.packets_rx:
|
||||||
mov eax, [ICMP_PACKETS_RX + eax]
|
mov eax, [ICMP_packets_rx + eax]
|
||||||
ret
|
ret
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; loopback.inc ;;
|
;; loopback.inc ;;
|
||||||
@ -54,9 +54,9 @@ local .fail
|
|||||||
cmp eax, -1
|
cmp eax, -1
|
||||||
je .fail
|
je .fail
|
||||||
|
|
||||||
mov [IP_LIST], 127 + 1 shl 24
|
mov [IPv4_address], 127 + 1 shl 24
|
||||||
mov [SUBNET_LIST], 255
|
mov [IPv4_subnet], 255
|
||||||
mov [BROADCAST_LIST], 0xffffff00 + 127
|
mov [IPv4_broadcast], 0xffffff00 + 127
|
||||||
|
|
||||||
.fail:
|
.fail:
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ local .fail
|
|||||||
; ;
|
; ;
|
||||||
; IN: [esp+4] = Pointer to buffer ;
|
; IN: [esp+4] = Pointer to buffer ;
|
||||||
; ;
|
; ;
|
||||||
; OUT: / ;
|
; OUT: eax = 0 on success, errorcode otherwise ;
|
||||||
; ;
|
; ;
|
||||||
;-----------------------------------------------------------------;
|
;-----------------------------------------------------------------;
|
||||||
align 4
|
align 4
|
||||||
@ -76,17 +76,20 @@ loop_input:
|
|||||||
mov eax, [esp+4]
|
mov eax, [esp+4]
|
||||||
|
|
||||||
; Update stats
|
; Update stats
|
||||||
|
inc [LOOPBACK_DEVICE.packets_tx]
|
||||||
inc [LOOPBACK_DEVICE.packets_rx]
|
inc [LOOPBACK_DEVICE.packets_rx]
|
||||||
|
|
||||||
mov ecx, [eax + NET_BUFF.length]
|
mov ecx, [eax + NET_BUFF.length]
|
||||||
add dword[LOOPBACK_DEVICE.bytes_rx], ecx
|
add dword[LOOPBACK_DEVICE.bytes_rx], ecx
|
||||||
adc dword[LOOPBACK_DEVICE.bytes_rx + 4], 0
|
adc dword[LOOPBACK_DEVICE.bytes_rx + 4], 0
|
||||||
|
add dword[LOOPBACK_DEVICE.bytes_tx], ecx
|
||||||
|
adc dword[LOOPBACK_DEVICE.bytes_tx + 4], 0
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: ptr=%x size=%u\n", eax, ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: ptr=%x size=%u\n", eax, ecx
|
||||||
|
|
||||||
; Reverse buffptr and returnaddr on stack
|
; Reverse buffptr and returnaddr on stack
|
||||||
pop edx edi
|
pop edx edi
|
||||||
push edx edi
|
push edx .done edi
|
||||||
|
|
||||||
; Set registers for protocol handlers
|
; Set registers for protocol handlers
|
||||||
lea edx, [eax + NET_BUFF.data]
|
lea edx, [eax + NET_BUFF.data]
|
||||||
@ -102,6 +105,12 @@ loop_input:
|
|||||||
.dump:
|
.dump:
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
|
||||||
call net_buff_free
|
call net_buff_free
|
||||||
|
|
||||||
|
or eax, -1
|
||||||
|
ret
|
||||||
|
|
||||||
|
.done:
|
||||||
|
xor eax, eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
|
||||||
@ -140,10 +149,6 @@ loop_output:
|
|||||||
mov [eax + NET_BUFF.length], ecx
|
mov [eax + NET_BUFF.length], ecx
|
||||||
lea edi, [eax + NET_BUFF.data]
|
lea edi, [eax + NET_BUFF.data]
|
||||||
|
|
||||||
inc [LOOPBACK_DEVICE.packets_tx]
|
|
||||||
add dword[LOOPBACK_DEVICE.bytes_tx], ecx
|
|
||||||
adc dword[LOOPBACK_DEVICE.bytes_tx + 4], 0
|
|
||||||
|
|
||||||
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, ecx
|
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Part of the TCP/IP network stack for KolibriOS ;;
|
;; Part of the TCP/IP network stack for KolibriOS ;;
|
||||||
@ -600,7 +600,7 @@ socket_listen:
|
|||||||
|
|
||||||
cmp [eax + IP_SOCKET.LocalIP], 0
|
cmp [eax + IP_SOCKET.LocalIP], 0
|
||||||
jne @f
|
jne @f
|
||||||
push [IP_LIST + 4] ;;; fixme!!!!
|
push [IPv4_address + 4] ;;; fixme!!!!
|
||||||
pop [eax + IP_SOCKET.LocalIP]
|
pop [eax + IP_SOCKET.LocalIP]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
@ -1228,7 +1228,7 @@ socket_set_opt:
|
|||||||
cmp edx, NET_DEVICES_MAX
|
cmp edx, NET_DEVICES_MAX
|
||||||
ja .invalid
|
ja .invalid
|
||||||
|
|
||||||
mov edx, [NET_DRV_LIST + 4*edx]
|
mov edx, [net_drv_list + 4*edx]
|
||||||
test edx, edx
|
test edx, edx
|
||||||
jz .already
|
jz .already
|
||||||
mov [eax + SOCKET.device], edx
|
mov [eax + SOCKET.device], edx
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2016. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; STACK.INC ;;
|
;; STACK.INC ;;
|
||||||
@ -251,10 +251,10 @@ include "socket.inc"
|
|||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
|
|
||||||
NET_RUNNING dd ?
|
net_running dd ?
|
||||||
NET_DRV_LIST rd NET_DEVICES_MAX
|
net_drv_list rd NET_DEVICES_MAX
|
||||||
|
|
||||||
NET_BUFFS_FREE rd NET_BUFFERS
|
net_buffs_free rd NET_BUFFERS
|
||||||
.current dd ?
|
.current dd ?
|
||||||
|
|
||||||
endg
|
endg
|
||||||
@ -276,7 +276,7 @@ stack_init:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .fail
|
jz .fail
|
||||||
|
|
||||||
mov edi, NET_BUFFS_FREE
|
mov edi, net_buffs_free
|
||||||
mov ecx, NET_BUFFERS
|
mov ecx, NET_BUFFERS
|
||||||
cld
|
cld
|
||||||
.loop:
|
.loop:
|
||||||
@ -285,12 +285,12 @@ stack_init:
|
|||||||
dec ecx
|
dec ecx
|
||||||
jnz .loop
|
jnz .loop
|
||||||
|
|
||||||
mov eax, NET_BUFFS_FREE
|
mov eax, net_buffs_free
|
||||||
stosd
|
stosd
|
||||||
|
|
||||||
; Init the network drivers list
|
; Init the network drivers list
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, NET_RUNNING
|
mov edi, net_running
|
||||||
mov ecx, (NET_DEVICES_MAX + 1)
|
mov ecx, (NET_DEVICES_MAX + 1)
|
||||||
rep stosd
|
rep stosd
|
||||||
|
|
||||||
@ -346,7 +346,7 @@ stack_handler:
|
|||||||
je .exit
|
je .exit
|
||||||
mov [net_10ms], eax
|
mov [net_10ms], eax
|
||||||
|
|
||||||
cmp [NET_RUNNING], 0
|
cmp [net_running], 0
|
||||||
je .exit
|
je .exit
|
||||||
|
|
||||||
test [net_10ms], 0x0f ; 160ms
|
test [net_10ms], 0x0f ; 160ms
|
||||||
@ -378,11 +378,11 @@ proc net_buff_alloc stdcall, buffersize
|
|||||||
|
|
||||||
spin_lock_irqsave
|
spin_lock_irqsave
|
||||||
|
|
||||||
mov eax, [NET_BUFFS_FREE.current]
|
mov eax, [net_buffs_free.current]
|
||||||
cmp eax, NET_BUFFS_FREE+NET_BUFFERS*4
|
cmp eax, net_buffs_free+NET_BUFFERS*4
|
||||||
jae .out_of_mem
|
jae .out_of_mem
|
||||||
mov eax, [eax]
|
mov eax, [eax]
|
||||||
add [NET_BUFFS_FREE.current], 4
|
add [net_buffs_free.current], 4
|
||||||
|
|
||||||
spin_unlock_irqrestore
|
spin_unlock_irqrestore
|
||||||
|
|
||||||
@ -410,8 +410,8 @@ proc net_buff_free stdcall, buffer
|
|||||||
|
|
||||||
spin_lock_irqsave
|
spin_lock_irqsave
|
||||||
|
|
||||||
sub [NET_BUFFS_FREE.current], 4
|
sub [net_buffs_free.current], 4
|
||||||
mov eax, [NET_BUFFS_FREE.current]
|
mov eax, [net_buffs_free.current]
|
||||||
push [buffer]
|
push [buffer]
|
||||||
pop dword[eax]
|
pop dword[eax]
|
||||||
|
|
||||||
@ -460,14 +460,14 @@ 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
|
cmp [net_running], NET_DEVICES_MAX
|
||||||
jae .error
|
jae .error
|
||||||
|
|
||||||
;----------------------------------
|
;----------------------------------
|
||||||
; Check if device is already listed
|
; Check if device is already listed
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ecx, NET_DEVICES_MAX ; We need to check whole list because a device may be removed without re-organizing list
|
mov ecx, NET_DEVICES_MAX ; We need to check whole list because a device may be removed without re-organizing list
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, net_drv_list
|
||||||
|
|
||||||
repne scasd ; See if device is already in the list
|
repne scasd ; See if device is already in the list
|
||||||
jz .error
|
jz .error
|
||||||
@ -476,7 +476,7 @@ net_add_device:
|
|||||||
; Find empty slot in the list
|
; Find empty slot in the list
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ecx, NET_DEVICES_MAX
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, net_drv_list
|
||||||
|
|
||||||
repne scasd
|
repne scasd
|
||||||
jnz .error
|
jnz .error
|
||||||
@ -488,10 +488,10 @@ net_add_device:
|
|||||||
mov [edi], ebx ; add device to list
|
mov [edi], ebx ; add device to list
|
||||||
|
|
||||||
mov eax, edi ; Calculate device number in eax
|
mov eax, edi ; Calculate device number in eax
|
||||||
sub eax, NET_DRV_LIST
|
sub eax, net_drv_list
|
||||||
shr eax, 2
|
shr eax, 2
|
||||||
|
|
||||||
inc [NET_RUNNING] ; Indicate that one more network device is up and running
|
inc [net_running] ; Indicate that one more network device is up and running
|
||||||
|
|
||||||
call net_send_event
|
call net_send_event
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ net_add_device:
|
|||||||
align 4
|
align 4
|
||||||
net_remove_device:
|
net_remove_device:
|
||||||
|
|
||||||
cmp [NET_RUNNING], 0
|
cmp [net_running], 0
|
||||||
je .error
|
je .error
|
||||||
|
|
||||||
;----------------------------
|
;----------------------------
|
||||||
@ -525,7 +525,7 @@ net_remove_device:
|
|||||||
|
|
||||||
mov eax, ebx
|
mov eax, ebx
|
||||||
mov ecx, NET_DEVICES_MAX
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, net_drv_list
|
||||||
|
|
||||||
repne scasd
|
repne scasd
|
||||||
jnz .error
|
jnz .error
|
||||||
@ -535,7 +535,7 @@ net_remove_device:
|
|||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov dword [edi-4], eax
|
mov dword [edi-4], eax
|
||||||
dec [NET_RUNNING]
|
dec [net_running]
|
||||||
|
|
||||||
call net_send_event
|
call net_send_event
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ net_ptr_to_num4: ; Todo, place number in device structure so we o
|
|||||||
|
|
||||||
push ecx
|
push ecx
|
||||||
mov ecx, NET_DEVICES_MAX
|
mov ecx, NET_DEVICES_MAX
|
||||||
mov edi, NET_DRV_LIST
|
mov edi, net_drv_list
|
||||||
.loop:
|
.loop:
|
||||||
cmp ebx, [edi]
|
cmp ebx, [edi]
|
||||||
je .found
|
je .found
|
||||||
@ -589,7 +589,7 @@ net_ptr_to_num4: ; Todo, place number in device structure so we o
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.found:
|
.found:
|
||||||
sub edi, NET_DRV_LIST
|
sub edi, net_drv_list
|
||||||
pop ecx
|
pop ecx
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -717,7 +717,7 @@ sys_network:
|
|||||||
cmp bl, 255
|
cmp bl, 255
|
||||||
jne @f
|
jne @f
|
||||||
|
|
||||||
mov eax, [NET_RUNNING]
|
mov eax, [net_running]
|
||||||
mov [esp+32], eax
|
mov [esp+32], eax
|
||||||
ret
|
ret
|
||||||
|
|
||||||
@ -729,10 +729,10 @@ sys_network:
|
|||||||
and esi, 0x0000ff00
|
and esi, 0x0000ff00
|
||||||
shr esi, 6
|
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
|
je .doesnt_exist
|
||||||
|
|
||||||
mov eax, [esi + NET_DRV_LIST]
|
mov eax, [esi + net_drv_list]
|
||||||
|
|
||||||
and ebx, 0x000000ff
|
and ebx, 0x000000ff
|
||||||
cmp ebx, .number
|
cmp ebx, .number
|
||||||
@ -840,7 +840,7 @@ sys_protocols:
|
|||||||
mov esi, ebx
|
mov esi, ebx
|
||||||
and esi, 0x0000ff00
|
and esi, 0x0000ff00
|
||||||
shr esi, 6 ; now we have the device num * 4 in esi
|
shr esi, 6 ; now we have the device num * 4 in esi
|
||||||
cmp [esi + NET_DRV_LIST], 0 ; check if driver is running
|
cmp [esi + net_drv_list], 0 ; check if driver is running
|
||||||
je .doesnt_exist
|
je .doesnt_exist
|
||||||
|
|
||||||
push .return ; return address (we will be using jumps instead of calls)
|
push .return ; return address (we will be using jumps instead of calls)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Part of the TCP/IP network stack for KolibriOS ;;
|
;; Part of the TCP/IP network stack for KolibriOS ;;
|
||||||
@ -122,7 +122,7 @@ tcp_connect:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .enoroute
|
jz .enoroute
|
||||||
pop eax
|
pop eax
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [net_drv_list + edi]
|
||||||
mov [eax + TCP_SOCKET.device], ebx
|
mov [eax + TCP_SOCKET.device], ebx
|
||||||
mov [eax + TCP_SOCKET.LocalIP], edx
|
mov [eax + TCP_SOCKET.LocalIP], edx
|
||||||
popa
|
popa
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;;
|
;; Copyright (C) KolibriOS team 2004-2019. All rights reserved. ;;
|
||||||
;; Distributed under terms of the GNU General Public License ;;
|
;; Distributed under terms of the GNU General Public License ;;
|
||||||
;; ;;
|
;; ;;
|
||||||
;; UDP.INC ;;
|
;; UDP.INC ;;
|
||||||
@ -30,8 +30,8 @@ ends
|
|||||||
uglobal
|
uglobal
|
||||||
align 4
|
align 4
|
||||||
|
|
||||||
UDP_PACKETS_TX rd NET_DEVICES_MAX
|
UDP_packets_tx rd NET_DEVICES_MAX
|
||||||
UDP_PACKETS_RX rd NET_DEVICES_MAX
|
UDP_packets_rx rd NET_DEVICES_MAX
|
||||||
|
|
||||||
endg
|
endg
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ endg
|
|||||||
macro udp_init {
|
macro udp_init {
|
||||||
|
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov edi, UDP_PACKETS_TX
|
mov edi, UDP_packets_tx
|
||||||
mov ecx, 2*NET_DEVICES_MAX
|
mov ecx, 2*NET_DEVICES_MAX
|
||||||
rep stosd
|
rep stosd
|
||||||
}
|
}
|
||||||
@ -188,7 +188,7 @@ udp_input:
|
|||||||
popa
|
popa
|
||||||
|
|
||||||
.updatesock:
|
.updatesock:
|
||||||
inc [UDP_PACKETS_RX + edi]
|
inc [UDP_packets_rx + edi]
|
||||||
|
|
||||||
movzx ecx, [esi + UDP_header.Length]
|
movzx ecx, [esi + UDP_header.Length]
|
||||||
sub ecx, sizeof.UDP_header
|
sub ecx, sizeof.UDP_header
|
||||||
@ -286,7 +286,7 @@ udp_output:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jnz @f
|
jnz @f
|
||||||
call net_ptr_to_num4
|
call net_ptr_to_num4
|
||||||
inc [UDP_PACKETS_TX + edi]
|
inc [UDP_packets_tx + edi]
|
||||||
@@:
|
@@:
|
||||||
|
|
||||||
ret
|
ret
|
||||||
@ -341,7 +341,7 @@ udp_connect:
|
|||||||
test eax, eax
|
test eax, eax
|
||||||
jz .enoroute
|
jz .enoroute
|
||||||
pop eax
|
pop eax
|
||||||
mov ebx, [NET_DRV_LIST + edi]
|
mov ebx, [net_drv_list + edi]
|
||||||
mov [eax + UDP_SOCKET.device], ebx
|
mov [eax + UDP_SOCKET.device], ebx
|
||||||
mov [eax + UDP_SOCKET.LocalIP], edx
|
mov [eax + UDP_SOCKET.LocalIP], edx
|
||||||
popa
|
popa
|
||||||
@ -420,9 +420,9 @@ udp_api:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_tx:
|
.packets_tx:
|
||||||
mov eax, [UDP_PACKETS_TX + eax]
|
mov eax, [UDP_packets_tx + eax]
|
||||||
ret
|
ret
|
||||||
|
|
||||||
.packets_rx:
|
.packets_rx:
|
||||||
mov eax, [UDP_PACKETS_RX + eax]
|
mov eax, [UDP_packets_rx + eax]
|
||||||
ret
|
ret
|
||||||
|
Loading…
Reference in New Issue
Block a user