Created MOOSE Bridge Net Device. Added MOOSE Addressing.
authorRichard Whitehouse <github@richardwhiuk.com>
Mon, 24 Jan 2011 12:09:25 +0000 (12:09 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Mon, 24 Jan 2011 12:09:25 +0000 (12:09 +0000)
Todo: Implement packet rewriting in Moose Net Device.

16 files changed:
code/src/devices/bridge/model/bridge-net-device.cc
code/src/devices/bridge/model/bridge-net-device.h
code/src/devices/bridge/model/bridge-port-net-device.h
code/src/devices/bridge/model/moose-bridge-net-device.cc [new file with mode: 0644]
code/src/devices/bridge/model/moose-bridge-net-device.h [new file with mode: 0644]
code/src/devices/bridge/model/moose-bridge-port-net-device.cc [new file with mode: 0644]
code/src/devices/bridge/model/moose-bridge-port-net-device.h [new file with mode: 0644]
code/src/devices/bridge/wscript
code/src/node/mac48-address.h
code/src/node/moose-address.cc [new file with mode: 0644]
code/src/node/moose-address.h [new file with mode: 0644]
code/src/node/moose-prefix-address.cc [new file with mode: 0644]
code/src/node/moose-prefix-address.h [new file with mode: 0644]
code/src/node/moose-suffix-address.cc [new file with mode: 0644]
code/src/node/moose-suffix-address.h [new file with mode: 0644]
code/src/node/wscript

index 853997f9564f1fe6e312e91c6e9f5473280d75ba..602426d3a9f10f3cae56e27a9343ddba6d8c30cd 100644 (file)
@@ -13,6 +13,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
+ * Author: Richard Whitehouse <ns3@richardwhiuk.com>
  * Author: Gustavo Carneiro  <gjc@inescporto.pt>
  */
 #include "bridge-net-device.h"
@@ -228,19 +229,26 @@ BridgeNetDevice::AddBridgePort (Ptr<NetDevice> device)
   NS_LOG_FUNCTION_NOARGS ();
   NS_ASSERT (device != this);
 
-// This is probably wrong and needs fixing.
+
+  NS_LOG_DEBUG("AddBridgePort(bridge_addr=" << m_address << ", device_address=" << (Mac48Address::ConvertFrom(device->GetAddress())));
+
   if (m_address == Mac48Address ())
     {
       m_address = Mac48Address::ConvertFrom (device->GetAddress ());
     }
 
-  Ptr<BridgePortNetDevice> port = CreateObject<BridgePortNetDevice>(this, device, m_node);
+  Ptr<BridgePortNetDevice> port = CreateBridgePort(this, device, m_node);
 
   m_ports.push_back(port);
   m_channel->AddChannel (device->GetChannel ());
 
 }
 
