Subversion Repositories Kolibri OS

Rev

Rev 5586 | Rev 6971 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
6323 hidnplayr 3
;; Copyright (C) KolibriOS team 2010-2016. All rights reserved.    ;;
3545 hidnplayr 4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;  netstat.asm - Network Status Tool for KolibriOS                ;;
7
;;                                                                 ;;
8
;;  Written by hidnplayr@kolibrios.org                             ;;
9
;;                                                                 ;;
10
;;          GNU GENERAL PUBLIC LICENSE                             ;;
11
;;             Version 2, June 1991                                ;;
12
;;                                                                 ;;
13
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14
 
15
format binary as ""
16
 
4798 hidnplayr 17
BOX_WIDTH       = 390
18
BOX_HEIGHT      = 185
19
 
3545 hidnplayr 20
use32
21
 
22
        org    0x0
23
 
3601 hidnplayr 24
        db     'MENUET01'       ; 8 byte id
25
        dd     0x01             ; header version
26
        dd     START            ; start of code
27
        dd     I_END            ; size of image
28
        dd     (I_END+0x1000)   ; memory for app
29
        dd     (I_END+0x1000)   ; esp
4781 hidnplayr 30
        dd     0, 0             ; I_Param, I_Path
3545 hidnplayr 31
 
5586 hidnplayr 32
include '../../proc32.inc'
3618 hidnplayr 33
include '../../macros.inc'
5586 hidnplayr 34
include '../../dll.inc'
35
include '../../develop/libraries/box_lib/trunk/box_lib.mac'
36
 
3618 hidnplayr 37
include '../../network.inc'
3545 hidnplayr 38
 
5586 hidnplayr 39
include 'ipcfg.inc'
40
 
3545 hidnplayr 41
START:
5586 hidnplayr 42
 
43
        mcall   68, 11
44
 
45
        stdcall dll.Load, @IMPORT
46
        or      eax, eax
47
        jnz     exit
48
 
4742 hidnplayr 49
        mcall   40, EVM_REDRAW + EVM_BUTTON + EVM_STACK2 + EVM_KEY
3545 hidnplayr 50
 
4736 leency 51
window_redraw:
5586 hidnplayr 52
 
53
; get system colors
54
        mcall   48, 3, sc, 40
55
 
4781 hidnplayr 56
; Notify kernel of start of window draw
3545 hidnplayr 57
        mcall   12, 1
58
 
4781 hidnplayr 59
; Draw the window
60
        mcall   0, 100 shl 16 + 600, 100 shl 16 + 240, 0x34E1E1E1, , name
61
 
62
; Define the buttons (for tabs)
63
        mov     ebx, 5 shl 16 + 54
64
        mov     ecx, 4 shl 16 + 21
65
        mov     edx, 0x60000000 + 101
66
  .buttonloop:
67
        mcall   8
68
        add     ebx, 60 shl 16
69
        inc     edx
70
        cmp     dl, 106
71
        jle     .buttonloop
72
 
73
; draw sides and upper lines of the tab buttons
74
        mov     eax, 13
75
        mov     ebx, 5 shl 16 + 1
76
        mov     ecx, 4 shl 16 + 21
77
        mov     edx, 0x00777777
78
  .loop:
79
        mcall
80
        mov     bx, 54
81
        mov     cx, 1
82
        mcall
83
        mov     bx, 1
84
        mov     cx, 21
85
        add     ebx, 54 shl 16
86
        mcall
87
        add     ebx, 6 shl 16
88
        cmp     ebx, 360 shl 16
89
        jb      .loop
90
 
91
; Draw sides and bottom lines of the rectangle
4798 hidnplayr 92
        mcall  , 0 shl 16 + 1, 25 shl 16 + BOX_HEIGHT;, 0x00777777
93
        mcall  , (0+BOX_WIDTH) shl 16 +1, 25 shl 16 + (BOX_HEIGHT+1)
94
        mcall  , 0 shl 16 + BOX_WIDTH, (25+BOX_HEIGHT) shl 16 + 1
