src/node/node.h
changeset 1186 909e9eb2124e
parent 1176 4894ea885c0f
child 1194 b8e957eb0a94
--- a/src/node/node.h	Tue Jul 31 11:42:25 2007 +0200
+++ b/src/node/node.h	Wed Aug 01 08:58:18 2007 +0200
@@ -33,6 +33,7 @@
 class NetDevice;
 class Application;
 class Packet;
+class Address;
 
 /**
  * \brief A network Node.
@@ -56,6 +57,17 @@
 public:
   static const InterfaceId iid;
 
+  /**
+   * Must be invoked by subclasses only.
+   */
+  Node();
+  /**
+   * \param systemId a unique integer used for parallel simulations.
+   *
+   * Must be invoked by subclasses only.
+   */
+  Node(uint32_t systemId);
+
   virtual ~Node();
 
   /**
@@ -91,11 +103,15 @@
    * Associate this device to this node.
    * This method is called automatically from NetDevice::NetDevice
    * so the user has little reason to call this method himself.
+   * The index returned is always non-zero.
    */
   uint32_t AddDevice (Ptr<NetDevice> device);
   /**
    * \param index the index of the requested NetDevice
    * \returns the requested NetDevice associated to this Node.
+   *
+   * The indexes used by the GetDevice method start at one and
+   * end at GetNDevices ()
    */
   Ptr<NetDevice> GetDevice (uint32_t index) const;
   /**
@@ -128,11 +144,15 @@
   /**
    * A protocol handler
    */
-  typedef Callback<void,const Packet &,uint16_t,Ptr<NetDevice> > ProtocolHandler;
+  typedef Callback<void,Ptr<NetDevice>, const Packet &,uint16_t,const Address &> ProtocolHandler;
   /**
    * \param handler the handler to register
    * \param protocolType the type of protocol this handler is 
-   *        interested in.
+   *        interested in. This protocol type is a so-called
+   *        EtherType, as registered here:
+   *        http://standards.ieee.org/regauth/ethertype/eth.txt
+   *        the value zero is interpreted as matching all
+   *        protocols.
    * \param device the device attached to this handler. If the
    *        value is zero, the handler is attached to all
    *        devices on this node.
@@ -141,18 +161,6 @@
                                 uint16_t protocolType,
                                 Ptr<NetDevice> device);
   /**
-   * \param handler the handler to register
-   * \param device the device attached to this handler. If the
-   *        value is zero, the handler is attached to all
-   *        devices on this node.
-   *
-   * Register a handler to receive all packets for all
-   * protocols.
-   */
-  void RegisterProtocolHandler (ProtocolHandler handler,
-                                Ptr<NetDevice> device);
-
-  /**
    * \param handler the handler to unregister
    *
    * After this call returns, the input handler will never
@@ -162,16 +170,6 @@
 
 protected:
   /**
-   * Must be invoked by subclasses only.
-   */
-  Node();
-  /**
-   * \param systemId a unique integer used for parallel simulations.
-   *
-   * Must be invoked by subclasses only.
-   */
-  Node(uint32_t systemId);
-  /**
    * The dispose method. Subclasses must override this method
    * and must chain up to it by calling Node::DoDispose at the
    * end of their own DoDispose method.
@@ -195,11 +193,12 @@
    */
   virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
 
-  bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet, uint16_t protocol);
+  bool ReceiveFromDevice (Ptr<NetDevice> device, const Packet &packet, 
+                          uint16_t protocol, const Address &from);
+  void Construct (void);
 
   struct ProtocolHandlerEntry {
     ProtocolHandler handler;
-    bool isSpecificProtocol;
     uint16_t protocol;
     Ptr<NetDevice> device;
   };