src/node/mac48-address.cc
changeset 3852 9cf7ad0cac85
parent 3549 4eaf02702f17
child 4424 af26433b13bc
     1.1 --- a/src/node/mac48-address.cc	Mon Aug 25 10:02:52 2008 -0700
     1.2 +++ b/src/node/mac48-address.cc	Fri Nov 07 11:36:15 2008 -0800
     1.3 @@ -170,6 +170,12 @@
     1.4    static Mac48Address multicast = Mac48Address ("01:00:5e:00:00:00");
     1.5    return multicast;
     1.6  }
     1.7 +Mac48Address
     1.8 +Mac48Address::GetMulticast6Prefix (void)
     1.9 +{
    1.10 +  static Mac48Address multicast = Mac48Address ("33:33:00:00:00:00");
    1.11 +  return multicast;
    1.12 +}
    1.13  Mac48Address 
    1.14  Mac48Address::GetMulticast (Ipv4Address multicastGroup)
    1.15  {
    1.16 @@ -206,6 +212,26 @@
    1.17    result.CopyFrom (etherBuffer);
    1.18    return result;
    1.19  }
    1.20 +Mac48Address Mac48Address::GetMulticast(Ipv6Address addr)
    1.21 +{
    1.22 +  Mac48Address etherAddr = Mac48Address::GetMulticast6Prefix();
    1.23 +  uint8_t etherBuffer[6];
    1.24 +  uint8_t ipBuffer[16];
    1.25 +
    1.26 +  /* a MAC multicast IPv6 address is like 33:33 and the four low bytes */
    1.27 +  /* for 2001:db8::2fff:fe11:ac10 => 33:33:FE:11:AC:10 */
    1.28 +  etherAddr.CopyTo (etherBuffer);
    1.29 +  addr.Serialize (ipBuffer);
    1.30 +
    1.31 +  etherBuffer[2] = ipBuffer[12];
    1.32 +  etherBuffer[3] = ipBuffer[13];
    1.33 +  etherBuffer[4] = ipBuffer[14];
    1.34 +  etherBuffer[5] = ipBuffer[15];
    1.35 +
    1.36 +  etherAddr.CopyFrom (etherBuffer);
    1.37 +
    1.38 +  return etherAddr;
    1.39 +}
    1.40  
    1.41  bool operator == (const Mac48Address &a, const Mac48Address &b)
    1.42  {