4781 hidnplayr 95
 
4736 leency 96
redraw:
4781 hidnplayr 97
 
98
; Draw interface buttons (on the right hand side)
3545 hidnplayr 99
        call    draw_interfaces
100
 
4781 hidnplayr 101
; Draw upper line of rectangle
4798 hidnplayr 102
        mcall   13, 0 shl 16 + BOX_WIDTH, 25 shl 16 + 1, 0x00777777
4781 hidnplayr 103
 
104
; Fill rectangle
4798 hidnplayr 105
        mcall   13, 1 shl 16 + BOX_WIDTH-1, 26 shl 16 + BOX_HEIGHT-1, 0x00F3F3F3
4781 hidnplayr 106
 
107
; Fill tab buttons
108
        mov     eax, 13
109
        mov     ebx, 6 shl 16 + 53
110
        mov     si, 101
111
  .buttonloop:
112
        mov     ecx, 6 shl 16 + 19
113
        mov     edx, 0x00BBBBBB
114
        cmp     si, [mode]
115
        jne     @f
116
        mov     edx, 0x00F3F3F3         ; Activated button has other colors
117
        inc     ecx
118
  @@:
119
        mcall
120
        mov     edx, 0x00E1E1E1
121
        cmp     si, [mode]
122
        jne     @f
123
        mov     edx, 0x00FFFFFF         ; Activated button has other colors
124
  @@:
125
        mov     ecx, 5 shl 16 + 1
126
        mcall
127
        add     ebx, 60 shl 16
128
        inc     si
129
        cmp     si, 106
130
        jle     .buttonloop
131
; Print button names on top of the buttons
132
        mcall   4, 9 shl 16 + 12, 0x80000000, modes
133
 
134
; Get information about the selected device
3601 hidnplayr 135
        xor     ebx, ebx
136
        mov     bh, [device]
137
        mcall   74
138
        mov     [device_type], eax
139
 
3545 hidnplayr 140
        cmp     [mode], 101
141
        jne     .no_eth
142
 
3601 hidnplayr 143
        mcall   4, 8 shl 16 + 35, 0x80000000, str_packets_tx
3545 hidnplayr 144
        add     ebx, 18
145
        mov     edx, str_packets_rx
146
        mcall
147
        add     ebx, 18
148
        mov     edx, str_bytes_tx
149
        mcall
150
        add     ebx, 18
151
        mov     edx, str_bytes_rx
152
        mcall
153
        add     ebx, 18
5586 hidnplayr 154
        mov     edx, str_speed_tx
155
        mcall
156
        add     ebx, 18
157
        mov     edx, str_speed_rx
158
        mcall
159
        add     ebx, 18
3601 hidnplayr 160
        mov     edx, str_link
3545 hidnplayr 161
        mcall
3601 hidnplayr 162
 
163
        cmp     [device_type], 1
164
        jne     end_of_draw
165
 
3545 hidnplayr 166
        add     ebx, 18
3601 hidnplayr 167
        mov     edx, str_MAC
3545 hidnplayr 168
        mcall
169
 
3601 hidnplayr 170
        mov     ebx, API_ETH
3545 hidnplayr 171
        mov     bh, [device]
172
        mcall   76
173
        push    eax
174
        push    bx
175
 
5586 hidnplayr 176
        mov     edx, 134 shl 16 + 35 + 7*18
3545 hidnplayr 177
        call    draw_mac
178
        jmp     end_of_draw
179
 
180
 .no_eth:
181
 
182
        cmp     [mode], 102
183
        jne     .no_ip
184
 
3601 hidnplayr 185
        mcall   4, 8 shl 16 + 35, 0x80000000, str_packets_tx
3545 hidnplayr 186
        add     ebx, 18
187
        mov     edx, str_packets_rx
188
        mcall
189
        add     ebx, 18
190
        mov     edx, str_ip
191
        mcall
192
        add     ebx, 18
193
        mov     edx, str_dns
194
        mcall
195
        add     ebx, 18
196
        mov     edx, str_subnet
197
        mcall
