Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1171 hidnplayr 1
;
1192 hidnplayr 2
; Netstat for KolibriOS v0.1  (still alpha version)
1171 hidnplayr 3
;
4
; hidnplayr@gmail.com
5
;
6
 
7
use32
8
 
9
    org     0x0
10
 
11
    db	   'MENUET01'	     ; 8 byte id
12
    dd	   0x01 	     ; header version
13
    dd	   START	     ; start of code
1528 hidnplayr 14
    dd	   I_END	     ; size of image
1192 hidnplayr 15
    dd	   (I_END+0x100)     ; memory for app
16
    dd	   (I_END+0x100)     ; esp
17
    dd	   I_PARAM , 0x0     ; I_Param , I_Icon
1171 hidnplayr 18
 
19
__DEBUG__ equ 1
20
__DEBUG_LEVEL__ equ 1
21
 
22
include '..\macros.inc'
23
include '..\debug-fdo.inc'
24
 
25
START:				       ; start of execution
26
    ; TODO: check Parameters
27
 
1528 hidnplayr 28
    DEBUGF  1, 'Netstat application loaded!\n'
1171 hidnplayr 29
 
30
  redraw:
31
    mcall   12, 1
32
 
1528 hidnplayr 33
    mcall   0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc , , name
1171 hidnplayr 34
 
35
    mov     edx, 101
36
    mov     esi, 0x00aaaaff
37
    mov     edi, 0x00aaffff
38
 
39
    cmp     dl, [mode]
40
    cmove   esi, edi
41
    mcall   8, 25 shl 16 + 65, 25 shl 16 + 20
42
 
1528 hidnplayr 43
  .morebuttons:
1171 hidnplayr 44
    inc     edx
45
    add     ebx, 75 shl 16
46
    mov     esi, 0x00aaaaff
47
 
48
    cmp     dl, [mode]
49
    cmove   esi, edi
50
    mcall
51
 
52
    cmp     edx, 105
1528 hidnplayr 53
    jle     .morebuttons
1171 hidnplayr 54
 
55
    mcall   4, 28 shl 16 + 31, 0x80000000, modes
56
 
57
    cmp     [mode], 101
1528 hidnplayr 58
    jne     .no_eth
1171 hidnplayr 59
 
60
    mcall   4, 20 shl 16 + 75, 0x80000000, str_packets_tx
61
    add     ebx, 18
62
    mov     edx, str_packets_rx
63
    mcall
64
    add     ebx, 18
65
    mov     edx, str_bytes_tx
66
    mcall
67
    add     ebx, 18
68
    mov     edx, str_bytes_rx
69
    mcall
70
    add     ebx, 18
71
    mov     edx, str_MAC
72
    mcall
73
    add     ebx, 18
74
    mov     edx, str_queue_in
75
    mcall
76
    add     ebx, 18
77
    mov     edx, str_queue_out
78
    mcall
79
 
80
    mov     ebx,1337 shl 16 + 4
81
    mov     bh, [device]
2364 hidnplayr 82
    mcall   76
1171 hidnplayr 83
    push    eax
84
    push    bx
85
 
86
    mov     edx, 135 shl 16 + 75 + 4*18
1192 hidnplayr 87
    call    draw_mac
88
    jmp     end_of_draw
1171 hidnplayr 89
 
1528 hidnplayr 90
 .no_eth:
1171 hidnplayr 91
 
92
    cmp     [mode], 102
1528 hidnplayr 93
    jne     .no_ip
1171 hidnplayr 94
 
95
    mcall   4, 20 shl 16 + 75, 0x80000000, str_packets_tx
96
    add     ebx, 18
97
    mov     edx, str_packets_rx
98
    mcall
99
    add     ebx, 18
100
    mov     edx, str_ip
101
    mcall
102
    add     ebx, 18
103
    mov     edx, str_dns
104
    mcall
105
    add     ebx, 18
106
    mov     edx, str_subnet
107
    mcall
108
    add     ebx, 18
109
    mov     edx, str_gateway
110
    mcall
111
 
112
 
113
    mov     ebx, 0 shl 16 + 8
114
    mov     bh, [device]
2364 hidnplayr 115
    mcall   76
1171 hidnplayr 116
    push    eax
117
 
118
    dec     bl
