--- a/src/routing/click/ipv4-click-routing.cc Thu Jun 24 12:10:21 2010 +0530
+++ b/src/routing/click/ipv4-click-routing.cc Thu Jun 24 12:13:33 2010 +0530
@@ -29,6 +29,7 @@
#include "ns3/ipv4-interface.h"
#include "ns3/ipv4-l3-click-protocol.h"
#include "ns3/llc-snap-header.h"
+#include "ns3/csma-net-device.h"
#include "ipv4-click-routing.h"
#include <string>
@@ -272,24 +273,32 @@
// NetDevice::Send () attaches ethernet headers,
// so this one's not required.
- EthernetHeader header;
- p->RemoveHeader (header);
+
+ Ptr<NetDevice> netdev = m_ipv4->GetNetDevice (ifid);
- uint16_t protocol;
+ if (DynamicCast<CsmaNetDevice> (netdev))
+ {
+ EthernetHeader header;
+ p->PeekHeader (header);
+
+ uint16_t protocol;
- if (header.GetLengthType () <= 1500)
- {
- LlcSnapHeader llc;
- p->RemoveHeader (llc);
- protocol = llc.GetType ();
+ if (header.GetLengthType () <= 1500)
+ {
+ LlcSnapHeader llc;
+ p->PeekHeader (llc);
+ protocol = llc.GetType ();
+ }
+ else
+ {
+ protocol = header.GetLengthType ();
+ }
+ netdev->Send (p, header.GetDestination (), protocol);
}
else
{
- protocol = header.GetLengthType ();
+ NS_LOG_ERROR ("Ipv4ClickRouting: Non CSMA devices not supported yet");
}
-
- Ptr<NetDevice> netdev = m_ipv4->GetNetDevice (ifid);
- netdev->Send (p, header.GetDestination (), protocol);
}
}