src/devices/csma/csma-net-device.cc
changeset 3852 9cf7ad0cac85
parent 3841 1e7abf5fca79
child 3861 dacfd1f07538
     1.1 --- a/src/devices/csma/csma-net-device.cc	Wed Nov 05 14:33:20 2008 -0800
     1.2 +++ b/src/devices/csma/csma-net-device.cc	Fri Nov 07 11:36:15 2008 -0800
     1.3 @@ -600,6 +600,20 @@
     1.4    NS_LOG_FUNCTION (packet << senderDevice);
     1.5    NS_LOG_LOGIC ("UID is " << packet->GetUid ());
     1.6  
     1.7 +  /* IPv6 support*/
     1.8 +  uint8_t mac[6];
     1.9 +  Mac48Address multicast6AllNodes("33:33:00:00:00:01");
    1.10 +  Mac48Address multicast6AllRouters("33:33:00:00:00:02");
    1.11 +  Mac48Address multicast6AllHosts("33:33:00:00:00:03");
    1.12 +  Mac48Address multicast6Node; /* multicast address addressed to our MAC address */
    1.13 +
    1.14 +  /* generate IPv6 multicast ethernet destination that nodes will accept */
    1.15 +  GetAddress().CopyTo(mac);
    1.16 +  mac[0]=0x33;
    1.17 +  mac[1]=0x33;
    1.18 +  /* mac[2]=0xff; */
    1.19 +  multicast6Node.CopyFrom(mac);
    1.20 +
    1.21    //
    1.22    // We never forward up packets that we sent. Real devices don't do this since
    1.23    // their receivers are disabled during send, so we don't. Drop the packet
    1.24 @@ -672,7 +686,11 @@
    1.25            packetType = PACKET_BROADCAST;
    1.26            m_rxTrace (originalPacket);
    1.27          }
    1.28 -      else if (header.GetDestination ().IsMulticast ())
    1.29 +      else if (header.GetDestination ().IsMulticast () ||
    1.30 +          header.GetDestination() == multicast6Node ||
    1.31 +          header.GetDestination() == multicast6AllNodes ||
    1.32 +          header.GetDestination() == multicast6AllRouters ||
    1.33 +          header.GetDestination() == multicast6AllHosts)
    1.34          {
    1.35            packetType = PACKET_MULTICAST;          
    1.36            m_rxTrace (originalPacket);
    1.37 @@ -922,6 +940,14 @@
    1.38    m_rxCallback = cb;
    1.39  }
    1.40  
    1.41 +Address CsmaNetDevice::GetMulticast (Ipv6Address addr) const
    1.42 +{
    1.43 +  Mac48Address ad = Mac48Address::GetMulticast (addr);
    1.44 +
    1.45 +  NS_LOG_LOGIC("MAC IPv6 multicast address is " << ad);
    1.46 +  return ad;
    1.47 +}
    1.48 +
    1.49    void 
    1.50  CsmaNetDevice::SetPromiscReceiveCallback (NetDevice::PromiscReceiveCallback cb)
    1.51  {