Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3625 → Rev 3626

/kernel/branches/Kolibri-acpi/network/loopback.inc
1,6 → 1,6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; loopback.inc ;;
19,7 → 19,8
iglobal
 
LOOPBACK_DEVICE:
.type dd NET_TYPE_LOOPBACK
 
.device_type dd NET_DEVICE_LOOPBACK
.mtu dd 4096
.name dd .namestr
 
32,6 → 33,9
.packets_tx dd 0
.packets_rx dd 0
 
.link_state dd -1
.hwacc dd 0
 
.namestr db 'loopback', 0
 
.dummy_fn:
39,6 → 43,23
 
endg
 
 
macro LOOP_init {
local .fail
 
mov ebx, LOOPBACK_DEVICE
call NET_add_device
 
cmp eax, -1
je .fail
 
mov [IP_LIST], 127 + 1 shl 24
mov [SUBNET_LIST], 255
mov [BROADCAST_LIST], 0xffffff00 + 127
 
.fail:
}
 
;-----------------------------------------------------------------
;
; LOOP_input
59,12 → 80,16
push ecx
push eax
 
inc [LOOPBACK_DEVICE.packets_rx]
add dword[LOOPBACK_DEVICE.bytes_rx], ecx
adc dword[LOOPBACK_DEVICE.bytes_rx + 4], 0
 
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: size=%u\n", ecx
lea edx, [eax + 2]
mov ax, word[eax]
lea edx, [eax + 4]
mov eax, dword[eax]
mov ebx, LOOPBACK_DEVICE
 
cmp ax, ETHER_IPv4
cmp eax, AF_INET4
je IPv4_input
 
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_input: Unknown packet type=%x\n", ax
81,7 → 106,7
;
; IN:
; ecx = packet size
; di = protocol
; edi = address family
;
; OUT: edi = 0 on error, pointer to buffer otherwise
; eax = buffer start
96,9 → 121,9
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output\n"
 
push ecx
push di
push edi
 
add ecx, 2
add ecx, 4
cmp ecx, [LOOPBACK_DEVICE.mtu]
ja .out_of_ram
stdcall kernel_alloc, ecx
105,22 → 130,25
test eax, eax
jz .out_of_ram
mov edi, eax
pop ax
stosw
pop eax
stosd
 
lea eax, [edi - 2] ; Set eax to buffer start
lea eax, [edi - 4] ; Set eax to buffer start
pop ecx
lea edx, [ecx + 2] ; Set edx to complete buffer size
lea edx, [ecx + 4] ; Set edx to complete buffer size
mov ebx, LOOPBACK_DEVICE
 
.done:
inc [LOOPBACK_DEVICE.packets_tx]
add dword[LOOPBACK_DEVICE.bytes_tx], ecx
adc dword[LOOPBACK_DEVICE.bytes_tx + 4], 0
 
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: ptr=%x size=%u\n", eax, edx
ret
 
.out_of_ram:
DEBUGF DEBUG_NETWORK_VERBOSE, "LOOP_output: failed\n"
add esp, 2+4
sub edi, edi
DEBUGF DEBUG_NETWORK_ERROR, "LOOP_output: out of memory\n"
add esp, 4+4
xor edi, edi
ret