From 338b57422f43b7e66a62065f85ee5d00d44f8ddb Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Sun, 25 Aug 2019 18:21:44 +0000 Subject: [PATCH] network code cleanup, fix some statistics git-svn-id: svn://kolibrios.org@7678 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/network/ARP.inc | 58 ++++++++-------- kernel/trunk/network/IPv4.inc | 105 +++++++++++++++-------------- kernel/trunk/network/PPPoE.inc | 4 +- kernel/trunk/network/ethernet.inc | 2 +- kernel/trunk/network/icmp.inc | 21 +++--- kernel/trunk/network/loopback.inc | 25 ++++--- kernel/trunk/network/socket.inc | 6 +- kernel/trunk/network/stack.inc | 54 +++++++-------- kernel/trunk/network/tcp_usreq.inc | 4 +- kernel/trunk/network/udp.inc | 18 ++--- 10 files changed, 152 insertions(+), 145 deletions(-) diff --git a/kernel/trunk/network/ARP.inc b/kernel/trunk/network/ARP.inc index f15d19a327..2d566b443f 100644 --- a/kernel/trunk/network/ARP.inc +++ b/kernel/trunk/network/ARP.inc @@ -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 ;; ;; ;; ;; ARP.INC ;; @@ -60,10 +60,10 @@ align 4 ARP_table rb NET_DEVICES_MAX*(ARP_TABLE_SIZE * sizeof.ARP_entry) - ARP_entries_num rd NET_DEVICES_MAX - ARP_PACKETS_TX rd NET_DEVICES_MAX - ARP_PACKETS_RX rd NET_DEVICES_MAX - ARP_CONFLICTS rd NET_DEVICES_MAX + ARP_entries rd NET_DEVICES_MAX + ARP_packets_tx rd NET_DEVICES_MAX + ARP_packets_rx rd NET_DEVICES_MAX + ARP_conflicts rd NET_DEVICES_MAX endg @@ -78,7 +78,7 @@ endg macro arp_init { xor eax, eax - mov edi, ARP_entries_num + mov edi, ARP_entries mov ecx, 4*NET_DEVICES_MAX rep stosd @@ -107,7 +107,7 @@ local .exit xor edi, edi .loop_outer: - mov ecx, [ARP_entries_num + 4*edi] + mov ecx, [ARP_entries + 4*edi] test ecx, ecx jz .exit @@ -177,7 +177,7 @@ arp_input: cmp edi, -1 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",\ [edx + ARP_header.SenderIP]:1, [edx + ARP_header.SenderIP + 1]:1,\ @@ -187,7 +187,7 @@ arp_input: ; First, check for IP collision mov eax, [edx + ARP_header.SenderIP] - cmp eax, [IP_LIST + edi] + cmp eax, [IPv4_address + edi] je .collision ;--------------------- @@ -198,7 +198,7 @@ arp_input: 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 jz .exit @@ -242,7 +242,7 @@ arp_input: 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? jne .exit @@ -259,7 +259,7 @@ arp_input: movsd ; Move sender IP to Dest IP pop esi - mov esi, [NET_DRV_LIST + esi] + mov esi, [net_drv_list + esi] lea esi, [esi + ETH_DEVICE.mac] lea edi, [edx + ARP_header.SenderMAC] movsd ; Copy MAC address from in MAC_LIST @@ -288,7 +288,7 @@ arp_input: ret .collision: - inc [ARP_CONFLICTS + edi] + inc [ARP_conflicts + edi] DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: IP address conflict detected!\n" .exit: @@ -333,8 +333,8 @@ arp_output_request: push edi call net_ptr_to_num4 - inc [ARP_PACKETS_TX + edi] ; assume we will succeed - lea esi, [IP_LIST + edi] ; SenderIP + inc [ARP_packets_tx + edi] ; assume we will succeed + lea esi, [IPv4_address + edi] ; SenderIP pop edi movsd @@ -372,13 +372,13 @@ arp_add_entry: 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 ? jae .full ; 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 xor ecx, ecx @@ -417,7 +417,7 @@ arp_add_entry: .error: pop edi - dec [ARP_entries_num + edi] + dec [ARP_entries + edi] DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n" .full: mov eax, -1 @@ -460,7 +460,7 @@ arp_del_entry: rep stosw pop edi - dec [ARP_entries_num + 4*edi] + dec [ARP_entries + 4*edi] DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n" ret @@ -497,7 +497,7 @@ arp_ip_to_mac: ;-------------------------------- ; Try to find the IP in ARP_table - mov ecx, [ARP_entries_num + edi] + mov ecx, [ARP_entries + edi] test ecx, ecx jz .not_in_list 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 push esi edi - mov ebx, [NET_DRV_LIST + edi] + mov ebx, [net_drv_list + edi] call arp_output_request pop edi esi .found_it: @@ -620,23 +620,23 @@ arp_api: ret .packets_tx: - mov eax, [ARP_PACKETS_TX + eax] + mov eax, [ARP_packets_tx + eax] ret .packets_rx: - mov eax, [ARP_PACKETS_RX + eax] + mov eax, [ARP_packets_rx + eax] ret .conflicts: - mov eax, [ARP_CONFLICTS + eax] + mov eax, [ARP_conflicts + eax] ret .entries: - mov eax, [ARP_entries_num + eax] + mov eax, [ARP_entries + eax] ret .read: - cmp ecx, [ARP_entries_num + eax] + cmp ecx, [ARP_entries + eax] jae .error shr eax, 2 imul eax, sizeof.ARP_entry*ARP_TABLE_SIZE @@ -659,7 +659,7 @@ arp_api: .remove: ; ecx = # entry - cmp ecx, [ARP_entries_num + eax] + cmp ecx, [ARP_entries + eax] jae .error imul ecx, sizeof.ARP_entry lea esi, [ARP_table + ecx] @@ -669,8 +669,8 @@ arp_api: ret .send_announce: - mov ebx, [NET_DRV_LIST + eax] - mov eax, [IP_LIST + eax] + mov ebx, [net_drv_list + eax] + mov eax, [IPv4_address + eax] call arp_output_request ; now send a gratuitous ARP ret diff --git a/kernel/trunk/network/IPv4.inc b/kernel/trunk/network/IPv4.inc index 5990eb724e..cff408011e 100644 --- a/kernel/trunk/network/IPv4.inc +++ b/kernel/trunk/network/IPv4.inc @@ -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 ;; ;; ;; ;; 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) ends -struct IPv4_ROUTE - - Destination dd ? - Gateway dd ? - Flags dd ? - Use dd ? - Interface dd ? - -ends - +;struct IPv4_ROUTE +; +; Destination dd ? +; Gateway dd ? +; Flags dd ? +; Use dd ? +; Interface dd ? +; +;ends uglobal align 4 - IP_LIST rd NET_DEVICES_MAX - SUBNET_LIST rd NET_DEVICES_MAX - DNS_LIST rd NET_DEVICES_MAX - GATEWAY_LIST rd NET_DEVICES_MAX - BROADCAST_LIST rd NET_DEVICES_MAX + IPv4_address rd NET_DEVICES_MAX + IPv4_subnet rd NET_DEVICES_MAX + IPv4_nameserver rd NET_DEVICES_MAX + IPv4_gateway rd NET_DEVICES_MAX + IPv4_broadcast rd NET_DEVICES_MAX IPv4_packets_tx rd NET_DEVICES_MAX IPv4_packets_rx 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 @@ -100,7 +99,7 @@ endg macro ipv4_init { 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 rep stosd @@ -116,7 +115,7 @@ macro ipv4_decrease_fragment_ttls { local .loop, .next - mov esi, IPv4_FRAGMENT_LIST + mov esi, IPv4_fragments mov ecx, IPv4_MAX_FRAGMENTS .loop: cmp [esi + IPv4_FRAGMENT_slot.ttl], 0 @@ -244,11 +243,11 @@ ipv4_input: ; local ip (Using RFC1122 strong end system model) mov eax, [edx + IPv4_header.DestinationAddress] - cmp eax, [IP_LIST + edi] + cmp eax, [IPv4_address + edi] je .ip_ok ; network layer broadcast - cmp eax, [BROADCAST_LIST + edi] + cmp eax, [IPv4_broadcast + edi] je .ip_ok ; physical layer broadcast (255.255.255.255) @@ -261,7 +260,7 @@ ipv4_input: je .ip_ok ; 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 ; 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" ; try to locate a free slot.. mov ecx, IPv4_MAX_FRAGMENTS - mov esi, IPv4_FRAGMENT_LIST + mov esi, IPv4_fragments .find_free_slot: cmp word [esi + IPv4_FRAGMENT_slot.ttl], 0 je .found_free_slot @@ -584,7 +583,7 @@ ipv4_find_fragment_slot: push eax ebx ecx edx mov ax, [edx + IPv4_header.Identification] mov ecx, IPv4_MAX_FRAGMENTS - mov esi, IPv4_FRAGMENT_LIST + mov esi, IPv4_fragments mov ebx, [edx + IPv4_header.SourceAddress] mov edx, [edx + IPv4_header.DestinationAddress] .find_slot: @@ -649,7 +648,7 @@ ipv4_output: inc [IPv4_packets_tx + edi] ; update stats mov ax, ETHER_PROTO_IPv4 - mov ebx, [NET_DRV_LIST + edi] + mov ebx, [net_drv_list + edi] mov ecx, [esp + 6 + 8 + 2] add ecx, sizeof.IPv4_header mov edx, esp @@ -706,6 +705,8 @@ ipv4_output: ret .loopback: + inc [IPv4_packets_tx + edi] ; update stats + mov dword [esp], eax ; set source IP to dest IP mov ecx, [esp + 10] add ecx, sizeof.IPv4_header @@ -746,7 +747,7 @@ ipv4_output_raw: inc [IPv4_packets_tx + 4*edi] mov ax, ETHER_PROTO_IPv4 - mov ebx, [NET_DRV_LIST + 4*edi] + mov ebx, [net_drv_list + 4*edi] mov ecx, [esp + 6 + 4] add ecx, sizeof.IPv4_header mov edx, esp @@ -945,11 +946,11 @@ ipv4_route: xor edi, edi .loop: - mov ebx, [IP_LIST + edi] - and ebx, [SUBNET_LIST + edi] + mov ebx, [IPv4_address + edi] + and ebx, [IPv4_subnet + edi] jz .next mov ecx, eax - and ecx, [SUBNET_LIST + edi] + and ecx, [IPv4_subnet + edi] cmp ebx, ecx je .got_it .next: @@ -957,14 +958,14 @@ ipv4_route: cmp edi, 4*NET_DEVICES_MAX 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: mov edi, 4 ; TODO: same as above .got_it: DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi test edx, edx jnz @f - mov edx, [IP_LIST + edi] + mov edx, [IPv4_address + edi] @@: ret @@ -975,20 +976,20 @@ ipv4_route: cmp edi, -1 je .fail - mov edx, [IP_LIST + edi] ; Source IP + mov edx, [IPv4_address + edi] ; Source IP ; Broadcast does not need gateway cmp eax, 0xffffffff je @f ; Check if we should route to gateway or not - mov ebx, [IP_LIST + edi] - and ebx, [SUBNET_LIST + edi] + mov ebx, [IPv4_address + edi] + and ebx, [IPv4_subnet + edi] mov ecx, eax - and ecx, [SUBNET_LIST + edi] + and ecx, [IPv4_subnet + edi] cmp ecx, ebx je @f - mov eax, [GATEWAY_LIST + edi] + mov eax, [IPv4_gateway + edi] @@: DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi ret @@ -1038,7 +1039,7 @@ ipv4_connect: ; Fill in local IP cmp [eax + IP_SOCKET.LocalIP], 0 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] ; Fill in remote IP @@ -1100,21 +1101,21 @@ ipv4_api: ret .read_ip: - mov eax, [IP_LIST + eax] + mov eax, [IPv4_address + eax] ret .write_ip: - mov [IP_LIST + eax], ecx + mov [IPv4_address + eax], ecx mov edi, eax ; device number, we'll need it for ARP ; pre-calculate the local broadcast address - mov ebx, [SUBNET_LIST + eax] + mov ebx, [IPv4_subnet + eax] not ebx or ebx, ecx - mov [BROADCAST_LIST + eax], ebx + mov [IPv4_broadcast + eax], ebx - mov ebx, [NET_DRV_LIST + eax] - mov eax, [IP_LIST + eax] + mov ebx, [net_drv_list + eax] + mov eax, [IPv4_address + eax] call arp_output_request ; now send a gratuitous ARP call net_send_event @@ -1122,38 +1123,38 @@ ipv4_api: ret .read_dns: - mov eax, [DNS_LIST + eax] + mov eax, [IPv4_nameserver + eax] ret .write_dns: - mov [DNS_LIST + eax], ecx + mov [IPv4_nameserver + eax], ecx call net_send_event xor eax, eax ret .read_subnet: - mov eax, [SUBNET_LIST + eax] + mov eax, [IPv4_subnet + eax] ret .write_subnet: - mov [SUBNET_LIST + eax], ecx + mov [IPv4_subnet + eax], ecx ; pre-calculate the local broadcast address - mov ebx, [IP_LIST + eax] + mov ebx, [IPv4_address + eax] not ecx or ecx, ebx - mov [BROADCAST_LIST + eax], ecx + mov [IPv4_broadcast + eax], ecx call net_send_event xor eax, eax ret .read_gateway: - mov eax, [GATEWAY_LIST + eax] + mov eax, [IPv4_gateway + eax] ret .write_gateway: - mov [GATEWAY_LIST + eax], ecx + mov [IPv4_gateway + eax], ecx call net_send_event xor eax, eax diff --git a/kernel/trunk/network/PPPoE.inc b/kernel/trunk/network/PPPoE.inc index 3c2bed02a9..0ef368f476 100644 --- a/kernel/trunk/network/PPPoE.inc +++ b/kernel/trunk/network/PPPoE.inc @@ -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 ;; ;; ;; ;; PPPoE.INC ;; @@ -131,7 +131,7 @@ pppoe_discovery_output: cmp ebx, NET_DEVICES_MAX ja .bad - mov ebx, [NET_DRV_LIST + 4*ebx] + mov ebx, [net_drv_list + 4*ebx] test ebx, ebx jz .bad diff --git a/kernel/trunk/network/ethernet.inc b/kernel/trunk/network/ethernet.inc index 61ec373629..346ef9adb4 100644 --- a/kernel/trunk/network/ethernet.inc +++ b/kernel/trunk/network/ethernet.inc @@ -285,7 +285,7 @@ eth_api: cmp bh, NET_DEVICES_MAX ja .error 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 jne .error diff --git a/kernel/trunk/network/icmp.inc b/kernel/trunk/network/icmp.inc index 66d44396db..6f149a0d94 100644 --- a/kernel/trunk/network/icmp.inc +++ b/kernel/trunk/network/icmp.inc @@ -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 ;; ;; ;; ;; ICMP.INC ;; @@ -99,8 +99,8 @@ ends uglobal align 4 - ICMP_PACKETS_TX rd NET_DEVICES_MAX - ICMP_PACKETS_RX rd NET_DEVICES_MAX + ICMP_packets_tx rd NET_DEVICES_MAX + ICMP_packets_rx rd NET_DEVICES_MAX endg @@ -115,7 +115,7 @@ endg macro icmp_init { xor eax, eax - mov edi, ICMP_PACKETS_TX + mov edi, ICMP_packets_tx mov ecx, 2*NET_DEVICES_MAX rep stosd @@ -143,7 +143,7 @@ icmp_input: DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input\n" ; Dump all multicasts and broadcasts - mov eax, [IP_LIST + edi] + mov eax, [IPv4_address + edi] cmp eax, [edx + IPv4_header.DestinationAddress] jne .dump @@ -162,7 +162,7 @@ icmp_input: DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP_input: Checksum OK\n" ; Update stats - inc [ICMP_PACKETS_RX + edi] + inc [ICMP_packets_rx + edi] ; Is this an echo request? cmp [esi + ICMP_header.Type], ICMP_ECHO @@ -273,7 +273,8 @@ icmp_input: jnz @f DEBUGF DEBUG_NETWORK_VERBOSE, "ICMP transmit failed\n" call net_ptr_to_num4 - inc [ICMP_PACKETS_TX + edi] + inc [ICMP_packets_tx + edi] + inc [IPv4_packets_tx + edi] @@: ret @@ -406,7 +407,7 @@ icmp_output_raw: test eax, eax jnz @f call net_ptr_to_num4 - inc [ICMP_PACKETS_TX + edi] + inc [ICMP_packets_tx + edi] @@: ret @@ -447,9 +448,9 @@ icmp_api: ret .packets_tx: - mov eax, [ICMP_PACKETS_TX + eax] + mov eax, [ICMP_packets_tx + eax] ret .packets_rx: - mov eax, [ICMP_PACKETS_RX + eax] + mov eax, [ICMP_packets_rx + eax] ret diff --git a/kernel/trunk/network/loopback.inc b/kernel/trunk/network/loopback.inc index cf11f35155..c1ee9f2802 100644 --- a/kernel/trunk/network/loopback.inc +++ b/kernel/trunk/network/loopback.inc @@ -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 ;; ;; ;; ;; loopback.inc ;; @@ -54,9 +54,9 @@ local .fail cmp eax, -1 je .fail - mov [IP_LIST], 127 + 1 shl 24 - mov [SUBNET_LIST], 255 - mov [BROADCAST_LIST], 0xffffff00 + 127 + mov [IPv4_address], 127 + 1 shl 24 + mov [IPv4_subnet], 255 + mov [IPv4_broadcast], 0xffffff00 + 127 .fail: } @@ -67,7 +67,7 @@ local .fail ; ; ; IN: [esp+4] = Pointer to buffer ; ; ; -; OUT: / ; +; OUT: eax = 0 on success, errorcode otherwise ; ; ; ;-----------------------------------------------------------------; align 4 @@ -76,17 +76,20 @@ loop_input: mov eax, [esp+4] ; Update stats + inc [LOOPBACK_DEVICE.packets_tx] inc [LOOPBACK_DEVICE.packets_rx] mov ecx, [eax + NET_BUFF.length] add dword[LOOPBACK_DEVICE.bytes_rx], ecx 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 ; Reverse buffptr and returnaddr on stack pop edx edi - push edx edi + push edx .done edi ; Set registers for protocol handlers lea edx, [eax + NET_BUFF.data] @@ -102,6 +105,12 @@ loop_input: .dump: DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n" call net_buff_free + + or eax, -1 + ret + + .done: + xor eax, eax ret @@ -140,10 +149,6 @@ loop_output: mov [eax + NET_BUFF.length], ecx 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 ret diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 619e56f233..dc76743a3e 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -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 ;; ;; ;; ;; Part of the TCP/IP network stack for KolibriOS ;; @@ -600,7 +600,7 @@ socket_listen: cmp [eax + IP_SOCKET.LocalIP], 0 jne @f - push [IP_LIST + 4] ;;; fixme!!!! + push [IPv4_address + 4] ;;; fixme!!!! pop [eax + IP_SOCKET.LocalIP] @@: @@ -1228,7 +1228,7 @@ socket_set_opt: cmp edx, NET_DEVICES_MAX ja .invalid - mov edx, [NET_DRV_LIST + 4*edx] + mov edx, [net_drv_list + 4*edx] test edx, edx jz .already mov [eax + SOCKET.device], edx diff --git a/kernel/trunk/network/stack.inc b/kernel/trunk/network/stack.inc index d8f38949ff..d01598505b 100644 --- a/kernel/trunk/network/stack.inc +++ b/kernel/trunk/network/stack.inc @@ -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 ;; ;; ;; ;; STACK.INC ;; @@ -251,10 +251,10 @@ include "socket.inc" uglobal align 4 - NET_RUNNING dd ? - NET_DRV_LIST rd NET_DEVICES_MAX + net_running dd ? + net_drv_list rd NET_DEVICES_MAX - NET_BUFFS_FREE rd NET_BUFFERS + net_buffs_free rd NET_BUFFERS .current dd ? endg @@ -276,7 +276,7 @@ stack_init: test eax, eax jz .fail - mov edi, NET_BUFFS_FREE + mov edi, net_buffs_free mov ecx, NET_BUFFERS cld .loop: @@ -285,12 +285,12 @@ stack_init: dec ecx jnz .loop - mov eax, NET_BUFFS_FREE + mov eax, net_buffs_free stosd ; Init the network drivers list xor eax, eax - mov edi, NET_RUNNING + mov edi, net_running mov ecx, (NET_DEVICES_MAX + 1) rep stosd @@ -346,7 +346,7 @@ stack_handler: je .exit mov [net_10ms], eax - cmp [NET_RUNNING], 0 + cmp [net_running], 0 je .exit test [net_10ms], 0x0f ; 160ms @@ -378,11 +378,11 @@ proc net_buff_alloc stdcall, buffersize spin_lock_irqsave - mov eax, [NET_BUFFS_FREE.current] - cmp eax, NET_BUFFS_FREE+NET_BUFFERS*4 + mov eax, [net_buffs_free.current] + cmp eax, net_buffs_free+NET_BUFFERS*4 jae .out_of_mem mov eax, [eax] - add [NET_BUFFS_FREE.current], 4 + add [net_buffs_free.current], 4 spin_unlock_irqrestore @@ -410,8 +410,8 @@ proc net_buff_free stdcall, buffer spin_lock_irqsave - sub [NET_BUFFS_FREE.current], 4 - mov eax, [NET_BUFFS_FREE.current] + sub [net_buffs_free.current], 4 + mov eax, [net_buffs_free.current] push [buffer] 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 - cmp [NET_RUNNING], NET_DEVICES_MAX + cmp [net_running], NET_DEVICES_MAX jae .error ;---------------------------------- ; Check if device is already listed 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 edi, NET_DRV_LIST + mov edi, net_drv_list repne scasd ; See if device is already in the list jz .error @@ -476,7 +476,7 @@ net_add_device: ; Find empty slot in the list xor eax, eax mov ecx, NET_DEVICES_MAX - mov edi, NET_DRV_LIST + mov edi, net_drv_list repne scasd jnz .error @@ -488,10 +488,10 @@ net_add_device: mov [edi], ebx ; add device to list mov eax, edi ; Calculate device number in eax - sub eax, NET_DRV_LIST + sub eax, net_drv_list 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 @@ -517,7 +517,7 @@ net_add_device: align 4 net_remove_device: - cmp [NET_RUNNING], 0 + cmp [net_running], 0 je .error ;---------------------------- @@ -525,7 +525,7 @@ net_remove_device: mov eax, ebx mov ecx, NET_DEVICES_MAX - mov edi, NET_DRV_LIST + mov edi, net_drv_list repne scasd jnz .error @@ -535,7 +535,7 @@ net_remove_device: xor eax, eax mov dword [edi-4], eax - dec [NET_RUNNING] + dec [net_running] call net_send_event @@ -575,7 +575,7 @@ net_ptr_to_num4: ; Todo, place number in device structure so we o push ecx mov ecx, NET_DEVICES_MAX - mov edi, NET_DRV_LIST + mov edi, net_drv_list .loop: cmp ebx, [edi] je .found @@ -589,7 +589,7 @@ net_ptr_to_num4: ; Todo, place number in device structure so we o ret .found: - sub edi, NET_DRV_LIST + sub edi, net_drv_list pop ecx ret @@ -717,7 +717,7 @@ sys_network: cmp bl, 255 jne @f - mov eax, [NET_RUNNING] + mov eax, [net_running] mov [esp+32], eax ret @@ -729,10 +729,10 @@ sys_network: and esi, 0x0000ff00 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 - mov eax, [esi + NET_DRV_LIST] + mov eax, [esi + net_drv_list] and ebx, 0x000000ff cmp ebx, .number @@ -840,7 +840,7 @@ sys_protocols: mov esi, ebx and esi, 0x0000ff00 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 push .return ; return address (we will be using jumps instead of calls) diff --git a/kernel/trunk/network/tcp_usreq.inc b/kernel/trunk/network/tcp_usreq.inc index 25ad66a2d2..c9e5ffdb9d 100644 --- a/kernel/trunk/network/tcp_usreq.inc +++ b/kernel/trunk/network/tcp_usreq.inc @@ -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 ;; ;; ;; ;; Part of the TCP/IP network stack for KolibriOS ;; @@ -122,7 +122,7 @@ tcp_connect: test eax, eax jz .enoroute pop eax - mov ebx, [NET_DRV_LIST + edi] + mov ebx, [net_drv_list + edi] mov [eax + TCP_SOCKET.device], ebx mov [eax + TCP_SOCKET.LocalIP], edx popa diff --git a/kernel/trunk/network/udp.inc b/kernel/trunk/network/udp.inc index 5cca25c8ac..3c5a8bc48d 100644 --- a/kernel/trunk/network/udp.inc +++ b/kernel/trunk/network/udp.inc @@ -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 ;; ;; ;; ;; UDP.INC ;; @@ -30,8 +30,8 @@ ends uglobal align 4 - UDP_PACKETS_TX rd NET_DEVICES_MAX - UDP_PACKETS_RX rd NET_DEVICES_MAX + UDP_packets_tx rd NET_DEVICES_MAX + UDP_packets_rx rd NET_DEVICES_MAX endg @@ -44,7 +44,7 @@ endg macro udp_init { xor eax, eax - mov edi, UDP_PACKETS_TX + mov edi, UDP_packets_tx mov ecx, 2*NET_DEVICES_MAX rep stosd } @@ -188,7 +188,7 @@ udp_input: popa .updatesock: - inc [UDP_PACKETS_RX + edi] + inc [UDP_packets_rx + edi] movzx ecx, [esi + UDP_header.Length] sub ecx, sizeof.UDP_header @@ -286,7 +286,7 @@ udp_output: test eax, eax jnz @f call net_ptr_to_num4 - inc [UDP_PACKETS_TX + edi] + inc [UDP_packets_tx + edi] @@: ret @@ -341,7 +341,7 @@ udp_connect: test eax, eax jz .enoroute pop eax - mov ebx, [NET_DRV_LIST + edi] + mov ebx, [net_drv_list + edi] mov [eax + UDP_SOCKET.device], ebx mov [eax + UDP_SOCKET.LocalIP], edx popa @@ -420,9 +420,9 @@ udp_api: ret .packets_tx: - mov eax, [UDP_PACKETS_TX + eax] + mov eax, [UDP_packets_tx + eax] ret .packets_rx: - mov eax, [UDP_PACKETS_RX + eax] + mov eax, [UDP_packets_rx + eax] ret