A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
olsr-state.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2004 Francisco J. Ros
4  * Copyright (c) 2007 INESC Porto
5  *
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;
9  *
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.
14  *
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
18  *
19  * Authors: Francisco J. Ros <fjrm@dif.um.es>
20  * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
21  */
22 
24 
25 #ifndef OLSR_STATE_H
26 #define OLSR_STATE_H
27 
28 #include "olsr-repositories.h"
29 
30 namespace ns3 {
31 
32 using namespace olsr;
33 
35 class OlsrState
36 {
37  // friend class Olsr;
38 
39 protected:
50 
51 public:
52 
54  {}
55 
56  // MPR selector
58  {
59  return m_mprSelectorSet;
60  }
61  MprSelectorTuple* FindMprSelectorTuple (const Ipv4Address &mainAddr);
62  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
63  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
64  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
65  std::string PrintMprSelectorSet () const;
66 
67  // Neighbor
68  const NeighborSet & GetNeighbors () const
69  {
70  return m_neighborSet;
71  }
73  {
74  return m_neighborSet;
75  }
76  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
77  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
78  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr,
79  uint8_t willingness);
80  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
81  void EraseNeighborTuple (const Ipv4Address &mainAddr);
82  void InsertNeighborTuple (const NeighborTuple &tuple);
83 
84  // Two-hop neighbor
86  {
87  return m_twoHopNeighborSet;
88  }
90  {
91  return m_twoHopNeighborSet;
92  }
93  TwoHopNeighborTuple* FindTwoHopNeighborTuple (const Ipv4Address &neighbor,
94  const Ipv4Address &twoHopNeighbor);
95  void EraseTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
96  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
97  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
98  const Ipv4Address &twoHopNeighbor);
99  void InsertTwoHopNeighborTuple (const TwoHopNeighborTuple &tuple);
100 
101  // MPR
102  bool FindMprAddress (const Ipv4Address &address);
104  void SetMprSet (MprSet mprSet);
106  MprSet GetMprSet () const;
107 
108  // Duplicate
109  DuplicateTuple* FindDuplicateTuple (const Ipv4Address &address,
110  uint16_t sequenceNumber);
111  void EraseDuplicateTuple (const DuplicateTuple &tuple);
112  void InsertDuplicateTuple (const DuplicateTuple &tuple);
113 
114  // Link
115  const LinkSet & GetLinks () const
116  {
117  return m_linkSet;
118  }
119  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
120  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
121  void EraseLinkTuple (const LinkTuple &tuple);
122  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
123 
124  // Topology
125  const TopologySet & GetTopologySet () const
126  {
127  return m_topologySet;
128  }
129  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
130  const Ipv4Address &lastAddr);
131  TopologyTuple* FindNewerTopologyTuple (const Ipv4Address &lastAddr,
132  uint16_t ansn);
133  void EraseTopologyTuple (const TopologyTuple &tuple);
134  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
135  uint16_t ansn);
136  void InsertTopologyTuple (const TopologyTuple &tuple);
137 
138  // Interface association
140  {
141  return m_ifaceAssocSet;
142  }
144  {
145  return m_ifaceAssocSet;
146  }
147  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
148  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
149  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
150  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
151 
152  // Host-Network Association
153  const AssociationSet & GetAssociationSet () const // Associations known to the node
154  {
155  return m_associationSet;
156  }
157 
158  const Associations & GetAssociations () const // Set of associations that the node has
159  {
160  return m_associations;
161  }
162 
163  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
164  const Ipv4Address &networkAddr, \
165  const Ipv4Mask &netmask);
166  void EraseAssociationTuple (const AssociationTuple &tuple);
167  void InsertAssociationTuple (const AssociationTuple &tuple);
168  void EraseAssociation (const Association &tuple);
169  void InsertAssociation (const Association &tuple);
170 
171  // Returns a vector of all interfaces of a given neighbor, with the
172  // exception of the "main" one.
173  std::vector<Ipv4Address>
174  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
175 
176 };
177 
178 } // namespace ns3
179 
180 #endif /* OLSR_STATE_H */
std::vector< TopologyTuple > TopologySet
Topology Set type.
An MPR-Selector Tuple.
This class encapsulates all data structures needed for maintaining internal state of an OLSR node...
Definition: olsr-state.h:35
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
std::vector< Association > Associations
Association Set type.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
NeighborSet & GetNeighbors()
Definition: olsr-state.h:72
Associations m_associations
The node's local Host Network Associations that will be advertised using HNA messages.
Definition: olsr-state.h:49
TopologySet m_topologySet
Topology Set (RFC 3626, section 4.4).
Definition: olsr-state.h:43
const LinkSet & GetLinks() const
Definition: olsr-state.h:115
MprSelectorSet m_mprSelectorSet
MPR Selector Set (RFC 3626, section 4.3.4).
Definition: olsr-state.h:45
An Association Tuple.
TwoHopNeighborSet & GetTwoHopNeighbors()
Definition: olsr-state.h:89
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
AssociationSet m_associationSet
Association Set (RFC 3626, section12.2). Associations obtained from HNA messages generated by other n...
Definition: olsr-state.h:48
NeighborSet m_neighborSet
Neighbor Set (RFC 3626, section 4.3.1).
Definition: olsr-state.h:41
const Associations & GetAssociations() const
Definition: olsr-state.h:158
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
const IfaceAssocSet & GetIfaceAssocSet() const
Definition: olsr-state.h:139
DuplicateSet m_duplicateSet
Duplicate Set (RFC 3626, section 3.4).
Definition: olsr-state.h:46
TwoHopNeighborSet m_twoHopNeighborSet
2-hop Neighbor Set (RFC 3626, section 4.3.2).
Definition: olsr-state.h:42
LinkSet m_linkSet
Link Set (RFC 3626, section 4.2.1).
Definition: olsr-state.h:40
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
std::set< Ipv4Address > MprSet
MPR Set type.
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Definition: olsr-state.h:85
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
const AssociationSet & GetAssociationSet() const
Definition: olsr-state.h:153
const NeighborSet & GetNeighbors() const
Definition: olsr-state.h:68
MprSet m_mprSet
MPR Set (RFC 3626, section 4.3.3).
Definition: olsr-state.h:44
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
tuple address
Definition: first.py:37
const MprSelectorSet & GetMprSelectors() const
Definition: olsr-state.h:57
IfaceAssocSet & GetIfaceAssocSetMutable()
Definition: olsr-state.h:143
An Interface Association Tuple.
The type "list of interface addresses".
std::vector< AssociationTuple > AssociationSet
Association Set type.
const TopologySet & GetTopologySet() const
Definition: olsr-state.h:125
IfaceAssocSet m_ifaceAssocSet
Interface Association Set (RFC 3626, section 4.1).
Definition: olsr-state.h:47