Rev 6323 | 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 | ;; ;; |
||
6971 | hidnplayr | 3 | ;; Copyright (C) KolibriOS team 2010-2017. 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] |
||
315 | mcall 26, 9 |
||
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 | @@: |
||
321 | mov [delta_time], eax |
||
322 | |||
323 | mov eax, [esp+4] ; bytes received |
||
324 | push eax |
||
325 | sub eax, [prev_rx] |
||
326 | pop [prev_rx] |
||
327 | xor edx, edx |
||
328 | div [delta_time] |
||
329 | push eax |
||
330 | |||
331 | mov eax, [esp+4] ; bytes sent |
||
332 | push eax |
||
333 | sub eax, [prev_tx] |
||
334 | pop [prev_tx] |
||
335 | xor edx, edx |
||
336 | div [delta_time] |
||
337 | push eax |
||
338 | |||
339 | test cl, cl |
||
340 | jnz @f |
||
4845 | hidnplayr | 341 | mov edx, str_down |
342 | jmp .print_link |
||
343 | @@: |
||
5586 | hidnplayr | 344 | cmp cl, 100b |
4845 | hidnplayr | 345 | jnz @f |
346 | mov edx, str_10m |
||
347 | jmp .print_link |
||
348 | @@: |
||
5586 | hidnplayr | 349 | cmp cl, 110b |
4845 | hidnplayr | 350 | jnz @f |
351 | mov edx, str_10mfd |
||
352 | jmp .print_link |
||
353 | @@: |
||
5586 | hidnplayr | 354 | cmp cl, 1000b |
4845 | hidnplayr | 355 | jnz @f |
356 | mov edx, str_100m |
||
357 | jmp .print_link |
||
358 | @@: |
||
5586 | hidnplayr | 359 | cmp cl, 1010b |
4845 | hidnplayr | 360 | jnz @f |
361 | mov edx, str_100mfd |
||
362 | jmp .print_link |
||
363 | @@: |
||
5586 | hidnplayr | 364 | cmp cl, 1100b |
4845 | hidnplayr | 365 | jnz @f |
366 | mov edx, str_1g |
||
367 | jmp .print_link |
||
368 | @@: |
||
5586 | hidnplayr | 369 | cmp cl, 1110b |
4845 | hidnplayr | 370 | jnz @f |
371 | mov edx, str_1gfd |
||
372 | jmp .print_link |
||
373 | @@: |
||
374 | mov edx, str_unknown |
||
375 | |||
376 | .print_link: |
||
5586 | hidnplayr | 377 | mov ebx, 134 shl 16 + 35 + 6*18 |
4845 | hidnplayr | 378 | mov ecx, 0xc0000000 |
379 | mov edi, 0x00f3f3f3 |
||
380 | mcall 4 |
||
381 | |||
5586 | hidnplayr | 382 | ; speed tx |
3545 | hidnplayr | 383 | mov ebx, 0x000a0000 |
384 | pop ecx |
||
5586 | hidnplayr | 385 | mov edx, 134 shl 16 + 35 + 5*18 |
3545 | hidnplayr | 386 | mov esi, 0x40000000 |
387 | mcall 47 |
||
388 | |||
5586 | hidnplayr | 389 | ; speed rx |
3601 | hidnplayr | 390 | sub edx, 18 |
3545 | hidnplayr | 391 | pop ecx |
392 | mcall |
||
393 | |||
5586 | hidnplayr | 394 | ; bytes received |
3545 | hidnplayr | 395 | sub edx, 18 |
396 | pop ecx |
||
397 | mcall |
||
398 | |||
5586 | hidnplayr | 399 | ; bytes sent |
3545 | hidnplayr | 400 | sub edx, 18 |
401 | pop ecx |
||
402 | mcall |
||
403 | |||
5586 | hidnplayr | 404 | ; packets received |
405 | sub edx, 18 |
||
406 | pop ecx |
||
407 | mcall |
||
408 | |||
409 | ; packets sent |
||
410 | sub edx, 18 |
||
411 | pop ecx |
||
412 | mcall |
||
413 | |||
3545 | hidnplayr | 414 | jmp mainloop |
415 | |||
416 | |||
417 | not_101: |
||
418 | |||
419 | cmp [mode], 102 |
||
420 | jne not_102 |
||
421 | |||
422 | mov ebx, API_IPv4 |
||
423 | mov bh, [device] |
||
424 | push ebx |
||
425 | mcall 76 |
||
426 | pop ebx |
||
427 | push eax |
||
428 | |||
429 | inc bl |
||
430 | push ebx |
||
431 | mcall 76 |
||
432 | pop ebx |
||
433 | push eax |
||
434 | |||
435 | |||
436 | mov ebx, 0x000a0000 |
||
437 | pop ecx |
||
4740 | hidnplayr | 438 | mov edx, 134 shl 16 + 35 + 18 |
3545 | hidnplayr | 439 | mov esi, 0x40000000 |
4736 | leency | 440 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 441 | mcall 47 |
442 | |||
443 | sub edx, 18 |
||
444 | pop ecx |
||
445 | mcall |
||
446 | |||
447 | jmp mainloop |
||
448 | |||
449 | |||
450 | not_102: |
||
451 | |||
452 | cmp [mode], 103 |
||
453 | jne not_103 |
||
454 | |||
455 | mov ebx, API_ARP |
||
456 | mov bh, [device] |
||
457 | push ebx |
||
3641 | hidnplayr | 458 | mcall 76 ; tx |
3545 | hidnplayr | 459 | pop ebx |
460 | push eax |
||
461 | |||
462 | inc bl |
||
463 | push ebx |
||
3641 | hidnplayr | 464 | mcall 76 ; rx |
3545 | hidnplayr | 465 | pop ebx |
466 | push eax |
||
467 | |||
468 | inc bl |
||
469 | push ebx |
||
3641 | hidnplayr | 470 | mcall 76 ; entries |
3545 | hidnplayr | 471 | pop ebx |
472 | push eax |
||
473 | |||
474 | mov bl, 7 |
||
475 | push ebx |
||
476 | mcall 76 |
||
477 | pop ebx |
||
478 | push eax |
||
479 | |||
480 | mov ebx, 0x000a0000 |
||
481 | pop ecx |
||
4740 | hidnplayr | 482 | mov edx, 134 shl 16 + 35 + 3*18 |
3545 | hidnplayr | 483 | mov esi, 0x40000000 |
4736 | leency | 484 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 485 | mcall 47 |
486 | |||
487 | sub edx, 18 |
||
488 | pop ecx |
||
489 | mcall |
||
490 | |||
491 | sub edx, 18 |
||
492 | pop ecx |
||
493 | mcall |
||
494 | |||
495 | sub edx, 18 |
||
496 | pop ecx |
||
497 | mcall |
||
498 | |||
3618 | hidnplayr | 499 | ; mov edx, 50 shl 16 + 150 |
3601 | hidnplayr | 500 | mov [last], 0 |
501 | |||
502 | .arp_loop: |
||
3641 | hidnplayr | 503 | mov ebx, API_ARP + 3 ; read ARP entry |
3601 | hidnplayr | 504 | mov bh, [device] |
3641 | hidnplayr | 505 | mcall 76, ,[last], , , arp_buf |
3601 | hidnplayr | 506 | cmp eax, -1 |
507 | je mainloop |
||
508 | |||
3641 | hidnplayr | 509 | mov ebx, [last] |
510 | imul ebx, 16 |
||
511 | add ebx, 8 shl 16 + 140 |
||
512 | mcall 4, , 0x80000000, str_ARP_entry |
||
3601 | hidnplayr | 513 | mov edx, ebx |
514 | |||
515 | mov eax, 47 |
||
516 | mov ebx, 0x00030000 |
||
517 | mov esi, 0x40000000 |
||
4736 | leency | 518 | mov edi, 0x00F3F3F3 |
3601 | hidnplayr | 519 | xor ecx, ecx |
520 | |||
521 | mov cl, byte[arp_buf.IP+0] |
||
522 | mcall |
||
523 | |||
524 | mov cl, byte[arp_buf.IP+1] |
||
525 | add edx, 24 shl 16 |
||
526 | mcall |
||
527 | |||
528 | mov cl, byte[arp_buf.IP+2] |
||
529 | add edx, 24 shl 16 |
||
530 | mcall |
||
531 | |||
532 | mov cl, byte[arp_buf.IP+3] |
||
533 | add edx, 24 shl 16 |
||
534 | mcall |
||
535 | |||
536 | |||
537 | mov ebx, 0x00020100 |
||
538 | mov cl, byte[arp_buf.MAC+0] |
||
539 | add edx, 36 shl 16 |
||
540 | mcall |
||
541 | |||
542 | mov cl, byte[arp_buf.MAC+1] |
||
543 | add edx, 18 shl 16 |
||
544 | mcall |
||
545 | |||
546 | mov cl, byte[arp_buf.MAC+2] |
||
547 | add edx, 18 shl 16 |
||
548 | mcall |
||
549 | |||
550 | mov cl, byte[arp_buf.MAC+3] |
||
551 | add edx, 18 shl 16 |
||
552 | mcall |
||
553 | |||
554 | mov cl, byte[arp_buf.MAC+4] |
||
555 | add edx, 18 shl 16 |
||
556 | mcall |
||
557 | |||
558 | mov cl, byte[arp_buf.MAC+5] |
||
559 | add edx, 18 shl 16 |
||
560 | mcall |
||
561 | |||
562 | mov ebx, 0x00040000 |
||
563 | mov cx, [arp_buf.status] |
||
564 | add edx, 30 shl 16 |
||
565 | mcall |
||
566 | |||
567 | mov cx, [arp_buf.TTL] |
||
568 | add edx, 60 shl 16 |
||
569 | mcall |
||
570 | |||
571 | add dx, 18 |
||
572 | rol edx, 16 |
||
573 | mov dx, 8 |
||
574 | rol edx, 16 |
||
575 | inc [last] |
||
576 | |||
577 | jmp .arp_loop |
||
578 | |||
3545 | hidnplayr | 579 | not_103: |
580 | |||
581 | cmp [mode], 104 |
||
582 | jne not_104 |
||
583 | |||
584 | mov ebx, API_ICMP |
||
585 | mov bh, [device] |
||
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 | |||
597 | mov ebx, 0x000a0000 |
||
598 | pop ecx |
||
4740 | hidnplayr | 599 | mov edx, 134 shl 16 + 35 + 18 |
3545 | hidnplayr | 600 | mov esi, 0x40000000 |
4736 | leency | 601 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 602 | mcall 47 |
603 | |||
604 | sub edx, 18 |
||
605 | pop ecx |
||
606 | mcall |
||
607 | |||
608 | jmp mainloop |
||
609 | |||
610 | not_104: |
||
611 | |||
612 | cmp [mode], 105 |
||
613 | jne not_105 |
||
614 | |||
615 | mov ebx, API_UDP |
||
616 | mov bh, [device] |
||
617 | push ebx |
||
618 | mcall 76 |
||
619 | pop ebx |
||
620 | push eax |
||
621 | |||
622 | inc bl |
||
623 | push ebx |
||
624 | mcall 76 |
||
625 | pop ebx |
||
626 | push eax |
||
627 | |||
628 | mov ebx, 0x000a0000 |
||
629 | pop ecx |
||
4740 | hidnplayr | 630 | mov edx, 134 shl 16 + 35 + 18 |
3545 | hidnplayr | 631 | mov esi, 0x40000000 |
4736 | leency | 632 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 633 | mcall 47 |
634 | |||
635 | sub edx, 18 |
||
636 | pop ecx |
||
637 | mcall |
||
638 | |||
639 | jmp mainloop |
||
640 | |||
641 | not_105: |
||
642 | |||
643 | cmp [mode], 106 |
||
644 | jne not_106 |
||
645 | |||
646 | mov ebx, API_TCP |
||
647 | mov bh, [device] |
||
648 | push ebx |
||
649 | mcall 76 |
||
650 | pop ebx |
||
651 | push eax |
||
652 | |||
653 | inc bl |
||
654 | push ebx |
||
655 | mcall 76 |
||
656 | pop ebx |
||
657 | push eax |
||
658 | |||
659 | inc bl |
||
660 | push ebx |
||
661 | mcall 76 |
||
662 | pop ebx |
||
663 | push eax |
||
664 | |||
665 | inc bl |
||
666 | push ebx |
||
667 | mcall 76 |
||
668 | pop ebx |
||
669 | push eax |
||
670 | |||
5016 | hidnplayr | 671 | inc bl |
672 | push ebx |
||
673 | mcall 76 |
||
674 | pop ebx |
||
675 | push eax |
||
676 | |||
3545 | hidnplayr | 677 | mov ebx, 0x000a0000 |
678 | pop ecx |
||
5016 | hidnplayr | 679 | mov edx, 134 shl 16 + 35 + 18*4 |
3545 | hidnplayr | 680 | mov esi, 0x40000000 |
4736 | leency | 681 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 682 | mcall 47 |
683 | |||
684 | sub edx, 18 |
||
685 | pop ecx |
||
686 | mcall |
||
687 | |||
688 | sub edx, 18 |
||
689 | pop ecx |
||
690 | mcall |
||
691 | |||
692 | sub edx, 18 |
||
693 | pop ecx |
||
694 | mcall |
||
695 | |||
5016 | hidnplayr | 696 | sub edx, 18 |
697 | pop ecx |
||
698 | mcall |
||
699 | |||
3545 | hidnplayr | 700 | jmp mainloop |
701 | |||
702 | not_106: |
||
703 | |||
704 | mainloop: |
||
705 | |||
706 | mcall 23, 50 ; wait for event with timeout (0,5 s) |
||
707 | |||
4742 | hidnplayr | 708 | cmp eax, EV_REDRAW |
4736 | leency | 709 | je window_redraw |
4742 | hidnplayr | 710 | cmp eax, EV_BUTTON |
3545 | hidnplayr | 711 | je button |
4742 | hidnplayr | 712 | cmp eax, EV_KEY |
713 | je key |
||
3545 | hidnplayr | 714 | cmp eax, 11 |
715 | je redraw |
||
716 | |||
717 | jmp draw_stats |
||
718 | |||
719 | button: ; button |
||
720 | mcall 17 ; get id |
||
721 | cmp ah, 1 |
||
722 | je exit |
||
5586 | hidnplayr | 723 | cmp ah, 2 |
724 | je .ipcfg |
||
3545 | hidnplayr | 725 | cmp ah, 0 |
726 | je .interface |
||
4781 | hidnplayr | 727 | shr ax, 8 |
728 | mov [mode], ax |
||
3545 | hidnplayr | 729 | jmp redraw |
730 | |||
5586 | hidnplayr | 731 | .ipcfg: |
732 | mcall 51, 1, ipcfg, I_END+0x1000 |
||
733 | jmp mainloop |
||
734 | |||
3545 | hidnplayr | 735 | .interface: |
736 | shr eax, 16 |
||
737 | mov [device], al |
||
738 | jmp redraw |
||
739 | |||
4742 | hidnplayr | 740 | key: |
741 | mcall 2 |
||
742 | cmp ah, 9 |
||
743 | je .tab |
||
744 | cmp ah, 183 |
||
745 | je .pgdown |
||
746 | cmp ah, 184 |
||
747 | je .pgup |
||
748 | jmp mainloop |
||
749 | |||
750 | .tab: |
||
751 | inc [mode] |
||
752 | cmp [mode], 106 |
||
753 | jbe redraw |
||
754 | mov [mode], 101 |
||
755 | jmp redraw |
||
756 | |||
757 | .pgdown: |
||
758 | inc [device] |
||
759 | mov al, [device] |
||
760 | cmp al, [last_device] |
||
761 | jbe redraw |
||
762 | mov [device], 0 |
||
763 | jmp redraw |
||
764 | |||
765 | .pgup: |
||
766 | dec [device] |
||
767 | cmp [device], 0 |
||
768 | jge redraw |
||
769 | mov al, [last_device] |
||
770 | mov [device], al |
||
771 | jmp redraw |
||
772 | |||
3545 | hidnplayr | 773 | exit: |
774 | mcall -1 |
||
775 | |||
776 | |||
777 | |||
778 | draw_mac: |
||
779 | |||
780 | mov eax, 47 |
||
781 | mov ebx, 0x00020100 |
||
782 | mov esi, 0x40000000 |
||
4736 | leency | 783 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 784 | |
785 | mov cl, [esp+4] |
||
786 | mcall |
||
787 | |||
788 | mov cl, [esp+4+1] |
||
4740 | hidnplayr | 789 | add edx, 18 shl 16 |
3545 | hidnplayr | 790 | mcall |
791 | |||
792 | mov cl, [esp+4+2] |
||
4740 | hidnplayr | 793 | add edx, 18 shl 16 |
3545 | hidnplayr | 794 | mcall |
795 | |||
796 | mov cl, [esp+4+3] |
||
4740 | hidnplayr | 797 | add edx, 18 shl 16 |
3545 | hidnplayr | 798 | mcall |
799 | |||
800 | mov cl, [esp+4+4] |
||
4740 | hidnplayr | 801 | add edx, 18 shl 16 |
3545 | hidnplayr | 802 | mcall |
803 | |||
804 | mov cl, [esp+4+5] |
||
4740 | hidnplayr | 805 | add edx, 18 shl 16 |
3545 | hidnplayr | 806 | mcall |
807 | |||
4740 | hidnplayr | 808 | sub edx, 5*18 shl 16 |
3545 | hidnplayr | 809 | |
810 | ret 6 |
||
811 | |||
812 | |||
813 | draw_ip: |
||
814 | |||
815 | mov eax, 47 |
||
816 | mov ebx, 0x00030000 |
||
817 | mov esi, 0x40000000 |
||
4736 | leency | 818 | mov edi, 0x00F3F3F3 |
3545 | hidnplayr | 819 | |
820 | xor ecx, ecx |
||
821 | |||
822 | mov cl, [esp+4] |
||
823 | mcall |
||
824 | |||
825 | mov cl, [esp+4+1] |
||
4740 | hidnplayr | 826 | add edx, 24 shl 16 |
3545 | hidnplayr | 827 | mcall |
828 | |||
829 | mov cl, [esp+4+2] |
||
4740 | hidnplayr | 830 | add edx, 24 shl 16 |
3545 | hidnplayr | 831 | mcall |
832 | |||
833 | mov cl, [esp+4+3] |
||
4740 | hidnplayr | 834 | add edx, 24 shl 16 |
3545 | hidnplayr | 835 | mcall |
836 | |||
4740 | hidnplayr | 837 | sub edx, 3*24 shl 16 |
3545 | hidnplayr | 838 | ret 4 |
839 | |||
840 | |||
841 | draw_interfaces: |
||
842 | |||
3601 | hidnplayr | 843 | mov [.btnpos], 5 shl 16 + 20 |
4798 | hidnplayr | 844 | mov [.txtpos], 405 shl 16 + 12 |
3545 | hidnplayr | 845 | |
846 | mcall 74, -1 ; get number of active network devices |
||
847 | mov ecx, eax |
||
4742 | hidnplayr | 848 | dec al |
849 | mov [last_device], al |
||
5250 | hidnplayr | 850 | cmp [device], al |
851 | jbe @f |
||
852 | mov [device], 0 |
||
853 | @@: |
||
3545 | hidnplayr | 854 | |
855 | xor ebx, ebx ; get device type |
||
856 | .loop: |
||
857 | mcall 74 |
||
3601 | hidnplayr | 858 | cmp eax, 1 ; loopback or ethernet? |
859 | jbe .hit |
||
3545 | hidnplayr | 860 | inc bh |
861 | jb .loop ; tried all 256? |
||
862 | ret |
||
863 | |||
864 | |||
865 | .hit: |
||
866 | push ecx ebx |
||
867 | movzx edx, bh |
||
868 | shl edx, 8 |
||
4736 | leency | 869 | mov esi, 0x00BBBbbb |
3545 | hidnplayr | 870 | cmp bh, [device] |
4736 | leency | 871 | cmove esi, 0x0081BBFF |
4798 | hidnplayr | 872 | mcall 8, 400 shl 16 + 185, [.btnpos] |
3545 | hidnplayr | 873 | mov ebx, [esp] |
874 | inc bl |
||
875 | mov ecx, namebuf |
||
876 | mov edx, namebuf |
||
3601 | hidnplayr | 877 | mcall 74 ; get device name |
3545 | hidnplayr | 878 | cmp eax, -1 |
879 | jne @f |
||
880 | mov edx, str_unknown |
||
881 | @@: |
||
3601 | hidnplayr | 882 | mcall 4, [.txtpos], 0x80000000 ; print the name |
3545 | hidnplayr | 883 | pop ebx ecx |
884 | |||
885 | inc bh |
||
886 | |||
887 | add [.btnpos], 25 shl 16 |
||
888 | add [.txtpos], 25 |
||
889 | |||
890 | dec ecx |
||
891 | jnz .loop |
||
892 | |||
893 | ret |
||
894 | |||
895 | .btnpos dd ? |
||
896 | .txtpos dd ? |
||
897 | |||
898 | |||
899 | ; DATA AREA |
||
900 | |||
5586 | hidnplayr | 901 | align 16 |
902 | @IMPORT: |
||
903 | |||
904 | library box_lib , 'box_lib.obj', \ |
||
905 | libini , 'libini.obj' |
||
906 | |||
907 | import libini, \ |
||
908 | ini.get_str , 'ini_get_str' ,\ |
||
909 | ini.set_str , 'ini_set_str' ,\ |
||
910 | ini.enum_sections, 'ini_enum_sections' |
||
911 | |||
912 | import box_lib ,\ |
||
913 | edit_box_draw , 'edit_box' ,\ |
||
914 | edit_box_key , 'edit_box_key' ,\ |
||
915 | edit_box_mouse , 'edit_box_mouse' ,\ |
||
916 | edit_set_text , 'edit_box_set_text' ,\ |
||
917 | version_ed , 'version_ed' ,\ |
||
918 | init_checkbox , 'init_checkbox2' ,\ |
||
919 | check_box_draw , 'check_box_draw2' ,\ |
||
920 | check_box_mouse , 'check_box_mouse2' ,\ |
||
921 | version_ch , 'version_ch2' ,\ |
||
922 | option_box_draw , 'option_box_draw' ,\ |
||
923 | option_box_mouse, 'option_box_mouse' ,\ |
||
924 | version_op , 'version_op' |
||
925 | |||
4742 | hidnplayr | 926 | name db 'Network status', 0 |
5250 | hidnplayr | 927 | mode dw 101 ; currently selected protocol |
928 | device db 1 ; currently selected device |
||
929 | last_device db ? ; last device available |
||
930 | device_type dd ? |
||
931 | last dd ? |
||
4798 | hidnplayr | 932 | modes db 'Physical IPv4 ARP ICMP UDP TCP', 0 |
3545 | hidnplayr | 933 | |
934 | str_packets_tx db 'Packets sent:', 0 |
||
935 | str_packets_rx db 'Packets received:', 0 |
||
936 | str_bytes_tx db 'Bytes sent:', 0 |
||
937 | str_bytes_rx db 'Bytes received:', 0 |
||
4740 | hidnplayr | 938 | str_MAC db 'MAC address: - - - - -', 0 |
939 | str_ip db 'IP address: . . .', 0 |
||
940 | str_dns db 'DNS address: . . .', 0 |
||
941 | str_subnet db 'Subnet mask: . . .', 0 |
||
942 | str_gateway db 'Standard gateway: . . .', 0 |
||
3545 | hidnplayr | 943 | str_arp db 'ARP entrys:', 0 |
944 | str_conflicts db 'ARP conflicts:', 0 |
||
5586 | hidnplayr | 945 | str_missed db 'Packets missed:', 0 |
946 | str_dumped db 'Packets dumped:', 0 |
||
947 | str_queued db 'Packets queued:', 0 |
||
948 | str_link db 'Link state:', 0 |
||
949 | str_speed_tx db 'Upload (kb/s):', 0 |
||
950 | str_speed_rx db 'Download (kb/s):', 0 |
||
951 | str_ip_cfg db 'Configure' |
||
952 | .len = $ - str_ip_cfg |
||
3545 | hidnplayr | 953 | |
5498 | hidnplayr | 954 | str_down db 'disconnected ', 0 |
955 | str_unknown db 'unknown ', 0 |
||
956 | str_10m db '10 Mbit Half duplex ', 0 |
||
957 | str_10mfd db '10 Mbit Full duplex ', 0 |
||
4845 | hidnplayr | 958 | str_100m db '100 Mbit Half duplex', 0 |
959 | str_100mfd db '100 Mbit Full duplex', 0 |
||
5498 | hidnplayr | 960 | str_1g db '1 Gbit Half duplex ', 0 |
961 | str_1gfd db '1 Gbit Full duplex ', 0 |
||
4845 | hidnplayr | 962 | |
3601 | hidnplayr | 963 | str_ARP_legend db 'IP-address MAC-address Status TTL', 0 |
4740 | hidnplayr | 964 | str_ARP_entry db ' . . . - - - - -', 0 |
3601 | hidnplayr | 965 | |
5586 | hidnplayr | 966 | prev_rx dd ? |
967 | prev_tx dd ? |
||
968 | time dd ? |
||
969 | delta_time dd ? |
||
970 | |||
3545 | hidnplayr | 971 | namebuf rb 64 |
3601 | hidnplayr | 972 | arp_buf ARP_entry |
3545 | hidnplayr | 973 | |
5586 | hidnplayr | 974 | sc system_colors |
975 | |||
4742 | hidnplayr | 976 | I_END: |