Subversion Repositories Kolibri OS

Rev

Rev 5016 | Rev 5498 | 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
 
5016 hidnplayr 253
        add     ebx, 18
254
        mov     edx, str_queued
255
        mcall
256
 
4742 hidnplayr 257
end_of_draw:
3545 hidnplayr 258
 
4742 hidnplayr 259
        mcall   12, 2
3545 hidnplayr 260
 
261
draw_stats:
262
 
263
        cmp     [mode], 101
264
        jne     not_101
265
 
266
        mov     ebx, API_ETH
267
        mov     bh, [device]
3601 hidnplayr 268
        mov     bl, 6
3545 hidnplayr 269
  @@:
270
        push    ebx
3601 hidnplayr 271
        mcall   74
3545 hidnplayr 272
        pop     ebx
273
        push    eax
274
        inc     bl
3601 hidnplayr 275
        cmp     bl, 10
3545 hidnplayr 276
        jbe     @r
277
 
4845 hidnplayr 278
        pop     eax
279
        test    al, al
280
        jnz     @f
281
        mov     edx, str_down
282
        jmp     .print_link
283
  @@:
284
        cmp     al, 100b
285
        jnz     @f
286
        mov     edx, str_10m
287
        jmp     .print_link
288
  @@:
289
        cmp     al, 110b
290
        jnz     @f
291
        mov     edx, str_10mfd
292
        jmp     .print_link
293
  @@:
294
        cmp     al, 1000b
295
        jnz     @f
296
        mov     edx, str_100m
297
        jmp     .print_link
298
  @@:
299
        cmp     al, 1010b
300
        jnz     @f
301
        mov     edx, str_100mfd
302
        jmp     .print_link
303
  @@:
304
        cmp     al, 10000b
305
        jnz     @f
306
        mov     edx, str_1g
307
        jmp     .print_link
308
  @@:
309
        cmp     al, 10010b
310
        jnz     @f
311
        mov     edx, str_1gfd
312
        jmp     .print_link
313
  @@:
314
        mov     edx, str_unknown
315
 
316
  .print_link:
317
        mov     ebx, 134 shl 16 + 35 + 4*18
318
        mov     ecx, 0xc0000000
319
        mov     edi, 0x00f3f3f3
320
        mcall   4
321
 
3545 hidnplayr 322
        mov     ebx, 0x000a0000
323
        pop     ecx
4845 hidnplayr 324
        mov     edx, 134 shl 16 + 35 + 3*18
3545 hidnplayr 325
        mov     esi, 0x40000000
326
        mcall   47
327
 
3601 hidnplayr 328
        sub     edx, 18
3545 hidnplayr 329
        pop     ecx
330
        mcall
331
 
332
        sub     edx, 18
333
        pop     ecx
334
        mcall
335
 
336
        sub     edx, 18
337
        pop     ecx
338
        mcall
339
 
340
        jmp     mainloop
341
 
342
 
343
not_101:
344
 
345
        cmp     [mode], 102
346
        jne     not_102
347
 
348
        mov     ebx, API_IPv4
349
        mov     bh, [device]
350
        push    ebx
351
        mcall   76
352
        pop     ebx
353
        push    eax
354
 
355
        inc     bl
356
        push    ebx
357
        mcall   76
358
        pop     ebx
359
        push    eax
360
 
361
 
362
        mov     ebx, 0x000a0000
363
        pop     ecx
4740 hidnplayr 364
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 365
        mov     esi, 0x40000000
4736 leency 366
        mov     edi, 0x00F3F3F3
3545 hidnplayr 367
        mcall   47
368
 
369
        sub     edx, 18
370
        pop     ecx
371
        mcall
372
 
373
        jmp     mainloop
374
 
375
 
376
not_102:
377
 
378
        cmp     [mode], 103
379
        jne     not_103
380
 
381
        mov     ebx, API_ARP
382
        mov     bh, [device]
383
        push    ebx
3641 hidnplayr 384
        mcall   76      ; tx
3545 hidnplayr 385
        pop     ebx