119
    dec     bl
2364 hidnplayr 120
    mcall   76
1171 hidnplayr 121
    push    eax
122
 
123
    dec     bl
124
    dec     bl
2364 hidnplayr 125
    mcall   76
1171 hidnplayr 126
    push    eax
127
 
128
    dec     bl
129
    dec     bl
2364 hidnplayr 130
    mcall   76
1171 hidnplayr 131
    push    eax
132
 
133
    mov     edx, 135 shl 16 + 75 + 2*18
134
    call    draw_ip
135
 
136
    add     edx, 18
137
    call    draw_ip
138
 
139
    add     edx, 18
140
    call    draw_ip
141
 
142
    add     edx, 18
143
    call    draw_ip
144
 
145
    jmp     end_of_draw
146
 
1528 hidnplayr 147
 .no_ip:
1171 hidnplayr 148
 
149
    cmp     [mode], 103
1528 hidnplayr 150
    jne     .no_arp
1171 hidnplayr 151
 
152
    mcall   4, 20 shl 16 + 75, 0x80000000, str_packets_tx
153
    add     ebx, 18
154
    mov     edx, str_packets_rx
155
    mcall
156
    add     ebx, 18
157
    mov     edx, str_arp
158
    mcall
159
 
160
    jmp     end_of_draw
161
 
1528 hidnplayr 162
 .no_arp:
1171 hidnplayr 163
 
164
    mcall   4, 20 shl 16 + 75, 0x80000000, str_packets_tx
165
    add     ebx, 18
166
    mov     edx, str_packets_rx
167
    mcall
168
 
169
 end_of_draw:
170
 
171
    mcall   12, 2
172
 
173
    jmp     draw_stats
174
 
175
  mainloop:
176
 
1528 hidnplayr 177
    mcall   23,500		    ; wait for event with timeout    (0,5 s)
1171 hidnplayr 178
 
179
    cmp     eax, 1
180
    je	    redraw
181
    cmp     eax, 2
182
    je	    key
183
    cmp     eax, 3
184
    je	    button
185
 
186
 
187
 
188
 
189
;-------------------------------
190
;
191
;------------------------------
192
 
193
  draw_stats:
194
 
195
    cmp     [mode], 101
196
    jne     not_101
197
 
198
    mov     ebx, 1337 shl 16 + 0
199
    mov     bh, [device]
200
   @@:
1192 hidnplayr 201
    push    ebx
2364 hidnplayr 202
    mcall   76
1192 hidnplayr 203
    pop     ebx
1171 hidnplayr 204
    push    eax
205
    inc     bl
206
    cmp     bl, 3
207
    jle     @r
208
 
1192 hidnplayr 209
    inc     bl	 ;5
210
    inc     bl	 ;6
1171 hidnplayr 211
 
212
   @@:
1192 hidnplayr 213
    push    ebx
2364 hidnplayr 214
    mcall   76
1192 hidnplayr 215
    pop     ebx
1171 hidnplayr 216
    push    eax
217
    inc     bl
218
    cmp     bl, 7
219
    jle     @r
220
 
221
    mov     eax, 47
222
    mov     ebx, 0x000a0000
223
    mov     esi, 0x40000000
224
    mov     edi, 0x00bcbcbc
225
    mov     edx, 135 shl 16 + 75 + 6*18
226
    pop     ecx
227
    mcall
228
    sub     edx, 18
229
    pop     ecx
230
    mcall
231
    sub     edx, 2*18
232
    pop     ecx
233
    mcall
234
    sub     edx, 18
235
    pop     ecx
236
    mcall
237
    sub     edx, 18
238
    pop     ecx
239
    mcall
240
    sub     edx, 18
241
    pop     ecx
242
    mcall
243
 
244
    jmp     mainloop
245
 
246
 
247
 not_101:
248
 
249
    cmp     [mode], 102
250
    jne     not_102
251
 
252
    mov     ebx, 0 shl 16
253
    mov     bh, [device]
1192 hidnplayr 254
    push    ebx
2364 hidnplayr 255
    mcall   76
1192 hidnplayr 256
    pop     ebx
1171 hidnplayr 257
    push    eax
258
    inc     bl
1192 hidnplayr 259
    push    ebx
2364 hidnplayr 260
    mcall   76
