From 6a9ea8829621373d1e1ab2fb45fcf743353416d8 Mon Sep 17 00:00:00 2001 From: Vladimir Melnikov Date: Wed, 21 Apr 2021 10:46:49 +0300 Subject: [PATCH] Forms a proper multicast MAC address for multicast IP. --- src/tcpip.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/tcpip.cpp b/src/tcpip.cpp index 6dbd0957..e876931c 100644 --- a/src/tcpip.cpp +++ b/src/tcpip.cpp @@ -379,6 +379,13 @@ void EtherCard::udpPrepare (uint16_t sport, const uint8_t *dip, uint16_t dport) } else { // checked if dip is dns ip and separately if dip is hisip and then use correct mac. setMACandIPs(gwmacaddr, dip); } + //form a valid multicast mac + if ((dip[0] & 0xF0) == 0xE0){ + uint8_t cMac[6];cMac[0]=1;cMac[1]=0;cMac[2]=0x5e; + memcpy(&cMac[3],dip+1,3); + cMac[3]&=0x7f; + EtherCard::copyMac(gPB + ETH_DST_MAC, cMac); + } else // see http://tldp.org/HOWTO/Multicast-HOWTO-2.html // multicast or broadcast address, https://github.com/njh/EtherCard/issues/59 if ((dip[0] & 0xF0) == 0xE0 || *((unsigned long*) dip) == 0xFFFFFFFF || !memcmp(broadcastip,dip,IP_LEN))