386
        push    eax
387
 
388
        inc     bl
389
        push    ebx
3641 hidnplayr 390
        mcall   76      ; rx
3545 hidnplayr 391
        pop     ebx
392
        push    eax
393
 
394
        inc     bl
395
        push    ebx
3641 hidnplayr 396
        mcall   76      ; entries
3545 hidnplayr 397
        pop     ebx
398
        push    eax
399
 
400
        mov     bl, 7
401
        push    ebx
402
        mcall   76
403
        pop     ebx
404
        push    eax
405
 
406
        mov     ebx, 0x000a0000
407
        pop     ecx
4740 hidnplayr 408
        mov     edx, 134 shl 16 + 35 + 3*18
3545 hidnplayr 409
        mov     esi, 0x40000000
4736 leency 410
        mov     edi, 0x00F3F3F3
3545 hidnplayr 411
        mcall   47
412
 
413
        sub     edx, 18
414
        pop     ecx
415
        mcall
416
 
417
        sub     edx, 18
418
        pop     ecx
419
        mcall
420
 
421
        sub     edx, 18
422
        pop     ecx
423
        mcall
424
 
3618 hidnplayr 425
;        mov     edx, 50 shl 16 + 150
3601 hidnplayr 426
        mov     [last], 0
427
 
428
  .arp_loop:
3641 hidnplayr 429
        mov     ebx, API_ARP + 3                ; read ARP entry
3601 hidnplayr 430
        mov     bh, [device]
3641 hidnplayr 431
        mcall   76, ,[last], , , arp_buf
3601 hidnplayr 432
        cmp     eax, -1
433
        je      mainloop
434
 
3641 hidnplayr 435
        mov     ebx, [last]
436
        imul    ebx, 16
437
        add     ebx, 8 shl 16 + 140
438
        mcall   4, , 0x80000000, str_ARP_entry
3601 hidnplayr 439
        mov     edx, ebx
440
 
441
        mov     eax, 47
442
        mov     ebx, 0x00030000
443
        mov     esi, 0x40000000
4736 leency 444
        mov     edi, 0x00F3F3F3
3601 hidnplayr 445
        xor     ecx, ecx
446
 
447
        mov     cl, byte[arp_buf.IP+0]
448
        mcall
449
 
450
        mov     cl, byte[arp_buf.IP+1]
451
        add     edx, 24 shl 16
452
        mcall
453
 
454
        mov     cl, byte[arp_buf.IP+2]
455
        add     edx, 24 shl 16
456
        mcall
457
 
458
        mov     cl, byte[arp_buf.IP+3]
459
        add     edx, 24 shl 16
460
        mcall
461
 
462
 
463
        mov     ebx, 0x00020100
464
        mov     cl, byte[arp_buf.MAC+0]
465
        add     edx, 36 shl 16
466
        mcall
467
 
468
        mov     cl, byte[arp_buf.MAC+1]
469
        add     edx, 18 shl 16
470
        mcall
471
 
472
        mov     cl, byte[arp_buf.MAC+2]
473
        add     edx, 18 shl 16
474
        mcall
475
 
476
        mov     cl, byte[arp_buf.MAC+3]
477
        add     edx, 18 shl 16
478
        mcall
479
 
480
        mov     cl, byte[arp_buf.MAC+4]
481
        add     edx, 18 shl 16
482
        mcall
483
 
484
        mov     cl, byte[arp_buf.MAC+5]
485
        add     edx, 18 shl 16
486
        mcall
487
 
488
        mov     ebx, 0x00040000
489
        mov     cx, [arp_buf.status]
490
        add     edx, 30 shl 16
491
        mcall
492
 
493
        mov     cx, [arp_buf.TTL]
494
        add     edx, 60 shl 16
495
        mcall
496
 
497
        add     dx, 18
498
        rol     edx, 16
499
        mov     dx, 8
500
        rol     edx, 16
501
        inc     [last]
502
 
503
        jmp     .arp_loop
504
 
3545 hidnplayr 505
not_103:
506
 
