Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3600 → Rev 3601

/kernel/trunk/network/ARP.inc
58,10 → 58,10
align 4
uglobal
 
NumARP dd ?
 
ARP_table rb ARP_TABLE_SIZE * sizeof.ARP_entry ; TODO: separate ARP table and stats per interface
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
81,10 → 81,8
macro ARP_init {
 
xor eax, eax
mov [NumARP], eax
 
mov edi, ARP_PACKETS_TX
mov ecx, 3*NET_DEVICES_MAX
mov edi, ARP_entries_num
mov ecx, 4*NET_DEVICES_MAX
rep stosd
 
}
111,11 → 109,15
; The last status value is provided to allow the network layer to delete
; a packet that is queued awaiting an ARP response
 
mov ecx, [NumARP]
xor edi, edi
.loop_outer:
mov ecx, [ARP_entries_num + 4*edi]
test ecx, ecx
jz .exit
 
mov esi, ARP_table
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
imul esi, edi
add esi, ARP_table
.loop:
cmp [esi + ARP_entry.TTL], ARP_STATIC_ENTRY
je .next
133,9 → 135,9
cmp [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE
je .response_timeout
 
push esi ecx
push esi edi ecx
call ARP_del_entry
pop ecx esi
pop ecx edi esi
 
jmp .next
 
146,6 → 148,9
jmp .next
 
.exit:
inc edi
cmp edi, NET_DEVICES_MAX
jb .loop_outer
 
}
 
196,11 → 201,13
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_input: It's a reply\n"
 
mov ecx, [NumARP]
mov ecx, [ARP_entries_num + 4*edi]
test ecx, ecx
jz .exit
 
mov esi, ARP_table
mov esi, (ARP_TABLE_SIZE * sizeof.ARP_entry)
imul esi, edi
add esi, ARP_table
.loop:
cmp [esi + ARP_entry.IP], eax
je .gotit
298,23 → 305,20
;
; ARP_output_request
;
; IN: ip in eax
; device in edi
; IN: ebx = device ptr
; eax = IP
; OUT: /
; scratched: probably everything
;
;---------------------------------------------------------------------------
align 4
ARP_output_request:
 
push eax ; DestIP
pushd [IP_LIST + edi] ; SenderIP
inc [ARP_PACKETS_TX + edi] ; assume we will succeed
push eax
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u\n",\
[esp + 4]:1, [esp + 5]:1, [esp + 6]:1, [esp + 7]:1
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u device=0x%x\n",\
[esp]:1, [esp + 1]:1, [esp + 2]:1, [esp + 3]:1, ebx
 
mov ebx, [NET_DRV_LIST + edi] ; device ptr
 
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac
mov edx, ETH_BROADCAST ; broadcast mac
mov ecx, sizeof.ARP_header
322,8 → 326,6
call ETH_output
jz .exit
 
mov ecx, eax
 
mov [edi + ARP_header.HardwareType], 0x0100 ; Ethernet
mov [edi + ARP_header.ProtocolType], 0x0008 ; IP
mov [edi + ARP_header.HardwareSize], 6 ; MAC-addr length
331,29 → 333,29
mov [edi + ARP_header.Opcode], ARP_REQ_OPCODE ; Request
 
add edi, ARP_header.SenderMAC
 
lea esi, [ebx + ETH_DEVICE.mac] ; SenderMac
movsw ;
movsd ;
pop eax ; SenderIP
stosd ;
 
mov eax, -1 ; DestMac
stosd ;
stosw ;
pop eax ; DestIP
stosd ;
; mov esi, [ebx + NET_DEVICE.number]
xor esi, esi ;;;; FIXME
inc esi ;;;;;;;;;
inc [ARP_PACKETS_TX + 4*esi] ; assume we will succeed
lea esi, [IP_LIST + 4*esi] ; SenderIP
movsd
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: device=%x\n", ebx
mov esi, ETH_BROADCAST ; DestMac
movsw ;
movsd ;
popd [edi] ; DestIP
 