1192 hidnplayr 261
    pop     ebx
1171 hidnplayr 262
    push    eax
263
    inc     bl
264
 
265
    mov     eax, 47
266
    mov     ebx, 0x000a0000
267
    mov     esi, 0x40000000
268
    mov     edi, 0x00bcbcbc
269
    mov     edx, 135 shl 16 + 75 + 18
270
    pop     ecx
271
    mcall
272
    sub     edx, 18
273
    pop     ecx
274
    mcall
275
 
276
    jmp     mainloop
277
 
278
 
279
 not_102:
280
 
281
    cmp     [mode], 103
282
    jne     not_103
283
 
284
    mov     ebx, 0x0608 shl 16 + 0
285
    mov     bh, [device]
1192 hidnplayr 286
    push    ebx
2364 hidnplayr 287
    mcall   76
1192 hidnplayr 288
    pop     ebx
1171 hidnplayr 289
    push    eax
290
    inc     bl
1192 hidnplayr 291
    push    ebx
2364 hidnplayr 292
    mcall   76
1192 hidnplayr 293
    pop     ebx
1171 hidnplayr 294
    push    eax
295
    inc     bl
1192 hidnplayr 296
    push    ebx
2364 hidnplayr 297
    mcall   76
1192 hidnplayr 298
    pop     ebx
1171 hidnplayr 299
    push    eax
300
    inc     bl
301
 
302
    mov     eax, 47
303
    mov     ebx, 0x000a0000
304
    mov     esi, 0x40000000
305
    mov     edi, 0x00bcbcbc
306
    mov     edx, 135 shl 16 + 75 + 2*18
307
    pop     ecx
308
    mcall
309
    sub     edx, 18
310
    pop     ecx
311
    mcall
312
    sub     edx, 18
313
    pop     ecx
314
    mcall
315
 
316
    jmp     mainloop
317
 
318
not_103:
319
 
320
    cmp     [mode], 104
321
    jne     not_104
322
 
323
    mov     ebx, 1 shl 16 + 0
324
    mov     bh, [device]
1192 hidnplayr 325
    push    ebx
2364 hidnplayr 326
    mcall   76
1192 hidnplayr 327
    pop     ebx
1171 hidnplayr 328
    push    eax
329
    inc     bl
1192 hidnplayr 330
    push    ebx
2364 hidnplayr 331
    mcall   76
1192 hidnplayr 332
    pop     ebx
1171 hidnplayr 333
    push    eax
334
    inc     bl
335
 
336
    mov     eax, 47
337
    mov     ebx, 0x000a0000
338
    mov     esi, 0x40000000
339
    mov     edi, 0x00bcbcbc
340
    mov     edx, 135 shl 16 + 75 + 18
341
    pop     ecx
342
    mcall
343
    sub     edx, 18
344
    pop     ecx
345
    mcall
346
 
347
    jmp     mainloop
348
 
349
not_104:
350
 
351
    cmp     [mode], 105
352
    jne     not_105
353
 
354
    mov     ebx, 17 shl 16 + 0
355
    mov     bh, [device]
1192 hidnplayr 356
    push    ebx
2364 hidnplayr 357
    mcall   76
1192 hidnplayr 358
    pop     ebx
1171 hidnplayr 359
    push    eax
360
    inc     bl
1192 hidnplayr 361
    push    ebx
2364 hidnplayr 362
    mcall   76
1192 hidnplayr 363
    pop     ebx
1171 hidnplayr 364
    push    eax
365
    inc     bl
366
 
367
    mov     eax, 47
368
    mov     ebx, 0x000a0000
369
    mov     esi, 0x40000000
370
    mov     edi, 0x00bcbcbc
371
    mov     edx, 135 shl 16 + 75 + 18
372
    pop     ecx
373
    mcall
374
    sub     edx, 18
375
    pop     ecx
376
    mcall
377
 
378
    jmp     mainloop
379
 
380
not_105:
381
 
382
    cmp     [mode], 106
383
    jne     not_106
384
 
385
    mov     ebx, 6 shl 16 + 0
386
    mov     bh, [device]
1192 hidnplayr 387
    push    ebx
2364 hidnplayr 388
    mcall   76
1192 hidnplayr 389
    pop     ebx
