Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 7677 → Rev 7678

/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
 
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
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
 
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
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
; 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
 
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
 
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
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
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
 
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
 
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
 
.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
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
;--------------------------------
; 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
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
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
 
.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
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
 
/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
; Ip header begins here (we will need the IP header to re-construct the complete packet)
ends
 
struct IPv4_ROUTE
;struct IPv4_ROUTE
;
; Destination dd ?
; Gateway dd ?
; Flags dd ?
; Use dd ?
; Interface dd ?
;
;ends
 
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
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
 
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
 
; 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
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
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
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
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
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
 
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
 
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,7 → 958,7
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:
964,7 → 965,7
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,7 → 976,7
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
982,13 → 983,13
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
; 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
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,27 → 1123,27
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
1149,11 → 1150,11
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
/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
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
 
/kernel/trunk/network/ethernet.inc
285,7 → 285,7
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
 
/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
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
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
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
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
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
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
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
/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
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
; ;
; IN: [esp+4] = Pointer to buffer ;
; ;
; OUT: / ;
; OUT: eax = 0 on success, errorcode otherwise ;
; ;
;-----------------------------------------------------------------;
align 4
76,17 → 76,20
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,9 → 105,15
.dump:
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: dumping\n"
call net_buff_free
 
or eax, -1
ret
 
.done:
xor eax, eax
ret
 
 
;-----------------------------------------------------------------;
; ;
; loop_output ;
140,10 → 149,6
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
 
/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
 
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
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
/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
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
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
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
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
 
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
 
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,7 → 460,7
 
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
 
;----------------------------------
467,7 → 467,7
; 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
; 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
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
align 4
net_remove_device:
 
cmp [NET_RUNNING], 0
cmp [net_running], 0
je .error
 
;----------------------------
525,7 → 525,7
 
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
 
xor eax, eax
mov dword [edi-4], eax
dec [NET_RUNNING]
dec [net_running]
 
call net_send_event
 
575,7 → 575,7
 
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
ret
 
.found:
sub edi, NET_DRV_LIST
sub edi, net_drv_list
pop ecx
ret
 
717,7 → 717,7
cmp bl, 255
jne @f
 
mov eax, [NET_RUNNING]
mov eax, [net_running]
mov [esp+32], eax
ret
 
729,10 → 729,10
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
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)
/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
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
/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
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
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
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
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
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
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