diff --git a/kernel/trunk/network/PPPoE.inc b/kernel/trunk/network/PPPoE.inc index 90421d0bb8..68f80fb2c2 100644 --- a/kernel/trunk/network/PPPoE.inc +++ b/kernel/trunk/network/PPPoE.inc @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2012-2019. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2012-2021. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; PPPoE.INC ;; @@ -141,38 +141,41 @@ pppoe_discovery_output: DEBUGF DEBUG_NETWORK_VERBOSE, "PPPoE_discovery_output: device=%x\n", ebx ; Create packet. - push ecx esi -;;;; FIXME stdcall kernel_alloc, 1500 - pop esi ecx + stdcall net_buff_alloc, 1514 + NET_BUFF.data test eax, eax jz .bad +; Net buffer header + mov [eax + NET_BUFF.type], NET_BUFF_ETH + mov [eax + NET_BUFF.device], ebx + mov [eax + NET_BUFF.offset], NET_BUFF.data + +; Packet data mov edx, ecx - mov edi, eax + lea edi, [eax + NET_BUFF.data] rep movsb - cmp edx, 60 ; Min ETH size +; Packet size + cmp edx, 60 ja @f mov edx, 60 - @@: + @@: + mov [eax + NET_BUFF.length], edx - push edx eax ; size and packet ptr for driver send proc - -; Overwrite source MAC and protocol type - lea edi, [eax + ETH_header.SrcMAC] +; Overwrite ETH source MAC with our own lea esi, [ebx + ETH_DEVICE.mac] + lea edi, [eax + NET_BUFF.data + ETH_header.SrcMAC] movsd movsw - cmp word[edi], ETHER_PROTO_PPP_SESSION ; Allow only PPP_discovery, or LCP + +; Allow only PPP_discovery, or LCP + cmp word[edi], ETHER_PROTO_PPP_SESSION je @f - mov ax, ETHER_PROTO_PPP_DISCOVERY - stosw + mov word[edi], ETHER_PROTO_PPP_DISCOVERY @@: ; And send the packet - call [ebx + NET_DEVICE.transmit] - - xor eax, eax + stdcall [ebx + NET_DEVICE.transmit], eax ret .bad: diff --git a/kernel/trunk/network/socket.inc b/kernel/trunk/network/socket.inc index 7cd567b420..cf39877801 100644 --- a/kernel/trunk/network/socket.inc +++ b/kernel/trunk/network/socket.inc @@ -332,8 +332,8 @@ socket_open: cmp ecx, AF_PPP jne .no_ppp - cmp esi, PPP_PROTO_ETHERNET - je .pppoe +; cmp esi, PPP_PROTO_ETHERNET +; je .pppoe .no_ppp: .unsupported: @@ -404,15 +404,15 @@ align 4 mov [eax + SOCKET.connect_proc], ipv4_connect ret -align 4 - .pppoe: - push eax - init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue - pop eax - - mov [eax + SOCKET.snd_proc], socket_send_pppoe - mov [eax + SOCKET.rcv_proc], socket_receive_dgram - ret +;align 4 +; .pppoe: +; push eax +; init_queue (eax + SOCKET_QUEUE_LOCATION) ; Set up data receiving queue +; pop eax +; +; mov [eax + SOCKET.snd_proc], socket_send_pppoe +; mov [eax + SOCKET.rcv_proc], socket_receive_dgram +; ret ;-----------------------------------------------------------------; @@ -774,7 +774,7 @@ socket_close: ; ; ; IN: ecx = socket number ; ; edx = addr to application buffer ; -; edx = length of application buffer ; +; esi = length of application buffer ; ; edi = flags ; ; ; ; OUT: eax = number of bytes copied ; @@ -792,6 +792,9 @@ socket_receive: test eax, eax jz .invalid + stdcall is_region_userspace, edx, esi + jnz .invalid + .loop: push edi call [eax + SOCKET.rcv_proc] @@ -998,6 +1001,9 @@ socket_send: test eax, eax jz .invalid + stdcall is_region_userspace, edx, esi + jnz .invalid + mov ecx, esi mov esi, edx @@ -1080,23 +1086,23 @@ socket_send_icmp: ret -align 4 -socket_send_pppoe: - - DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n" - - mov [esp+32], ecx - mov ebx, [eax + SOCKET.device] - - call pppoe_discovery_output ; FIXME: errorcodes - cmp eax, -1 - je .error - ret - - .error: - mov dword[esp+32], -1 - mov dword[esp+20], EMSGSIZE - ret +;align 4 +;socket_send_pppoe: +; +; DEBUGF DEBUG_NETWORK_VERBOSE, "SOCKET_send: PPPoE\n" +; +; mov [esp+32], ecx +; mov ebx, [eax + SOCKET.device] +; +; call pppoe_discovery_output ; FIXME: errorcodes +; cmp eax, -1 +; je .error +; ret +; +; .error: +; mov dword[esp+32], -1 +; mov dword[esp+20], EMSGSIZE +; ret @@ -1383,6 +1389,9 @@ socket_debug: test eax, eax jz .invalid + stdcall is_region_userspace, edi, SOCKET_STRUCT_SIZE + jnz .invalid + mov esi, eax mov ecx, SOCKET_STRUCT_SIZE/4 rep movsd diff --git a/kernel/trunk/network/stack.inc b/kernel/trunk/network/stack.inc index 2c70f858d2..ab3377e74a 100644 --- a/kernel/trunk/network/stack.inc +++ b/kernel/trunk/network/stack.inc @@ -243,11 +243,11 @@ include "queue.inc" include "loopback.inc" include "ethernet.inc" -include "PPPoE.inc" +;include "PPPoE.inc" include "ARP.inc" include "IPv4.inc" -include "IPv6.inc" +;include "IPv6.inc" include "icmp.inc" include "udp.inc" @@ -319,7 +319,7 @@ end if eth_init - pppoe_init +; pppoe_init ipv4_init ; ipv6_init @@ -828,10 +828,9 @@ sys_network: ret .get_dev_name: - mov ebx, eax stdcall is_region_userspace, ecx, 64 jnz .bad_buffer - mov esi, [ebx + NET_DEVICE.name] + mov esi, [eax + NET_DEVICE.name] mov edi, ecx mov ecx, 64/4 ; max length @@ -968,11 +967,11 @@ sys_protocols: cmp ax, API_ARP je arp_api - cmp ax, API_PPPOE - je pppoe_api +; cmp ax, API_PPPOE +; je pppoe_api - cmp ax, API_IPv6 - je ipv6_api +; cmp ax, API_IPv6 +; je ipv6_api add esp, 4 ; if we reached here, no function was called, so we need to balance stack