add MacHighAdhoc to build
authorMathieu Lacage <mathieu.lacage@sophia.inria.fr>
Tue, 09 Oct 2007 16:11:08 +0200
changeset 1933 59328b2e04e1
parent 1932 72929b535ec4
child 1934 13c65460caee
add MacHighAdhoc to build
src/devices/wifi/mac-high-adhoc.cc
src/devices/wifi/mac-high-adhoc.h
src/devices/wifi/wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/mac-high-adhoc.cc	Tue Oct 09 16:11:08 2007 +0200
@@ -0,0 +1,91 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+
+#include "mac-high-adhoc.h"
+#include "dca-txop.h"
+#include "wifi-net-device.h"
+#include "ns3/packet.h"
+
+#define noADHOC_TRACE 1
+
+#ifdef ADHOC_TRACE
+# include <iostream>
+# define TRACE(x) \
+  std::cout << "HIGH ADHOC "<<x<<std::endl;
+#else /* ADHOC_TRACE */
+# define TRACE(x)
+#endif /* ADHOC_TRACE */
+
+namespace ns3 {
+
+MacHighAdhoc::MacHighAdhoc ()
+{}
+MacHighAdhoc::~MacHighAdhoc ()
+{}
+
+void
+MacHighAdhoc::SetInterface (WifiNetDevice *interface)
+{
+  m_interface = interface;
+
+}
+void 
+MacHighAdhoc::SetForwardCallback (ForwardCallback callback)
+{
+  m_callback = callback;
+}
+void
+MacHighAdhoc::SetDcaTxop (DcaTxop *dca)
+{
+  m_dca = dca;
+}
+
+Mac48Address 
+MacHighAdhoc::GetBssid (void) const
+{
+  // XXX the bssid should be generated by the procedure
+  // described in ieee802.11 section 11.1.3
+  return Mac48Address::GetBroadcast ();
+}
+
+void 
+MacHighAdhoc::Enqueue (Packet packet, Mac48Address to)
+{
+  TRACE ("enqueue size="<<packet.GetSize ()<<", to="<<to<<
+         ", queueSize="<<m_queue->GetSize ());
+  WifiMacHeader hdr;
+  hdr.SetType (WIFI_MAC_DATA);
+  hdr.SetAddr1 (to);
+  hdr.SetAddr2 (m_interface->GetSelfAddress ());
+  hdr.SetAddr3 (m_interface->GetBssid ());
+  hdr.SetDsNotFrom ();
+  hdr.SetDsNotTo ();
+  m_dca->Queue (packet, hdr);
+}
+
+void 
+MacHighAdhoc::Receive (Packet packet, WifiMacHeader const *hdr)
+{
+  TRACE ("received size="<<packet.GetSize ()<<", from="<<hdr->GetAddr2 ());
+  m_callback (packet);
+}
+
+}; // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/devices/wifi/mac-high-adhoc.h	Tue Oct 09 16:11:08 2007 +0200
@@ -0,0 +1,60 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2005 INRIA
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as 
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
+ */
+#ifndef MAC_HIGH_ADHOC_H
+#define MAC_HIGH_ADHOC_H
+
+#include "ns3/mac48-address.h"
+#include "ns3/callback.h"
+#include "ns3/packet.h"
+
+namespace ns3 {
+
+class DcaTxop;
+class Packet;
+class WifiNetDevice;
+class WifiMacHeader;
+
+class MacHighAdhoc {
+public:
+  typedef Callback<void, Packet > ForwardCallback;
+
+  MacHighAdhoc ();
+  ~MacHighAdhoc ();
+
+  void SetInterface (WifiNetDevice *interface);
+  void SetForwardCallback (ForwardCallback callback);
+  void SetDcaTxop (DcaTxop *dca);
+
+  Mac48Address GetBssid (void) const;
+
+  void Enqueue (Packet packet, Mac48Address to);
+
+  /* invoked by the MacLows. */
+  void Receive (Packet packet, WifiMacHeader const*hdr);
+private:
+  DcaTxop *m_dca;
+  WifiNetDevice *m_interface;
+  ForwardCallback m_callback;
+};
+
+}; // namespace ns3
+
+#endif /* MAC_HIGH_ADHOC_H */
--- a/src/devices/wifi/wscript	Tue Oct 09 16:09:37 2007 +0200
+++ b/src/devices/wifi/wscript	Tue Oct 09 16:11:08 2007 +0200
@@ -23,6 +23,7 @@
         'mac-rx-middle.cc',
         'dca-txop.cc',
         'ideal-mac-stations.cc',
+        'mac-high-adhoc.cc',
         ]
     headers = bld.create_obj('ns3header')
     headers.source = [