198
        add     ebx, 18
199
        mov     edx, str_gateway
200
        mcall
201
 
202
 
203
        mov     ebx, API_IPv4 + 8
204
        mov     bh, [device]
205
        mcall   76
206
        push    eax
207
 
208
        dec     bl
209
        dec     bl
210
        mcall   76
211
        push    eax
212
 
213
        dec     bl
214
        dec     bl
215
        mcall   76
216
        push    eax
217
 
218
        dec     bl
219
        dec     bl
220
        mcall   76
221
        push    eax
222
 
4740 hidnplayr 223
        mov     edx, 134 shl 16 + 35 + 2*18
3545 hidnplayr 224
        call    draw_ip
225
 
226
        add     edx, 18
227
        call    draw_ip
228
 
229
        add     edx, 18
230
        call    draw_ip
231
 
232
        add     edx, 18
233
        call    draw_ip
234
 
5586 hidnplayr 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]
239
        mcall   4, 150 shl 16 + 157, [sc.work_button_text], str_ip_cfg, str_ip_cfg.len
240
 
3545 hidnplayr 241
        jmp     end_of_draw
242
 
243
 .no_ip:
244
 
245
        cmp     [mode], 103
246
        jne     .no_arp
247
 
3601 hidnplayr 248
        mcall   4, 8 shl 16 + 35, 0x80000000, str_packets_tx
3545 hidnplayr 249
        add     ebx, 18
250
        mov     edx, str_packets_rx
251
        mcall
252
        add     ebx, 18
253
        mov     edx, str_arp
254
        mcall
255
        add     ebx, 18
256
        mov     edx, str_conflicts
257
        mcall
258
 
3601 hidnplayr 259
        mcall   4, 8 shl 16 + 130, 0x80000000, str_ARP_legend
260
 
3545 hidnplayr 261
        jmp     end_of_draw
262
 
263
 .no_arp:
264
 
3601 hidnplayr 265
        mcall   4, 8 shl 16 + 35, 0x80000000, str_packets_tx
3545 hidnplayr 266
 
267
        add     ebx, 18
268
        mov     edx, str_packets_rx
269
        mcall
270
 
271
        cmp     [mode], 106
272
        jne     end_of_draw
273
 
274
        add     ebx, 18
275
        mov     edx, str_missed
276
        mcall
277
 
278
        add     ebx, 18
279
        mov     edx, str_dumped
280
        mcall
281
 
5016 hidnplayr 282
        add     ebx, 18
283
        mov     edx, str_queued
284
        mcall
285
 
4742 hidnplayr 286
end_of_draw:
3545 hidnplayr 287
 
4742 hidnplayr 288
        mcall   12, 2
3545 hidnplayr 289
 
290
draw_stats:
291
 
292
        cmp     [mode], 101
293
        jne     not_101
294
 
295
        mov     ebx, API_ETH
296
        mov     bh, [device]
3601 hidnplayr 297
        mov     bl, 6
3545 hidnplayr 298
  @@:
299
        push    ebx
3601 hidnplayr 300
        mcall   74
3545 hidnplayr 301
        pop     ebx
302
        push    eax
303
        inc     bl
3601 hidnplayr 304
        cmp     bl, 10
3545 hidnplayr 305
        jbe     @r
306
 
5586 hidnplayr 307
        pop     ecx
308
 
309
        push    [time]
310
        pop     [delta_time]
311
        mcall   26, 9
312
        mov     [time], eax
313
        sub     eax, [delta_time]
4845 hidnplayr 314
        jnz     @f
5586 hidnplayr 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
334
 
335
        test    cl, cl
336
        jnz     @f
4845 hidnplayr 337
        mov     edx, str_down
338
        jmp     .print_link
339
  @@:
5586 hidnplayr 340
        cmp     cl, 100b
4845 hidnplayr 341
        jnz     @f
342
        mov     edx, str_10m
343
        jmp     .print_link
344
  @@:
5586 hidnplayr 345
        cmp     cl, 110b
4845 hidnplayr 346
        jnz     @f
