src/routing/olsr/model/olsr-routing-protocol.h
changeset 6814 17ff75a3dcbf
parent 6812 a3140070b40a
equal deleted inserted replaced
6813:3049df5a97b8 6814:17ff75a3dcbf
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     1 /* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
     2 /*
     2 /*
     3  * Copyright (c) 2004 Francisco J. Ros 
     3  * Copyright (c) 2004 Francisco J. Ros
     4  * Copyright (c) 2007 INESC Porto
     4  * Copyright (c) 2007 INESC Porto
     5  *
     5  *
     6  * This program is free software; you can redistribute it and/or modify
     6  * This program is free software; you can redistribute it and/or modify
     7  * it under the terms of the GNU General Public License version 2 as
     7  * it under the terms of the GNU General Public License version 2 as
     8  * published by the Free Software Foundation;
     8  * published by the Free Software Foundation;
    87   RoutingProtocol ();
    87   RoutingProtocol ();
    88   virtual ~RoutingProtocol ();
    88   virtual ~RoutingProtocol ();
    89 
    89 
    90   ///
    90   ///
    91   /// \brief Set the OLSR main address to the first address on the indicated
    91   /// \brief Set the OLSR main address to the first address on the indicated
    92   ///        interface 
    92   ///        interface
    93   /// \param interface IPv4 interface index
    93   /// \param interface IPv4 interface index
    94   ///
    94   ///
    95   void SetMainInterface (uint32_t interface);
    95   void SetMainInterface (uint32_t interface);
    96 
    96 
    97   /// 
    97   ///
    98   /// Dump the neighbor table, two-hop neighbor table, and routing table
    98   /// Dump the neighbor table, two-hop neighbor table, and routing table
    99   /// to logging output (NS_LOG_DEBUG log level).  If logging is disabled,
    99   /// to logging output (NS_LOG_DEBUG log level).  If logging is disabled,
   100   /// this function does nothing.
   100   /// this function does nothing.
   101   /// 
   101   ///
   102   void Dump (void);
   102   void Dump (void);
   103 
   103 
   104   /**
   104   /**
   105    * Return the list of routing table entries discovered by OLSR
   105    * Return the list of routing table entries discovered by OLSR
   106    **/
   106    **/
   117     }
   117     }
   118   void SetInterfaceExclusions (std::set<uint32_t> exceptions);
   118   void SetInterfaceExclusions (std::set<uint32_t> exceptions);
   119 
   119 
   120   /// Inject Association to be sent in HNA message
   120   /// Inject Association to be sent in HNA message
   121   void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
   121   void AddHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
       
   122   /// Removes Association sent in HNA message
       
   123   void RemoveHostNetworkAssociation (Ipv4Address networkAddr, Ipv4Mask netmask);
   122 
   124 
   123   /// Inject Associations from an Ipv4StaticRouting instance
   125   /// Inject Associations from an Ipv4StaticRouting instance
   124   void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable);
   126   void SetRoutingTableAssociation (Ptr<Ipv4StaticRouting> routingTable);
   125 
   127 
   126 protected:
   128 protected:
   147   Time m_midInterval;
   149   Time m_midInterval;
   148   /// HNA messages' emission interval.
   150   /// HNA messages' emission interval.
   149   Time m_hnaInterval;
   151   Time m_hnaInterval;
   150   /// Willingness for forwarding packets on behalf of other nodes.
   152   /// Willingness for forwarding packets on behalf of other nodes.
   151   uint8_t m_willingness;
   153   uint8_t m_willingness;
   152 	
   154 
   153   /// Internal state with all needed data structs.
   155   /// Internal state with all needed data structs.
   154   OlsrState m_state;
   156   OlsrState m_state;
   155 
   157 
   156   Ptr<Ipv4> m_ipv4;
   158   Ptr<Ipv4> m_ipv4;
   157 	
   159 
   158   void Clear ();
   160   void Clear ();
   159   uint32_t GetSize () const { return m_table.size (); }
   161   uint32_t GetSize () const { return m_table.size (); }
   160   void RemoveEntry (const Ipv4Address &dest);
   162   void RemoveEntry (const Ipv4Address &dest);
   161   void AddEntry (const Ipv4Address &dest,
   163   void AddEntry (const Ipv4Address &dest,
   162                  const Ipv4Address &next,
   164                  const Ipv4Address &next,
   170                RoutingTableEntry &outEntry) const;
   172                RoutingTableEntry &outEntry) const;
   171   bool FindSendEntry (const RoutingTableEntry &entry,
   173   bool FindSendEntry (const RoutingTableEntry &entry,
   172                       RoutingTableEntry &outEntry) const;
   174                       RoutingTableEntry &outEntry) const;
   173 
   175 
   174   // From Ipv4RoutingProtocol
   176   // From Ipv4RoutingProtocol
   175   virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
   177   virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p,
   176    virtual bool RouteInput  (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
   178                                       const Ipv4Header &header,
   177                              UnicastForwardCallback ucb, MulticastForwardCallback mcb,
   179                                       Ptr<NetDevice> oif,
   178                              LocalDeliverCallback lcb, ErrorCallback ecb);  
   180                                       Socket::SocketErrno &sockerr);
       
   181   virtual bool RouteInput (Ptr<const Packet> p,
       
   182                            const Ipv4Header &header,
       
   183                            Ptr<const NetDevice> idev,
       
   184                            UnicastForwardCallback ucb,
       
   185                            MulticastForwardCallback mcb,
       
   186                            LocalDeliverCallback lcb,
       
   187                            ErrorCallback ecb);
   179   virtual void NotifyInterfaceUp (uint32_t interface);
   188   virtual void NotifyInterfaceUp (uint32_t interface);
   180   virtual void NotifyInterfaceDown (uint32_t interface);
   189   virtual void NotifyInterfaceDown (uint32_t interface);
   181   virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
   190   virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
   182   virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
   191   virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
   183   virtual void SetIpv4 (Ptr<Ipv4> ipv4);
   192   virtual void SetIpv4 (Ptr<Ipv4> ipv4);
   184   virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
   193   virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
   185 
   194 
   186 
       
   187   void DoDispose ();
   195   void DoDispose ();
   188 
   196 
   189   void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages);
   197   void SendPacket (Ptr<Packet> packet, const MessageList &containedMessages);
   190 	
   198 
   191   /// Increments packet sequence number and returns the new value.
   199   /// Increments packet sequence number and returns the new value.
   192   inline uint16_t GetPacketSequenceNumber ();
   200   inline uint16_t GetPacketSequenceNumber ();
   193   /// Increments message sequence number and returns the new value.
   201   /// Increments message sequence number and returns the new value.
   194   inline uint16_t GetMessageSequenceNumber ();
   202   inline uint16_t GetMessageSequenceNumber ();
   195 	
   203 
   196   void RecvOlsr (Ptr<Socket> socket);
   204   void RecvOlsr (Ptr<Socket> socket);
   197 
   205 
   198   void MprComputation ();
   206   void MprComputation ();
   199   void RoutingTableComputation ();
   207   void RoutingTableComputation ();
   200   Ipv4Address GetMainAddress (Ipv4Address iface_addr) const;
   208   Ipv4Address GetMainAddress (Ipv4Address iface_addr) const;
       
   209   bool UsesNonOlsrOutgoingInterface (const Ipv4RoutingTableEntry &route);
   201 
   210 
   202   // Timer handlers
   211   // Timer handlers
   203   Timer m_helloTimer;
   212   Timer m_helloTimer;
   204   void HelloTimerExpire ();
   213   void HelloTimerExpire ();
   205   
   214 
   206   Timer m_tcTimer;
   215   Timer m_tcTimer;
   207   void TcTimerExpire ();
   216   void TcTimerExpire ();
   208 
   217 
   209   Timer m_midTimer;
   218   Timer m_midTimer;
   210   void MidTimerExpire ();
   219   void MidTimerExpire ();