heinbali01 wrote on Thursday, September 01, 2016:
Indeed there is no explicit support for multi-cast (except for LLMNR and LinkLayer Auto-IP).
The reception of multi-cast packets is perfectly possible if you:
ipconfigETHERNET_DRIVER_FILTERS_PACKETS as 1 to stop the IP-task from filtering packets
● program the EMAC peripheral to allow for multi-cast IP addresses, this often uses a hash table
● create an ordinary UDP socket and bind it to the target port number
Suppose you want to serve these two end-points:
22.214.171.124 port 5000
126.96.36.199 port 5000
The IP-task will forward all multi-cast packets to a UDP socket bound to port 5000. Just like normal UDP traffic you can receive the messages by calling:
struct freertos_sockaddr *pxSourceAddress,
socklen_t *pxSourceAddressLength )
When receiving a UDP packet, you get to know the source IP-address and source port number. What you do not know is the destination address (x.x.x.37/x.x.x.38 in this example)
In an email you asked:
I saw that there are some advanced callback features in the stack.
Any of those do what I’m looking for?
For your UDP application
FREERTOS_SO_UDP_RECV_HANDLER might be useful.
You’ll find an example in
#if( ipconfigUSE_CALLBACKS != 0 )
memset( &xHandler, '\0', sizeof ( xHandler ) );
xHandler.pxOnUDPReceive = xOnUDPReceive;
FreeRTOS_setsockopt( xUDPSocket, 0, FREERTOS_SO_UDP_RECV_HANDLER, ( void * ) &xHandler, sizeof( xHandler ) );
You also get to see the destination address in
static BaseType_t xOnUDPReceive( Socket_t xSocket, void * pvData, size_t xLength,
const struct freertos_sockaddr *pxFrom, const struct freertos_sockaddr *pxDest )
/* When returning non-zero, the packet data will be released.
When returning zero, the packet data can still be received in a
call to FreeRTOS_recvfrom(). */
The driver will pass both addresses:
We called the call-back mechanisms “advanced” because they must be handled with care. Be aware that the function is called from the IP-task, which has its own high priority and its own small stack. It is not wise to do a blocking call from within a call-back. Also the use of +TCP API’s is very limited.
Conclusion: it is very well possible to receive multi-cast traffic. When using
FREERTOS_SO_UDP_RECV_HANDLER it is possible to see both source and destination address of each incoming packet.
Replying to multi-cast messages is only possible with normal UDP, i.e. from the local IP address