347
        mov     edx, str_10mfd
348
        jmp     .print_link
349
  @@:
5586 hidnplayr 350
        cmp     cl, 1000b
4845 hidnplayr 351
        jnz     @f
352
        mov     edx, str_100m
353
        jmp     .print_link
354
  @@:
5586 hidnplayr 355
        cmp     cl, 1010b
4845 hidnplayr 356
        jnz     @f
357
        mov     edx, str_100mfd
358
        jmp     .print_link
359
  @@:
5586 hidnplayr 360
        cmp     cl, 1100b
4845 hidnplayr 361
        jnz     @f
362
        mov     edx, str_1g
363
        jmp     .print_link
364
  @@:
5586 hidnplayr 365
        cmp     cl, 1110b
4845 hidnplayr 366
        jnz     @f
367
        mov     edx, str_1gfd
368
        jmp     .print_link
369
  @@:
370
        mov     edx, str_unknown
371
 
372
  .print_link:
5586 hidnplayr 373
        mov     ebx, 134 shl 16 + 35 + 6*18
4845 hidnplayr 374
        mov     ecx, 0xc0000000
375
        mov     edi, 0x00f3f3f3
376
        mcall   4
377
 
5586 hidnplayr 378
; speed tx
3545 hidnplayr 379
        mov     ebx, 0x000a0000
380
        pop     ecx
5586 hidnplayr 381
        mov     edx, 134 shl 16 + 35 + 5*18
3545 hidnplayr 382
        mov     esi, 0x40000000
383
        mcall   47
384
 
5586 hidnplayr 385
; speed rx
3601 hidnplayr 386
        sub     edx, 18
3545 hidnplayr 387
        pop     ecx
388
        mcall
389
 
5586 hidnplayr 390
; bytes received
3545 hidnplayr 391
        sub     edx, 18
392
        pop     ecx
393
        mcall
394
 
5586 hidnplayr 395
; bytes sent
3545 hidnplayr 396
        sub     edx, 18
397
        pop     ecx
398
        mcall
399
 
5586 hidnplayr 400
; packets received
401
        sub     edx, 18
402
        pop     ecx
403
        mcall
404
 
405
; packets sent
406
        sub     edx, 18
407
        pop     ecx
408
        mcall
409
 
3545 hidnplayr 410
        jmp     mainloop
411
 
412
 
413
not_101:
414
 
415
        cmp     [mode], 102
416
        jne     not_102
417
 
418
        mov     ebx, API_IPv4
419
        mov     bh, [device]
420
        push    ebx
421
        mcall   76
422
        pop     ebx
423
        push    eax
424
 
425
        inc     bl
426
        push    ebx
427
        mcall   76
428
        pop     ebx
429
        push    eax
430
 
431
 
432
        mov     ebx, 0x000a0000
433
        pop     ecx
4740 hidnplayr 434
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 435
        mov     esi, 0x40000000
4736 leency 436
        mov     edi, 0x00F3F3F3
3545 hidnplayr 437
        mcall   47
438
 
439
        sub     edx, 18
440
        pop     ecx
441
        mcall
442
 
443
        jmp     mainloop
444
 
445
 
446
not_102:
447
 
448
        cmp     [mode], 103
449
        jne     not_103
450
 
451
        mov     ebx, API_ARP
452
        mov     bh, [device]
453
        push    ebx
3641 hidnplayr 454
        mcall   76      ; tx
3545 hidnplayr 455
        pop     ebx
456
        push    eax
457
 
458
        inc     bl
459
        push    ebx
3641 hidnplayr 460
        mcall   76      ; rx
3545 hidnplayr 461
        pop     ebx
462
        push    eax
463
 
464
        inc     bl
465
        push    ebx
3641 hidnplayr 466
        mcall   76      ; entries
3545 hidnplayr 467
        pop     ebx
468
        push    eax
469
 
470
        mov     bl, 7
471
        push    ebx
472
        mcall   76
473
        pop     ebx
474
        push    eax
475
 
476
        mov     ebx, 0x000a0000
477
        pop     ecx
