src/node/node.h
changeset 3460 99698bc858e8
parent 3450 73e90de6eb47
child 3516 dacc57c5d31f
equal deleted inserted replaced
3459:a67df503c7bc 3460:99698bc858e8
   134    */
   134    */
   135   uint32_t GetNApplications (void) const;
   135   uint32_t GetNApplications (void) const;
   136 
   136 
   137   /**
   137   /**
   138    * A protocol handler
   138    * A protocol handler
       
   139    *
       
   140    * \param device a pointer to the net device which received the packet
       
   141    * \param packet the packet received
       
   142    * \param protocol the 16 bit protocol number associated with this packet.
       
   143    *        This protocol number is expected to be the same protocol number
       
   144    *        given to the Send method by the user on the sender side.
       
   145    * \param sender the address of the sender
       
   146    * \param receiver the address of the receiver; Note: this value is
       
   147    *                 only valid for promiscuous mode protocol
       
   148    *                 handlers.
       
   149    * \param packetType type of packet received
       
   150    *                   (broadcast/multicast/unicast/otherhost); Note:
       
   151    *                   this value is only valid for promiscuous mode
       
   152    *                   protocol handlers.
   139    */
   153    */
   140   typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,const Address &,
   154   typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,const Address &,
   141                    const Address &, NetDevice::PacketType> ProtocolHandler;
   155                    const Address &, NetDevice::PacketType> ProtocolHandler;
   142   /**
   156   /**
   143    * \param handler the handler to register
   157    * \param handler the handler to register
   148    *        the value zero is interpreted as matching all
   162    *        the value zero is interpreted as matching all
   149    *        protocols.
   163    *        protocols.
   150    * \param device the device attached to this handler. If the
   164    * \param device the device attached to this handler. If the
   151    *        value is zero, the handler is attached to all
   165    *        value is zero, the handler is attached to all
   152    *        devices on this node.
   166    *        devices on this node.
       
   167    * \param promiscuous whether to register a promiscuous mode handler
   153    */
   168    */
   154   void RegisterProtocolHandler (ProtocolHandler handler, 
   169   void RegisterProtocolHandler (ProtocolHandler handler, 
   155                                 uint16_t protocolType,
   170                                 uint16_t protocolType,
   156                                 Ptr<NetDevice> device);
   171                                 Ptr<NetDevice> device,
       
   172                                 bool promiscuous=false);
   157   /**
   173   /**
   158    * \param handler the handler to unregister
   174    * \param handler the handler to unregister
   159    *
   175    *
   160    * After this call returns, the input handler will never
   176    * After this call returns, the input handler will never
   161    * be invoked anymore.
   177    * be invoked anymore.
   162    */
   178    */
   163   void UnregisterProtocolHandler (ProtocolHandler handler);
   179   void UnregisterProtocolHandler (ProtocolHandler handler);
   164 
       
   165   /**
       
   166    * A promiscuous protocol handler
       
   167    */
       
   168   typedef Callback<void,Ptr<NetDevice>, Ptr<Packet>,uint16_t,
       
   169                    const Address &, const Address &, bool> PromiscuousProtocolHandler;
       
   170   /**
       
   171    * \param handler the handler to register
       
   172    * \param protocolType the type of protocol this handler is 
       
   173    *        interested in. This protocol type is a so-called
       
   174    *        EtherType, as registered here:
       
   175    *        http://standards.ieee.org/regauth/ethertype/eth.txt
       
   176    *        the value zero is interpreted as matching all
       
   177    *        protocols.
       
   178    * \param device the device attached to this handler. If the
       
   179    *        value is zero, the handler is attached to all
       
   180    *        devices on this node.
       
   181    */
       
   182   void RegisterPromiscuousProtocolHandler (PromiscuousProtocolHandler handler, 
       
   183                                            uint16_t protocolType,
       
   184                                            Ptr<NetDevice> device);
       
   185   /**
       
   186    * \param handler the handler to unregister
       
   187    *
       
   188    * After this call returns, the input handler will never
       
   189    * be invoked anymore.
       
   190    */
       
   191   void UnregisterPromiscuousProtocolHandler (PromiscuousProtocolHandler handler);
       
   192 
   180 
   193 
   181 
   194 protected:
   182 protected:
   195   /**
   183   /**
   196    * The dispose method. Subclasses must override this method
   184    * The dispose method. Subclasses must override this method
   205    *
   193    *
   206    * This method is invoked whenever a user calls Node::AddDevice.
   194    * This method is invoked whenever a user calls Node::AddDevice.
   207    */
   195    */
   208   virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
   196   virtual void NotifyDeviceAdded (Ptr<NetDevice> device);
   209 
   197 
       
   198   bool NonPromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol, const Address &from);
       
   199   bool PromiscReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
       
   200                                  const Address &from, const Address &to, NetDevice::PacketType packetType);
   210   bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
   201   bool ReceiveFromDevice (Ptr<NetDevice> device, Ptr<Packet>, uint16_t protocol,
   211                           const Address &from, const Address &to, NetDevice::PacketType packetType);
   202                           const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc);
       
   203 
   212   void Construct (void);
   204   void Construct (void);
   213 
   205 
   214   struct ProtocolHandlerEntry {
   206   struct ProtocolHandlerEntry {
   215     ProtocolHandler handler;
   207     ProtocolHandler handler;
       
   208     Ptr<NetDevice> device;
   216     uint16_t protocol;
   209     uint16_t protocol;
   217     Ptr<NetDevice> device;
   210     bool promiscuous;
   218   };
   211   };
   219   typedef std::vector<struct Node::ProtocolHandlerEntry> ProtocolHandlerList;
   212   typedef std::vector<struct Node::ProtocolHandlerEntry> ProtocolHandlerList;
   220   uint32_t    m_id;         // Node id for this node
   213   uint32_t    m_id;         // Node id for this node
   221   uint32_t    m_sid;        // System id for this node
   214   uint32_t    m_sid;        // System id for this node
   222   std::vector<Ptr<NetDevice> > m_devices;
   215   std::vector<Ptr<NetDevice> > m_devices;