A Discrete-Event Network Simulator
API
olsr-repositories.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004 Francisco J. Ros
3  * Copyright (c) 2007 INESC Porto
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Francisco J. Ros <fjrm@dif.um.es>
19  * Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
20  */
21 
22 #ifndef OLSR_REPOSITORIES_H
23 #define OLSR_REPOSITORIES_H
24 
25 #include "ns3/ipv4-address.h"
26 #include "ns3/nstime.h"
27 
28 #include <set>
29 #include <vector>
30 
31 namespace ns3
32 {
33 namespace olsr
34 {
35 
39 {
46 };
47 
48 static inline bool
50 {
51  return (a.ifaceAddr == b.ifaceAddr && a.mainAddr == b.mainAddr);
52 }
53 
54 static inline std::ostream&
55 operator<<(std::ostream& os, const IfaceAssocTuple& tuple)
56 {
57  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr << ", mainAddr=" << tuple.mainAddr
58  << ", time=" << tuple.time << ")";
59  return os;
60 }
61 
64 struct LinkTuple
65 {
76 };
77 
78 static inline bool
79 operator==(const LinkTuple& a, const LinkTuple& b)
80 {
82 }
83 
84 static inline std::ostream&
85 operator<<(std::ostream& os, const LinkTuple& tuple)
86 {
87  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
88  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr << ", symTime=" << tuple.symTime
89  << ", asymTime=" << tuple.asymTime << ", expTime=" << tuple.time << ")";
90  return os;
91 }
92 
96 {
99 
101  enum Status
102  {
103  STATUS_NOT_SYM = 0, // "not symmetric"
104  STATUS_SYM = 1, // "symmetric"
105  };
106 
109 
112  uint8_t willingness;
113 };
114 
115 static inline bool
117 {
118  return (a.neighborMainAddr == b.neighborMainAddr && a.status == b.status &&
119  a.willingness == b.willingness);
120 }
121 
122 static inline std::ostream&
123 operator<<(std::ostream& os, const NeighborTuple& tuple)
124 {
125  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
126  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
127  << ", willingness=" << (int)tuple.willingness << ")";
128  return os;
129 }
130 
134 {
140  Time expirationTime; // previously called 'time_'
141 };
142 
143 static inline std::ostream&
144 operator<<(std::ostream& os, const TwoHopNeighborTuple& tuple)
145 {
146  os << "TwoHopNeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
147  << ", twoHopNeighborAddr=" << tuple.twoHopNeighborAddr
148  << ", expirationTime=" << tuple.expirationTime << ")";
149  return os;
150 }
151 
152 static inline bool
154 {
155  return (a.neighborMainAddr == b.neighborMainAddr &&
157 }
158 
162 {
166  Time expirationTime; // previously called 'time_'
167 };
168 
169 static inline bool
171 {
172  return (a.mainAddr == b.mainAddr);
173 }
174 
175 // The type "list of interface addresses"
176 // typedef std::vector<nsaddr_t> addr_list_t;
177 
181 {
185  uint16_t sequenceNumber;
189  std::vector<Ipv4Address> ifaceList;
192 };
193 
194 static inline bool
196 {
197  return (a.address == b.address && a.sequenceNumber == b.sequenceNumber);
198 }
199 
203 {
209  uint16_t sequenceNumber;
212 };
213 
214 static inline bool
216 {
217  return (a.destAddr == b.destAddr && a.lastAddr == b.lastAddr &&
219 }
220 
221 static inline std::ostream&
222 operator<<(std::ostream& os, const TopologyTuple& tuple)
223 {
224  os << "TopologyTuple(destAddr=" << tuple.destAddr << ", lastAddr=" << tuple.lastAddr
225  << ", sequenceNumber=" << (int)tuple.sequenceNumber
226  << ", expirationTime=" << tuple.expirationTime << ")";
227  return os;
228 }
229 
233 {
236 };
237 
238 static inline bool
239 operator==(const Association& a, const Association& b)
240 {
241  return (a.networkAddr == b.networkAddr && a.netmask == b.netmask);
242 }
243 
244 static inline std::ostream&
245 operator<<(std::ostream& os, const Association& tuple)
246 {
247  os << "Association(networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask << ")";
248  return os;
249 }
250 
254 {
263 };
264 
265 static inline bool
267 {
268  return (a.gatewayAddr == b.gatewayAddr && a.networkAddr == b.networkAddr &&
269  a.netmask == b.netmask);
270 }
271 
272 static inline std::ostream&
273 operator<<(std::ostream& os, const AssociationTuple& tuple)
274 {
275  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
276  << ", networkAddr=" << tuple.networkAddr << ", netmask=" << tuple.netmask
277  << ", expirationTime=" << tuple.expirationTime << ")";
278  return os;
279 }
280 
281 typedef std::set<Ipv4Address> MprSet;
282 typedef std::vector<MprSelectorTuple> MprSelectorSet;
283 typedef std::vector<LinkTuple> LinkSet;
284 typedef std::vector<NeighborTuple> NeighborSet;
285 typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet;
286 typedef std::vector<TopologyTuple> TopologySet;
287 typedef std::vector<DuplicateTuple> DuplicateSet;
288 typedef std::vector<IfaceAssocTuple> IfaceAssocSet;
289 typedef std::vector<AssociationTuple> AssociationSet;
290 typedef std::vector<Association> Associations;
291 
292 } // namespace olsr
293 } // namespace ns3
294 
295 #endif /* OLSR_REPOSITORIES_H */
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:43
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:258
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
static bool operator==(const IfaceAssocTuple &a, const IfaceAssocTuple &b)
std::vector< MprSelectorTuple > MprSelectorSet
MPR Selector Set type.
std::vector< AssociationTuple > AssociationSet
Association Set type.
std::vector< TwoHopNeighborTuple > TwoHopNeighborSet
2-hop Neighbor Set type.
std::vector< LinkTuple > LinkSet
Link Set type.
std::vector< Association > Associations
Association Set type.
std::vector< TopologyTuple > TopologySet
Topology Set type.
std::set< Ipv4Address > MprSet
MPR Set type.
std::vector< DuplicateTuple > DuplicateSet
Duplicate Set type.
std::vector< NeighborTuple > NeighborSet
Neighbor Set type.
std::vector< IfaceAssocTuple > IfaceAssocSet
Interface Association Set type.
static std::ostream & operator<<(std::ostream &os, const PacketHeader &packet)
Definition: olsr-header.h:688
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Definition: olsr.py:1
Ipv4Address networkAddr
IPv4 Network address.
Ipv4Mask netmask
IPv4 Network mask.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address gatewayAddr
Main address of the gateway.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.
Ipv4Address address
Originator address of the message.
uint16_t sequenceNumber
Message sequence number.
bool retransmitted
Indicates whether the message has been retransmitted or not.
Time expirationTime
Time at which this tuple expires and must be removed.
An Interface Association Tuple.
Ipv4Address ifaceAddr
Interface address of a node.
Time time
Time at which this tuple expires and must be removed.
Ipv4Address mainAddr
Main address of the node.
An MPR-Selector Tuple.
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes.
Status status
Status of the link.
Status
Status of the link (Symmetric or not Symmetric).
Ipv4Address destAddr
Main address of the destination.
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
uint16_t sequenceNumber
Sequence number.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Ipv4Address neighborMainAddr
Main address of a neighbor.
Time expirationTime
Time at which this tuple expires and must be removed.