4740 hidnplayr 478
        mov     edx, 134 shl 16 + 35 + 3*18
3545 hidnplayr 479
        mov     esi, 0x40000000
4736 leency 480
        mov     edi, 0x00F3F3F3
3545 hidnplayr 481
        mcall   47
482
 
483
        sub     edx, 18
484
        pop     ecx
485
        mcall
486
 
487
        sub     edx, 18
488
        pop     ecx
489
        mcall
490
 
491
        sub     edx, 18
492
        pop     ecx
493
        mcall
494
 
3618 hidnplayr 495
;        mov     edx, 50 shl 16 + 150
3601 hidnplayr 496
        mov     [last], 0
497
 
498
  .arp_loop:
3641 hidnplayr 499
        mov     ebx, API_ARP + 3                ; read ARP entry
3601 hidnplayr 500
        mov     bh, [device]
3641 hidnplayr 501
        mcall   76, ,[last], , , arp_buf
3601 hidnplayr 502
        cmp     eax, -1
503
        je      mainloop
504
 
3641 hidnplayr 505
        mov     ebx, [last]
506
        imul    ebx, 16
507
        add     ebx, 8 shl 16 + 140
508
        mcall   4, , 0x80000000, str_ARP_entry
3601 hidnplayr 509
        mov     edx, ebx
510
 
511
        mov     eax, 47
512
        mov     ebx, 0x00030000
513
        mov     esi, 0x40000000
4736 leency 514
        mov     edi, 0x00F3F3F3
3601 hidnplayr 515
        xor     ecx, ecx
516
 
517
        mov     cl, byte[arp_buf.IP+0]
518
        mcall
519
 
520
        mov     cl, byte[arp_buf.IP+1]
521
        add     edx, 24 shl 16
522
        mcall
523
 
524
        mov     cl, byte[arp_buf.IP+2]
525
        add     edx, 24 shl 16
526
        mcall
527
 
528
        mov     cl, byte[arp_buf.IP+3]
529
        add     edx, 24 shl 16
530
        mcall
531
 
532
 
533
        mov     ebx, 0x00020100
534
        mov     cl, byte[arp_buf.MAC+0]
535
        add     edx, 36 shl 16
536
        mcall
537
 
538
        mov     cl, byte[arp_buf.MAC+1]
539
        add     edx, 18 shl 16
540
        mcall
541
 
542
        mov     cl, byte[arp_buf.MAC+2]
543
        add     edx, 18 shl 16
544
        mcall
545
 
546
        mov     cl, byte[arp_buf.MAC+3]
547
        add     edx, 18 shl 16
548
        mcall
549
 
550
        mov     cl, byte[arp_buf.MAC+4]
551
        add     edx, 18 shl 16
552
        mcall
553
 
554
        mov     cl, byte[arp_buf.MAC+5]
555
        add     edx, 18 shl 16
556
        mcall
557
 
558
        mov     ebx, 0x00040000
559
        mov     cx, [arp_buf.status]
560
        add     edx, 30 shl 16
561
        mcall
562
 
563
        mov     cx, [arp_buf.TTL]
564
        add     edx, 60 shl 16
565
        mcall
566
 
567
        add     dx, 18
568
        rol     edx, 16
569
        mov     dx, 8
570
        rol     edx, 16
571
        inc     [last]
572
 
573
        jmp     .arp_loop
574
 
3545 hidnplayr 575
not_103:
576
 
577
        cmp     [mode], 104
578
        jne     not_104
579
 
580
        mov     ebx, API_ICMP
581
        mov     bh, [device]
582
        push    ebx
583
        mcall   76
584
        pop     ebx
585
        push    eax
586
 
587
        inc     bl
588
        push    ebx
589
        mcall   76
590
        pop     ebx
591
        push    eax
592
 
593
        mov     ebx, 0x000a0000
594
        pop     ecx
4740 hidnplayr 595
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 596
        mov     esi, 0x40000000
4736 leency 597
        mov     edi, 0x00F3F3F3
3545 hidnplayr 598
        mcall   47
