Subversion Repositories Kolibri OS

Rev

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

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