Subversion Repositories Kolibri OS

Rev

Rev 5498 | Rev 6323 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5498 Rev 5586
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2010-2014. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2010-2015. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
6
;;  netstat.asm - Network Status Tool for KolibriOS                ;;
6
;;  netstat.asm - Network Status Tool for KolibriOS                ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;  Written by hidnplayr@kolibrios.org                             ;;
8
;;  Written by hidnplayr@kolibrios.org                             ;;
Line 27... Line 27...
27
        dd     I_END            ; size of image
27
        dd     I_END            ; size of image
28
        dd     (I_END+0x1000)   ; memory for app
28
        dd     (I_END+0x1000)   ; memory for app
29
        dd     (I_END+0x1000)   ; esp
29
        dd     (I_END+0x1000)   ; esp
30
        dd     0, 0             ; I_Param, I_Path
30
        dd     0, 0             ; I_Param, I_Path
Line -... Line 31...
-
 
31
 
31
 
32
include '../../proc32.inc'
-
 
33
include '../../macros.inc'
-
 
34
include '../../dll.inc'
-
 
35
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
32
include '../../macros.inc'
36
 
Line -... Line 37...
-
 
37
include '../../network.inc'
-
 
38
 
33
include '../../network.inc'
39
include 'ipcfg.inc'
-
 
40
 
-
 
41
START:
-
 
42
 
-
 
43
        mcall   68, 11
-
 
44
 
-
 
45
        stdcall dll.Load, @IMPORT
-
 
46
        or      eax, eax
34
 
47
        jnz     exit
Line 35... Line 48...
35
START:
48
 
-
 
49
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK2 + EVM_KEY
-
 
50
 
-
 
51
window_redraw:
-
 
52
 
36
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK2 + EVM_KEY
53
; get system colors
37
 
54
        mcall   48, 3, sc, 40
Line 38... Line 55...
38
window_redraw:
55
 
39
; Notify kernel of start of window draw
56
; Notify kernel of start of window draw
Line 132... Line 149...
132
        mcall
149
        mcall
133
        add     ebx, 18
150
        add     ebx, 18
134
        mov     edx, str_bytes_rx
151
        mov     edx, str_bytes_rx
135
        mcall
152
        mcall
136
        add     ebx, 18
153
        add     ebx, 18
-
 
154
        mov     edx, str_speed_tx
-
 
155
        mcall
-
 
156
        add     ebx, 18
-
 
157
        mov     edx, str_speed_rx
-
 
158
        mcall
-
 
159
        add     ebx, 18
137
        mov     edx, str_link
160
        mov     edx, str_link
138
        mcall
161
        mcall
Line 139... Line 162...
139
 
162
 
140
        cmp     [device_type], 1
163
        cmp     [device_type], 1
Line 148... Line 171...
148
        mov     bh, [device]
171
        mov     bh, [device]
149
        mcall   76
172
        mcall   76
150
        push    eax
173
        push    eax
151
        push    bx
174
        push    bx
Line 152... Line 175...
152
 
175
 
153
        mov     edx, 134 shl 16 + 35 + 5*18
176
        mov     edx, 134 shl 16 + 35 + 7*18
154
        call    draw_mac
177
        call    draw_mac
Line 155... Line 178...
155
        jmp     end_of_draw
178
        jmp     end_of_draw
Line 207... Line 230...
207
        call    draw_ip
230
        call    draw_ip
Line 208... Line 231...
208
 
231
 
209
        add     edx, 18
232
        add     edx, 18
Line -... Line 233...
-
 
233
        call    draw_ip
-
 
234
 
-
 
235
        cmp     [device], 0
-
 
236
        je      end_of_draw
-
 
237
 
-
 
238
        mcall   8, 128 shl 16 + 100, 150 shl 16 + 20, 2, [sc.work_button]
210
        call    draw_ip
239
        mcall   4, 150 shl 16 + 157, [sc.work_button_text], str_ip_cfg, str_ip_cfg.len
Line 211... Line 240...
211
 
240
 
Line 212... Line 241...
212
        jmp     end_of_draw
241
        jmp     end_of_draw
Line 273... Line 302...
273
        push    eax
302
        push    eax
274
        inc     bl
303
        inc     bl
275
        cmp     bl, 10
304
        cmp     bl, 10
276
        jbe     @r
305
        jbe     @r
Line 277... Line 306...
277
 
306
 
-
 
307
        pop     ecx
-
 
308
 
-
 
309
        push    [time]
-
 
310
        pop     [delta_time]
-
 
311
        mcall   26, 9
-
 
312
        mov     [time], eax
-
 
313
        sub     eax, [delta_time]
-
 
314
        jnz     @f
-
 
315
        inc     eax             ; Zero time units? Lets make it at least one.
-
 
316
  @@:
