Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3601 → Rev 3600

/programs/network/netstat/netstat.asm
22,9 → 22,9
dd 0x01 ; header version
dd START ; start of code
dd I_END ; size of image
dd (I_END+0x1000) ; memory for app
dd (I_END+0x1000) ; esp
dd 0, 0 ; I_Param , I_Path
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
 
include '..\macros.inc'
include '..\network.inc'
38,11 → 38,6
 
call draw_interfaces
 
xor ebx, ebx
mov bh, [device]
mcall 74
mov [device_type], eax
 
mov edx, 101
mov esi, 0x00aaaaff
mov edi, 0x00aaffff
49,10 → 44,11
 
cmp dl, [mode]
cmove esi, edi
mcall 8, 5 shl 16 + 55, 5 shl 16 + 20
mcall 8, 25 shl 16 + 65, 25 shl 16 + 20
 
.morebuttons:
inc edx
add ebx, 60 shl 16
add ebx, 75 shl 16
mov esi, 0x00aaaaff
 
cmp dl, [mode]
62,12 → 58,12
cmp edx, 105
jle .morebuttons
 
mcall 4, 8 shl 16 + 11, 0x80000000, modes
mcall 4, 28 shl 16 + 31, 0x80000000, modes
 
cmp [mode], 101
jne .no_eth
 
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
78,23 → 74,19
mov edx, str_bytes_rx
mcall
add ebx, 18
mov edx, str_link
mov edx, str_MAC
mcall
 
cmp [device_type], 1
jne end_of_draw
 
add ebx, 18
mov edx, str_MAC
mov edx, str_link
mcall
 
mov ebx, API_ETH
mov ebx, API_ETH + 4
mov bh, [device]
mcall 76
push eax
push bx
 
mov edx, 135 shl 16 + 35 + 5*18
mov edx, 135 shl 16 + 75 + 4*18
call draw_mac
jmp end_of_draw
 
103,7 → 95,7
cmp [mode], 102
jne .no_ip
 
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
141,7 → 133,7
mcall 76
push eax
 
mov edx, 135 shl 16 + 35 + 2*18
mov edx, 135 shl 16 + 75 + 2*18
call draw_ip
 
add edx, 18
160,7 → 152,7
cmp [mode], 103
jne .no_arp
 
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
add ebx, 18
mov edx, str_packets_rx
mcall
171,13 → 163,11
mov edx, str_conflicts
mcall
 
mcall 4, 8 shl 16 + 130, 0x80000000, str_ARP_legend
 
jmp end_of_draw
 
.no_arp:
 
mcall 4, 8 shl 16 + 35, 0x80000000, str_packets_tx
mcall 4, 20 shl 16 + 75, 0x80000000, str_packets_tx
 
add ebx, 18
mov edx, str_packets_rx
206,24 → 196,26
 
mov ebx, API_ETH
mov bh, [device]
mov bl, 6
@@:
push ebx
mcall 74
mcall 76
pop ebx
push eax
inc bl
cmp bl, 10
cmp bl, 3
jbe @r
inc bl
mcall 76
push eax
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 4*18
mov edx, 135 shl 16 + 75 + 5*18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
 
sub edx, 18
sub edx, 18*2
pop ecx
mcall
 
263,7 → 255,7
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 18
mov edx, 135 shl 16 + 75 + 18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
307,7 → 299,7
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 3*18
mov edx, 135 shl 16 + 75 + 3*18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
324,85 → 316,8
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:
 
cmp [mode], 104
423,7 → 338,7
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 18
mov edx, 135 shl 16 + 75 + 18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
454,7 → 369,7
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 18
mov edx, 135 shl 16 + 75 + 18
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
497,7 → 412,7
 
mov ebx, 0x000a0000
pop ecx
mov edx, 135 shl 16 + 35 + 18*3
mov edx, 135 shl 16 + 75 + 18*3
mov esi, 0x40000000
mov edi, 0x00bcbcbc
mcall 47
615,8 → 530,8
 
draw_interfaces:
 
mov [.btnpos], 5 shl 16 + 20
mov [.txtpos], 455 shl 16 + 12
mov [.btnpos], 8 shl 16 + 20
mov [.txtpos], 490 shl 16 + 15
 
mcall 74, -1 ; get number of active network devices
mov ecx, eax
624,8 → 539,8
xor ebx, ebx ; get device type
.loop:
mcall 74
cmp eax, 1 ; loopback or ethernet?
jbe .hit
cmp eax, 1 ; ethernet?
je .hit
inc bh
jb .loop ; tried all 256?
ret
638,7 → 553,7
mov esi, 0x00aaaaff
cmp bh, [device]
cmove esi, 0x00aaffff
mcall 8, 450 shl 16 + 135, [.btnpos]
mcall 8, 485 shl 16 + 100, [.btnpos]
mov ebx, [esp]
inc bl
mov ecx, namebuf
672,9 → 587,7
name db 'Netstat', 0
mode db 101
device db 0
device_type dd 0
last dd 0
modes db 'Physical IPv4 ARP ICMP UDP TCP', 0
modes db 'Ethernet IPv4 ARP ICMP UDP TCP', 0
 
str_packets_tx db 'Packets sent:', 0
str_packets_rx db 'Packets received:', 0
692,12 → 605,10
str_dumped db 'Packets dumped:',0
str_link db 'Link state:',0
 
str_ARP_legend db 'IP-address MAC-address Status TTL', 0
str_ARP_entry db ' . . . - - - - - s', 0
 
namebuf rb 64
arp_buf ARP_entry
 
I_PARAM rb 1024
 
I_END: