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