forked from KolibriOS/kolibrios
Improved loopback device, separate ARP tables for every interface, added arpstat functionality to netstat, preparing zeroconf to work on multiple interfaces, improved API (fn 76, fn 74), fixed some bugs.
git-svn-id: svn://kolibrios.org@3601 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
c2bc66096c
commit
c0fe9dddf7
@ -187,7 +187,6 @@ FASM_PROGRAMS:=\
|
||||
media/midamp:MEDIA/MIDAMP:$(PROGS)/media/midamp/trunk/midamp.asm \
|
||||
media/palitra:MEDIA/PALITRA:$(PROGS)/media/palitra/trunk/palitra.asm \
|
||||
media/startmus:MEDIA/STARTMUS:$(PROGS)/media/startmus/trunk/STARTMUS.ASM \
|
||||
network/arpcfg:NETWORK/ARPCFG:$(PROGS)/network/arpcfg/arpcfg.asm \
|
||||
network/ping:NETWORK/PING:$(PROGS)/network/icmp/ping.asm \
|
||||
network/netcfg:NETWORK/NETCFG:$(PROGS)/network/netcfg/netcfg.asm \
|
||||
network/netstat:NETWORK/NETSTAT:$(PROGS)/network/netstat/netstat.asm \
|
||||
|
@ -131,7 +131,6 @@ Clients > /@17
|
||||
Zero-Config /sys/network/zeroconf
|
||||
Network Config /sys/network/netcfg
|
||||
Network status /sys/network/netstat
|
||||
ARP status /sys/network/arpcfg
|
||||
#16 **** SERVERS ****
|
||||
FTP daemon /sys/network/ftpd
|
||||
#17 **** CLIENTS ****
|
||||
|
@ -187,7 +187,6 @@ FASM_PROGRAMS:=\
|
||||
media/midamp:MEDIA/MIDAMP:$(PROGS)/media/midamp/trunk/midamp.asm \
|
||||
media/palitra:MEDIA/PALITRA:$(PROGS)/media/palitra/trunk/palitra.asm \
|
||||
media/startmus:MEDIA/STARTMUS:$(PROGS)/media/startmus/trunk/STARTMUS.ASM \
|
||||
network/arpcfg:NETWORK/ARPCFG:$(PROGS)/network/arpcfg/arpcfg.asm \
|
||||
network/ping:NETWORK/PING:$(PROGS)/network/icmp/ping.asm \
|
||||
network/netcfg:NETWORK/NETCFG:$(PROGS)/network/netcfg/netcfg.asm \
|
||||
network/netstat:NETWORK/NETSTAT:$(PROGS)/network/netstat/netstat.asm \
|
||||
|
@ -130,7 +130,6 @@ Clients > /@17
|
||||
Zero-Config /sys/network/zeroconf
|
||||
Network Config /sys/network/netcfg
|
||||
Network status /sys/network/netstat
|
||||
ARP status /sys/network/arpcfg
|
||||
#16 **** SERVERS ****
|
||||
FTP daemon /sys/network/ftpd
|
||||
#17 **** CLIENTS ****
|
||||
|
@ -187,7 +187,6 @@ FASM_PROGRAMS:=\
|
||||
media/midamp:MEDIA/MIDAMP:$(PROGS)/media/midamp/trunk/midamp.asm \
|
||||
media/palitra:MEDIA/PALITRA:$(PROGS)/media/palitra/trunk/palitra.asm \
|
||||
media/startmus:MEDIA/STARTMUS:$(PROGS)/media/startmus/trunk/STARTMUS.ASM \
|
||||
network/arpcfg:NETWORK/ARPCFG:$(PROGS)/network/arpcfg/arpcfg.asm \
|
||||
network/ping:NETWORK/PING:$(PROGS)/network/icmp/ping.asm \
|
||||
network/netcfg:NETWORK/NETCFG:$(PROGS)/network/netcfg/netcfg.asm \
|
||||
network/netstat:NETWORK/NETSTAT:$(PROGS)/network/netstat/netstat.asm \
|
||||
|
@ -136,7 +136,6 @@ HEX-।
|
||||
Zero-Config /sys/network/zeroconf
|
||||
Network Config /sys/network/netcfg
|
||||
Network status /sys/network/netstat
|
||||
ARP status /sys/network/arpcfg
|
||||
#16 **** SERVERS ****
|
||||
FTP daemon /sys/network/ftpd
|
||||
#17 **** CLIENTS ****
|
||||
|
@ -187,7 +187,6 @@ FASM_PROGRAMS:=\
|
||||
media/midamp:MEDIA/MIDAMP:$(PROGS)/media/midamp/trunk/midamp.asm \
|
||||
media/palitra:MEDIA/PALITRA:$(PROGS)/media/palitra/trunk/palitra.asm \
|
||||
media/startmus:MEDIA/STARTMUS:$(PROGS)/media/startmus/trunk/STARTMUS.ASM \
|
||||
network/arpcfg:NETWORK/ARPCFG:$(PROGS)/network/arpcfg/arpcfg.asm \
|
||||
network/ping:NETWORK/PING:$(PROGS)/network/icmp/ping.asm \
|
||||
network/netcfg:NETWORK/NETCFG:$(PROGS)/network/netcfg/netcfg.asm \
|
||||
network/netstat:NETWORK/NETSTAT:$(PROGS)/network/netstat/netstat.asm \
|
||||
|
@ -131,7 +131,6 @@ Clientes > /@17
|
||||
Zero-Config /sys/network/zeroconf
|
||||
Network Config /sys/network/netcfg
|
||||
Network status /sys/network/netstat
|
||||
ARP status /sys/network/arpcfg
|
||||
#16 **** SERVIDORES ****
|
||||
FTP daemon /sys/network/ftpd
|
||||
#17 **** CLIENTES ****
|
||||
|
@ -58,10 +58,10 @@ ends
|
||||
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 @@ endg
|
||||
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 @@ local .exit
|
||||
; 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 @@ local .exit
|
||||
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 @@ local .exit
|
||||
jmp .next
|
||||
|
||||
.exit:
|
||||
inc edi
|
||||
cmp edi, NET_DEVICES_MAX
|
||||
jb .loop_outer
|
||||
|
||||
}
|
||||
|
||||
@ -196,11 +201,13 @@ ARP_input:
|
||||
|
||||
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,22 +305,19 @@ ARP_input:
|
||||
;
|
||||
; 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
|
||||
|
||||
mov ebx, [NET_DRV_LIST + edi] ; device ptr
|
||||
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
|
||||
|
||||
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac
|
||||
mov edx, ETH_BROADCAST ; broadcast mac
|
||||
@ -322,8 +326,6 @@ ARP_output_request:
|
||||
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 @@ ARP_output_request:
|
||||
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_output_request:
|
||||
; 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,29 +432,35 @@ ARP_add_entry:
|
||||
; ARP_del_entry
|
||||
;
|
||||
; IN: esi = ptr to arp entry
|
||||
; edi = device number
|
||||
; OUT: /
|
||||
;
|
||||
;-----------------------------------------------------------------
|
||||
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 @@ ARP_IP_to_MAC:
|
||||
|
||||
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 @@ ARP_IP_to_MAC:
|
||||
;--------------------------------
|
||||
; 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,38 +505,41 @@ ARP_IP_to_MAC:
|
||||
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
|
||||
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
|
||||
|
||||
push esi edi
|
||||
call ARP_output_request ; And send a request
|
||||
pop edi esi
|
||||
|
||||
;-----------------------------------------------
|
||||
; 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
|
||||
mov ebx, [NET_DRV_LIST + 4*edi]
|
||||
call ARP_output_request
|
||||
pop edi esi
|
||||
.found_it:
|
||||
cmp [esi + ARP_entry.Status], ARP_VALID_MAPPING ; Does it have a MAC assigned?
|
||||
je .valid
|
||||
@ -522,10 +548,10 @@ if ARP_BLOCK
|
||||
|
||||
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 @@ end if
|
||||
|
||||
.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 @@ ARP_api:
|
||||
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 @@ ARP_api:
|
||||
|
||||
.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
|
||||
|
@ -568,7 +568,7 @@ IPv4_find_fragment_slot:
|
||||
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 @@ IPv4_output:
|
||||
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 @@ IPv4_output_raw:
|
||||
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_fragment:
|
||||
; IPv4_route
|
||||
;
|
||||
; IN: eax = Destination IP
|
||||
; OUT: edi = device id * 4
|
||||
; OUT: edi = device number
|
||||
; eax = ip of gateway if nescessary, unchanged otherwise
|
||||
;
|
||||
;---------------------------------------------------------------------------
|
||||
@ -882,15 +882,17 @@ IPv4_route:
|
||||
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
|
||||
ret
|
||||
|
||||
.broadcast:
|
||||
xor edi, edi
|
||||
xor edi, edi ;;;; FIXME
|
||||
inc di
|
||||
ret
|
||||
|
||||
|
||||
@ -973,7 +975,8 @@ IPv4_api:
|
||||
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
|
||||
|
@ -67,10 +67,10 @@ ETH_input:
|
||||
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_output:
|
||||
;
|
||||
; 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,39 +187,13 @@ ETH_api:
|
||||
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:
|
||||
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]
|
||||
@ -227,7 +201,4 @@ ETH_api:
|
||||
mov [esp+20+4], ebx ; TODO: fix this ugly code
|
||||
ret
|
||||
|
||||
.state:
|
||||
mov eax, [eax + NET_DEVICE.link_state]
|
||||
ret
|
||||
|
||||
|
@ -16,7 +16,6 @@
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
|
||||
$Revision: 2924 $
|
||||
|
||||
; ICMP types & codes
|
||||
@ -168,16 +167,18 @@ ICMP_input:
|
||||
|
||||
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
|
||||
cmp edi, -1
|
||||
je .dump
|
||||
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 @@ ICMP_input:
|
||||
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]
|
||||
|
@ -33,6 +33,9 @@ LOOPBACK_DEVICE:
|
||||
.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 @@ LOOPBACK_DEVICE:
|
||||
|
||||
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
|
||||
|
@ -433,11 +433,10 @@ SOCKET_bind:
|
||||
.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 @@ SOCKET_connect:
|
||||
.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 @@ align 4
|
||||
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 @@ SOCKET_listen:
|
||||
|
||||
cmp [eax + IP_SOCKET.LocalIP], 0
|
||||
jne @f
|
||||
push [IP_LIST]
|
||||
push [IP_LIST + 4] ;;; fixme!!!!
|
||||
pop [eax + IP_SOCKET.LocalIP]
|
||||
@@:
|
||||
|
||||
|
@ -217,7 +217,6 @@ align 4
|
||||
uglobal
|
||||
|
||||
NET_RUNNING dd ?
|
||||
NET_DEFAULT dd ?
|
||||
NET_DRV_LIST rd NET_DEVICES_MAX
|
||||
|
||||
endg
|
||||
@ -254,6 +253,8 @@ stack_init:
|
||||
|
||||
SOCKET_init
|
||||
|
||||
LOOP_init
|
||||
|
||||
mov [net_tmr_count], 0
|
||||
|
||||
ret
|
||||
@ -312,7 +313,7 @@ stack_handler:
|
||||
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_add_device:
|
||||
;
|
||||
; 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 @@ NET_remove_device:
|
||||
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 @@ NET_remove_device:
|
||||
|
||||
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 @@ checksum_2:
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; 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 @@ sys_network: ; FIXME: make default device easily accessible
|
||||
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
|
||||
|
||||
|
||||
.get_dev_name: ; 1 = Get device name
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
.get_dev_name:
|
||||
mov esi, [eax + NET_DEVICE.name]
|
||||
mov edi, ecx
|
||||
|
||||
@ -664,38 +655,66 @@ sys_network: ; FIXME: make default device easily accessible
|
||||
rep movsd
|
||||
|
||||
xor eax, eax
|
||||
jmp .return
|
||||
|
||||
.reset: ; 2 = Reset the device
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
.reset:
|
||||
call [eax + NET_DEVICE.reset]
|
||||
jmp .return
|
||||
|
||||
.stop: ; 3 = Stop driver for this device
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
.stop:
|
||||
call [eax + NET_DEVICE.unload]
|
||||
jmp .return
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
|
||||
.get_ptr: ; 4 = Get driver pointer
|
||||
|
||||
jmp .return
|
||||
.get_ptr:
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
|
||||
.get_drv_name: ; 5 = Get driver name
|
||||
|
||||
.get_drv_name:
|
||||
xor eax, eax
|
||||
jmp .return
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
.packets_tx:
|
||||
mov eax, [eax + NET_DEVICE.packets_tx]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
.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
|
||||
|
||||
.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
|
||||
|
||||
.state:
|
||||
mov eax, [eax + NET_DEVICE.link_state]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
|
||||
|
||||
.doesnt_exist:
|
||||
mov eax, -1
|
||||
|
||||
.return:
|
||||
mov [esp+32], eax
|
||||
mov dword[esp+32], -1
|
||||
ret
|
||||
|
||||
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;
|
||||
; System function to work with protocols (76)
|
||||
|
@ -675,7 +675,7 @@ lock xadd [DNSrequestID], eax ; atomically increment ID, get old value
|
||||
mov eax, 0x01000100
|
||||
stosd
|
||||
; 7. Get DNS server address.
|
||||
mcall 76, API_IPv4 + 4 ; protocol IP=0, device number=0, function=get DNS address
|
||||
mcall 76, API_IPv4 + (1 shl 8) + 4 ; protocol IP=0, device number=0, function=get DNS address
|
||||
cmp eax, -1
|
||||
je .ret.dnserr
|
||||
mov esi, eax ; put server address to esi
|
||||
|
@ -1,156 +0,0 @@
|
||||
;
|
||||
; ARPmanager for KolibriOS
|
||||
;
|
||||
; hidnplayr@gmail.com
|
||||
;
|
||||
|
||||
format binary as ""
|
||||
|
||||
use32
|
||||
|
||||
org 0x0
|
||||
|
||||
db 'MENUET01' ; 8 byte id
|
||||
dd 0x01 ; header version
|
||||
dd START ; start of code
|
||||
dd IM_END ; size of image
|
||||
dd (I_END+0x100) ; memory for app
|
||||
dd (I_END+0x100) ; esp
|
||||
dd 0x0 , 0x0 ; I_Param , I_Icon
|
||||
|
||||
include '../macros.inc'
|
||||
purge mov, add, sub
|
||||
include '../struct.inc'
|
||||
include '../network.inc'
|
||||
|
||||
START:
|
||||
|
||||
redraw:
|
||||
|
||||
mcall 12, 1
|
||||
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, , str_name
|
||||
mcall 4, 25 shl 16 + 31, 0x80000000, str_legend
|
||||
mcall 12, 2
|
||||
|
||||
draw_stats:
|
||||
|
||||
mov edx, 50 shl 16 + 50
|
||||
mov [last], 0
|
||||
|
||||
.loop:
|
||||
mcall 76, API_ARP + 3, [last],,, arp_buf
|
||||
cmp eax, -1
|
||||
je mainloop
|
||||
|
||||
mcall 4, edx, 0x80000000, str_entry
|
||||
mov edx, ebx
|
||||
|
||||
mov eax, 47
|
||||
mov ebx, 0x00030000
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
xor ecx, ecx
|
||||
|
||||
mov cl, byte[arp_buf.IP+0]
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+1]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+2]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+3]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
|
||||
mov ebx, 0x00020100
|
||||
mov cl, byte[arp_buf.MAC+0]
|
||||
add edx, 36 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+1]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+2]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+3]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+4]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+5]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov ebx, 0x00040000
|
||||
mov cx, [arp_buf.status]
|
||||
add edx, 30 shl 16
|
||||
mcall
|
||||
|
||||
mov cx, [arp_buf.TTL]
|
||||
add edx, 60 shl 16
|
||||
mcall
|
||||
|
||||
add dx, 20
|
||||
rol edx, 16
|
||||
mov dx, 50
|
||||
rol edx, 16
|
||||
inc [last]
|
||||
|
||||
jmp .loop
|
||||
|
||||
|
||||
mainloop:
|
||||
|
||||
mcall 23,50 ; wait for event with timeout (0,5 s)
|
||||
|
||||
cmp eax, 1
|
||||
je redraw
|
||||
cmp eax, 2
|
||||
je key
|
||||
cmp eax, 3
|
||||
je button
|
||||
|
||||
jmp draw_stats
|
||||
|
||||
|
||||
key:
|
||||
mcall 2
|
||||
jmp mainloop
|
||||
|
||||
|
||||
button: ; button
|
||||
mcall 17 ; get id
|
||||
cmp ah, 1
|
||||
je exit
|
||||
jmp redraw
|
||||
|
||||
exit:
|
||||
mcall -1
|
||||
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
str_name db 'ARP manager', 0
|
||||
str_legend db '# IP-address MAC-address Status TTL', 0
|
||||
str_entry db ' . . . - - - - - s', 0
|
||||
|
||||
IM_END:
|
||||
|
||||
last dd ?
|
||||
arp_buf ARP_entry
|
||||
|
||||
I_END:
|
||||
|
||||
|
@ -22,9 +22,9 @@ use32
|
||||
dd 0x01 ; header version
|
||||
dd START ; start of code
|
||||
dd I_END ; size of image
|
||||
dd (I_END+0x100) ; memory for app
|
||||
dd (I_END+0x100) ; esp
|
||||
dd I_PARAM , 0x0 ; I_Param , I_Icon
|
||||
dd (I_END+0x1000) ; memory for app
|
||||
dd (I_END+0x1000) ; esp
|
||||
dd 0, 0 ; I_Param , I_Path
|
||||
|
||||
include '..\macros.inc'
|
||||
include '..\network.inc'
|
||||
@ -38,17 +38,21 @@ redraw:
|
||||
|
||||
call draw_interfaces
|
||||
|
||||
xor ebx, ebx
|
||||
mov bh, [device]
|
||||
mcall 74
|
||||
mov [device_type], eax
|
||||
|
||||
mov edx, 101
|
||||
mov esi, 0x00aaaaff
|
||||
mov edi, 0x00aaffff
|
||||
|
||||
cmp dl, [mode]
|
||||
cmove esi, edi
|
||||
mcall 8, 25 shl 16 + 65, 25 shl 16 + 20
|
||||
|
||||
mcall 8, 5 shl 16 + 55, 5 shl 16 + 20
|
||||
.morebuttons:
|
||||
inc edx
|
||||
add ebx, 75 shl 16
|
||||
add ebx, 60 shl 16
|
||||
mov esi, 0x00aaaaff
|
||||
|
||||
cmp dl, [mode]
|
||||
@ -58,12 +62,12 @@ redraw:
|
||||
cmp edx, 105
|
||||
jle .morebuttons
|
||||
|
||||
mcall 4, 28 shl 16 + 31, 0x80000000, modes
|
||||
mcall 4, 8 shl 16 + 11, 0x80000000, modes
|
||||
|
||||
cmp [mode], 101
|
||||
jne .no_eth
|
||||
|
||||
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
|
||||
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
|
||||
add ebx, 18
|
||||
mov edx, str_packets_rx
|
||||
mcall
|
||||
@ -74,19 +78,23 @@ redraw:
|
||||
mov edx, str_bytes_rx
|
||||
mcall
|
||||
add ebx, 18
|
||||
mov edx, str_MAC
|
||||
mcall
|
||||
add ebx, 18
|
||||
mov edx, str_link
|
||||
mcall
|
||||
|
||||
mov ebx, API_ETH + 4
|
||||
cmp [device_type], 1
|
||||
jne end_of_draw
|
||||
|
||||
add ebx, 18
|
||||
mov edx, str_MAC
|
||||
mcall
|
||||
|
||||
mov ebx, API_ETH
|
||||
mov bh, [device]
|
||||
mcall 76
|
||||
push eax
|
||||
push bx
|
||||
|
||||
mov edx, 135 shl 16 + 75 + 4*18
|
||||
mov edx, 135 shl 16 + 35 + 5*18
|
||||
call draw_mac
|
||||
jmp end_of_draw
|
||||
|
||||
@ -95,7 +103,7 @@ redraw:
|
||||
cmp [mode], 102
|
||||
jne .no_ip
|
||||
|
||||
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
|
||||
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
|
||||
add ebx, 18
|
||||
mov edx, str_packets_rx
|
||||
mcall
|
||||
@ -133,7 +141,7 @@ redraw:
|
||||
mcall 76
|
||||
push eax
|
||||
|
||||
mov edx, 135 shl 16 + 75 + 2*18
|
||||
mov edx, 135 shl 16 + 35 + 2*18
|
||||
call draw_ip
|
||||
|
||||
add edx, 18
|
||||
@ -152,7 +160,7 @@ redraw:
|
||||
cmp [mode], 103
|
||||
jne .no_arp
|
||||
|
||||
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
|
||||
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
|
||||
add ebx, 18
|
||||
mov edx, str_packets_rx
|
||||
mcall
|
||||
@ -163,11 +171,13 @@ redraw:
|
||||
mov edx, str_conflicts
|
||||
mcall
|
||||
|
||||
mcall 4, 8 shl 16 + 130, 0x80000000, str_ARP_legend
|
||||
|
||||
jmp end_of_draw
|
||||
|
||||
.no_arp:
|
||||
|
||||
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
|
||||
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
|
||||
|
||||
add ebx, 18
|
||||
mov edx, str_packets_rx
|
||||
@ -196,26 +206,24 @@ draw_stats:
|
||||
|
||||
mov ebx, API_ETH
|
||||
mov bh, [device]
|
||||
mov bl, 6
|
||||
@@:
|
||||
push ebx
|
||||
mcall 76
|
||||
mcall 74
|
||||
pop ebx
|
||||
push eax
|
||||
inc bl
|
||||
cmp bl, 3
|
||||
cmp bl, 10
|
||||
jbe @r
|
||||
inc bl
|
||||
mcall 76
|
||||
push eax
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 5*18
|
||||
mov edx, 135 shl 16 + 35 + 4*18
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
|
||||
sub edx, 18*2
|
||||
sub edx, 18
|
||||
pop ecx
|
||||
mcall
|
||||
|
||||
@ -255,7 +263,7 @@ not_101:
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 18
|
||||
mov edx, 135 shl 16 + 35 + 18
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
@ -299,7 +307,7 @@ not_102:
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 3*18
|
||||
mov edx, 135 shl 16 + 35 + 3*18
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
@ -316,7 +324,84 @@ not_102:
|
||||
pop ecx
|
||||
mcall
|
||||
|
||||
jmp mainloop
|
||||
|
||||
|
||||
mov edx, 50 shl 16 + 150
|
||||
mov [last], 0
|
||||
|
||||
.arp_loop:
|
||||
mov ebx, API_ARP + 3
|
||||
mov bh, [device]
|
||||
mcall 76, , [last],,, arp_buf
|
||||
cmp eax, -1
|
||||
je mainloop
|
||||
|
||||
mcall 4, 20 shl 16 + 140, 0x80000000, str_ARP_entry
|
||||
mov edx, ebx
|
||||
|
||||
mov eax, 47
|
||||
mov ebx, 0x00030000
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
xor ecx, ecx
|
||||
|
||||
mov cl, byte[arp_buf.IP+0]
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+1]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+2]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.IP+3]
|
||||
add edx, 24 shl 16
|
||||
mcall
|
||||
|
||||
|
||||
mov ebx, 0x00020100
|
||||
mov cl, byte[arp_buf.MAC+0]
|
||||
add edx, 36 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+1]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+2]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+3]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+4]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov cl, byte[arp_buf.MAC+5]
|
||||
add edx, 18 shl 16
|
||||
mcall
|
||||
|
||||
mov ebx, 0x00040000
|
||||
mov cx, [arp_buf.status]
|
||||
add edx, 30 shl 16
|
||||
mcall
|
||||
|
||||
mov cx, [arp_buf.TTL]
|
||||
add edx, 60 shl 16
|
||||
mcall
|
||||
|
||||
add dx, 18
|
||||
rol edx, 16
|
||||
mov dx, 8
|
||||
rol edx, 16
|
||||
inc [last]
|
||||
|
||||
jmp .arp_loop
|
||||
|
||||
not_103:
|
||||
|
||||
@ -338,7 +423,7 @@ not_103:
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 18
|
||||
mov edx, 135 shl 16 + 35 + 18
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
@ -369,7 +454,7 @@ not_104:
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 18
|
||||
mov edx, 135 shl 16 + 35 + 18
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
@ -412,7 +497,7 @@ not_105:
|
||||
|
||||
mov ebx, 0x000a0000
|
||||
pop ecx
|
||||
mov edx, 135 shl 16 + 75 + 18*3
|
||||
mov edx, 135 shl 16 + 35 + 18*3
|
||||
mov esi, 0x40000000
|
||||
mov edi, 0x00bcbcbc
|
||||
mcall 47
|
||||
@ -530,8 +615,8 @@ draw_ip:
|
||||
|
||||
draw_interfaces:
|
||||
|
||||
mov [.btnpos], 8 shl 16 + 20
|
||||
mov [.txtpos], 490 shl 16 + 15
|
||||
mov [.btnpos], 5 shl 16 + 20
|
||||
mov [.txtpos], 455 shl 16 + 12
|
||||
|
||||
mcall 74, -1 ; get number of active network devices
|
||||
mov ecx, eax
|
||||
@ -539,8 +624,8 @@ draw_interfaces:
|
||||
xor ebx, ebx ; get device type
|
||||
.loop:
|
||||
mcall 74
|
||||
cmp eax, 1 ; ethernet?
|
||||
je .hit
|
||||
cmp eax, 1 ; loopback or ethernet?
|
||||
jbe .hit
|
||||
inc bh
|
||||
jb .loop ; tried all 256?
|
||||
ret
|
||||
@ -553,7 +638,7 @@ draw_interfaces:
|
||||
mov esi, 0x00aaaaff
|
||||
cmp bh, [device]
|
||||
cmove esi, 0x00aaffff
|
||||
mcall 8, 485 shl 16 + 100, [.btnpos]
|
||||
mcall 8, 450 shl 16 + 135, [.btnpos]
|
||||
mov ebx, [esp]
|
||||
inc bl
|
||||
mov ecx, namebuf
|
||||
@ -587,7 +672,9 @@ draw_interfaces:
|
||||
name db 'Netstat', 0
|
||||
mode db 101
|
||||
device db 0
|
||||
modes db 'Ethernet IPv4 ARP ICMP UDP TCP', 0
|
||||
device_type dd 0
|
||||
last dd 0
|
||||
modes db 'Physical IPv4 ARP ICMP UDP TCP', 0
|
||||
|
||||
str_packets_tx db 'Packets sent:', 0
|
||||
str_packets_rx db 'Packets received:', 0
|
||||
@ -605,9 +692,11 @@ str_missed db 'Packets missed:',0
|
||||
str_dumped db 'Packets dumped:',0
|
||||
str_link db 'Link state:',0
|
||||
|
||||
namebuf rb 64
|
||||
str_ARP_legend db 'IP-address MAC-address Status TTL', 0
|
||||
str_ARP_entry db ' . . . - - - - - s', 0
|
||||
|
||||
I_PARAM rb 1024
|
||||
namebuf rb 64
|
||||
arp_buf ARP_entry
|
||||
|
||||
I_END:
|
||||
|
||||
|
@ -141,7 +141,9 @@ START:
|
||||
DEBUGF 1,">Zero-config service loaded\n"
|
||||
|
||||
.wait:
|
||||
mcall 76, API_ETH + 4 ; get MAC of ethernet interface 0
|
||||
mov ebx, API_ETH + 0
|
||||
mov bh, [device]
|
||||
mcall 76 ; get MAC of ethernet interface 1
|
||||
cmp eax, -1
|
||||
jne .start
|
||||
|
||||
@ -342,10 +344,15 @@ request:
|
||||
|
||||
call dhcp_end
|
||||
|
||||
mcall 76, API_IPv4 + 3, [dhcp.ip] ; ip
|
||||
mcall 76, API_IPv4 + 5, [dhcp.dns] ; dns
|
||||
mcall 76, API_IPv4 + 7, [dhcp.subnet] ; subnet
|
||||
mcall 76, API_IPv4 + 9, [dhcp.gateway] ; gateway
|
||||
mov ebx, API_IPv4 + 3
|
||||
mov bh, [device]
|
||||
mcall 76, , [dhcp.ip] ; ip
|
||||
mov bl, 5
|
||||
mcall 76, , [dhcp.dns] ; dns
|
||||
mov bl, 7
|
||||
mcall 76, , [dhcp.subnet] ; subnet
|
||||
mov bl, 9
|
||||
mcall 76, , [dhcp.gateway] ; gateway
|
||||
|
||||
jmp exit
|
||||
|
||||
@ -479,11 +486,16 @@ link_local:
|
||||
mov cx, ax
|
||||
shl ecx, 16
|
||||
mov cx, 0xfea9 ; IP 169.254.0.0 link local net, see RFC3927
|
||||
mcall 76, API_IPv4 + 3, ecx ; mask is 255.255.0.0
|
||||
mov ebx, API_IPv4 + 3
|
||||
mov bh, [device]
|
||||
mcall 76, , ecx ; mask is 255.255.0.0
|
||||
DEBUGF 1,"Link Local IP assinged: 169.254.%u.%u\n", [generator+0]:1, [generator+1]:1
|
||||
mcall 76, API_IPv4 + 7, 0xffff
|
||||
mcall 76, API_IPv4 + 9, 0x0
|
||||
mcall 76, API_IPv4 + 5, 0x0
|
||||
mov bl, 7
|
||||
mcall 76, , 0xffff
|
||||
mov bl, 9
|
||||
mcall 76, , 0x0
|
||||
mov bl, 5
|
||||
mcall 76, , 0x0
|
||||
|
||||
mcall 5, PROBE_WAIT*100
|
||||
|
||||
@ -506,7 +518,9 @@ link_local:
|
||||
mcall 5
|
||||
|
||||
DEBUGF 1,"Sending Probe\n"
|
||||
mcall 76, API_ARP + 6
|
||||
mov ebx, API_ARP + 6
|
||||
mov bh, [device]
|
||||
mcall 76
|
||||
inc esi
|
||||
|
||||
cmp esi, PROBE_NUM
|
||||
@ -521,7 +535,9 @@ link_local:
|
||||
announce_loop:
|
||||
|
||||
DEBUGF 1,"Sending Announce\n"
|
||||
mcall 76, API_ARP + 6
|
||||
mov ebx, API_ARP + 6
|
||||
mov bh, [device]
|
||||
mcall 76
|
||||
|
||||
inc esi
|
||||
cmp esi,ANNOUNCE_NUM
|
||||
@ -594,6 +610,7 @@ path db '/sys/network.ini'
|
||||
|
||||
IM_END:
|
||||
|
||||
device db 1
|
||||
inibuf rb 16
|
||||
|
||||
dhcpMsgType db ?
|
||||
|
Loading…
Reference in New Issue
Block a user