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 namespace olsr {
32 
34 class OlsrState
35 {
36  // friend class Olsr;
37 
38 protected:
49 
50 public:
51 
53  {}
54 
55  // MPR selector
57  {
58  return m_mprSelectorSet;
59  }
61  void EraseMprSelectorTuple (const MprSelectorTuple &tuple);
62  void EraseMprSelectorTuples (const Ipv4Address &mainAddr);
63  void InsertMprSelectorTuple (const MprSelectorTuple &tuple);
64  std::string PrintMprSelectorSet () const;
65 
66  // Neighbor
67  const NeighborSet & GetNeighbors () const
68  {
69  return m_neighborSet;
70  }
72  {
73  return m_neighborSet;
74  }
75  NeighborTuple* FindNeighborTuple (const Ipv4Address &mainAddr);
76  const NeighborTuple* FindSymNeighborTuple (const Ipv4Address &mainAddr) const;
78  uint8_t willingness);
79  void EraseNeighborTuple (const NeighborTuple &neighborTuple);
80  void EraseNeighborTuple (const Ipv4Address &mainAddr);
81  void InsertNeighborTuple (const NeighborTuple &tuple);
82 
83  // Two-hop neighbor
85  {
86  return m_twoHopNeighborSet;
87  }
89  {
90  return m_twoHopNeighborSet;
91  }
93  const Ipv4Address &twoHopNeighbor);
95  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor);
96  void EraseTwoHopNeighborTuples (const Ipv4Address &neighbor,
97  const Ipv4Address &twoHopNeighbor);
99 
100  // MPR
101  bool FindMprAddress (const Ipv4Address &address);
103  void SetMprSet (MprSet mprSet);
105  MprSet GetMprSet () const;
106 
107  // Duplicate
109  uint16_t sequenceNumber);
110  void EraseDuplicateTuple (const DuplicateTuple &tuple);
111  void InsertDuplicateTuple (const DuplicateTuple &tuple);
112 
113  // Link
114  const LinkSet & GetLinks () const
115  {
116  return m_linkSet;
117  }
118  LinkTuple* FindLinkTuple (const Ipv4Address &ifaceAddr);
119  LinkTuple* FindSymLinkTuple (const Ipv4Address &ifaceAddr, Time time);
120  void EraseLinkTuple (const LinkTuple &tuple);
121  LinkTuple& InsertLinkTuple (const LinkTuple &tuple);
122 
123  // Topology
124  const TopologySet & GetTopologySet () const
125  {
126  return m_topologySet;
127  }
128  TopologyTuple* FindTopologyTuple (const Ipv4Address &destAddr,
129  const Ipv4Address &lastAddr);
131  uint16_t ansn);
132  void EraseTopologyTuple (const TopologyTuple &tuple);
133  void EraseOlderTopologyTuples (const Ipv4Address &lastAddr,
134  uint16_t ansn);
135  void InsertTopologyTuple (const TopologyTuple &tuple);
136 
137  // Interface association
139  {
140  return m_ifaceAssocSet;
141  }
143  {
144  return m_ifaceAssocSet;
145  }
146  IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr);
147  const IfaceAssocTuple* FindIfaceAssocTuple (const Ipv4Address &ifaceAddr) const;
148  void EraseIfaceAssocTuple (const IfaceAssocTuple &tuple);
149  void InsertIfaceAssocTuple (const IfaceAssocTuple &tuple);
150 
151  // Host-Network Association
152  const AssociationSet & GetAssociationSet () const // Associations known to the node
153  {
154  return m_associationSet;
155  }
156 
157  const Associations & GetAssociations () const // Set of associations that the node has
158  {
159  return m_associations;
160  }
161 
162  AssociationTuple* FindAssociationTuple (const Ipv4Address &gatewayAddr, \
163  const Ipv4Address &networkAddr, \
164  const Ipv4Mask &netmask);
165  void EraseAssociationTuple (const AssociationTuple &tuple);
166  void InsertAssociationTuple (const AssociationTuple &tuple);
167  void EraseAssociation (const Association &tuple);
168  void InsertAssociation (const Association &tuple);
169 
170  // Returns a vector of all interfaces of a given neighbor, with the
171  // exception of the "main" one.
172  std::vector<Ipv4Address>
173  FindNeighborInterfaces (const Ipv4Address &neighborMainAddr) const;
174 
175 };
176 
177 }} // namespace olsr,ns3
178 
179 #endif /* OLSR_STATE_H */
std::vector< TopologyTuple > TopologySet
Topology Set type.
An MPR-Selector Tuple.
const MprSelectorSet & GetMprSelectors() const
Definition: olsr-state.h:56
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
IfaceAssocSet & GetIfaceAssocSetMutable()
Definition: olsr-state.h:142
AssociationSet m_associationSet
Association Set (RFC 3626, section12.2). Associations obtained from HNA messages generated by other n...
Definition: olsr-state.h:47
TwoHopNeighborTuple * FindTwoHopNeighborTuple(const Ipv4Address &neighbor, const Ipv4Address &twoHopNeighbor)
Definition: olsr-state.cc:190
std::vector< Association > Associations
Association Set type.
void EraseMprSelectorTuples(const Ipv4Address &mainAddr)
Definition: olsr-state.cc:64
void InsertAssociationTuple(const AssociationTuple &tuple)
Definition: olsr-state.cc:521
const Associations & GetAssociations() const
Definition: olsr-state.h:157
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:222
const NeighborTuple * FindSymNeighborTuple(const Ipv4Address &mainAddr) const
Definition: olsr-state.cc:120
std::string PrintMprSelectorSet() const
Definition: olsr-state.cc:87
void InsertNeighborTuple(const NeighborTuple &tuple)
Definition: olsr-state.cc:172
std::vector< Ipv4Address > FindNeighborInterfaces(const Ipv4Address &neighborMainAddr) const
Definition: olsr-state.cc:478
TwoHopNeighborSet m_twoHopNeighborSet
2-hop Neighbor Set (RFC 3626, section 4.3.2).
Definition: olsr-state.h:41
void SetMprSet(MprSet mprSet)
MprSet is set by routing protocol after MprCompute.
Definition: olsr-state.cc:271
bool FindMprAddress(const Ipv4Address &address)
Definition: olsr-state.cc:264
void InsertMprSelectorTuple(const MprSelectorTuple &tuple)
Definition: olsr-state.cc:81
NeighborTuple * FindNeighborTuple(const Ipv4Address &mainAddr)
Definition: olsr-state.cc:108
void EraseIfaceAssocTuple(const IfaceAssocTuple &tuple)
Definition: olsr-state.cc:458
LinkTuple * FindSymLinkTuple(const Ipv4Address &ifaceAddr, Time time)
Definition: olsr-state.cc:330
LinkTuple * FindLinkTuple(const Ipv4Address &ifaceAddr)
Definition: olsr-state.cc:318
void EraseDuplicateTuple(const DuplicateTuple &tuple)
Definition: olsr-state.cc:296
void EraseTopologyTuple(const TopologyTuple &tuple)
Definition: olsr-state.cc:395
NeighborSet m_neighborSet
Neighbor Set (RFC 3626, section 4.3.1).
Definition: olsr-state.h:40
void EraseOlderTopologyTuples(const Ipv4Address &lastAddr, uint16_t ansn)
Definition: olsr-state.cc:409
const TopologySet & GetTopologySet() const
Definition: olsr-state.h:124
TopologyTuple * FindTopologyTuple(const Ipv4Address &destAddr, const Ipv4Address &lastAddr)
Definition: olsr-state.cc:370
IfaceAssocSet m_ifaceAssocSet
Interface Association Set (RFC 3626, section 4.1).
Definition: olsr-state.h:46
const AssociationSet & GetAssociationSet() const
Definition: olsr-state.h:152
An Association Tuple.
IfaceAssocTuple * FindIfaceAssocTuple(const Ipv4Address &ifaceAddr)
Definition: olsr-state.cc:434
LinkSet m_linkSet
Link Set (RFC 3626, section 4.2.1).
Definition: olsr-state.h:39
void InsertDuplicateTuple(const DuplicateTuple &tuple)
Definition: olsr-state.cc:310
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
MprSet GetMprSet() const
Gets an MPR Set needed by tests.
Definition: olsr-state.cc:276
void EraseLinkTuple(const LinkTuple &tuple)
Definition: olsr-state.cc:347
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
AssociationTuple * FindAssociationTuple(const Ipv4Address &gatewayAddr, const Ipv4Address &networkAddr, const Ipv4Mask &netmask)
Definition: olsr-state.cc:493
void InsertIfaceAssocTuple(const IfaceAssocTuple &tuple)
Definition: olsr-state.cc:472
const NeighborSet & GetNeighbors() const
Definition: olsr-state.h:67
NeighborSet & GetNeighbors()
Definition: olsr-state.h:71
This class encapsulates all data structures needed for maintaining internal state of an OLSR node...
Definition: olsr-state.h:34
MprSelectorTuple * FindMprSelectorTuple(const Ipv4Address &mainAddr)
Definition: olsr-state.cc:38
DuplicateSet m_duplicateSet
Duplicate Set (RFC 3626, section 3.4).
Definition: olsr-state.h:45
void EraseAssociationTuple(const AssociationTuple &tuple)
Definition: olsr-state.cc:507
TwoHopNeighborSet & GetTwoHopNeighbors()
Definition: olsr-state.h:88
Associations m_associations
The node's local Host Network Associations that will be advertised using HNA messages.
Definition: olsr-state.h:48
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
void EraseAssociation(const Association &tuple)
Definition: olsr-state.cc:527
DuplicateTuple * FindDuplicateTuple(const Ipv4Address &address, uint16_t sequenceNumber)
Definition: olsr-state.cc:284
void InsertTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Definition: olsr-state.cc:256
const IfaceAssocSet & GetIfaceAssocSet() const
Definition: olsr-state.h:138
std::set< Ipv4Address > MprSet
MPR Set type.
const LinkSet & GetLinks() const
Definition: olsr-state.h:114
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
void EraseTwoHopNeighborTuple(const TwoHopNeighborTuple &tuple)
Definition: olsr-state.cc:206
LinkTuple & InsertLinkTuple(const LinkTuple &tuple)
Definition: olsr-state.cc:361
MprSet m_mprSet
MPR Set (RFC 3626, section 4.3.3).
Definition: olsr-state.h:43
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
MprSelectorSet m_mprSelectorSet
MPR Selector Set (RFC 3626, section 4.3.4).
Definition: olsr-state.h:44
void EraseNeighborTuple(const NeighborTuple &neighborTuple)
Definition: olsr-state.cc:144
tuple address
Definition: first.py:37
const TwoHopNeighborSet & GetTwoHopNeighbors() const
Definition: olsr-state.h:84
TopologyTuple * FindNewerTopologyTuple(const Ipv4Address &lastAddr, uint16_t ansn)
Definition: olsr-state.cc:383
TopologySet m_topologySet
Topology Set (RFC 3626, section 4.4).
Definition: olsr-state.h:42
An Interface Association Tuple.
The type "list of interface addresses".
void EraseMprSelectorTuple(const MprSelectorTuple &tuple)
Definition: olsr-state.cc:50
void InsertAssociation(const Association &tuple)
Definition: olsr-state.cc:541
std::vector< AssociationTuple > AssociationSet
Association Set type.
void EraseTwoHopNeighborTuples(const Ipv4Address &neighbor)
Definition: olsr-state.cc:239
void InsertTopologyTuple(const TopologyTuple &tuple)
Definition: olsr-state.cc:426