forked from KolibriOS/kolibrios
netstat now works with all network interfaces instead of default device 0.
git-svn-id: svn://kolibrios.org@2864 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ce6a93da60
commit
042f832f0c
@ -1,11 +1,21 @@
|
||||
;
|
||||
; Netstat for KolibriOS v0.2
|
||||
;
|
||||
; 0.1 - 22 sept 2009 - initial release
|
||||
; 0.2 - 9 july 2012 - converted to new sysfunc numbers
|
||||
;
|
||||
; hidnplayr@gmail.com
|
||||
;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; ;;
|
||||
;; Copyright (C) KolibriOS team 2010-2012. All rights reserved. ;;
|
||||
;; Distributed under terms of the GNU General Public License ;;
|
||||
;; ;;
|
||||
;; netstat.asm - Network Status Tool for KolibriOS ;;
|
||||
;; ;;
|
||||
;; Written by hidnplayr@kolibrios.org ;;
|
||||
;; ;;
|
||||
;; GNU GENERAL PUBLIC LICENSE ;;
|
||||
;; Version 2, June 1991 ;;
|
||||
;; ;;
|
||||
;; ;;
|
||||
;; 0.1 - 22 sept 2009 - initial release ;;
|
||||
;; 0.2 - 9 july 2012 - converted to new sysfunc numbers ;;
|
||||
;; 0.3 - 13 july 2012 - work with multiple network interfaces ;;
|
||||
;; ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
format binary as ""
|
||||
|
||||
@ -21,22 +31,17 @@ use32
|
||||
dd (I_END+0x100) ; esp
|
||||
dd I_PARAM , 0x0 ; I_Param , I_Icon
|
||||
|
||||
__DEBUG__ equ 1
|
||||
__DEBUG_LEVEL__ equ 1
|
||||
|
||||
include '..\macros.inc'
|
||||
include '..\debug-fdo.inc'
|
||||
include '..\network.inc'
|
||||
|
||||
START: ; start of execution
|
||||
; TODO: check Parameters
|
||||
|
||||
DEBUGF 1, 'Netstat application loaded!\n'
|
||||
START:
|
||||
mcall 40, 101b
|
||||
|
||||
redraw:
|
||||
mcall 12, 1
|
||||
mcall 0, 100 shl 16 + 600, 100 shl 16 + 240, 0x34bcbcbc , , name ; draw window
|
||||
|
||||
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc , , name
|
||||
call draw_interfaces
|
||||
|
||||
mov edx, 101
|
||||
mov esi, 0x00aaaaff
|
||||
@ -172,30 +177,11 @@ START: ; start of execution
|
||||
mov edx, str_packets_rx
|
||||
mcall
|
||||
|
||||
|
||||
|
||||
end_of_draw:
|
||||
|
||||
mcall 12, 2
|
||||
|
||||
jmp draw_stats
|
||||
|
||||
mainloop:
|
||||
|
||||
mcall 23,500 ; wait for event with timeout (0,5 s)
|
||||
|
||||
cmp eax, 1
|
||||
je redraw
|
||||
cmp eax, 2
|
||||
je key
|
||||
cmp eax, 3
|
||||
je button
|
||||
|
||||
|
||||
|
||||
|
||||
;-------------------------------
|
||||
;
|
||||
;------------------------------
|
||||
|
||||
draw_stats:
|
||||
|
||||
cmp [mode], 101
|
||||
@ -416,20 +402,31 @@ not_105:
|
||||
|
||||
not_106:
|
||||
|
||||
jmp mainloop
|
||||
mainloop:
|
||||
|
||||
key:
|
||||
mcall 2
|
||||
jmp mainloop
|
||||
mcall 23, 50 ; wait for event with timeout (0,5 s)
|
||||
|
||||
cmp eax, 1
|
||||
je redraw
|
||||
cmp eax, 3
|
||||
je button
|
||||
|
||||
jmp draw_stats
|
||||
|
||||
button: ; button
|
||||
mcall 17 ; get id
|
||||
cmp ah, 1
|
||||
je exit
|
||||
cmp ah, 0
|
||||
je .interface
|
||||
mov [mode], ah
|
||||
jmp redraw
|
||||
|
||||
.interface:
|
||||
shr eax, 16
|
||||
mov [device], al
|
||||
jmp redraw
|
||||
|
||||
exit:
|
||||
mcall -1
|
||||
|
||||
@ -498,6 +495,60 @@ draw_ip:
|
||||
ret 4
|
||||
|
||||
|
||||
draw_interfaces:
|
||||
|
||||
mov [.btnpos], 8 shl 16 + 20
|
||||
mov [.txtpos], 490 shl 16 + 15
|
||||
|
||||
mcall 74, -1 ; get number of active network devices
|
||||
mov ecx, eax
|
||||
|
||||
xor ebx, ebx ; get device type
|
||||
.loop:
|
||||
mcall 74
|
||||
cmp eax, 1 ; ethernet?
|
||||
je .hit
|
||||
inc bh
|
||||
jb .loop ; tried all 256?
|
||||
ret
|
||||
|
||||
|
||||
.hit:
|
||||
push ecx ebx
|
||||
movzx edx, bh
|
||||
shl edx, 8
|
||||
mov esi, 0x00aaaaff
|
||||
cmp bh, [device]
|
||||
cmove esi, 0x00aaffff
|
||||
mcall 8, 485 shl 16 + 100, [.btnpos]
|
||||
mov ebx, [esp]
|
||||
inc bl
|
||||
mov ecx, namebuf
|
||||
mov edx, namebuf
|
||||
mcall 74 ; get device name
|
||||
cmp eax, -1
|
||||
jne @f
|
||||
mov edx, str_unknown
|
||||
@@:
|
||||
mcall 4, [.txtpos], 0x80000000 ; print the name
|
||||
pop ebx ecx
|
||||
|
||||
inc bh
|
||||
|
||||
add [.btnpos], 25 shl 16
|
||||
add [.txtpos], 25
|
||||
|
||||
dec ecx
|
||||
jnz .loop
|
||||
|
||||
ret
|
||||
|
||||
.btnpos dd ?
|
||||
.txtpos dd ?
|
||||
|
||||
|
||||
|
||||
|
||||
; DATA AREA
|
||||
|
||||
name db 'Netstat', 0
|
||||
@ -517,8 +568,9 @@ str_dns db 'DNS address:', 0
|
||||
str_subnet db 'Subnet mask:', 0
|
||||
str_gateway db 'Standard gateway:', 0
|
||||
str_arp db 'ARP entrys:', 0
|
||||
str_unknown db 'unknown', 0
|
||||
|
||||
include_debug_strings ; ALWAYS present in data section
|
||||
namebuf rb 64
|
||||
|
||||
I_PARAM rb 1024
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user