network code cleanup

git-svn-id: svn://kolibrios.org@7679 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2019-08-25 18:46:47 +00:00
parent 338b57422f
commit 93a672ba27
8 changed files with 33 additions and 33 deletions

View File

@ -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_device_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
@ -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_device_list + edi]
call arp_output_request call arp_output_request
pop edi esi pop edi esi
.found_it: .found_it:
@ -669,7 +669,7 @@ arp_api:
ret ret
.send_announce: .send_announce:
mov ebx, [net_drv_list + eax] mov ebx, [net_device_list + eax]
mov eax, [IPv4_address + 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

View File

@ -648,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_device_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
@ -747,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_device_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
@ -1114,7 +1114,7 @@ ipv4_api:
or ebx, ecx or ebx, ecx
mov [IPv4_broadcast + eax], ebx mov [IPv4_broadcast + eax], ebx
mov ebx, [net_drv_list + eax] mov ebx, [net_device_list + eax]
mov eax, [IPv4_address + eax] mov eax, [IPv4_address + eax]
call arp_output_request ; now send a gratuitous ARP call arp_output_request ; now send a gratuitous ARP

View File

@ -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_device_list + 4*ebx]
test ebx, ebx test ebx, ebx
jz .bad jz .bad

View File

@ -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 ;;
;; ;; ;; ;;
;; ETHERNET.INC ;; ;; ETHERNET.INC ;;
@ -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_device_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

View File

@ -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_device_list + 4*edx]
test edx, edx test edx, edx
jz .already jz .already
mov [eax + SOCKET.device], edx mov [eax + SOCKET.device], edx

View File

@ -251,11 +251,11 @@ include "socket.inc"
uglobal uglobal
align 4 align 4
net_running dd ? net_device_count dd ?
net_drv_list rd NET_DEVICES_MAX net_device_list rd NET_DEVICES_MAX
net_buffs_free rd NET_BUFFERS net_buffs_free rd NET_BUFFERS
.current dd ? .current dd ?
endg endg
@ -290,7 +290,7 @@ stack_init:
; Init the network drivers list ; Init the network drivers list
xor eax, eax xor eax, eax
mov edi, net_running mov edi, net_device_count
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_device_count], 0
je .exit je .exit
test [net_10ms], 0x0f ; 160ms test [net_10ms], 0x0f ; 160ms
@ -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_device_count], 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_device_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_device_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_device_list
shr eax, 2 shr eax, 2
inc [net_running] ; Indicate that one more network device is up and running inc [net_device_count] ; 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_device_count], 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_device_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_device_count]
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_device_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_device_list
pop ecx pop ecx
ret ret
@ -717,22 +717,22 @@ sys_network:
cmp bl, 255 cmp bl, 255
jne @f jne @f
mov eax, [net_running] mov eax, [net_device_count]
mov [esp+32], eax mov [esp+32], eax
ret ret
@@: @@:
cmp bh, NET_DEVICES_MAX ; Check if device number exists cmp bh, NET_DEVICES_MAX ; Check if device number exists
jae .doesnt_exist jae .doesnt_exist
mov esi, ebx mov esi, ebx
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_device_list], 0 ; check if device is running
je .doesnt_exist je .doesnt_exist
mov eax, [esi + net_drv_list] mov eax, [esi + net_device_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_device_list], 0 ; check if device 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)

View File

@ -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_device_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

View File

@ -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_device_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