Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

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