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));
if (sendto(mfd, mbuffer0101, mbuffer0101len, 0, (struct sockaddr*)&msockaddr, sizeof(struct sockaddrll)) < 0)
LogErr(VBCHANNELOUT, "Error sending 0x0101 packet: %sn", strerror(errno));
where mbuffer is:
// Setup 0x0101 packet data
mbuffer0101len = sizeof(struct etherheader) + 98;
mbuffer0101 = (char *)calloc(mbuffer0101len, 1);
LogErr(VBCHANNELOUT, "Error allocating mbuffer_0101n");
memset(m_buffer_0101, 0, m_buffer_0101_len);
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.
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
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?
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?
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.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.