599
 
600
        sub     edx, 18
601
        pop     ecx
602
        mcall
603
 
604
        jmp     mainloop
605
 
606
not_104:
607
 
608
        cmp     [mode], 105
609
        jne     not_105
610
 
611
        mov     ebx, API_UDP
612
        mov     bh, [device]
613
        push    ebx
614
        mcall   76
615
        pop     ebx
616
        push    eax
617
 
618
        inc     bl
619
        push    ebx
620
        mcall   76
621
        pop     ebx
622
        push    eax
623
 
624
        mov     ebx, 0x000a0000
625
        pop     ecx
4740 hidnplayr 626
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 627
        mov     esi, 0x40000000
4736 leency 628
        mov     edi, 0x00F3F3F3
3545 hidnplayr 629
        mcall   47
630
 
631
        sub     edx, 18
632
        pop     ecx
633
        mcall
634
 
635
        jmp     mainloop
636
 
637
not_105:
638
 
639
        cmp     [mode], 106
640
        jne     not_106
641
 
642
        mov     ebx, API_TCP
643
        mov     bh, [device]
644
        push    ebx
645
        mcall   76
646
        pop     ebx
647
        push    eax
648
 
649
        inc     bl
650
        push    ebx
651
        mcall   76
652
        pop     ebx
653
        push    eax
654
 
655
        inc     bl
656
        push    ebx
657
        mcall   76
658
        pop     ebx
659
        push    eax
660
 
661
        inc     bl
662
        push    ebx
663
        mcall   76
664
        pop     ebx
665
        push    eax
666
 
5016 hidnplayr 667
        inc     bl
668
        push    ebx
669
        mcall   76
670
        pop     ebx
671
        push    eax
672
 
3545 hidnplayr 673
        mov     ebx, 0x000a0000
674
        pop     ecx
5016 hidnplayr 675
        mov     edx, 134 shl 16 + 35 + 18*4
3545 hidnplayr 676
        mov     esi, 0x40000000
4736 leency 677
        mov     edi, 0x00F3F3F3
3545 hidnplayr 678
        mcall   47
679
 
680
        sub     edx, 18
681
        pop     ecx
682
        mcall
683
 
684
        sub     edx, 18
685
        pop     ecx
686
        mcall
687
 
688
        sub     edx, 18
689
        pop     ecx
690
        mcall
691
 
5016 hidnplayr 692
        sub     edx, 18
693
        pop     ecx
694
        mcall
695
 
3545 hidnplayr 696
        jmp     mainloop
697
 
698
not_106:
699
 
700
mainloop:
701
 
702
        mcall   23, 50          ; wait for event with timeout    (0,5 s)
703
 
4742 hidnplayr 704
        cmp     eax, EV_REDRAW
4736 leency 705
        je      window_redraw
4742 hidnplayr 706
        cmp     eax, EV_BUTTON
3545 hidnplayr 707
        je      button
4742 hidnplayr 708
        cmp     eax, EV_KEY
709
        je      key
3545 hidnplayr 710
        cmp     eax, 11
711
        je      redraw
712
 
713
        jmp     draw_stats
714
 
715
button:                         ; button
716
        mcall   17              ; get id
717
        cmp     ah, 1
718
        je      exit
5586 hidnplayr 719
        cmp     ah, 2
720
        je      .ipcfg
3545 hidnplayr 721
        cmp     ah, 0
722
        je      .interface
4781 hidnplayr 723
        shr     ax, 8
724
        mov     [mode], ax
3545 hidnplayr 725
        jmp     redraw
726
 
5586 hidnplayr 727
  .ipcfg:
728
        mcall   51, 1, ipcfg, I_END+0x1000
729
        jmp     mainloop
730
 
3545 hidnplayr 731
  .interface:
732
        shr     eax, 16
733
        mov     [device], al
734
        jmp     redraw
735
 
4742 hidnplayr 736
key:
737
        mcall   2
738
        cmp     ah, 9
739
        je      .tab
740
        cmp     ah, 183
741
        je      .pgdown
