Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 1199 → Rev 1200

/kernel/branches/net/applications/arpcfg/arpcfg.asm
0,0 → 1,175
;
; ARPmanager for KolibriOS
;
; hidnplayr@gmail.com
;
 
use32
 
org 0x0
 
db 'MENUET01' ; 8 byte id
dd 0x01 ; header version
dd START ; start of code
dd IM_END ; size of image
dd (I_END+0x100) ; memory for app
dd (I_END+0x100) ; esp
dd I_PARAM , 0x0 ; I_Param , I_Icon
 
__DEBUG__ equ 1
__DEBUG_LEVEL__ equ 1
 
include '..\macros.inc'
include '..\debug-fdo.inc'
 
START: ; start of execution
; TODO: check Parameters
 
DEBUGF 1, 'Hello!\n'
 
redraw:
 
mcall 12, 1
 
mcall 0, 100 shl 16 + 520, 100 shl 16 + 240, 0x34bcbcbc, ,name
 
mcall 4, 25 shl 16 + 31, 0x80000000, title
 
;; call draw_stats
 
mcall 12, 2
 
jmp draw_stats
 
mainloop:
 
mcall 23,50 ; wait for event with timeout (0,5 s)
 
cmp eax, 1
je redraw
cmp eax, 2
je key
cmp eax, 3
je button
 
 
draw_stats:
 
mov edx, 50 shl 16 + 50
 
.loop:
mcall 75, 0x06080003, [last],,,ARP_ENTRY
cmp eax, -1
je mainloop
 
 
mcall 4, edx, 0x80000000, str_entry
mov edx, ebx
 
mov eax, 47
mov ebx, 0x00030000
mov esi, 0x40000000
mov edi, 0x00bcbcbc
xor ecx, ecx
 
mov cl, byte[ARP_ENTRY.IP+0]
mcall
 
mov cl, byte[ARP_ENTRY.IP+1]
add edx, 24 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.IP+2]
add edx, 24 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.IP+3]
add edx, 24 shl 16
mcall
 
 
mov ebx, 0x00020100
mov cl, byte[ARP_ENTRY.MAC+0]
add edx, 36 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.MAC+1]
add edx, 18 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.MAC+2]
add edx, 18 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.MAC+3]
add edx, 18 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.MAC+4]
add edx, 18 shl 16
mcall
 
mov cl, byte[ARP_ENTRY.MAC+5]
add edx, 18 shl 16
mcall
 
mov ebx, 0x00040000
mov cx, [ARP_ENTRY.Status]
add edx, 30 shl 16
mcall
 
mov cx, [ARP_ENTRY.TTL]
add edx, 60 shl 16
mcall
 
add dx, 20
rol edx, 16
mov dx, 50
rol edx, 16
inc [last]
 
jmp .loop
 
 
key:
mcall 2
jmp mainloop
 
 
button: ; button
mcall 17 ; get id
cmp ah, 1
je close
jmp redraw
 
close:
mcall -1
 
 
 
; DATA AREA
 
IM_END:
 
name db 'ARP manager',0
 
title db '# IP-address MAC-address Status TTL',0
str_entry db ' . . . - - - - - s',0
 
last dd 0
 
 
ARP_ENTRY:
.IP dd 192 shl 0 + 168 shl 8 + 1 shl 16 + 1 shl 24
.MAC dp 0xdeadbeef1337
.Status dw 0x0300
.TTL dw 37
.size:
 
include_debug_strings ; ALWAYS present in data section
 
I_PARAM rb 1024
 
I_END:
 
 
/kernel/branches/net/applications/netcfg/macros.inc
File deleted
/kernel/branches/net/applications/netcfg/netcfg.asm
1,4 → 1,4
include 'macros.inc'
include '../macros.inc'
MEOS_APP_START
 
type_ethernet equ 1
/kernel/branches/net/applications/network_lib/network.asm
2,9 → 2,9
 
public @EXPORT as 'EXPORTS'
 
include '../../../struct.inc'
include '../../../proc32.inc'
include '../../../macros.inc'
include '../struct.inc'
include '../proc32.inc'
include '../macros.inc'
purge section,mov,add,sub
 
include 'network.inc'
/kernel/branches/net/applications/nslookup/dll.inc
0,0 → 1,157
;-----------------------------------------------------------------------------
proc mem.Alloc size ;/////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx
mov eax,[size]
lea ecx,[eax+4+4095]
and ecx,not 4095
mcall 68,12
add ecx,-4
mov [eax],ecx
add eax,4
pop ecx ebx
ret
endp
 
