FreeRTOS +TCP/+UDP – how to send raw ethernet packets?

Hi All, I’m looking to send raw Ethernet packets Under Linux something in the vein of: // Open our raw socket if ((mfd = socket(AFPACKET, SOCKRAW, IPPROTORAW)) == -1) { LogErr(VB_CHANNELOUT, “Error creating raw socket: %sn”, strerror(errno)); return 0; }
if (sendto(m_fd, m_buffer_0101, m_buffer_0101_len, 0, (struct sockaddr*)&m_sock_addr, sizeof(struct                                sockaddr_ll)) < 0)
{
    LogErr(VB_CHANNELOUT, "Error sending 0x0101 packet: %sn", strerror(errno));
    return 0;
}
where mbuffer is: //////////////////////////// // Setup 0x0101 packet data mbuffer0101len = sizeof(struct etherheader) + 98; mbuffer0101 = (char *)calloc(mbuffer0101len, 1); if (!mbuffer0101) { LogErr(VBCHANNELOUT, “Error allocating mbuffer_0101n”); return 0; }
memset(m_buffer_0101, 0, m_buffer_0101_len);
SetHostMACs(m_buffer_0101);
m_eh = (struct ether_header *)m_buffer_0101;
m_eh->ether_type = htons(0x0101);

m_sock_addr.sll_ifindex = m_if_idx.ifr_ifindex;
m_sock_addr.sll_halen = ETH_ALEN;
memcpy(m_sock_addr.sll_addr, m_eh->ether_dhost, 6);

 Essentially a src & dest mac addr and a protocal type and the data....

I have not been able to determine if this is possible with FreeRTOS +TCP/+UDP or any setup therein.

Hopefully someone here will know either how to do this or if I'm barking up the wrong tree.

Thanks,
Matt

FreeRTOS +TCP/+UDP – how to send raw ethernet packets?

The user documentation only describes the interface to the TCP/IP stack, rather than directly to the Ethernet. There are a few function intended for use by people who are porting the TCP stack to a different platform though, and it is possible, with a bit of fiddling, you may be able to do what you want with those: https://www.freertos.org/FreeRTOS-Plus/FreeRTOSPlusTCP/Networkinterfacefunctions.html

FreeRTOS +TCP/+UDP – how to send raw ethernet packets?

Thanks for the quick response. However, I don’t see how this will help me. It appears to still call the same stack functions and I don’t see the stuff there that will handle the raw packets. Now it’s clear that I may not understand what’s going on, but that’s why I’m asking. I have found neither AFPACKET (which I understand is a Linux term) nor SOCKRAW in the code anywhere – or anything that looks like it will setup things like those will. So, is there another way to get from point a to b? Thanks, Matt

FreeRTOS +TCP/+UDP – how to send raw ethernet packets?

So I see this: xDomain Must be set to FREERTOSAFINET. [no other choices} xType Set to FREERTOSSOCKSTREAM to create a TCP socket.
Set to FREERTOSSOCKDGRAM to create a UDP socket. No other values are valid. [no other choices -> SOCKRAW] xProtocol Set to FREERTOSIPPROTOTCP to create a TCP socket. Set to FREERTOSIPPROTOUDP to create a UDP socket. No other values are valid. [no other choices -> IPPROTORAW] So I doubtfull that the stuff exists to do the raw packets. So this begs the question: how likely is it for this functionality to be added?

FreeRTOS +TCP/+UDP – how to send raw ethernet packets?

You are right, there is no support yet for exchanging RAW Ethernet packets. Just curiosity: why would you like to have that feature? What type of packets do you actually want to send? When you send RAW packets, you probably also want to receive responses in a RAW way, or not? It shouldn’t be too difficult to add both sending and reception of RAW packets.