raw_socket.h
Go to the documentation of this file.
1 /**
2  * @file raw_socket.h
3  * @brief TCP/IP raw sockets
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _RAW_SOCKET_H
32 #define _RAW_SOCKET_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "core/ip.h"
37 #include "core/socket.h"
38 
39 //Raw socket support
40 #ifndef RAW_SOCKET_SUPPORT
41  #define RAW_SOCKET_SUPPORT DISABLED
42 #elif (RAW_SOCKET_SUPPORT != ENABLED && RAW_SOCKET_SUPPORT != DISABLED)
43  #error RAW_SOCKET_SUPPORT parameter is not valid
44 #endif
45 
46 //Receive queue depth for raw sockets
47 #ifndef RAW_SOCKET_RX_QUEUE_SIZE
48  #define RAW_SOCKET_RX_QUEUE_SIZE 4
49 #elif (RAW_SOCKET_RX_QUEUE_SIZE < 1)
50  #error RAW_SOCKET_RX_QUEUE_SIZE parameter is not valid
51 #endif
52 
53 //C++ guard
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 //Raw socket related functions
60  const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset,
61  const NetRxAncillary *ancillary);
62 
63 void rawSocketProcessEthPacket(NetInterface *interface, const uint8_t *data,
64  size_t length, const NetRxAncillary *ancillary);
65 
67  uint_t flags);
68 
70  uint_t flags);
71 
73  uint_t flags);
74 
76  uint_t flags);
77 
79 
80 //C++ guard
81 #ifdef __cplusplus
82 }
83 #endif
84 
85 #endif
error_t rawSocketReceiveIpPacket(Socket *socket, SocketMsg *message, uint_t flags)
Receive an IP packet from a raw socket.
Definition: raw_socket.c:824
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:89
uint8_t message[]
Definition: chap.h:154
uint8_t data[]
Definition: ethernet.h:222
Message and ancillary data.
Definition: socket.h:241
void rawSocketProcessEthPacket(NetInterface *interface, const uint8_t *data, size_t length, const NetRxAncillary *ancillary)
Process incoming Ethernet packet.
Definition: raw_socket.c:385
IP pseudo header.
Definition: ip.h:110
error_t
Error codes.
Definition: error.h:43
int_t socket(int_t family, int_t type, int_t protocol)
Create a socket that is bound to a specific transport service provider.
Definition: bsd_socket.c:65
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
uint8_t length
Definition: tcp.h:368
error_t rawSocketReceiveEthPacket(Socket *socket, SocketMsg *message, uint_t flags)
Receive an Ethernet packet from a raw socket.
Definition: raw_socket.c:930
void rawSocketUpdateEvents(Socket *socket)
Update event state for raw sockets.
Definition: raw_socket.c:1025
uint8_t flags
Definition: tcp.h:351
IPv4 and IPv6 common routines.
#define Socket
Definition: socket.h:36
error_t rawSocketProcessIpPacket(NetInterface *interface, const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary)
Process incoming IP packet.
Definition: raw_socket.c:68
Socket API.
unsigned int uint_t
Definition: compiler_port.h:50
error_t rawSocketSendIpPacket(Socket *socket, const SocketMsg *message, uint_t flags)
Send a raw IP packet.
Definition: raw_socket.c:538
TCP/IP stack core.
error_t rawSocketSendEthPacket(Socket *socket, const SocketMsg *message, uint_t flags)
Send a raw Ethernet packet.
Definition: raw_socket.c:732