1171 hidnplayr 390
    push    eax
391
    inc     bl
1192 hidnplayr 392
    push    ebx
2364 hidnplayr 393
    mcall   76
1192 hidnplayr 394
    pop     ebx
1171 hidnplayr 395
    push    eax
396
    inc     bl
397
 
398
    mov     eax, 47
399
    mov     ebx, 0x000a0000
400
    mov     esi, 0x40000000
401
    mov     edi, 0x00bcbcbc
402
    mov     edx, 135 shl 16 + 75 + 18
403
    pop     ecx
404
    mcall
405
    sub     edx, 18
406
    pop     ecx
407
    mcall
408
 
409
    jmp     mainloop
410
 
411
not_106:
412
 
413
    jmp     mainloop
414
 
415
  key:
416
    mcall   2
417
    jmp     mainloop
418
 
419
 
420
  button:			  ; button
421
    mcall   17			  ; get id
422
    cmp     ah, 1
423
    je	    close
424
    mov     [mode], ah
425
    jmp     redraw
426
 
427
  close:
428
    mcall   -1
429
 
430
 
431
 
432
draw_mac:
433
 
434
	mov	eax, 47
435
	mov	ebx, 0x00020100
436
	mov	esi, 0x40000000
437
	mov	edi, 0x00bcbcbc
438
 
1192 hidnplayr 439
	mov	cl, [esp+4]
1171 hidnplayr 440
	mcall
441
 
1192 hidnplayr 442
	mov	cl, [esp+4+1]
1171 hidnplayr 443
	add	edx, 15 shl 16
444
	mcall
445
 
1192 hidnplayr 446
	mov	cl, [esp+4+2]
1171 hidnplayr 447
	add	edx, 15 shl 16
448
	mcall
449
 
1192 hidnplayr 450
	mov	cl, [esp+4+3]
1171 hidnplayr 451
	add	edx, 15 shl 16
452
	mcall
453
 
1192 hidnplayr 454
	mov	cl, [esp+4+4]
1171 hidnplayr 455
	add	edx, 15 shl 16
456
	mcall
457
 
1192 hidnplayr 458
	mov	cl, [esp+4+5]
1171 hidnplayr 459
	add	edx, 15 shl 16
460
	mcall
461
 
462
	sub	edx, 5*15 shl 16
463
 
1528 hidnplayr 464
	ret	6
1171 hidnplayr 465
 
466
 
467
draw_ip:
468
 
469
	mov	eax, 47
470
	mov	ebx, 0x00030000
471
	mov	esi, 0x40000000
472
	mov	edi, 0x00bcbcbc
473
 
474
	xor	ecx, ecx
475
 
476
	mov	cl, [esp+4]
477
	mcall
478
 
479
	mov	cl, [esp+4+1]
480
	add	edx, 30 shl 16
481
	mcall
482
 
483
	mov	cl, [esp+4+2]
484
	add	edx, 30 shl 16
485
	mcall
486
 
487
	mov	cl, [esp+4+3]
488
	add	edx, 30 shl 16
489
	mcall
490
 
491
	sub	edx, 3*30 shl 16
1528 hidnplayr 492
	ret	4
1171 hidnplayr 493
 
494
 
495
; DATA AREA
496
 
497
name	db 'Netstat',0
498
mode	db 101
499
device	db 0
500
modes	db 'Ethernet        IPv4        ARP         ICMP         UDP         TCP',0
501
 
502
str_packets_tx db 'Packets sent:',0
503
str_packets_rx db 'Packets received:',0
504
str_bytes_tx   db 'Bytes sent:',0
505
str_bytes_rx   db 'Bytes received:',0
506
str_MAC        db 'MAC address:',0
507
str_queue_in   db 'IN-queue size:',0
508
str_queue_out  db 'OUT-queue size:',0
509
str_ip	       db 'IP address:',0
510
str_dns        db 'DNS address:',0
511
str_subnet     db 'Subnet mask:',0
512
str_gateway    db 'Standard gateway:',0
513
str_arp        db 'ARP entrys:',0
514
 
515
include_debug_strings	 ; ALWAYS present in data section
516
 
517
I_PARAM rb 1024
518
 
1192 hidnplayr 519
I_END:
1171 hidnplayr 520