1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
3 * Copyright (c) 2004 Francisco J. Ros
4 * Copyright (c) 2007 INESC Porto
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
8 * published by the Free Software Foundation;
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * Authors: Francisco J. Ros <fjrm@dif.um.es>
20 * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
23 /// \brief This header file declares and defines internal state of an OLSR node.
25 #ifndef __OLSR_STATE_H__
26 #define __OLSR_STATE_H__
28 #include "repositories.h"
34 /// This class encapsulates all data structures needed for maintaining internal state of an OLSR node.
40 LinkSet m_linkSet; ///< Link Set (RFC 3626, section 4.2.1).
41 NeighborSet m_neighborSet; ///< Neighbor Set (RFC 3626, section 4.3.1).
42 TwoHopNeighborSet m_twoHopNeighborSet; ///< 2-hop Neighbor Set (RFC 3626, section 4.3.2).
43 TopologySet m_topologySet; ///< Topology Set (RFC 3626, section 4.4).
44 MprSet m_mprSet; ///< MPR Set (RFC 3626, section 4.3.3).
45 MprSelectorSet m_mprSelectorSet; ///< MPR Selector Set (RFC 3626, section 4.3.4).
46 DuplicateSet m_duplicateSet; ///< Duplicate Set (RFC 3626, section 3.4).
47 IfaceAssocSet m_ifaceAssocSet; ///< Interface Association Set (RFC 3626, section 4.1).
55 const MprSelectorSet & GetMprSelectors () const
57 return m_mprSelectorSet;
59 MprSelectorTuple* FindMprSelectorTuple (const Ipv4Address &mainAddr);
60 void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
61 void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
62 void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
63 std::string PrintMprSelectorSet () const;
66 const NeighborSet & GetNeighbors () const
70 NeighborSet & GetNeighbors ()
74 NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
75 const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
76 NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
78 void EraseNeighborTuple (const NeighborTuple &neighborTuple);
79 void EraseNeighborTuple (const Ipv4Address &mainAddr);
80 void InsertNeighborTuple (const NeighborTuple &tuple);
83 const TwoHopNeighborSet & GetTwoHopNeighbors () const
85 return m_twoHopNeighborSet;
87 TwoHopNeighborSet & GetTwoHopNeighbors ()
89 return m_twoHopNeighborSet;
91 TwoHopNeighborTuple* FindTwoHopNeighborTuple (const Ipv4Address &neighbor,
92 const Ipv4Address &twoHopNeighbor);
93 void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
94 void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
95 void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
96 const Ipv4Address &twoHopNeighbor);
97 void InsertTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
100 bool FindMprAddress (const Ipv4Address &address);
101 void SetMprSet (MprSet mprSet);
104 DuplicateTuple* FindDuplicateTuple (const Ipv4Address &address,
105 uint16_t sequenceNumber);
106 void EraseDuplicateTuple (const DuplicateTuple &tuple);
107 void InsertDuplicateTuple (const DuplicateTuple &tuple);
110 const LinkSet & GetLinks () const
114 LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
115 LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
116 void EraseLinkTuple (const LinkTuple &tuple);
117 LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
120 const TopologySet & GetTopologySet () const
122 return m_topologySet;
124 TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
125 const Ipv4Address &lastAddr);
126 TopologyTuple* FindNewerTopologyTuple (const Ipv4Address &lastAddr,
128 void EraseTopologyTuple (const TopologyTuple &tuple);
129 void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
131 void InsertTopologyTuple (const TopologyTuple &tuple);
133 // Interface association
134 const IfaceAssocSet & GetIfaceAssocSet () const
136 return m_ifaceAssocSet;
138 IfaceAssocSet & GetIfaceAssocSetMutable ()
140 return m_ifaceAssocSet;
142 IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
143 const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
144 void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
145 void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
147 // Returns a vector of all interfaces of a given neighbor, with the
148 // exception of the "main" one.
149 std::vector<Ipv4Address>
150 FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;