-
 
317
        mov     [delta_time], eax
-
 
318
 
-
 
319
        mov     eax, [esp+4]    ; bytes received
-
 
320
        push    eax
-
 
321
        sub     eax, [prev_rx]
-
 
322
        pop     [prev_rx]
-
 
323
        xor     edx, edx
-
 
324
        div     [delta_time]
-
 
325
        push    eax
-
 
326
 
-
 
327
        mov     eax, [esp+4]    ; bytes sent
-
 
328
        push    eax
-
 
329
        sub     eax, [prev_tx]
-
 
330
        pop     [prev_tx]
-
 
331
        xor     edx, edx
-
 
332
        div     [delta_time]
-
 
333
        push    eax
278
        pop     eax
334
 
279
        test    al, al
335
        test    cl, cl
280
        jnz     @f
336
        jnz     @f
281
        mov     edx, str_down
337
        mov     edx, str_down
282
        jmp     .print_link
338
        jmp     .print_link
283
  @@:
339
  @@:
284
        cmp     al, 100b
340
        cmp     cl, 100b
285
        jnz     @f
341
        jnz     @f
286
        mov     edx, str_10m
342
        mov     edx, str_10m
287
        jmp     .print_link
343
        jmp     .print_link
288
  @@:
344
  @@:
289
        cmp     al, 110b
345
        cmp     cl, 110b
290
        jnz     @f
346
        jnz     @f
291
        mov     edx, str_10mfd
347
        mov     edx, str_10mfd
292
        jmp     .print_link
348
        jmp     .print_link
293
  @@:
349
  @@:
294
        cmp     al, 1000b
350
        cmp     cl, 1000b
295
        jnz     @f
351
        jnz     @f
296
        mov     edx, str_100m
352
        mov     edx, str_100m
297
        jmp     .print_link
353
        jmp     .print_link
298
  @@:
354
  @@:
299
        cmp     al, 1010b
355
        cmp     cl, 1010b
300
        jnz     @f
356
        jnz     @f
301
        mov     edx, str_100mfd
357
        mov     edx, str_100mfd
302
        jmp     .print_link
358
        jmp     .print_link
303
  @@:
359
  @@:
304
        cmp     al, 1100b
360
        cmp     cl, 1100b
305
        jnz     @f
361
        jnz     @f
306
        mov     edx, str_1g
362
        mov     edx, str_1g
307
        jmp     .print_link
363
        jmp     .print_link
308
  @@:
364
  @@:
309
        cmp     al, 1110b
365
        cmp     cl, 1110b
310
        jnz     @f
366
        jnz     @f
311
        mov     edx, str_1gfd
367
        mov     edx, str_1gfd
312
        jmp     .print_link
368
        jmp     .print_link
313
  @@:
369
  @@:
Line 314... Line 370...
314
        mov     edx, str_unknown
370
        mov     edx, str_unknown
315
 
371
 
316
  .print_link:
372
  .print_link:
317
        mov     ebx, 134 shl 16 + 35 + 4*18
373
        mov     ebx, 134 shl 16 + 35 + 6*18
318
        mov     ecx, 0xc0000000
374
        mov     ecx, 0xc0000000
Line -... Line 375...
-
 
375
        mov     edi, 0x00f3f3f3
319
        mov     edi, 0x00f3f3f3
376
        mcall   4
320
        mcall   4
377
 
321
 
378
; speed tx
322
        mov     ebx, 0x000a0000
379
        mov     ebx, 0x000a0000
323
        pop     ecx
380
        pop     ecx
Line -... Line 381...
-
 
381
        mov     edx, 134 shl 16 + 35 + 5*18
324
        mov     edx, 134 shl 16 + 35 + 3*18
382
        mov     esi, 0x40000000
325
        mov     esi, 0x40000000
383
        mcall   47
326
        mcall   47
384
 
Line -... Line 385...
-
 
385
; speed rx
327
 
386
        sub     edx, 18
328
        sub     edx, 18
387
        pop     ecx
329
        pop     ecx
388
        mcall
Line -... Line 389...
-
 
389
 
-
 
390
; bytes received
-
 
391
        sub     edx, 18
-
 
392
        pop     ecx
-
 
393
        mcall
-
 
394
 
-
 
395
; bytes sent
-
 
396
        sub     edx, 18
-
 
397
        pop     ecx
-
 
398
        mcall
-
 
399
 
330
        mcall
400
; packets received
331
 
401
        sub     edx, 18
332
        sub     edx, 18
402
        pop     ecx
Line 333... Line 403...
333
        pop     ecx
403
        mcall
Line 644... Line 714...
644
 
714
 
645
button:                         ; button
715
button:                         ; button
646
        mcall   17              ; get id
716
        mcall   17              ; get id
647
        cmp     ah, 1