push edx ecx
push edx eax
call [ebx + NET_DEVICE.transmit]
ret
 
.exit:
add esp, 4 + 4
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: failed\n"
sub eax, eax
add esp, 4
DEBUGF DEBUG_NETWORK_ERROR, "ARP_output_request: send failed\n"
ret
 
 
362,50 → 364,65
; ARP_add_entry (or update)
;
; IN: esi = ptr to entry (can easily be made on the stack)
; edi = device num
; OUT: eax = entry #, -1 on error
; edi = ptr to newly created entry
; esi = ptr to newly created entry
;
;----------------------------------------------------------------- ; TODO: use a mutex
align 4
ARP_add_entry:
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: "
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: device=%u\n", edi
 
mov ecx, [NumARP]
mov ecx, [ARP_entries_num + 4*edi]
cmp ecx, ARP_TABLE_SIZE ; list full ?
jae .error
jae .full
 
xor eax, eax
mov edi, ARP_table
mov ecx, [esi + ARP_entry.IP]
 
; From this point on, we can only fail if IP has a static entry, or if table is corrupt.
 
inc [ARP_entries_num + 4*edi] ; assume we will succeed
 
push edi
xor ecx, ecx
imul edi, ARP_TABLE_SIZE*sizeof.ARP_entry
add edi, ARP_table
mov eax, [edi + ARP_entry.IP]
.loop:
cmp [edi + ARP_entry.Status], ARP_NO_ENTRY ; is this slot empty?
je .add
 
cmp [edi + ARP_entry.IP], ecx ; if not, check if it doesnt collide
cmp [edi + ARP_entry.IP], eax ; if not, check if it doesnt collide
jne .maybe_next
 
cmp [edi + ARP_entry.TTL], ARP_STATIC_ENTRY ; ok, its the same IP, update it if not static
jne .add
 
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry: failed, IP already has a static entry\n"
jmp .error
 
.maybe_next: ; try the next slot
add edi, sizeof.ARP_entry
inc eax
cmp eax, ARP_TABLE_SIZE
jae .error
jmp .loop
inc ecx
cmp ecx, ARP_TABLE_SIZE
jb .loop
 
.add:
push ecx
mov ecx, sizeof.ARP_entry/2
rep movsw
inc [NumARP]
sub edi, sizeof.ARP_entry
DEBUGF DEBUG_NETWORK_VERBOSE, "entry=%u\n", eax
pop ecx
lea esi, [edi - sizeof.ARP_entry]
pop edi
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_add_entry: entry=%u\n", ecx
 
ret
 
.error:
DEBUGF DEBUG_NETWORK_VERBOSE, "failed\n"
pop edi
dec [ARP_entries_num + 4*edi]
DEBUGF DEBUG_NETWORK_ERROR, "ARP_add_entry_failed\n"
.full:
mov eax, -1
ret
 
415,6 → 432,7
; ARP_del_entry
;
; IN: esi = ptr to arp entry
; edi = device number
; OUT: /
;
;-----------------------------------------------------------------
421,23 → 439,28
align 4
ARP_del_entry:
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [NumARP]
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: entry=%x entrys=%u\n", esi, [ARP_entries_num + 4*edi]
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: IP=%u.%u.%u.%u\n", \
[esi + ARP_entry.IP]:1, [esi + ARP_entry.IP + 1]:1, [esi + ARP_entry.IP + 2]:1, [esi + ARP_entry.IP + 3]:1
 
mov ecx, ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry
push edi
imul edi, (ARP_TABLE_SIZE) * sizeof.ARP_entry
lea ecx, [ARP_table + (ARP_TABLE_SIZE - 1) * sizeof.ARP_entry + edi]
sub ecx, esi
shr ecx, 1
 
; move all trailing entries, sizeof.ARP_entry bytes to left.
mov edi, esi
add esi, sizeof.ARP_entry
rep movsw
 
; now add an empty entry to the end (erasing previous one)
xor eax, eax
mov ecx, sizeof.ARP_entry/2
rep stosw
 