507
        cmp     [mode], 104
508
        jne     not_104
509
 
510
        mov     ebx, API_ICMP
511
        mov     bh, [device]
512
        push    ebx
513
        mcall   76
514
        pop     ebx
515
        push    eax
516
 
517
        inc     bl
518
        push    ebx
519
        mcall   76
520
        pop     ebx
521
        push    eax
522
 
523
        mov     ebx, 0x000a0000
524
        pop     ecx
4740 hidnplayr 525
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 526
        mov     esi, 0x40000000
4736 leency 527
        mov     edi, 0x00F3F3F3
3545 hidnplayr 528
        mcall   47
529
 
530
        sub     edx, 18
531
        pop     ecx
532
        mcall
533
 
534
        jmp     mainloop
535
 
536
not_104:
537
 
538
        cmp     [mode], 105
539
        jne     not_105
540
 
541
        mov     ebx, API_UDP
542
        mov     bh, [device]
543
        push    ebx
544
        mcall   76
545
        pop     ebx
546
        push    eax
547
 
548
        inc     bl
549
        push    ebx
550
        mcall   76
551
        pop     ebx
552
        push    eax
553
 
554
        mov     ebx, 0x000a0000
555
        pop     ecx
4740 hidnplayr 556
        mov     edx, 134 shl 16 + 35 + 18
3545 hidnplayr 557
        mov     esi, 0x40000000
4736 leency 558
        mov     edi, 0x00F3F3F3
3545 hidnplayr 559
        mcall   47
560
 
561
        sub     edx, 18
562
        pop     ecx
563
        mcall
564
 
565
        jmp     mainloop
566
 
567
not_105:
568
 
569
        cmp     [mode], 106
570
        jne     not_106
571
 
572
        mov     ebx, API_TCP
573
        mov     bh, [device]
574
        push    ebx
575
        mcall   76
576
        pop     ebx
577
        push    eax
578
 
579
        inc     bl
580
        push    ebx
581
        mcall   76
582
        pop     ebx
583
        push    eax
584
 
585
        inc     bl
586
        push    ebx
587
        mcall   76
588
        pop     ebx
589
        push    eax
590
 
591
        inc     bl
592
        push    ebx
593
        mcall   76
594
        pop     ebx
595
        push    eax
596
 
5016 hidnplayr 597
        inc     bl
598
        push    ebx
599
        mcall   76
600
        pop     ebx
601
        push    eax
602
 
3545 hidnplayr 603
        mov     ebx, 0x000a0000
604
        pop     ecx
5016 hidnplayr 605
        mov     edx, 134 shl 16 + 35 + 18*4
3545 hidnplayr 606
        mov     esi, 0x40000000
4736 leency 607
        mov     edi, 0x00F3F3F3
3545 hidnplayr 608
        mcall   47
609
 
610
        sub     edx, 18
611
        pop     ecx
612
        mcall
613
 
614
        sub     edx, 18
615
        pop     ecx
616
        mcall
617
 
618
        sub     edx, 18
619
        pop     ecx
620
        mcall
621
 
5016 hidnplayr 622
        sub     edx, 18
623
        pop     ecx
624
        mcall
625
 
3545 hidnplayr 626
        jmp     mainloop
627
 
628
not_106:
629
 
630
mainloop:
631
 
632
        mcall   23, 50          ; wait for event with timeout    (0,5 s)
633
 
4742 hidnplayr 634
        cmp     eax, EV_REDRAW
4736 leency 635
        je      window_redraw
4742 hidnplayr 636
        cmp     eax, EV_BUTTON
3545 hidnplayr 637
        je      button
4742 hidnplayr 638
        cmp     eax, EV_KEY
639
        je      key
3545 hidnplayr 640
        cmp     eax, 11
641
        je      redraw
642
 
643
        jmp     draw_stats
644
 
645
button:                         ; button
646
        mcall   17              ; get id
647
        cmp     ah, 1
648
        je      exit
649
        cmp     ah, 0
650
        je      .interface
