add constructors to specify the address of a device
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Wed, 21 Nov 2007 09:43:57 +0100
changeset 2151 7c63780653f2
parent 2150 e4aff46fe6c5
child 2152 5c6c0f580aca
add constructors to specify the address of a device
src/devices/wifi/wifi-net-device.cc
src/devices/wifi/wifi-net-device.h
--- a/src/devices/wifi/wifi-net-device.cc	Tue Nov 20 16:45:52 2007 +0100
+++ b/src/devices/wifi/wifi-net-device.cc	Wed Nov 21 09:43:57 2007 +0100
@@ -159,8 +159,12 @@
 WifiNetDevice::WifiNetDevice (Ptr<Node> node)
   : NetDevice (node, Mac48Address::Allocate ())
 {
-  SetMtu (2300);
-  EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
+  Construct ();
+}
+
+WifiNetDevice::WifiNetDevice (Ptr<Node> node, Mac48Address self)
+  : NetDevice (node, self)
+{
   Construct ();
 }
 
@@ -170,6 +174,9 @@
 void
 WifiNetDevice::Construct (void)
 {
+  SetMtu (2300);
+  EnableBroadcast (Mac48Address ("ff:ff:ff:ff:ff:ff"));
+
   // the physical layer.
   m_phy = Create<WifiPhy> (this);
 
@@ -365,6 +372,16 @@
 AdhocWifiNetDevice::AdhocWifiNetDevice (Ptr<Node> node)
   : WifiNetDevice (node)
 {
+  DoConstruct ();
+}
+AdhocWifiNetDevice::AdhocWifiNetDevice (Ptr<Node> node, Mac48Address self)
+  : WifiNetDevice (node, self)
+{
+  DoConstruct ();
+}
+void
+AdhocWifiNetDevice::DoConstruct (void)
+{
   m_ssid = WifiDefaultParameters::GetSsid ();
   m_dca = CreateDca (15, 1023, 2);
 
@@ -378,6 +395,7 @@
   m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighAdhoc::Receive, high));
   m_high = high;
 }
+
 AdhocWifiNetDevice::~AdhocWifiNetDevice ()
 {}
 Mac48Address 
@@ -427,6 +445,16 @@
 NqstaWifiNetDevice::NqstaWifiNetDevice (Ptr<Node> node)
   : WifiNetDevice (node)
 {
+  DoConstruct ();
+}
+NqstaWifiNetDevice::NqstaWifiNetDevice (Ptr<Node> node, Mac48Address self)
+  : WifiNetDevice (node, self)
+{
+  DoConstruct ();
+}
+void
+NqstaWifiNetDevice::DoConstruct (void)
+{
   m_ssid = WifiDefaultParameters::GetSsid ();
   m_dca = CreateDca (15, 1023, 2);
   
@@ -444,6 +472,7 @@
   m_rxMiddle->SetForwardCallback (MakeCallback (&MacHighNqsta::Receive, high));
   m_high = high;
 }
+
 NqstaWifiNetDevice::~NqstaWifiNetDevice ()
 {}
 Mac48Address 
@@ -506,6 +535,17 @@
 NqapWifiNetDevice::NqapWifiNetDevice (Ptr<Node> node)
   : WifiNetDevice (node)
 {
+  DoConstruct ();
+}
+NqapWifiNetDevice::NqapWifiNetDevice (Ptr<Node> node, Mac48Address self)
+  : WifiNetDevice (node, self)
+{
+  DoConstruct ();
+
+}
+void
+NqapWifiNetDevice::DoConstruct (void)
+{
   m_ssid = WifiDefaultParameters::GetSsid ();
 
   // The Beacon DCA is higher priority than
--- a/src/devices/wifi/wifi-net-device.h	Tue Nov 20 16:45:52 2007 +0100
+++ b/src/devices/wifi/wifi-net-device.h	Wed Nov 21 09:43:57 2007 +0100
@@ -118,6 +118,7 @@
   CallbackTraceSource<Packet, Mac48Address> m_txLogger;
 protected:
   WifiNetDevice (Ptr<Node> node);
+  WifiNetDevice (Ptr<Node> node, Mac48Address self);
   void DoForwardUp (Packet packet, const Mac48Address &from);
   virtual void DoDispose (void);
   DcaTxop *CreateDca (uint32_t minCw, uint32_t maxCw, uint32_t aifsn) const;
@@ -143,6 +144,7 @@
 class AdhocWifiNetDevice : public WifiNetDevice {
 public:
   AdhocWifiNetDevice (Ptr<Node> node);
+  AdhocWifiNetDevice (Ptr<Node> node, Mac48Address self);
   virtual ~AdhocWifiNetDevice ();
 
   virtual Mac48Address GetBssid (void) const;
@@ -152,6 +154,7 @@
 protected:
   virtual void DoDispose (void);
 private:
+  void DoConstruct (void);
   void ForwardUp (void);
   virtual bool DoSendTo (const Packet &packet, Mac48Address const & to);
   virtual void NotifyConnected (void);
@@ -178,6 +181,7 @@
    * The ssid is initialized from \valueref{WifiSsid}.
    */
   NqstaWifiNetDevice (Ptr<Node> node);
+  NqstaWifiNetDevice (Ptr<Node> node, Mac48Address self);
   virtual ~NqstaWifiNetDevice ();
 
   virtual Mac48Address GetBssid (void) const;
@@ -193,6 +197,7 @@
 protected:
   virtual void DoDispose (void);
 private:
+  void DoConstruct (void);
   void Associated (void);
   void DisAssociated (void);
   virtual bool DoSendTo (const Packet &packet, Mac48Address const & to);
@@ -218,6 +223,7 @@
    * The ssid is initialized from \valueref{WifiSsid}.
    */
   NqapWifiNetDevice (Ptr<Node> node);
+  NqapWifiNetDevice (Ptr<Node> node, Mac48Address self);
   virtual ~NqapWifiNetDevice ();
 
   virtual Mac48Address GetBssid (void) const;
@@ -227,6 +233,7 @@
 protected:
   virtual void DoDispose (void);
 private:
+  void DoConstruct (void);
   virtual bool DoSendTo (const Packet &packet, Mac48Address const & to);
   virtual void NotifyConnected (void);
   friend class WifiNetDeviceFactory;