742
        cmp     ah, 184
743
        je      .pgup
744
        jmp     mainloop
745
 
746
  .tab:
747
        inc     [mode]
748
        cmp     [mode], 106
749
        jbe     redraw
750
        mov     [mode], 101
751
        jmp     redraw
752
 
753
  .pgdown:
754
        inc     [device]
755
        mov     al, [device]
756
        cmp     al, [last_device]
757
        jbe     redraw
758
        mov     [device], 0
759
        jmp     redraw
760
 
761
  .pgup:
762
        dec     [device]
763
        cmp     [device], 0
764
        jge     redraw
765
        mov     al, [last_device]
766
        mov     [device], al
767
        jmp     redraw
768
 
3545 hidnplayr 769
exit:
770
        mcall   -1
771
 
772
 
773
 
774
draw_mac:
775
 
776
        mov     eax, 47
777
        mov     ebx, 0x00020100
778
        mov     esi, 0x40000000
4736 leency 779
        mov     edi, 0x00F3F3F3
3545 hidnplayr 780
 
781
        mov     cl, [esp+4]
782
        mcall
783
 
784
        mov     cl, [esp+4+1]
4740 hidnplayr 785
        add     edx, 18 shl 16
3545 hidnplayr 786
        mcall
787
 
788
        mov     cl, [esp+4+2]
4740 hidnplayr 789
        add     edx, 18 shl 16
3545 hidnplayr 790
        mcall
791
 
792
        mov     cl, [esp+4+3]
4740 hidnplayr 793
        add     edx, 18 shl 16
3545 hidnplayr 794
        mcall
795
 
796
        mov     cl, [esp+4+4]
4740 hidnplayr 797
        add     edx, 18 shl 16
3545 hidnplayr 798
        mcall
799
 
800
        mov     cl, [esp+4+5]
4740 hidnplayr 801
        add     edx, 18 shl 16
3545 hidnplayr 802
        mcall
803
 
4740 hidnplayr 804
        sub     edx, 5*18 shl 16
3545 hidnplayr 805
 
806
        ret     6
807
 
808
 
809
draw_ip:
810
 
811
        mov     eax, 47
812
        mov     ebx, 0x00030000
813
        mov     esi, 0x40000000
4736 leency 814
        mov     edi, 0x00F3F3F3
3545 hidnplayr 815
 
816
        xor     ecx, ecx
817
 
818
        mov     cl, [esp+4]
819
        mcall
820
 
821
        mov     cl, [esp+4+1]
4740 hidnplayr 822
        add     edx, 24 shl 16
3545 hidnplayr 823
        mcall
824
 
825
        mov     cl, [esp+4+2]
4740 hidnplayr 826
        add     edx, 24 shl 16
3545 hidnplayr 827
        mcall
828
 
829
        mov     cl, [esp+4+3]
4740 hidnplayr 830
        add     edx, 24 shl 16
3545 hidnplayr 831
        mcall
832
 
4740 hidnplayr 833
        sub     edx, 3*24 shl 16
3545 hidnplayr 834
        ret     4
835
 
836
 
837
draw_interfaces:
838
 
3601 hidnplayr 839
        mov     [.btnpos], 5 shl 16 + 20
4798 hidnplayr 840
        mov     [.txtpos], 405 shl 16 + 12
3545 hidnplayr 841
 
842
        mcall   74, -1          ; get number of active network devices
843
        mov     ecx, eax
4742 hidnplayr 844
        dec     al
845
        mov     [last_device], al
5250 hidnplayr 846
        cmp     [device], al
847
        jbe     @f
848
        mov     [device], 0
849
  @@:
3545 hidnplayr 850
 
851
        xor     ebx, ebx        ; get device type
852
  .loop:
853
        mcall   74
3601 hidnplayr 854
        cmp     eax, 1          ; loopback or ethernet?
855
        jbe     .hit
3545 hidnplayr 856
        inc     bh
857
        jb      .loop           ; tried all 256?
858
        ret
859
 
860
 
861
  .hit:
862
        push    ecx ebx