4781 hidnplayr 651
        shr     ax, 8
652
        mov     [mode], ax
3545 hidnplayr 653
        jmp     redraw
654
 
655
  .interface:
656
        shr     eax, 16
657
        mov     [device], al
658
        jmp     redraw
659
 
4742 hidnplayr 660
key:
661
        mcall   2
662
        cmp     ah, 9
663
        je      .tab
664
        cmp     ah, 183
665
        je      .pgdown
666
        cmp     ah, 184
667
        je      .pgup
668
        jmp     mainloop
669
 
670
  .tab:
671
        inc     [mode]
672
        cmp     [mode], 106
673
        jbe     redraw
674
        mov     [mode], 101
675
        jmp     redraw
676
 
677
  .pgdown:
678
        inc     [device]
679
        mov     al, [device]
680
        cmp     al, [last_device]
681
        jbe     redraw
682
        mov     [device], 0
683
        jmp     redraw
684
 
685
  .pgup:
686
        dec     [device]
687
        cmp     [device], 0
688
        jge     redraw
689
        mov     al, [last_device]
690
        mov     [device], al
691
        jmp     redraw
692
 
3545 hidnplayr 693
exit:
694
        mcall   -1
695
 
696
 
697
 
698
draw_mac:
699
 
700
        mov     eax, 47
701
        mov     ebx, 0x00020100
702
        mov     esi, 0x40000000
4736 leency 703
        mov     edi, 0x00F3F3F3
3545 hidnplayr 704
 
705
        mov     cl, [esp+4]
706
        mcall
707
 
708
        mov     cl, [esp+4+1]
4740 hidnplayr 709
        add     edx, 18 shl 16
3545 hidnplayr 710
        mcall
711
 
712
        mov     cl, [esp+4+2]
4740 hidnplayr 713
        add     edx, 18 shl 16
3545 hidnplayr 714
        mcall
715
 
716
        mov     cl, [esp+4+3]
4740 hidnplayr 717
        add     edx, 18 shl 16
3545 hidnplayr 718
        mcall
719
 
720
        mov     cl, [esp+4+4]
4740 hidnplayr 721
        add     edx, 18 shl 16
3545 hidnplayr 722
        mcall
723
 
724
        mov     cl, [esp+4+5]
4740 hidnplayr 725
        add     edx, 18 shl 16
3545 hidnplayr 726
        mcall
727
 
4740 hidnplayr 728
        sub     edx, 5*18 shl 16
3545 hidnplayr 729
 
730
        ret     6
731
 
732
 
733
draw_ip:
734
 
735
        mov     eax, 47
736
        mov     ebx, 0x00030000
737
        mov     esi, 0x40000000
4736 leency 738
        mov     edi, 0x00F3F3F3
3545 hidnplayr 739
 
740
        xor     ecx, ecx
741
 
742
        mov     cl, [esp+4]
743
        mcall
744
 
745
        mov     cl, [esp+4+1]
4740 hidnplayr 746
        add     edx, 24 shl 16
3545 hidnplayr 747
        mcall
748
 
749
        mov     cl, [esp+4+2]
4740 hidnplayr 750
        add     edx, 24 shl 16
3545 hidnplayr 751
        mcall
752
 
753
        mov     cl, [esp+4+3]
4740 hidnplayr 754
        add     edx, 24 shl 16
3545 hidnplayr 755
        mcall
756
 
4740 hidnplayr 757
        sub     edx, 3*24 shl 16
3545 hidnplayr 758
        ret     4
759
 
760
 
761
draw_interfaces:
762
 
3601 hidnplayr 763
        mov     [.btnpos], 5 shl 16 + 20
4798 hidnplayr 764
        mov     [.txtpos], 405 shl 16 + 12
3545 hidnplayr 765
 
766
        mcall   74, -1          ; get number of active network devices
767
        mov     ecx, eax
4742 hidnplayr 768
        dec     al
769
        mov     [last_device], al
5250 hidnplayr 770
        cmp     [device], al
771
        jbe     @f
772
        mov     [device], 0
