--- a/src/click/model/ipv4-l3-click-protocol.cc Sat Jul 16 13:57:50 2011 -0400
+++ b/src/click/model/ipv4-l3-click-protocol.cc Sun Jul 17 11:32:05 2011 +0530
@@ -30,6 +30,7 @@
#include "ns3/net-device.h"
#include "ns3/uinteger.h"
#include "ns3/object-vector.h"
+#include "ns3/wifi-net-device.h"
#include "ns3/ipv4-raw-socket-impl.h"
#include "ns3/arp-l3-protocol.h"
@@ -718,13 +719,20 @@
NS_LOG_FUNCTION (this << device << p << from << to);
Ptr<Packet> packet = p->Copy ();
- // Add an ethernet frame. This allows
- // Click to work with csma and wifi
- EthernetHeader hdr;
- hdr.SetSource (Mac48Address::ConvertFrom (from));
- hdr.SetDestination (Mac48Address::ConvertFrom (to));
- hdr.SetLengthType (protocol);
- packet->AddHeader (hdr);
+ // If we're running a Wifi Device in Monitor mode,
+ // then we need to use Click's Wifi MAC. Else
+ // we attach a 'fake' ethernet header.
+ if (!(DynamicCast<WifiNetDevice> (device) &&
+ DynamicCast<WifiNetDevice> (device)->GetMonitorMode ()))
+ {
+ //Add an ethernet frame. This allows
+ // Click to work with csma and wifi
+ EthernetHeader hdr;
+ hdr.SetSource (Mac48Address::ConvertFrom (from));
+ hdr.SetDestination (Mac48Address::ConvertFrom (to));
+ hdr.SetLengthType (protocol);
+ packet->AddHeader (hdr);
+ }
Ptr<Ipv4ClickRouting> click = DynamicCast<Ipv4ClickRouting> (GetRoutingProtocol ());
click->Receive (packet->Copy (), Mac48Address::ConvertFrom (device->GetAddress ()), Mac48Address::ConvertFrom (to));