dec [NumARP]
pop edi
dec [ARP_entries_num + 4*edi]
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_del_entry: success\n"
 
ret
465,7 → 488,7
 
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: %u.%u", al, ah
rol eax, 16
DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u\n", al, ah
DEBUGF DEBUG_NETWORK_VERBOSE, ".%u.%u device: %u\n", al, ah, edi
rol eax, 16
 
cmp eax, 0xffffffff
474,7 → 497,7
;--------------------------------
; Try to find the IP in ARP_table
 
mov ecx, [NumARP]
mov ecx, [ARP_entries_num + 4*edi]
test ecx, ecx
jz .not_in_list
mov esi, ARP_table + ARP_entry.IP
482,17 → 505,14
cmp [esi], eax
je .found_it
add esi, sizeof.ARP_entry
loop .scan_loop
dec ecx
jnz .scan_loop
 
.not_in_list:
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: preparing for ARP request\n"
 
;--------------------
; Send an ARP request
 
push eax edi ; save IP for ARP_output_request
 
; Now create the ARP entry
; Now craft the ARP entry on the stack
pushw ARP_REQUEST_TTL ; TTL
pushw ARP_AWAITING_RESPONSE ; status
pushd 0 ; mac
499,21 → 519,27
pushw 0
pushd eax ; ip
mov esi, esp
 
; Add it to the list
call ARP_add_entry
 
; Delete the temporary entry
add esp, sizeof.ARP_entry ; clear the entry from stack
 
; If we could not add it to the list, give up
cmp eax, -1 ; did ARP_add_entry fail?
je .full
 
mov esi, edi
pop edi eax ; IP in eax, device number in edi, for ARP_output_request
;-----------------------------------------------
; At this point, we got an ARP entry in the list
 
; Now send a request packet on the network
pop edi eax ; IP in eax, device number in ebx, for ARP_output_request
 
push esi edi
call ARP_output_request ; And send a request
mov ebx, [NET_DRV_LIST + 4*edi]
call ARP_output_request
pop edi esi
 
;-----------------------------------------------
; At this point, we got an ARP entry in the list
.found_it:
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
je .valid
522,10 → 548,10
 
cmp [esi + ARP_entry.Status], ARP_AWAITING_RESPONSE ; Are we waiting for reply from remote end?
jne .give_up
push esi
push esi edi
mov esi, 10 ; wait 10 ms
call delay_ms
pop esi
pop edi esi
jmp .found_it ; now check again
 
else
536,8 → 562,8
 
.valid:
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_IP_to_MAC: found MAC\n"
movzx eax, word[esi + ARP_entry.MAC]
mov ebx, dword[esi + ARP_entry.MAC + 2]
movzx eax, word[edi + ARP_entry.MAC]
mov ebx, dword[edi + ARP_entry.MAC + 2]
ret
 
.full:
606,17 → 632,19
ret
 
.entries:
mov eax, [NumARP]
mov eax, [ARP_entries_num + eax]
ret
 
.read:
cmp ecx, [NumARP]
cmp ecx, [ARP_entries_num + eax]
jae .error
shr eax, 2
imul eax, sizeof.ARP_entry*ARP_TABLE_SIZE
add eax, ARP_table
; edi = pointer to buffer
; ecx = # entry
imul ecx, sizeof.ARP_entry
add ecx, ARP_table
mov esi, ecx
lea esi, [eax + ecx]
mov ecx, sizeof.ARP_entry/2
rep movsw
 
625,20 → 653,24
 
.write:
; esi = pointer to buffer
mov edi, eax
shr edi, 2
call ARP_add_entry ; out: eax = entry number, -1 on error
ret
 
.remove:
; ecx = # entry
cmp ecx, [NumARP]
cmp ecx, [ARP_entries_num + eax]
jae .error
imul ecx, sizeof.ARP_entry
lea esi, [ARP_table + ecx]
mov edi, eax
shr edi, 2
call ARP_del_entry
ret
 