863
        movzx   edx, bh
864
        shl     edx, 8
4736 leency 865
        mov     esi, 0x00BBBbbb
3545 hidnplayr 866
        cmp     bh, [device]
4736 leency 867
        cmove   esi, 0x0081BBFF
4798 hidnplayr 868
        mcall   8, 400 shl 16 + 185, [.btnpos]
3545 hidnplayr 869
        mov     ebx, [esp]
870
        inc     bl
871
        mov     ecx, namebuf
872
        mov     edx, namebuf
3601 hidnplayr 873
        mcall   74                              ; get device name
3545 hidnplayr 874
        cmp     eax, -1
875
        jne     @f
876
        mov     edx, str_unknown
877
       @@:
3601 hidnplayr 878
        mcall   4, [.txtpos], 0x80000000        ; print the name
3545 hidnplayr 879
        pop     ebx ecx
880
 
881
        inc     bh
882
 
883
        add     [.btnpos], 25 shl 16
884
        add     [.txtpos], 25
885
 
886
        dec     ecx
887
        jnz     .loop
888
 
889
        ret
890
 
891
  .btnpos       dd ?
892
  .txtpos       dd ?
893
 
894
 
895
; DATA AREA
896
 
5586 hidnplayr 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'     ,\
919
        option_box_mouse, 'option_box_mouse'    ,\
920
        version_op      , 'version_op'
921
 
4742 hidnplayr 922
name            db 'Network status', 0
5250 hidnplayr 923
mode            dw 101          ; currently selected protocol
924
device          db 1            ; currently selected device
925
last_device     db ?            ; last device available
926
device_type     dd ?
927
last            dd ?
4798 hidnplayr 928
modes           db 'Physical    IPv4      ARP       ICMP      UDP       TCP', 0
3545 hidnplayr 929
 
930
str_packets_tx  db 'Packets sent:', 0
931
str_packets_rx  db 'Packets received:', 0
932
str_bytes_tx    db 'Bytes sent:', 0
933
str_bytes_rx    db 'Bytes received:', 0
4740 hidnplayr 934
str_MAC         db 'MAC address:           -  -  -  -  -', 0
935
str_ip          db 'IP address:             .   .   .', 0
936
str_dns         db 'DNS address:            .   .   .', 0
937
str_subnet      db 'Subnet mask:            .   .   .', 0
938
str_gateway     db 'Standard gateway:       .   .   .', 0
3545 hidnplayr 939
str_arp         db 'ARP entrys:', 0
940
str_conflicts   db 'ARP conflicts:', 0
5586 hidnplayr 941
str_missed      db 'Packets missed:', 0
942
str_dumped      db 'Packets dumped:', 0
943
str_queued      db 'Packets queued:', 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
3545 hidnplayr 949
 
5498 hidnplayr 950
str_down        db 'disconnected        ', 0
951
str_unknown     db 'unknown             ', 0
952
str_10m         db '10 Mbit Half duplex ', 0
953
str_10mfd       db '10 Mbit Full duplex ', 0
4845 hidnplayr 954
str_100m        db '100 Mbit Half duplex', 0
955
str_100mfd      db '100 Mbit Full duplex', 0
5498 hidnplayr 956
str_1g          db '1 Gbit Half duplex  ', 0
957
str_1gfd        db '1 Gbit Full duplex  ', 0
4845 hidnplayr 958
 
3601 hidnplayr 959
str_ARP_legend  db 'IP-address        MAC-address         Status    TTL', 0
4740 hidnplayr 960
str_ARP_entry   db '   .   .   .        -  -  -  -  -', 0
3601 hidnplayr 961
 
5586 hidnplayr 962
prev_rx         dd ?
963
prev_tx         dd ?
964
time            dd ?
965
delta_time      dd ?
966
 
3545 hidnplayr 967
namebuf         rb 64
3601 hidnplayr 968
arp_buf         ARP_entry
3545 hidnplayr 969
 
5586 hidnplayr 970
sc              system_colors
971
 
4742 hidnplayr 972
I_END: