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  * Copyright (C) 2010-2018 Oryx Embedded SARL. All rights reserved.
8  *
9  * This file is part of CycloneTCP Open.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software Foundation,
23  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24  *
25  * @author Oryx Embedded SARL (www.oryx-embedded.com)
26  * @version 1.9.0
27  **/
28 
29 #ifndef _RAW_SOCKET_H
30 #define _RAW_SOCKET_H
31 
32 //Dependencies
33 #include "core/net.h"
34 #include "core/ip.h"
35 #include "core/socket.h"
36 
37 //Raw socket support
38 #ifndef RAW_SOCKET_SUPPORT
39  #define RAW_SOCKET_SUPPORT DISABLED
40 #elif (RAW_SOCKET_SUPPORT != ENABLED && RAW_SOCKET_SUPPORT != DISABLED)
41  #error RAW_SOCKET_SUPPORT parameter is not valid
42 #endif
43 
44 //Receive queue depth for raw sockets
45 #ifndef RAW_SOCKET_RX_QUEUE_SIZE
46  #define RAW_SOCKET_RX_QUEUE_SIZE 4
47 #elif (RAW_SOCKET_RX_QUEUE_SIZE < 1)
48  #error RAW_SOCKET_RX_QUEUE_SIZE parameter is not valid
49 #endif
50 
51 //C++ guard
52 #ifdef __cplusplus
53  extern "C" {
54 #endif
55 
56 //Raw socket related functions
58  IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset);
59 
61  EthHeader *ethFrame, size_t length);
62 
64  const void *data, size_t length, size_t *written);
65 
67  const void *data, size_t length, size_t *written);
68 
70  IpAddr *destIpAddr, void *data, size_t size, size_t *received, uint_t flags);
71 
73  void *data, size_t size, size_t *received, uint_t flags);
74 
76 
77 //C++ guard
78 #ifdef __cplusplus
79  }
80 #endif
81 
82 #endif
__start_packed struct @114 EthHeader
Ethernet frame header.
uint8_t flags
Definition: tcp.h:312
TCP/IP stack core.
error_t rawSocketSendIpPacket(Socket *socket, const IpAddr *destIpAddr, const void *data, size_t length, size_t *written)
Send an raw IP packet.
Definition: raw_socket.c:384
IP network address.
Definition: ip.h:57
IPv4 and IPv6 common routines.
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:106
void rawSocketProcessEthPacket(NetInterface *interface, EthHeader *ethFrame, size_t length)
Process incoming Ethernet packet.
Definition: raw_socket.c:269
#define Socket
Definition: socket.h:34
error_t rawSocketReceiveIpPacket(Socket *socket, IpAddr *srcIpAddr, IpAddr *destIpAddr, void *data, size_t size, size_t *received, uint_t flags)
Receive an IP packet from a raw socket.
Definition: raw_socket.c:609
Structure describing a buffer that spans multiple chunks.
Definition: net_mem.h:86
Ipv4Addr srcIpAddr
Definition: ipcp.h:75
error_t
Error codes.
Definition: error.h:40
Ipv4Addr destIpAddr
Definition: ipcp.h:76
unsigned int uint_t
Definition: compiler_port.h:43
uint8_t data[]
Definition: dtls_misc.h:167
#define NetInterface
Definition: net.h:34
error_t rawSocketSendEthPacket(Socket *socket, const void *data, size_t length, size_t *written)
Send an raw Ethernet packet.
Definition: raw_socket.c:492
IP pseudo header.
Definition: ip.h:76
error_t rawSocketProcessIpPacket(NetInterface *interface, IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset)
Process incoming IP packet.
Definition: raw_socket.c:61
void rawSocketUpdateEvents(Socket *socket)
Update event state for raw sockets.
Definition: raw_socket.c:745
error_t rawSocketReceiveEthPacket(Socket *socket, void *data, size_t size, size_t *received, uint_t flags)
Receive an Ethernet packet from a raw socket.
Definition: raw_socket.c:683
Socket API.
uint8_t length
Definition: dtls_misc.h:140