where m_buffer is:
////////////////////////////
// Setup 0x0101 packet data
m_buffer_0101_len = sizeof(struct ether_header) + 98;
m_buffer_0101 = (char *)calloc(m_buffer_0101_len, 1);
if (!m_buffer_0101)
{
LogErr(VB_CHANNELOUT, “Error allocating m_buffer_0101\n”);
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
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/FreeRTOS_Plus_TCP/Network_interface_functions.html
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 AF_PACKET (which I understand is a Linux term) nor SOCK_RAW 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?
So I see this:
xDomain Must be set to FREERTOS_AF_INET. [no other choices}
xType Set to FREERTOS_SOCK_STREAM to create a TCP socket.
Set to FREERTOS_SOCK_DGRAM to create a UDP socket.
No other values are valid. [no other choices -> SOCKRAW]
xProtocol Set to FREERTOS_IPPROTO_TCP to create a TCP socket.
Set to FREERTOS_IPPROTO_UDP 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?
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.
It seems like you are using LWIP network stack. I would suggest reaching out to the LWIP forum/mailing list if you wish to keep using that.
It would be great if you could share the use case you are trying to solve so that we could suggest possible alternatives if any.
FreeRTOS+TCP does not support raw ethernet packets yet, but it has trace macros like: iptraceNETWORK_INTERFACE_INPUT and iptraceNETWORK_INTERFACE_OUTPUT which can be defined to a user defined function in the application so that all the RAW TX, RX packets of the FreeRTOS+TCP stack will be passed to these functions (via pucEthernetBuffer pointer).
Note that based on where these macros are invoked from in the library, it can be either called from the IP task, network interface task, or even user application tasks.