.send_announce:
mov edi, eax
mov ebx, [NET_DRV_LIST + eax]
mov eax, [IP_LIST + eax]
call ARP_output_request ; now send a gratuitous ARP
ret
/kernel/trunk/network/IPv4.inc
568,7 → 568,7
align 4
IPv4_output:
 
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u\n", ecx
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_output: size=%u ip=0x%x\n", ecx, eax
 
cmp ecx, 65500 ; Max IPv4 packet size
ja .too_large
585,9 → 585,9
push ebx ; push the mac onto the stack
push ax
 
inc [IP_packets_tx + edi] ; update stats
inc [IP_packets_tx + 4*edi] ; update stats
 
mov ebx, [NET_DRV_LIST + edi]
mov ebx, [NET_DRV_LIST + 4*edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 10 + 6]
675,8 → 675,8
push ebx ; push the mac
push ax
 
inc [IP_packets_tx + edi]
mov ebx, [NET_DRV_LIST + edi]
inc [IP_packets_tx + 4*edi]
mov ebx, [NET_DRV_LIST + 4*edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 6 + 4]
855,7 → 855,7
; IPv4_route
;
; IN: eax = Destination IP
; OUT: edi = device id * 4
; OUT: edi = device number
; eax = ip of gateway if nescessary, unchanged otherwise
;
;---------------------------------------------------------------------------
882,8 → 882,9
jnz .loop
 
.invalid:
xor edi, edi ; if none found, use device 0 as default
mov eax, [GATEWAY_LIST]
xor edi, edi ; if none found, use device 1 as default ;;; FIXME
inc di
mov eax, [GATEWAY_LIST+4]
 
.found_it:
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
890,7 → 891,8
ret
 
.broadcast:
xor edi, edi
xor edi, edi ;;;; FIXME
inc di
ret
 
 
973,7 → 975,8
or ebx, ecx
mov [BROADCAST_LIST + eax], ebx
 
mov eax, ecx
mov ebx, [NET_DRV_LIST + eax]
mov eax, [IP_LIST + eax]
call ARP_output_request ; now send a gratuitous ARP
 
call NET_send_event
/kernel/trunk/network/ethernet.inc
67,10 → 67,10
cmp ax, ETHER_PROTO_IPv4
je IPv4_input
 
cmp ax, ETHER_PROTO_IPv4
cmp ax, ETHER_PROTO_ARP
je ARP_input
 
cmp ax, ETHER_PROTO_IPv4
cmp ax, ETHER_PROTO_IPv6
je IPv6_input
 
cmp ax, ETHER_PROTO_PPP_DISCOVERY
162,7 → 162,7
;
; ETH_API
;
; This function is called by system function 75
; This function is called by system function 76
;
; IN: subfunction number in bl
; device number in bh
187,12 → 187,7
jmp dword [.table + 4*ebx]
 
.table:
dd .packets_tx ; 0
dd .packets_rx ; 1
dd .bytes_tx ; 2
dd .bytes_rx ; 3
dd .read_mac ; 4
dd .state ; 5
dd .read_mac ; 0
.number = ($ - .table) / 4 - 1
 
.error:
199,28 → 194,7
or eax, -1
ret
 
.packets_tx:
mov eax, [eax + NET_DEVICE.packets_tx]
 
ret
 
.packets_rx:
mov eax, [eax + NET_DEVICE.packets_rx]
ret
 
.bytes_tx:
mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
mov eax, dword [eax + NET_DEVICE.bytes_tx]
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
 
.bytes_rx:
mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
mov eax, dword [eax + NET_DEVICE.bytes_rx]
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
 
 
.read_mac:
movzx ebx, word [eax + ETH_DEVICE.mac]
mov eax, dword [eax + ETH_DEVICE.mac + 2]
227,7 → 201,4
mov [esp+20+4], ebx ; TODO: fix this ugly code
ret
 
.state:
mov eax, [eax + NET_DEVICE.link_state]
ret
 
/kernel/trunk/network/icmp.inc
16,7 → 16,6
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 
$Revision: 2924 $
 
; ICMP types & codes
168,9 → 167,6
 
