Subversion Repositories Kolibri OS

Rev

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

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