Forms a proper multicast MAC address for multicast IP.#413
Open
Forms a proper multicast MAC address for multicast IP.#413
Conversation
njh
reviewed
Apr 21, 2021
| } 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)) |
Owner
There was a problem hiding this comment.
Isn't this a duplicate if statement condition?
Author
|
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
<#413 (comment)>:
> @@ -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, #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
<#413 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALXH6MSZBVR62NSTBAATPPLTJ2FCVANCNFSM43JZSTLQ>
.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.