--- a/src/devices/wifi/wifi-remote-station-manager.cc Thu Apr 24 15:44:15 2008 -0700
+++ b/src/devices/wifi/wifi-remote-station-manager.cc Thu Apr 24 15:44:35 2008 -0700
@@ -21,7 +21,7 @@
#include "wifi-remote-station-manager.h"
#include "ns3/assert.h"
#include "ns3/log.h"
-#include "ns3/tag.h"
+#include "ns3/mtag.h"
#include "ns3/boolean.h"
#include "ns3/uinteger.h"
#include "ns3/wifi-phy.h"
@@ -306,7 +306,7 @@
namespace ns3 {
-class TxModeTag : public Tag
+class TxModeTag : public Mtag
{
public:
TxModeTag ();
@@ -314,11 +314,11 @@
WifiMode GetRtsMode (void) const;
WifiMode GetDataMode (void) const;
- static uint32_t GetUid (void);
- void Print (std::ostream &os) const;
- void Serialize (ns3::Buffer::Iterator start) const;
- uint32_t Deserialize (ns3::Buffer::Iterator start);
- uint32_t GetSerializedSize (void) const;
+ static TypeId GetTypeId (void);
+ virtual TypeId GetInstanceTypeId (void) const;
+ virtual uint32_t GetSerializedSize (void) const;
+ virtual void Serialize (MtagBuffer i) const;
+ virtual void Deserialize (MtagBuffer i);
private:
WifiMode m_rtsMode;
WifiMode m_dataMode;
@@ -340,30 +340,46 @@
{
return m_dataMode;
}
-
-uint32_t
-TxModeTag::GetUid (void)
-{
- static uint32_t uid = Tag::AllocateUid<TxModeTag> ("ns3.wifi.TxModeTag");
- return uid;
-}
-void
-TxModeTag::Print (std::ostream &os) const
+TypeId
+TxModeTag::GetTypeId (void)
{
- os << "rts="<<m_rtsMode<<" data="<<m_dataMode;
+ static TypeId tid = TypeId ("ns3::TxModeTag")
+ .SetParent<Mtag> ()
+ .AddConstructor<TxModeTag> ()
+ .AddAttribute ("RtsTxMode",
+ "Tx mode of rts to use later",
+ EmptyAttributeValue (),
+ MakeWifiModeAccessor (&TxModeTag::GetRtsMode),
+ MakeWifiModeChecker ())
+ .AddAttribute ("DataTxMode",
+ "Tx mode of data to use later",
+ EmptyAttributeValue (),
+ MakeWifiModeAccessor (&TxModeTag::GetDataMode),
+ MakeWifiModeChecker ())
+ ;
+ return tid;
}
-void
-TxModeTag::Serialize (ns3::Buffer::Iterator start) const
-{}
-uint32_t
-TxModeTag::Deserialize (ns3::Buffer::Iterator start)
+TypeId
+TxModeTag::GetInstanceTypeId (void) const
{
- return 0;
+ return GetTypeId ();
}
uint32_t
TxModeTag::GetSerializedSize (void) const
{
- return 0;
+ return sizeof (WifiMode) * 2;
+}
+void
+TxModeTag::Serialize (MtagBuffer i) const
+{
+ i.Write ((uint8_t *)&m_rtsMode, sizeof (WifiMode));
+ i.Write ((uint8_t *)&m_dataMode, sizeof (WifiMode));
+}
+void
+TxModeTag::Deserialize (MtagBuffer i)
+{
+ i.Read ((uint8_t *)&m_rtsMode, sizeof (WifiMode));
+ i.Read ((uint8_t *)&m_dataMode, sizeof (WifiMode));
}
} // namespace ns3
@@ -535,7 +551,7 @@
return;
}
TxModeTag tag = TxModeTag (DoGetRtsMode (), DoGetDataMode (fullPacketSize));
- packet->AddTag (tag);
+ packet->AddMtag (tag);
}
WifiMode
WifiRemoteStation::GetDataMode (Ptr<const Packet> packet, uint32_t fullPacketSize)
@@ -546,7 +562,7 @@
}
TxModeTag tag;
bool found;
- found = packet->PeekTag (tag);
+ found = packet->FindFirstMatchingTag (tag);
NS_ASSERT (found);
return tag.GetDataMode ();
}
@@ -559,7 +575,7 @@
}
TxModeTag tag;
bool found;
- found = packet->PeekTag (tag);
+ found = packet->FindFirstMatchingTag (tag);
NS_ASSERT (found);
return tag.GetRtsMode ();
}