mov esi, [esp] ; Start of buffer
 
cmp dword[edi + 4], 1 shl 24 + 127
je .loopback
 
; Update stats (and validate device ptr)
call NET_ptr_to_num
cmp edi,-1
178,6 → 174,11
inc [ICMP_PACKETS_RX + 4*edi]
inc [ICMP_PACKETS_TX + 4*edi]
 
cmp ebx, LOOPBACK_DEVICE
je .loopback
 
; FIXME: dont assume device is an ethernet device!
 
; exchange dest and source address in IP header
; exchange dest and source MAC in ETH header
push dword [esi + ETH_header.DstMAC]
188,10 → 189,10
push word [esi + ETH_header.SrcMAC + 4]
pop word [esi + ETH_header.DstMAC + 4]
pop word [esi + ETH_header.SrcMAC + 4]
add esi, sizeof.ETH_header-2
add esi, sizeof.ETH_header-4
 
.loopback:
add esi, 2
add esi, 4
push [esi + IPv4_header.SourceAddress]
push [esi + IPv4_header.DestinationAddress]
pop [esi + IPv4_header.SourceAddress]
/kernel/trunk/network/loopback.inc
33,6 → 33,9
.packets_tx dd 0
.packets_rx dd 0
 
.link_state dd -1
.hwacc dd 0
 
.namestr db 'loopback', 0
 
.dummy_fn:
40,6 → 43,23
 
endg
 
 
macro LOOP_init {
local .fail
 
mov ebx, LOOPBACK_DEVICE
call NET_add_device
 
cmp eax, -1
je .fail
 
mov [IP_LIST], 127 + 1 shl 24
mov [SUBNET_LIST], 255
mov [BROADCAST_LIST], 0xffffff00 + 127
 
.fail:
}
 
;-----------------------------------------------------------------
;
; LOOP_input
/kernel/trunk/network/socket.inc
433,11 → 433,10
.tcp:
.udp:
 
mov ebx, [edx + 4] ; First, fill in the IP
cmp ebx, [edx + 4] ; First, fill in the IP
test ebx, ebx ; If IP is 0, use default
jnz @f
mov ebx, [NET_DEFAULT]
mov ebx, [IP_LIST + 4*ebx]
mov ebx, [IP_LIST + 4] ;;;;; FIXME !i!i!i
@@:
mov [eax + IP_SOCKET.LocalIP], ebx
 
484,7 → 483,7
.af_inet4:
cmp [eax + IP_SOCKET.LocalIP], 0
jne @f
push [IP_LIST] ; FIXME
push [IP_LIST + 4] ; FIXME !i!i!i!
pop [eax + IP_SOCKET.LocalIP]
@@:
 
515,6 → 514,8
pushd [edx + 4]
pop [eax + IP_SOCKET.RemoteIP]
 
DEBUGF 1, "Connecting to 0x%x\n", [eax + IP_SOCKET.RemoteIP]
 
cmp [eax + UDP_SOCKET.LocalPort], 0
jne @f
call SOCKET_find_port
633,7 → 634,7
 
cmp [eax + IP_SOCKET.LocalIP], 0
jne @f
push [IP_LIST]
push [IP_LIST + 4] ;;; fixme!!!!
pop [eax + IP_SOCKET.LocalIP]
@@:
 
/kernel/trunk/network/stack.inc
217,7 → 217,6
uglobal
 
NET_RUNNING dd ?
NET_DEFAULT dd ?
NET_DRV_LIST rd NET_DEVICES_MAX
 
endg
254,6 → 253,8
 
SOCKET_init
 
LOOP_init
 
mov [net_tmr_count], 0
 
ret
312,7 → 313,7
align 4
NET_link_changed:
 
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.state]
DEBUGF DEBUG_NETWORK_VERBOSE, "NET_link_changed device=0x%x status=0x%x\n", ebx, [ebx + NET_DEVICE.link_state]
 
