Subversion Repositories Kolibri OS

Rev

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

  1. ;
  2. ; ARPmanager for KolibriOS
  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     IM_END            ; size of image
  15.     dd     (I_END+0x100)     ; memory for app
  16.     dd     (I_END+0x100)     ; 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.   redraw:
  31.  
  32.     mcall   12, 1
  33.  
  34.     mcall   0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, ,name
  35.  
  36.     mcall   4, 25 shl 16 + 31, 0x80000000, title
  37.  
  38. ;;    call    draw_stats
  39.  
  40.     mcall   12, 2
  41.  
  42.     jmp     draw_stats
  43.  
  44.   mainloop:
  45.  
  46.     mcall   23,50                  ; wait for event with timeout    (0,5 s)
  47.  
  48.     cmp     eax, 1
  49.     je      redraw
  50.     cmp     eax, 2
  51.     je      key
  52.     cmp     eax, 3
  53.     je      button
  54.  
  55.  
  56.   draw_stats:
  57.  
  58.         mov     edx, 50 shl 16 + 50
  59.  
  60.     .loop:
  61.         mcall   75, 0x06080003, [last],,,ARP_ENTRY
  62.         cmp     eax, -1
  63.         je      mainloop
  64.  
  65.  
  66.         mcall   4, edx, 0x80000000, str_entry
  67.         mov     edx, ebx
  68.  
  69.         mov     eax, 47
  70.         mov     ebx, 0x00030000
  71.         mov     esi, 0x40000000
  72.         mov     edi, 0x00bcbcbc
  73.         xor     ecx, ecx
  74.  
  75.         mov     cl, byte[ARP_ENTRY.IP+0]
  76.         mcall
  77.  
  78.         mov     cl, byte[ARP_ENTRY.IP+1]
  79.         add     edx, 24 shl 16
  80.         mcall
  81.  
  82.         mov     cl, byte[ARP_ENTRY.IP+2]
  83.         add     edx, 24 shl 16
  84.         mcall
  85.  
  86.         mov     cl, byte[ARP_ENTRY.IP+3]
  87.         add     edx, 24 shl 16
  88.         mcall
  89.  
  90.  
  91.         mov     ebx, 0x00020100
  92.         mov     cl, byte[ARP_ENTRY.MAC+0]
  93.         add     edx, 36 shl 16
  94.         mcall
  95.  
  96.         mov     cl, byte[ARP_ENTRY.MAC+1]
  97.         add     edx, 18 shl 16
  98.         mcall
  99.  
  100.         mov     cl, byte[ARP_ENTRY.MAC+2]
  101.         add     edx, 18 shl 16
  102.         mcall
  103.  
  104.         mov     cl, byte[ARP_ENTRY.MAC+3]
  105.         add     edx, 18 shl 16
  106.         mcall
  107.  
  108.         mov     cl, byte[ARP_ENTRY.MAC+4]
  109.         add     edx, 18 shl 16
  110.         mcall
  111.  
  112.         mov     cl, byte[ARP_ENTRY.MAC+5]
  113.         add     edx, 18 shl 16
  114.         mcall
  115.  
  116.         mov     ebx, 0x00040000
  117.         mov     cx, [ARP_ENTRY.Status]
  118.         add     edx, 30 shl 16
  119.         mcall
  120.  
  121.         mov     cx, [ARP_ENTRY.TTL]
  122.         add     edx, 60 shl 16
  123.         mcall
  124.  
  125.         add     dx, 20
  126.         rol     edx, 16
  127.         mov     dx, 50
  128.         rol     edx, 16
  129.         inc     [last]
  130.  
  131.         jmp     .loop
  132.  
  133.  
  134.   key:
  135.     mcall   2
  136.     jmp     mainloop
  137.  
  138.  
  139.   button:                         ; button
  140.     mcall   17                    ; get id
  141.     cmp     ah, 1
  142.     je      close
  143.     jmp     redraw
  144.  
  145.   close:
  146.     mcall   -1
  147.  
  148.  
  149.  
  150. ; DATA AREA
  151.  
  152. IM_END:
  153.  
  154. name    db 'ARP manager',0
  155.  
  156. title   db '#   IP-address        MAC-address         Status    TTL',0
  157. str_entry   db '   .   .   .        -  -  -  -  -                     s',0
  158.  
  159. last    dd 0
  160.  
  161.  
  162. ARP_ENTRY:
  163.        .IP              dd  192 shl 0 + 168 shl 8 + 1 shl 16 + 1 shl 24
  164.        .MAC             dp  0xdeadbeef1337
  165.        .Status          dw  0x0300
  166.        .TTL             dw  37
  167.        .size:
  168.  
  169. include_debug_strings    ; ALWAYS present in data section
  170.  
  171. I_PARAM rb 1024
  172.  
  173. I_END:
  174.  
  175.  
  176.