717
        cmp     ah, 1
-
 
718
        je      exit
-
 
719
        cmp     ah, 2
648
        je      exit
720
        je      .ipcfg
649
        cmp     ah, 0
721
        cmp     ah, 0
650
        je      .interface
722
        je      .interface
651
        shr     ax, 8
723
        shr     ax, 8
652
        mov     [mode], ax
724
        mov     [mode], ax
Line -... Line 725...
-
 
725
        jmp     redraw
-
 
726
 
-
 
727
  .ipcfg:
-
 
728
        mcall   51, 1, ipcfg, I_END+0x1000
653
        jmp     redraw
729
        jmp     mainloop
654
 
730
 
655
  .interface:
731
  .interface:
656
        shr     eax, 16
732
        shr     eax, 16
Line 816... Line 892...
816
  .txtpos       dd ?
892
  .txtpos       dd ?
Line 817... Line 893...
817
 
893
 
Line -... Line 894...
-
 
894
 
-
 
895
; DATA AREA
-
 
896
 
-
 
897
align 16
-
 
898
@IMPORT:
-
 
899
 
-
 
900
library box_lib         , 'box_lib.obj', \
-
 
901
        libini          , 'libini.obj'
-
 
902
 
-
 
903
import  libini, \
-
 
904
        ini.get_str     , 'ini_get_str'         ,\
-
 
905
        ini.set_str     , 'ini_set_str'         ,\
-
 
906
        ini.enum_sections, 'ini_enum_sections'
-
 
907
 
-
 
908
import  box_lib                                 ,\
-
 
909
        edit_box_draw   , 'edit_box'            ,\
-
 
910
        edit_box_key    , 'edit_box_key'        ,\
-
 
911
        edit_box_mouse  , 'edit_box_mouse'      ,\
-
 
912
        edit_set_text   , 'edit_box_set_text'   ,\
-
 
913
        version_ed      , 'version_ed'          ,\
-
 
914
        init_checkbox   , 'init_checkbox2'      ,\
-
 
915
        check_box_draw  , 'check_box_draw2'     ,\
-
 
916
        check_box_mouse , 'check_box_mouse2'    ,\
-
 
917
        version_ch      , 'version_ch2'         ,\
-
 
918
        option_box_draw , 'option_box_draw'     ,\
818
 
919
        option_box_mouse, 'option_box_mouse'    ,\
819
; DATA AREA
920
        version_op      , 'version_op'
820
 
921
 
821
name            db 'Network status', 0
922
name            db 'Network status', 0
822
mode            dw 101          ; currently selected protocol
923
mode            dw 101          ; currently selected protocol
Line 839... Line 940...
839
str_conflicts   db 'ARP conflicts:', 0
940
str_conflicts   db 'ARP conflicts:', 0
840
str_missed      db 'Packets missed:',0
941
str_missed      db 'Packets missed:', 0
841
str_dumped      db 'Packets dumped:',0
942
str_dumped      db 'Packets dumped:', 0
842
str_queued      db 'Packets queued:',0
943
str_queued      db 'Packets queued:', 0
843
str_link        db 'Link state:',0
944
str_link        db 'Link state:', 0
-
 
945
str_speed_tx    db 'Upload (kb/s):', 0
-
 
946
str_speed_rx    db 'Download (kb/s):', 0
-
 
947
str_ip_cfg      db 'Configure'
-
 
948
.len = $ - str_ip_cfg
Line 844... Line 949...
844
 
949
 
845
str_down        db 'disconnected        ', 0
950
str_down        db 'disconnected        ', 0
846
str_unknown     db 'unknown             ', 0
951
str_unknown     db 'unknown             ', 0
847
str_10m         db '10 Mbit Half duplex ', 0
952
str_10m         db '10 Mbit Half duplex ', 0
Line 852... Line 957...
852
str_1gfd        db '1 Gbit Full duplex  ', 0
957
str_1gfd        db '1 Gbit Full duplex  ', 0
Line 853... Line 958...
853
 
958
 
854
str_ARP_legend  db 'IP-address        MAC-address         Status    TTL', 0
959
str_ARP_legend  db 'IP-address        MAC-address         Status    TTL', 0
Line -... Line 960...
-
 
960
str_ARP_entry   db '   .   .   .        -  -  -  -  -', 0
-
 
961
 
-
 
962
prev_rx         dd ?
-
 
963
prev_tx         dd ?
-
 
964
time            dd ?
855
str_ARP_entry   db '   .   .   .        -  -  -  -  -', 0
965
delta_time      dd ?
856
 
966
 
Line -... Line 967...
-
 
967
namebuf         rb 64
-
 
968
arp_buf         ARP_entry
857
namebuf         rb 64
969
 
858
arp_buf         ARP_entry
970
sc              system_colors