773
  @@:
3545 hidnplayr 774
 
775
        xor     ebx, ebx        ; get device type
776
  .loop:
777
        mcall   74
3601 hidnplayr 778
        cmp     eax, 1          ; loopback or ethernet?
779
        jbe     .hit
3545 hidnplayr 780
        inc     bh
781
        jb      .loop           ; tried all 256?
782
        ret
783
 
784
 
785
  .hit:
786
        push    ecx ebx
787
        movzx   edx, bh
788
        shl     edx, 8
4736 leency 789
        mov     esi, 0x00BBBbbb
3545 hidnplayr 790
        cmp     bh, [device]
4736 leency 791
        cmove   esi, 0x0081BBFF
4798 hidnplayr 792
        mcall   8, 400 shl 16 + 185, [.btnpos]
3545 hidnplayr 793
        mov     ebx, [esp]
794
        inc     bl
795
        mov     ecx, namebuf
796
        mov     edx, namebuf
3601 hidnplayr 797
        mcall   74                              ; get device name
3545 hidnplayr 798
        cmp     eax, -1
799
        jne     @f
800
        mov     edx, str_unknown
801
       @@:
3601 hidnplayr 802
        mcall   4, [.txtpos], 0x80000000        ; print the name
3545 hidnplayr 803
        pop     ebx ecx
804
 
805
        inc     bh
806
 
807
        add     [.btnpos], 25 shl 16
808
        add     [.txtpos], 25
809
 
810
        dec     ecx
811
        jnz     .loop
812
 
813
        ret
814
 
815
  .btnpos       dd ?
816
  .txtpos       dd ?
817
 
818
 
819
; DATA AREA
820
 
4742 hidnplayr 821
name            db 'Network status', 0
5250 hidnplayr 822
mode            dw 101          ; currently selected protocol
823
device          db 1            ; currently selected device
824
last_device     db ?            ; last device available
825
device_type     dd ?
826
last            dd ?
4798 hidnplayr 827
modes           db 'Physical    IPv4      ARP       ICMP      UDP       TCP', 0
3545 hidnplayr 828
 
829
str_packets_tx  db 'Packets sent:', 0
830
str_packets_rx  db 'Packets received:', 0
831
str_bytes_tx    db 'Bytes sent:', 0
832
str_bytes_rx    db 'Bytes received:', 0
4740 hidnplayr 833
str_MAC         db 'MAC address:           -  -  -  -  -', 0
834
str_ip          db 'IP address:             .   .   .', 0
835
str_dns         db 'DNS address:            .   .   .', 0
836
str_subnet      db 'Subnet mask:            .   .   .', 0
837
str_gateway     db 'Standard gateway:       .   .   .', 0
3545 hidnplayr 838
str_arp         db 'ARP entrys:', 0
839
str_conflicts   db 'ARP conflicts:', 0
840
str_missed      db 'Packets missed:',0
841
str_dumped      db 'Packets dumped:',0
5016 hidnplayr 842
str_queued      db 'Packets queued:',0
3545 hidnplayr 843
str_link        db 'Link state:',0
844
 
4845 hidnplayr 845
str_down        db 'down', 0
846
str_unknown     db 'unknown', 0
847
str_10m         db '10 Mbit Half duplex', 0
848
str_10mfd       db '10 Mbit Full duplex', 0
849
str_100m        db '100 Mbit Half duplex', 0
850
str_100mfd      db '100 Mbit Full duplex', 0
851
str_1g          db '1 Gbit Half duplex', 0
852
str_1gfd        db '1 Gbit Full duplex', 0
853
 
3601 hidnplayr 854
str_ARP_legend  db 'IP-address        MAC-address         Status    TTL', 0
4740 hidnplayr 855
str_ARP_entry   db '   .   .   .        -  -  -  -  -', 0
3601 hidnplayr 856
 
3545 hidnplayr 857
namebuf         rb 64
3601 hidnplayr 858
arp_buf         ARP_entry
3545 hidnplayr 859
 
4742 hidnplayr 860
I_END: