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-2020 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 1.9.8
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  IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset,
61  NetRxAncillary *ancillary);
62 
63 void rawSocketProcessEthPacket(NetInterface *interface, EthHeader *header,
64  const uint8_t *data, size_t length, 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
uint8_t length
Definition: coap_common.h:190
uint8_t data[]
Definition: ethernet.h:209
error_t rawSocketReceiveIpPacket(Socket *socket, SocketMsg *message, uint_t flags)
Receive an IP packet from a raw socket.
Definition: raw_socket.c:727
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:88
Message and ancillary data.
Definition: socket.h:198
error_t rawSocketProcessIpPacket(NetInterface *interface, IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, NetRxAncillary *ancillary)
Process incoming IP packet.
Definition: raw_socket.c:66
IP pseudo header.
Definition: ip.h:97
error_t
Error codes.
Definition: error.h:42
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:108
#define NetRxAncillary
Definition: net_misc.h:40
#define NetInterface
Definition: net.h:36
error_t rawSocketReceiveEthPacket(Socket *socket, SocketMsg *message, uint_t flags)
Receive an Ethernet packet from a raw socket.
Definition: raw_socket.c:831
void rawSocketUpdateEvents(Socket *socket)
Update event state for raw sockets.
Definition: raw_socket.c:920
uint8_t flags
Definition: tcp.h:314
void rawSocketProcessEthPacket(NetInterface *interface, EthHeader *header, const uint8_t *data, size_t length, NetRxAncillary *ancillary)
Process incoming Ethernet packet.
Definition: raw_socket.c:287
__start_packed struct @7 EthHeader
Ethernet frame header.
IPv4 and IPv6 common routines.
#define Socket
Definition: socket.h:36
uint8_t message[]
Definition: chap.h:152
Socket API.
unsigned int uint_t
Definition: compiler_port.h:45
error_t rawSocketSendIpPacket(Socket *socket, const SocketMsg *message, uint_t flags)
Send an raw IP packet.
Definition: raw_socket.c:427
TCP/IP stack core.
error_t rawSocketSendEthPacket(Socket *socket, const SocketMsg *message, uint_t flags)
Send an raw Ethernet packet.
Definition: raw_socket.c:591