raw_socket.c File Reference

TCP/IP raw sockets. More...

#include "core/net.h"
#include "core/socket.h"
#include "core/raw_socket.h"
#include "core/ethernet_misc.h"
#include "ipv4/ipv4.h"
#include "ipv4/ipv4_misc.h"
#include "ipv6/ipv6.h"
#include "ipv6/ipv6_misc.h"
#include "mibs/mib2_module.h"
#include "mibs/if_mib_module.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   RAW_SOCKET_TRACE_LEVEL
 

Functions

error_t rawSocketProcessIpPacket (NetInterface *interface, const IpPseudoHeader *pseudoHeader, const NetBuffer *buffer, size_t offset, const NetRxAncillary *ancillary)
 Process incoming IP packet. More...
 
void rawSocketProcessEthPacket (NetInterface *interface, const uint8_t *data, size_t length, const NetRxAncillary *ancillary)
 Process incoming Ethernet packet. More...
 
error_t rawSocketSendIpPacket (Socket *socket, const SocketMsg *message, uint_t flags)
 Send a raw IP packet. More...
 
error_t rawSocketSendEthPacket (Socket *socket, const SocketMsg *message, uint_t flags)
 Send a raw Ethernet packet. More...
 
error_t rawSocketReceiveIpPacket (Socket *socket, SocketMsg *message, uint_t flags)
 Receive an IP packet from a raw socket. More...
 
error_t rawSocketReceiveEthPacket (Socket *socket, SocketMsg *message, uint_t flags)
 Receive an Ethernet packet from a raw socket. More...
 
void rawSocketUpdateEvents (Socket *socket)
 Update event state for raw sockets. More...
 

Detailed Description

TCP/IP raw sockets.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Description

A raw socket is a type of socket that allows access to the underlying transport provider

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.0

Definition in file raw_socket.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   RAW_SOCKET_TRACE_LEVEL

Definition at line 37 of file raw_socket.c.

Function Documentation

◆ rawSocketProcessEthPacket()

void rawSocketProcessEthPacket ( NetInterface interface,
const uint8_t *  data,
size_t  length,
const NetRxAncillary ancillary 
)

Process incoming Ethernet packet.

Parameters
[in]interfaceUnderlying network interface
[in]dataPointer to the payload data
[in]lengthLength of the payload data, in bytes
[in]ancillaryAdditional options passed to the stack along with the packet

Definition at line 360 of file raw_socket.c.

◆ rawSocketProcessIpPacket()

error_t rawSocketProcessIpPacket ( NetInterface interface,
const IpPseudoHeader pseudoHeader,
const NetBuffer buffer,
size_t  offset,
const NetRxAncillary ancillary 
)

Process incoming IP packet.

Parameters
[in]interfaceUnderlying network interface
[in]pseudoHeaderIPv4 or IPv6 pseudo header
[in]bufferMulti-part buffer containing the IP packet
[in]offsetOffset to the first byte of the IP packet
[in]ancillaryAdditional options passed to the stack along with the packet
Returns
Error code

Definition at line 67 of file raw_socket.c.

◆ rawSocketReceiveEthPacket()

error_t rawSocketReceiveEthPacket ( Socket socket,
SocketMsg message,
uint_t  flags 
)

Receive an Ethernet packet from a raw socket.

Parameters
[in]socketHandle referencing the socket
[out]messageReceived Ethernet packet and ancillary data
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 904 of file raw_socket.c.

◆ rawSocketReceiveIpPacket()

error_t rawSocketReceiveIpPacket ( Socket socket,
SocketMsg message,
uint_t  flags 
)

Receive an IP packet from a raw socket.

Parameters
[in]socketHandle referencing the socket
[out]messageReceived IP packet and ancillary data
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 798 of file raw_socket.c.

◆ rawSocketSendEthPacket()

error_t rawSocketSendEthPacket ( Socket socket,
const SocketMsg message,
uint_t  flags 
)

Send a raw Ethernet packet.

Parameters
[in]socketHandle referencing the socket
[in]messagePointer to the structure describing the raw packet
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 706 of file raw_socket.c.

◆ rawSocketSendIpPacket()

error_t rawSocketSendIpPacket ( Socket socket,
const SocketMsg message,
uint_t  flags 
)

Send a raw IP packet.

Parameters
[in]socketHandle referencing the socket
[in]messagePointer to the structure describing the raw packet
[in]flagsSet of flags that influences the behavior of this function
Returns
Error code

Definition at line 512 of file raw_socket.c.

◆ rawSocketUpdateEvents()

void rawSocketUpdateEvents ( Socket socket)

Update event state for raw sockets.

Parameters
[in]socketHandle referencing the socket

Definition at line 999 of file raw_socket.c.