align 4
NET_send_event:
398,7 → 399,7
;
; NET_Remove_Device:
;
; This function is called by etwork drivers,
; This function is called by network drivers,
; to unregister network devices from the kernel
;
; IN: Pointer to device structure in ebx
411,28 → 412,12
cmp [NET_RUNNING], 0
je .error
 
cmp [NET_DRV_LIST], ebx
jne @f
mov [NET_DRV_LIST], 0
cmp [NET_RUNNING], 1
je @f
; there are still active devices, find one and make it default
xor eax, eax
mov ecx, NET_DEVICES_MAX
mov edi, NET_DRV_LIST
repe scasd
je @f
shr edi, 2
dec edi
mov [NET_DEFAULT], edi
@@:
 
;----------------------------
; Find the driver in the list
 
mov eax, ebx
mov ecx, NET_DEVICES_MAX
mov edi, NET_DRV_LIST+4
mov edi, NET_DRV_LIST
 
repne scasd
jnz .error
442,10 → 427,11
 
xor eax, eax
mov dword [edi-4], eax
dec [NET_RUNNING]
 
call NET_send_event
 
dec [NET_RUNNING]
xor eax, eax
ret
 
.error:
610,17 → 596,18
 
;----------------------------------------------------------------
;
; System function to work with network devices (75)
; System function to work with network devices (74)
;
;----------------------------------------------------------------
align 4
sys_network: ; FIXME: make default device easily accessible
sys_network:
 
cmp ebx, -1
jne @f
 
mov eax, [NET_RUNNING]
jmp .return
mov [esp+32], eax
ret
 
@@:
cmp bh, NET_DEVICES_MAX ; Check if device number exists
647,16 → 634,20
dd .stop ; 3
dd .get_ptr ; 4
dd .get_drv_name ; 5
 
dd .packets_tx ; 6
dd .packets_rx ; 7
dd .bytes_tx ; 8
dd .bytes_rx ; 9
dd .state ; 10
.number = ($ - .table) / 4 - 1
 
.get_type: ; 0 = Get device type (ethernet/token ring/...)
 
.get_type:
mov eax, [eax + NET_DEVICE.device_type]
jmp .return
mov [esp+32], eax
ret
 
 
.get_dev_name: ; 1 = Get device name
 
.get_dev_name:
mov esi, [eax + NET_DEVICE.name]
mov edi, ecx
 
664,38 → 655,66
rep movsd
 
xor eax, eax
jmp .return
mov [esp+32], eax
ret
 
.reset: ; 2 = Reset the device
 
.reset:
call [eax + NET_DEVICE.reset]
jmp .return
mov [esp+32], eax
ret
 
.stop: ; 3 = Stop driver for this device
 
.stop:
call [eax + NET_DEVICE.unload]
jmp .return
mov [esp+32], eax
ret
 
 
.get_ptr: ; 4 = Get driver pointer
.get_ptr:
mov [esp+32], eax
ret
 
jmp .return
 
.get_drv_name:
xor eax, eax
mov [esp+32], eax
ret
 
.get_drv_name: ; 5 = Get driver name
.packets_tx:
mov eax, [eax + NET_DEVICE.packets_tx]
mov [esp+32], eax
ret
 
xor eax, eax
jmp .return
.packets_rx:
mov eax, [eax + NET_DEVICE.packets_rx]
mov [esp+32], eax
ret
 
.bytes_tx:
mov ebx, dword [eax + NET_DEVICE.bytes_tx + 4]
mov [esp+20], ebx
mov eax, dword [eax + NET_DEVICE.bytes_tx]
mov [esp+32], eax
ret
 
.doesnt_exist:
mov eax, -1
.bytes_rx:
mov ebx, dword [eax + NET_DEVICE.bytes_rx + 4]
mov [esp+20], ebx
mov eax, dword [eax + NET_DEVICE.bytes_rx]
mov [esp+32], eax
ret
 
.return:
.state:
mov eax, [eax + NET_DEVICE.link_state]
mov [esp+32], eax
ret
 
 
.doesnt_exist:
mov dword[esp+32], -1
ret
 
 
 
;----------------------------------------------------------------
;
; System function to work with protocols (76)