forked from KolibriOS/kolibrios
Loopback device now works with entire 127.0.0.1/8 range, and also keeps some stats.
git-svn-id: svn://kolibrios.org@3610 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
e395aa6070
commit
c30fb05dcc
@ -575,10 +575,11 @@ IPv4_output:
|
||||
|
||||
push ecx eax edx di
|
||||
|
||||
cmp eax, 1 shl 24 + 127
|
||||
je .loopback
|
||||
|
||||
call IPv4_route ; outputs device number in edi, dest ip in eax
|
||||
|
||||
test edi, edi
|
||||
jz .loopback
|
||||
|
||||
call ARP_IP_to_MAC
|
||||
test eax, 0xffff0000 ; error bits
|
||||
jnz .arp_error
|
||||
@ -635,7 +636,8 @@ IPv4_output:
|
||||
ret
|
||||
|
||||
.loopback:
|
||||
mov dword [esp + 2], eax
|
||||
mov dword [esp + 2], eax ; change source IP to dest IP
|
||||
mov ecx, [esp + 10]
|
||||
add ecx, sizeof.IPv4_header
|
||||
mov edi, AF_INET4
|
||||
call LOOP_output
|
||||
@ -875,23 +877,20 @@ IPv4_route:
|
||||
and edx, [SUBNET_LIST+edi]
|
||||
|
||||
cmp ebx, edx
|
||||
je .found_it
|
||||
jne .next
|
||||
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
||||
ret
|
||||
|
||||
.next:
|
||||
add edi, 4
|
||||
dec ecx
|
||||
jnz .loop
|
||||
|
||||
.invalid:
|
||||
xor edi, edi ; if none found, use device 1 as default ;;; FIXME
|
||||
inc di
|
||||
mov eax, [GATEWAY_LIST+4]
|
||||
|
||||
.found_it:
|
||||
DEBUGF DEBUG_NETWORK_VERBOSE, "IPv4_route: %u\n", edi
|
||||
ret
|
||||
|
||||
mov eax, [GATEWAY_LIST+4] ;;; FIXME
|
||||
.broadcast:
|
||||
xor edi, edi ;;;; FIXME
|
||||
xor edi, edi ; if none found, use device 1 as default ;;;; FIXME
|
||||
inc di
|
||||
ret
|
||||
|
||||
|
@ -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 ;;
|
||||
@ -80,6 +80,10 @@ LOOP_input:
|
||||
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 + 4]
|
||||
mov eax, dword[eax]
|
||||
@ -102,7 +106,7 @@ LOOP_input:
|
||||
;
|
||||
; IN:
|
||||
; ecx = packet size
|
||||
; di = protocol
|
||||
; edi = address family
|
||||
;
|
||||
; OUT: edi = 0 on error, pointer to buffer otherwise
|
||||
; eax = buffer start
|
||||
@ -134,12 +138,15 @@ LOOP_output:
|
||||
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"
|
||||
DEBUGF DEBUG_NETWORK_ERROR, "LOOP_output: out of memory\n"
|
||||
add esp, 4+4
|
||||
xor edi, edi
|
||||
ret
|
||||
|
Loading…
Reference in New Issue
Block a user