00001 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2007 INESC Porto 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> 00019 */ 00020 00021 #ifndef OLSR_AGENT_H 00022 #define OLSR_AGENT_H 00023 00024 #include "ns3/node.h" 00025 #include "ns3/olsr-routing-table.h" 00026 00027 namespace ns3 { 00028 namespace olsr { 00029 00030 /** 00031 * \brief Class implementing the OLSR state machine 00032 * 00033 * This class represents an instance of the OLSR protocol. It 00034 * attaches itself to a Node, and its lifecycle is bound to that node. 00035 * Normally the functions in the ns3::olsr namespace are more simple 00036 * to use to start OLSR on nodes, but access to the underlying OLSR 00037 * agent can be useful in order to customize the OLSR parameters. 00038 * Example: 00039 * 00040 * \code 00041 * Ptr<olsr::Agent> olsr = Agend::CreateDefault (); 00042 * agent->SetMainInterface (2); 00043 * agent->Start (); 00044 * \endcode 00045 */ 00046 class Agent : public Object 00047 { 00048 public: 00049 static TypeId GetTypeId (void); 00050 00051 virtual void SetNode (Ptr<Node> node) = 0; 00052 00053 /** 00054 * \brief Sets the main interface to be used by OLSR 00055 * 00056 * Normally OLSR supports multiple interfaces, but the protocol 00057 * requires the definition of a "main interface". This interface's 00058 * IPv4 address provides the identity of the node, and all outgoing 00059 * OLSR routing messages must have the main interface address, 00060 * regardless of the actual interface used to transmit the packet. 00061 * This method allows one to explicitly select an interface as the 00062 * main interface. It must be called before the agent starts, but 00063 * calling it is optional; if not called, the agent tries to guess 00064 * and uses a suitable interface. 00065 */ 00066 virtual void SetMainInterface (uint32_t interface) = 0; 00067 00068 /** 00069 * \brief Starts the OLSR protocol operation 00070 * 00071 * Calling this method essentially bootstraps the OLSR protocol, and 00072 * causes the agent to start broadcasting OLSR messages to 00073 * neighbors, as well start listening to messages from neighbors. 00074 */ 00075 virtual void Start () = 0; 00076 00077 virtual Ptr<const olsr::RoutingTable> GetRoutingTable () const = 0; 00078 }; 00079 00080 }} // namespace olsr, ns3 00081 00082 #endif /* OLSR_AGENT_H */ 00083