EtherCard icon indicating copy to clipboard operation
EtherCard copied to clipboard

Forms a proper multicast MAC address for multicast IP.

Open wladwm opened this issue 3 years ago • 1 comments

wladwm avatar Apr 21 '21 07:04 wladwm

At this time, library sets the dst mac as ff:ff:ff:ff:ff:ff when I try to send udp to some multicast (240.0.0.0/4) address. I've added valid dst mac generation. Although you can remove term "(dip[0] & 0xF0) == 0xE0 || " in the following if statement, or just change it to

if (((unsigned long) dip) == 0xFFFFFFFF)

ср, 21 апр. 2021 г. в 11:36, Nicholas Humfrey @.***>:

@.**** commented on this pull request.

In src/tcpip.cpp https://github.com/njh/EtherCard/pull/413#discussion_r617316740:

@@ -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))

Isn't this a duplicate if statement condition?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/njh/EtherCard/pull/413#pullrequestreview-640774264, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALXH6MSZBVR62NSTBAATPPLTJ2FCVANCNFSM43JZSTLQ .

wladwm avatar Apr 21 '21 08:04 wladwm