+Ptr<BridgePortNetDevice>
+BridgeNetDevice::CreateBridgePort(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node){
+       return CreateObject<BridgePortNetDevice>(bridge, device, node);
+}
+
 void 
 BridgeNetDevice::SetIfIndex(const uint32_t index)
 {
index 947e05cff1331023e73695ba739ef4099dac3e4a..a005f1aced2104b408ae57b4bc7d967caaf72ae2 100644 (file)
@@ -24,6 +24,7 @@
 #include "ns3/mac48-address.h"
 #include "ns3/nstime.h"
 #include "ns3/bridge-channel.h"
+#include "ns3/object-factory.h"
 #include <stdint.h>
 #include <string>
 #include <map>
@@ -120,11 +121,13 @@ public:
 protected:
   virtual void DoDispose (void);
 
-  void Forward (Ptr<BridgePortNetDevice> port, Ptr<const Packet> packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType);
-  void ForwardUnicast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
-  void ForwardBroadcast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
-  void Learn (Address const &src, Ptr<BridgePortNetDevice> port);
-  Ptr<BridgePortNetDevice> GetLearnedState (Mac48Address source);
+  virtual void Forward (Ptr<BridgePortNetDevice> port, Ptr<const Packet> packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType);
+  virtual void ForwardUnicast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+  virtual void ForwardBroadcast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+  virtual void Learn (Address const &src, Ptr<BridgePortNetDevice> port);
+  virtual Ptr<BridgePortNetDevice> GetLearnedState (Mac48Address source);
+
+  virtual Ptr<BridgePortNetDevice> CreateBridgePort(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node);
 
 private:
   NetDevice::ReceiveCallback m_rxCallback;
index b9d62bf54a52ae2ecb97e150f0e714e442eaa754..ccc3da0d8ef1e3eecd53cad5edd85da3080d3dc4 100644 (file)
@@ -13,7 +13,6 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
- * Author: Gustavo Carneiro  <gjc@inescporto.pt>
  * Author: Richard Whitehouse <ns3@richardwhiuk.com>
  */
 #ifndef BRIDGE_PORT_NET_DEVICE_H
diff --git a/code/src/devices/bridge/model/moose-bridge-net-device.cc b/code/src/devices/bridge/model/moose-bridge-net-device.cc
new file mode 100644 (file)
index 0000000..f066c3b
--- /dev/null
@@ -0,0 +1,70 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ * Author: Gustavo Carneiro  <gjc@inescporto.pt>
+ */
+
+#include "moose-bridge-net-device.h"
+#include "moose-bridge-port-net-device.h"
+#include "ns3/log.h"
+#include "ns3/node.h"
+
+NS_LOG_COMPONENT_DEFINE ("MooseBridgeNetDevice");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (MooseBridgeNetDevice);
+
+TypeId
+MooseBridgeNetDevice::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MooseBridgeNetDevice")
+    .SetParent<BridgeNetDevice> ()
+    .AddConstructor<MooseBridgeNetDevice> ();
+  return tid;
+}
+
+MooseBridgeNetDevice::MooseBridgeNetDevice() : BridgeNetDevice() {
+  NS_LOG_FUNCTION_NOARGS ();
+
+  m_mooseAddress = MooseAddress::Allocate();
+
+}
+
+MooseBridgeNetDevice::~MooseBridgeNetDevice(){
+  NS_LOG_FUNCTION_NOARGS ();
+}
+
+Ptr<BridgePortNetDevice> MooseBridgeNetDevice::CreateBridgePort(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node){
+       return CreateObject<MooseBridgePortNetDevice>(bridge, device, node);
+}
+
+/*
+//bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
+//bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
+
+void Forward (Ptr<BridgePortNetDevice> port, Ptr<const Packet> packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType){
+       
+}
+
+void ForwardUnicast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+void ForwardBroadcast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+void Learn (Address const &src, Ptr<BridgePortNetDevice> port);
+Ptr<BridgePortNetDevice> GetLearnedState (Mac48Address source);*/
+
+
+}
+
diff --git a/code/src/devices/bridge/model/moose-bridge-net-device.h b/code/src/devices/bridge/model/moose-bridge-net-device.h
new file mode 100644 (file)
index 0000000..9f39dcb
--- /dev/null
@@ -0,0 +1,103 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+#ifndef MOOSE_BRIDGE_NET_DEVICE_H
+#define MOOSE_BRIDGE_NET_DEVICE_H
+
+#include "bridge-net-device.h"
+#include "ns3/moose-address.h"
+#include "ns3/moose-prefix-address.h"
+#include "ns3/moose-suffix-address.h"
+
+namespace ns3 {
+
+/**
+ * \ingroup bridge
+ * \brief a virtual net device that bridges multiple LAN segments
+ * 
+ * MOOSE (Multi-Level Origin Organised Scalable Ethernet) Implementation
+ */
+class MooseBridgeNetDevice : public BridgeNetDevice
+{
+
+public:
+  static TypeId GetTypeId (void);
+  MooseBridgeNetDevice ();
+  virtual ~MooseBridgeNetDevice ();
+
+protected:
+
+// From NetDevice
+
+// Unconvinced we need these...
+
+//  virtual bool Send (Ptr<Packet> packet, const Address& dest, uint16_t protocolNumber);
+//  virtual bool SendFrom (Ptr<Packet> packet, const Address& source, const Address& dest, uint16_t protocolNumber);
+
+// From BridgeNetDevice
+
+/*
+
+  virtual void Forward (Ptr<BridgePortNetDevice> port, Ptr<const Packet> packet, uint16_t protocol, Address const &src, Address const &dst, PacketType packetType);
+  virtual void ForwardUnicast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+  virtual void ForwardBroadcast (Ptr<BridgePortNetDevice> incomingPort, Ptr<const Packet> packet, uint16_t protocol, Mac48Address src, Mac48Address dst);
+  virtual void Learn (Address const &src, Ptr<BridgePortNetDevice> port);
+  virtual Ptr<BridgePortNetDevice> GetLearnedState (Mac48Address source); */
+
+  virtual Ptr<BridgePortNetDevice> CreateBridgePort(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node);
+
+private:
+
+// Need more types of state
+
+/**
+  Local Port Mappings
+       -- Implemented in parent.
+
+  struct LearnedState
+  {
+    Ptr<BridgePortNetDevice> associatedPort;
+    Time expirationTime;
+  };
+  std::map<Mac48Address, LearnedState> m_learnState;
+**/
+
+  MooseAddress m_mooseAddress;
+
+  // Remote Moose State
+
+  struct PrefixState
+  {
+    Ptr<BridgePortNetDevice> associatedPort;
+    Time expirationTime;
+  };
+  std::map<MoosePrefixAddress, PrefixState> m_remoteState;
+
+  // Local Moose State
+
+  struct SuffixState
+  {
+    Mac48Address ethernetAddr;
+    Time expirationTime;
+  };
+  std::map<MooseSuffixAddress, PrefixState> m_localState;
+
+};
+
+} // namespace ns3
+
+#endif
diff --git a/code/src/devices/bridge/model/moose-bridge-port-net-device.cc b/code/src/devices/bridge/model/moose-bridge-port-net-device.cc
new file mode 100644 (file)
index 0000000..59a74ca
--- /dev/null
@@ -0,0 +1,56 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "bridge-net-device.h"
+#include "moose-bridge-net-device.h"
+#include "bridge-port-net-device.h"
+#include "moose-bridge-port-net-device.h"
+#include "ns3/node.h"
+#include "ns3/channel.h"
+#include "ns3/packet.h"
+#include "ns3/log.h"
+#include "ns3/boolean.h"
+#include "ns3/simulator.h"
+#include "ns3/uinteger.h"
+
+NS_LOG_COMPONENT_DEFINE ("MooseBridgePortNetDevice");
+
+namespace ns3 {
+
+NS_OBJECT_ENSURE_REGISTERED (MooseBridgePortNetDevice);
+
+TypeId
+MooseBridgePortNetDevice::GetTypeId (void)
+{
+  static TypeId tid = TypeId ("ns3::MooseBridgePortNetDevice")
+    .SetParent<BridgePortNetDevice> ()
+    ;
+  return tid;
+}
+
+MooseBridgePortNetDevice::MooseBridgePortNetDevice(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node) : BridgePortNetDevice(bridge,device,node){
+  NS_LOG_FUNCTION_NOARGS ();
+}
+
+MooseBridgePortNetDevice::~MooseBridgePortNetDevice(){
+  NS_LOG_FUNCTION_NOARGS ();
+}
+
+}
+
+
diff --git a/code/src/devices/bridge/model/moose-bridge-port-net-device.h b/code/src/devices/bridge/model/moose-bridge-port-net-device.h
new file mode 100644 (file)
index 0000000..f0dfa78
--- /dev/null
@@ -0,0 +1,54 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+#ifndef MOOSE_BRIDGE_PORT_NET_DEVICE_H
+#define MOOSE_BRIDGE_PORT_NET_DEVICE_H
+
+#include "bridge-port-net-device.h"
+#include "ns3/net-device.h"
+#include "ns3/mac48-address.h"
+#include "ns3/moose-address.h"
+#include "ns3/moose-prefix-address.h"
+#include "ns3/moose-suffix-address.h"
+#include "ns3/nstime.h"
+#include <stdint.h>
+#include <string>
+#include <map>
+
+namespace ns3 {
+
+class Node;
+class BridgeNetDevice;
+
+/**
+ * \ingroup bridge
+ * \brief a port on a virtual net device that bridges multiple LAN segments
+ */
+
+class MooseBridgePortNetDevice : public BridgePortNetDevice  {
+
+public:
+  MooseBridgePortNetDevice(Ptr<BridgeNetDevice> bridge, Ptr<NetDevice> device, Ptr<Node> node);
+  virtual ~MooseBridgePortNetDevice();
+
+  static TypeId GetTypeId (void);
+
+};
+
+}
+
+#endif
index a14d756ad4a49df0c1183ec774a691df0897722b..13d18be99e41fbc60445d2d5f4af2692fb19af1f 100644 (file)
@@ -3,6 +3,8 @@
 def build(bld):
     obj = bld.create_ns3_module('bridge', ['node'])
     obj.source = [
+       'model/moose-bridge-port-net-device.cc',
+       'model/moose-bridge-net-device.cc',
         'model/bridge-net-device.cc',
         'model/bridge-port-net-device.cc',
         'model/bridge-channel.cc',
@@ -11,6 +13,8 @@ def build(bld):
     headers = bld.new_task_gen('ns3header')
     headers.module = 'bridge'
     headers.source = [
+        'model/moose-bridge-port-net-device.h',
+       'model/moose-bridge-net-device.h',
         'model/bridge-net-device.h',
        'model/bridge-port-net-device.h',
         'model/bridge-channel.h',
index 936cec0e84bc2e2cd67de79d1cd02242d124ddcc..f75e3a690cdf30028aa116a052544457fe9c0577 100644 (file)
@@ -125,6 +125,7 @@ public:
    * \returns a multicast address.
    */
   static Mac48Address GetMulticast6Prefix (void);
+
 private:
   /**
    * \returns a new Address instance
diff --git a/code/src/node/moose-address.cc b/code/src/node/moose-address.cc
new file mode 100644 (file)
index 0000000..ab300a0
--- /dev/null
@@ -0,0 +1,102 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "moose-address.h"
+#include <map>
+
+namespace ns3 {
+
+MooseAddress::MooseAddress (){
+   memset (m_address, 0, 6);
+}
+
+MooseAddress::MooseAddress (const char *str) {
+   memset (m_address, 0, 6);
+   Mac48Address mac(str);
+   mac.CopyTo(m_address);
+}
+
+MooseAddress::MooseAddress (const Mac48Address &mac) {
+   memset (m_address, 0, 6);
+   mac.CopyTo(m_address);
+}
+
+const MoosePrefixAddress MooseAddress::GetMoosePrefix() const
+{
+   MoosePrefixAddress prefix(m_address + 1);  
+   return prefix;
+}
+
+const MooseSuffixAddress MooseAddress::GetMooseSuffix() const
+{
+   MooseSuffixAddress suffix(m_address + 3);  
+   return suffix;
+}
+
+const Mac48Address MooseAddress::GetMacAddress() const
+{
+   Mac48Address mac;
+   mac.CopyFrom(m_address);
+   return mac;
+}
+
+bool MooseAddress::IsMoose () const
+{
+  return (m_address[0] & 0x02) == 0x02;
+}
+
+MooseAddress MooseAddress::Allocate()
+{
+  static uint16_t id = 0;
+  ++id;
+
+  MooseAddress moose;
+
+  moose.m_address[0] = 0 | 0x02;
+  moose.m_address[1] = (id >> 8) & 0xff;
+  moose.m_address[2] = (id >> 0) & 0xff;
+
+  return moose;
+}
+
+MooseAddress MooseAddress::Allocate(MoosePrefixAddress prefix){
+
+  static std::map<uint16_t, uint32_t> ids;
+
+  uint16_t key = prefix.GetInt();
+
+  uint16_t val = ++ids[key];
+
+  MooseAddress moose;
+  moose.m_address[0] = 0 | 0x02;                       // MOOSE Address
+
+  moose.m_address[1] = (key >>  8) & 0xff;             // Bridge
+  moose.m_address[2] = (key >>  0) & 0xff;
+
+  moose.m_address[3] = (val >> 16) & 0xff;             // Port
+  moose.m_address[4] = (val >>  8) & 0xff;
+  moose.m_address[5] = (val >>  0) & 0xff;
+
+  return moose;
+
+}
+
+}
+
diff --git a/code/src/node/moose-address.h b/code/src/node/moose-address.h
new file mode 100644 (file)
index 0000000..74253de
--- /dev/null
@@ -0,0 +1,88 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+#ifndef MOOSE_ADDRESS_H
+#define MOOSE_ADDRESS_H
+
+#include "moose-prefix-address.h"
+#include "moose-suffix-address.h"
+#include "mac48-address.h"
+
+namespace ns3 {
+
+class Address;
+
+/**
+ * \ingroup address
+ * 
+ * \brief a MOOSE (Multi-Level Object Orientated Ethernet) address
+ *
+ * This class can contain 48 bit MOOSE addresses.
+ */
+class MooseAddress
+{
+public:
+  MooseAddress ();
+  MooseAddress (const char *str);
+  MooseAddress (const Mac48Address &mac);
+
+  /**
+   * \returns true if this is a MOOSE address, false otherwise.
+   */
+
+  bool IsMoose() const;
+
+  /**
+   * \returns the MOOSE prefix
+   */
+
+  const MoosePrefixAddress GetMoosePrefix() const;
+
+  /**
+   * \returns the MOOSE prefix
+   */
+
+  const MooseSuffixAddress GetMooseSuffix() const;
+
+  /**
+   * \returns the Mac48Address
+   */
+
+  const Mac48Address GetMacAddress() const;
+
+  /**
+   * Allocate a new Moose Bridge Address.
+   */
+  static MooseAddress Allocate ();
+
+  /**
+   * Allocate a new Moose Host Address.
+   */
+  static MooseAddress Allocate (MoosePrefixAddress prefix);
+
+private:
+
+  uint8_t m_address[6];
+
+};
+
+}
+
+#endif
+
diff --git a/code/src/node/moose-prefix-address.cc b/code/src/node/moose-prefix-address.cc
new file mode 100644 (file)
index 0000000..5c8503c
--- /dev/null
@@ -0,0 +1,41 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "moose-prefix-address.h"
+
+namespace ns3 {
+
+MoosePrefixAddress::MoosePrefixAddress (){
+   memset (m_address, 0, 2);
+}
+
+MoosePrefixAddress::MoosePrefixAddress(const uint8_t buffer[2]){
+  memcpy(m_address, buffer, 2);
+}
+
+const uint16_t MoosePrefixAddress::GetInt() const{
+  uint16_t i;
+  i = m_address[0];
+  i += m_address[1] << 8;
+  return i;
+}
+
+
+}
diff --git a/code/src/node/moose-prefix-address.h b/code/src/node/moose-prefix-address.h
new file mode 100644 (file)
index 0000000..df332d0
--- /dev/null
@@ -0,0 +1,72 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+#ifndef MOOSE_PREFIX_ADDRESS_H
+#define MOOSE_PREFIX_ADDRESS_H
+
+#include <ostream>
+#include <string.h>
+#include <stdint.h>
+
+namespace ns3 {
+
+class MoosePrefixAddress {
+
+public:
+  MoosePrefixAddress();
+  MoosePrefixAddress(const uint8_t buffer[2]);
+  const uint16_t GetInt() const;
+
+private:
+
+  uint8_t m_address[2];
+
+  friend bool operator < (const MoosePrefixAddress &a, const MoosePrefixAddress &b);
+  friend bool operator == (const MoosePrefixAddress &a, const MoosePrefixAddress &b);
+  friend bool operator != (const MoosePrefixAddress &a, const MoosePrefixAddress &b);
+  friend std::istream& operator>> (std::istream& is, MoosePrefixAddress & address);
+
+  friend class MooseAddress;
+
+};
+
+/**
+ * \class ns3::Mac48AddressValue
+ * \brief hold objects of type ns3::Mac48Address
+ */
+
+inline bool operator == (const MoosePrefixAddress &a, const MoosePrefixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 2) == 0;
+}
+inline bool operator != (const MoosePrefixAddress &a, const MoosePrefixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 2) != 0;
+}
+inline bool operator < (const MoosePrefixAddress &a, const MoosePrefixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 2) < 0;
+}
+
+std::istream& operator>> (std::istream& is, MoosePrefixAddress & address);
+
+} // namespace ns3
+
+
+#endif
diff --git a/code/src/node/moose-suffix-address.cc b/code/src/node/moose-suffix-address.cc
new file mode 100644 (file)
index 0000000..49dc814
--- /dev/null
@@ -0,0 +1,35 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "moose-suffix-address.h"
+
+namespace ns3 {
+
+MooseSuffixAddress::MooseSuffixAddress (){
+   memset (m_address, 0, 6);
+}
+
+MooseSuffixAddress::MooseSuffixAddress(const uint8_t buffer[3]){
+  memcpy(m_address, buffer, 3);
+}
+
+
+
+}
diff --git a/code/src/node/moose-suffix-address.h b/code/src/node/moose-suffix-address.h
new file mode 100644 (file)
index 0000000..6827101
--- /dev/null
@@ -0,0 +1,68 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2007 INRIA
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+#ifndef MOOSE_SUFFIX_ADDRESS_H
+#define MOOSE_SUFFIX_ADDRESS_H
+
+#include <string.h>
+#include <ostream>
+#include <stdint.h>
+
+namespace ns3 {
+
+class MooseSuffixAddress {
+
+public:
+  MooseSuffixAddress();
+  MooseSuffixAddress(const uint8_t buffer[3]);
+
+private:
+
+  uint8_t m_address[6];
+
+  friend bool operator < (const MooseSuffixAddress &a, const MooseSuffixAddress &b);
+  friend bool operator == (const MooseSuffixAddress &a, const MooseSuffixAddress &b);
+  friend bool operator != (const MooseSuffixAddress &a, const MooseSuffixAddress &b);
+  friend std::istream& operator>> (std::istream& is, MooseSuffixAddress & address);
+
+};
+
+/**
+ * \class ns3::Mac48AddressValue
+ * \brief hold objects of type ns3::Mac48Address
+ */
+
+inline bool operator == (const MooseSuffixAddress &a, const MooseSuffixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 3) == 0;
+}
+inline bool operator != (const MooseSuffixAddress &a, const MooseSuffixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 3) != 0;
+}
+inline bool operator < (const MooseSuffixAddress &a, const MooseSuffixAddress &b)
+{
+  return memcmp (a.m_address, b.m_address, 3) < 0;
+}
+
+std::istream& operator>> (std::istream& is, MooseSuffixAddress & address);
+
+} // namespace ns3
+
+#endif
index 8c9764d85bb322d36f90982ce44c416f155cc9e9..f8a0bfcdfbdc3bae16168e9fb3e794d031563079 100644 (file)
@@ -5,6 +5,9 @@ def build(bld):
     node.source = [
         'address.cc',
         'mac48-address.cc',
+        'moose-address.cc',
+        'moose-prefix-address.cc',
+        'moose-suffix-address.cc',
         'mac64-address.cc',
         'inet-socket-address.cc',
         'packet-socket-address.cc',
@@ -60,6 +63,9 @@ def build(bld):
     headers.source = [
         'address.h',
         'mac48-address.h',
+        'moose-address.h',
+        'moose-prefix-address.h',
+        'moose-suffix-address.h',
         'mac64-address.h',
         'inet-socket-address.h',
         'packet-socket-address.h',