Cleanup/small refactor of some internal network functions.

git-svn-id: svn://kolibrios.org@5015 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr 2014-08-02 12:48:32 +00:00
parent 3f20695fd0
commit e7360b0f51
7 changed files with 57 additions and 64 deletions

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ARP.INC ;;
@ -318,10 +318,9 @@ ARP_output_request:
DEBUGF DEBUG_NETWORK_VERBOSE, "ARP_output_request: ip=%u.%u.%u.%u device=0x%x\n",\
[esp]:1, [esp + 1]:1, [esp + 2]:1, [esp + 3]:1, ebx
lea eax, [ebx + ETH_DEVICE.mac] ; local device mac
mov edx, ETH_BROADCAST ; broadcast mac
mov ax, ETHER_PROTO_ARP
mov ecx, sizeof.ARP_header
mov di, ETHER_PROTO_ARP
mov edx, ETH_BROADCAST ; broadcast mac
call ETH_output
jz .exit

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; IPv4.INC ;;
@ -574,13 +574,13 @@ IPv4_find_fragment_slot:
; IN: eax = Destination IP
; ecx = data length
; edx = Source IP
; di = TTL shl 8 + protocol
; di = TTL shl 8 + protocol
;
; OUT: eax = pointer to buffer start
; ebx = pointer to device struct (needed for sending procedure)
; ecx = unchanged (packet size of embedded data)
; edx = size of complete buffer
; edi = pointer to start of data (0 on error)
; OUT: eax = pointer to buffer start / 0 on error
; ebx = device ptr (send packet through this device)
; ecx = data length
; edx = size of complete frame
; edi = start of IPv4 payload
;
;------------------------------------------------------------------
align 4
@ -594,7 +594,6 @@ IPv4_output:
push ecx di eax
call IPv4_route ; outputs device number in edi, dest ip in eax, source IP in edx
push edx
test edi, edi
jz .loopback
@ -606,12 +605,11 @@ IPv4_output:
inc [IPv4_packets_tx + edi] ; update stats
mov ax, ETHER_PROTO_IPv4
mov ebx, [NET_DRV_LIST + edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 6 + 8 + 2]
add ecx, sizeof.IPv4_header
mov di, ETHER_PROTO_IPv4
mov edx, esp
call ETH_output
jz .eth_error
add esp, 6 ; pop the mac out of the stack
@ -641,18 +639,18 @@ IPv4_output:
.eth_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ethernet error\n"
add esp, 3*4+2+6
xor edi, edi
xor eax, eax
ret
.arp_error:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: ARP error=%x\n", eax
add esp, 3*4+2
xor edi, edi
xor eax, eax
ret
.too_large:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output: Packet too large!\n"
xor edi, edi
xor eax, eax
ret
.loopback:
@ -674,7 +672,7 @@ IPv4_output:
; ecx = data length
; esi = data ptr
;
; OUT: /
; OUT: eax = -1 on error
;
;------------------------------------------------------------------
align 4
@ -698,15 +696,13 @@ IPv4_output_raw:
push ax
inc [IPv4_packets_tx + 4*edi]
mov ax, ETHER_PROTO_IPv4
mov ebx, [NET_DRV_LIST + 4*edi]
lea eax, [ebx + ETH_DEVICE.mac]
mov edx, esp
mov ecx, [esp + 6 + 4]
add ecx, sizeof.IPv4_header
mov di, ETHER_PROTO_IPv4
mov edx, esp
call ETH_output
jz .error
add esp, 6 ; pop the mac
mov dword[esp+4+4], edx
@ -745,7 +741,7 @@ IPv4_output_raw:
add esp, 8+4+4
.too_large:
DEBUGF DEBUG_NETWORK_ERROR, "IPv4_output_raw: Failed\n"
sub edi, edi
or eax, -1
ret
@ -794,13 +790,9 @@ IPv4_fragment:
.new_fragment:
DEBUGF DEBUG_NETWORK_VERBOSE, "Ipv4_fragment: new fragment"
mov eax, [esp + 3*4]
mov ax, ETHER_PROTO_IPv4
lea ebx, [esp + 4*4]
mov di , ETHER_PROTO_IPv4
call ETH_output
cmp edi, -1
jz .err
; copy header

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2012-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2012-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; PPPoE.INC ;;
@ -243,17 +243,15 @@ PPPoE_session_input:
;
; PPPoE_output
;
; IN:
; IN: ax = protocol
; ebx = device ptr
; ecx = packet size
;
; di = protocol
;
; OUT: edi = 0 on error, pointer to buffer otherwise
; eax = buffer start
; ebx = to device structure
; ecx = unchanged (packet size of embedded data)
; OUT: eax = buffer start / 0 on error
; ebx = device ptr
; ecx = packet size
; edx = size of complete buffer
; edi = start of PPP payload
;
;-----------------------------------------------------------------
align 4
@ -261,13 +259,12 @@ PPPoE_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_output: size=%u device=%x\n", ecx, ebx
pushw di
pushw ax
pushw [PPPoE_SID]
lea eax, [ebx + ETH_DEVICE.mac]
lea edx, [PPPoE_MAC]
mov ax, ETHER_PROTO_PPP_SESSION
add ecx, PPPoE_frame.Payload + 2
mov di, ETHER_PROTO_PPP_SESSION
lea edx, [PPPoE_MAC]
call ETH_output
jz .eth_error
@ -290,8 +287,7 @@ PPPoE_output:
.eth_error:
add esp, 4
xor edi, edi
xor eax, eax
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ETHERNET.INC ;;
@ -166,17 +166,16 @@ ETH_process_input:
;
; ETH_output
;
; IN: eax = pointer to source mac
; IN: ax = protocol
; ebx = device ptr
; ecx = packet size
; ecx = payload size
; edx = pointer to destination mac
; di = protocol
;
; OUT: edi = 0 on error, pointer to buffer otherwise
; eax = buffer start
; ebx = to device structure
; ecx = unchanged (packet size of embedded data)
; edx = size of complete buffer
; OUT: eax = start of ethernet frame / 0 on error
; ebx = device ptr
; ecx = payload size
; edx = ethernet frame size
; edi = start of ethernet payload
;
;-----------------------------------------------------------------
align 4
@ -184,11 +183,11 @@ ETH_output:
DEBUGF DEBUG_NETWORK_VERBOSE, "ETH_output: size=%u device=%x\n", ecx, ebx
cmp ecx, [ebx + NET_DEVICE.mtu]
cmp ecx, [ebx + ETH_DEVICE.mtu]
ja .exit
push ecx
push di eax edx
push ax edx
add ecx, sizeof.ETH_header
stdcall kernel_alloc, ecx
@ -199,7 +198,7 @@ ETH_output:
pop esi
movsd
movsw
pop esi
lea esi, [ebx + ETH_DEVICE.mac]
movsd
movsw
pop ax
@ -217,18 +216,18 @@ ETH_output:
.adjust_size:
mov edx, ETH_FRAME_MINIMUM
test edx, edx ; clear zero flag
test edx, edx ; clear zero flag
jmp .done
.out_of_ram:
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Out of ram!\n"
add esp, 4+4+2+4
sub edi, edi
add esp, 4+2+4
xor eax, eax
ret
.exit:
DEBUGF DEBUG_NETWORK_ERROR, "ETH_output: Packet too large!\n"
sub edi, edi
xor eax, eax
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
@ -273,6 +273,8 @@ TCP_api:
jz .packets_missed ; 2
dec bl
jz .packets_dumped ; 3
dec bl
jz .packets_queued ; 4
.error:
mov eax, -1
@ -293,3 +295,7 @@ TCP_api:
.packets_dumped:
mov eax, [TCP_segments_dumped + eax]
ret
.packets_queued:
mov eax, [TCP_queue + queue.size]
ret

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; Part of the TCP/IP network stack for KolibriOS ;;
@ -143,7 +143,7 @@ TCP_pull_out_of_band:
;
;-------------------------
align 4
TCP_drop:
TCP_drop: ; FIXME CHECKME TODO
DEBUGF DEBUG_NETWORK_VERBOSE, "TCP_drop: %x\n", eax
@ -290,7 +290,6 @@ TCP_respond:
mov ecx, sizeof.TCP_header
mov di, IP_PROTO_TCP shl 8 + 128
call IPv4_output
test edi, edi
jz .error
pop esi cx
push edx eax

View File

@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved. ;;
;; Copyright (C) KolibriOS team 2004-2014. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; UDP.INC ;;
@ -245,6 +245,8 @@ UDP_input:
; ecx = number of bytes to send
; esi = pointer to data
;
; OUT: eax = -1 on error
;
;-----------------------------------------------------------------
align 4