;-----------------------------------------------------------------------------
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
;-----------------------------------------------------------------------------
push ebx ecx esi edi eax
mov eax,[mptr]
mov ebx,[size]
or eax,eax
jz @f
lea ecx,[ebx+4+4095]
and ecx,not 4095
add ecx,-4
cmp ecx,[eax-4]
je .exit
@@: mov eax,ebx
call mem.Alloc
xchg eax,[esp]
or eax,eax
jz .exit
mov esi,eax
xchg eax,[esp]
mov edi,eax
mov ecx,[esi-4]
cmp ecx,[edi-4]
jbe @f
mov ecx,[edi-4]
@@: add ecx,3
shr ecx,2
cld
rep movsd
xchg eax,[esp]
call mem.Free
.exit:
pop eax edi esi ecx ebx
ret
endp
 
;-----------------------------------------------------------------------------
proc mem.Free mptr ;//////////////////////////////////////////////////////////
;-----------------------------------------------------------------------------
mov eax,[mptr]
or eax,eax
jz @f
push ebx ecx
lea ecx,[eax-4]
mcall 68,13
pop ecx ebx
@@: ret
endp
 
 
proc dll.Load, import_table:dword
mov esi,[import_table]
.next_lib: mov edx,[esi]
or edx,edx
jz .exit
push esi
mov esi,[esi+4]
mov edi,s_libdir.fname
@@: lodsb
stosb
or al,al
jnz @b
mcall 68,19,s_libdir
or eax,eax
jz .fail
stdcall dll.Link,eax,edx
stdcall dll.Init,[eax+4]
pop esi
add esi,8
jmp .next_lib
.exit: xor eax,eax
ret
.fail: add esp,4
xor eax,eax
inc eax
ret
endp
 
proc dll.Link, exp:dword,imp:dword
push eax
mov esi,[imp]
test esi,esi
jz .done
.next: lodsd
test eax,eax
jz .done
stdcall dll.GetProcAddress,[exp],eax
or eax,eax
jz @f
mov [esi-4],eax
jmp .next
@@: mov dword[esp],0
.done: pop eax
ret
endp
 
proc dll.Init, dllentry:dword
pushad
mov eax,mem.Alloc
mov ebx,mem.Free
mov ecx,mem.ReAlloc
mov edx,dll.Load
stdcall [dllentry]
popad
ret
endp
 
proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx,[exp]
xor eax,eax
.next: or edx,edx
jz .end
cmp dword[edx],0
jz .end
stdcall strcmp,[edx],[sz_name]
test eax,eax
jz .ok
add edx,8
jmp .next
.ok: mov eax,[edx+4]
.end: ret
endp
 
proc strcmp, str1:dword,str2:dword
push esi edi
mov esi,[str1]
mov edi,[str2]
xor eax,eax
@@: lodsb
scasb
jne .fail
or al,al
jnz @b
jmp .ok
.fail: or eax,-1
.ok: pop edi esi
ret
endp
 
s_libdir:
db '/sys/lib/'
.fname rb 32
/kernel/branches/net/network/ARP.inc
601,16 → 601,30
ret
 
.read:
; TODO: write code
cmp ecx, [NumARP]
jge .error
; edi = pointer to buffer
; ecx = # entry
imul ecx, ARP_ENTRY.size
add ecx, ARPTable
mov esi, ecx
mov ecx, ARP_ENTRY.size/2
rep movsw
 
xor eax, eax
ret
 
.write:
; TODO: write code
; call ARP_write_entry
ret
; esi = pointer to buffer
sub esp, ARP_ENTRY.size
mov edi, esp
mov ecx, ARP_ENTRY.size/2
rep movsw
jmp ARP_add_entry ;out: eax = entry number, -1 on error
 
.remove:
mov esi, eax
; ecx = # entry
mov esi, ecx
call ARP_del_entry
ret
 
/kernel/branches/net/network/IPv4.inc
85,9 → 85,7
 
or eax, -1
mov edi, BROADCAST
stosd
xor eax, eax
mov ecx, 4*MAX_IP
mov ecx, 4*MAX_IP+1
rep stosd
 
xor eax, eax
/kernel/branches/net/network/stack.inc
50,6 → 50,11
IP_PROTO_TCP equ 6
IP_PROTO_UDP equ 17
 
; Socket types
SOCK_STREAM = 1
SOCK_DGRAM = 2
SOCK_RAW = 3
 
; TCP opening modes
SOCKET_PASSIVE equ 0
SOCKET_ACTIVE equ 1