A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
olsr-repositories.h
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 
26 
27 #ifndef OLSR_REPOSITORIES_H
28 #define OLSR_REPOSITORIES_H
29 
30 #include <set>
31 #include <vector>
32 
33 #include "ns3/ipv4-address.h"
34 #include "ns3/nstime.h"
35 
36 namespace ns3 { namespace olsr {
37 
38 
39 
42  {
49  };
50 
51  static inline bool
52  operator == (const IfaceAssocTuple &a, const IfaceAssocTuple &b)
53  {
54  return (a.ifaceAddr == b.ifaceAddr
55  && a.mainAddr == b.mainAddr);
56  }
57 
58  static inline std::ostream&
59  operator << (std::ostream &os, const IfaceAssocTuple &tuple)
60  {
61  os << "IfaceAssocTuple(ifaceAddr=" << tuple.ifaceAddr
62  << ", mainAddr=" << tuple.mainAddr
63  << ", time=" << tuple.time << ")";
64  return os;
65  }
66 
68  struct LinkTuple
69  {
80  };
81 
82  static inline bool
83  operator == (const LinkTuple &a, const LinkTuple &b)
84  {
85  return (a.localIfaceAddr == b.localIfaceAddr
87  }
88 
89  static inline std::ostream&
90  operator << (std::ostream &os, const LinkTuple &tuple)
91  {
92  os << "LinkTuple(localIfaceAddr=" << tuple.localIfaceAddr
93  << ", neighborIfaceAddr=" << tuple.neighborIfaceAddr
94  << ", symTime=" << tuple.symTime
95  << ", asymTime=" << tuple.asymTime
96  << ", expTime=" << tuple.time
97  << ")";
98  return os;
99  }
100 
103  {
107  enum Status {
108  STATUS_NOT_SYM = 0, // "not symmetric"
109  STATUS_SYM = 1, // "symmetric"
110  } status;
112  uint8_t willingness;
113  };
114 
115  static inline bool
116  operator == (const NeighborTuple &a, const NeighborTuple &b)
117  {
118  return (a.neighborMainAddr == b.neighborMainAddr
119  && a.status == b.status
120  && a.willingness == b.willingness);
121  }
122 
123  static inline std::ostream&
124  operator << (std::ostream &os, const NeighborTuple &tuple)
125  {
126  os << "NeighborTuple(neighborMainAddr=" << tuple.neighborMainAddr
127  << ", status=" << (tuple.status == NeighborTuple::STATUS_SYM ? "SYM" : "NOT_SYM")
128  << ", willingness=" << (int) tuple.willingness << ")";
129  return os;
130  }
131 
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  << ")";
150  return os;
151  }
152 
153  static inline bool
154  operator == (const TwoHopNeighborTuple &a, const TwoHopNeighborTuple &b)
155  {
156  return (a.neighborMainAddr == b.neighborMainAddr
158  }
159 
162  {
166  Time expirationTime; // previously called 'time_'
167  };
168 
169  static inline bool
170  operator == (const MprSelectorTuple &a, const MprSelectorTuple &b)
171  {
172  return (a.mainAddr == b.mainAddr);
173  }
174 
175 
177 //typedef std::vector<nsaddr_t> addr_list_t;
178 
181  {
185  uint16_t sequenceNumber;
189  std::vector<Ipv4Address> ifaceList;
192  };
193 
194  static inline bool
195  operator == (const DuplicateTuple &a, const DuplicateTuple &b)
196  {
197  return (a.address == b.address
198  && a.sequenceNumber == b.sequenceNumber);
199  }
200 
203  {
209  uint16_t sequenceNumber;
212  };
213 
214  static inline bool
215  operator == (const TopologyTuple &a, const TopologyTuple &b)
216  {
217  return (a.destAddr == b.destAddr
218  && a.lastAddr == b.lastAddr
219  && a.sequenceNumber == b.sequenceNumber);
220  }
221 
222  static inline std::ostream&
223  operator << (std::ostream &os, const TopologyTuple &tuple)
224  {
225  os << "TopologyTuple(destAddr=" << tuple.destAddr
226  << ", lastAddr=" << tuple.lastAddr
227  << ", sequenceNumber=" << (int) tuple.sequenceNumber
228  << ", expirationTime=" << tuple.expirationTime
229  << ")";
230  return os;
231  }
232 
234  struct Association
235  {
236  Ipv4Address networkAddr;
237  Ipv4Mask netmask;
238  };
239 
240  static inline bool
241  operator == (const Association &a, const Association &b)
242  {
243  return (a.networkAddr == b.networkAddr
244  && a.netmask == b.netmask);
245  }
246 
247  static inline std::ostream&
248  operator << (std::ostream &os, const Association &tuple)
249  {
250  os << "Association(networkAddr=" << tuple.networkAddr
251  << ", netmask=" << tuple.netmask
252  << ")";
253  return os;
254  }
255 
258  {
267  };
268 
269  static inline bool
270  operator == (const AssociationTuple &a, const AssociationTuple &b)
271  {
272  return (a.gatewayAddr == b.gatewayAddr
273  && a.networkAddr == b.networkAddr
274  && a.netmask == b.netmask);
275  }
276 
277  static inline std::ostream&
278  operator << (std::ostream &os, const AssociationTuple &tuple)
279  {
280  os << "AssociationTuple(gatewayAddr=" << tuple.gatewayAddr
281  << ", networkAddr=" << tuple.networkAddr
282  << ", netmask=" << tuple.netmask
283  << ", expirationTime=" << tuple.expirationTime
284  << ")";
285  return os;
286  }
287 
288 
289  typedef std::set<Ipv4Address> MprSet;
290  typedef std::vector<MprSelectorTuple> MprSelectorSet;
291  typedef std::vector<LinkTuple> LinkSet;
292  typedef std::vector<NeighborTuple> NeighborSet;
293  typedef std::vector<TwoHopNeighborTuple> TwoHopNeighborSet;
294  typedef std::vector<TopologyTuple> TopologySet;
295  typedef std::vector<DuplicateTuple> DuplicateSet;
296  typedef std::vector<IfaceAssocTuple> IfaceAssocSet;
297  typedef std::vector<AssociationTuple> AssociationSet;
298  typedef std::vector<Association> Associations;
299 
300 
301  }} // namespace ns3, olsr
302 
303 #endif /* OLSR_REPOSITORIES_H */
An MPR-Selector Tuple.
Ipv4Address networkAddr
Network Address of network reachable through gatewayAddr.
keep track of time unit.
Definition: nstime.h:149
uint16_t sequenceNumber
Sequence number.
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:210
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Mask netmask
Netmask of network reachable through gatewayAddr.
Ipv4Address lastAddr
Main address of a node which is a neighbor of the destination.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address mainAddr
Main address of the node.
Ipv4Address mainAddr
Main address of a node which have selected this node as a MPR.
An Association Tuple.
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address destAddr
Main address of the destination.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:43
uint8_t willingness
A value between 0 and 7 specifying the node's willingness to carry traffic on behalf of other nodes...
Time expirationTime
Time at which this tuple expires and must be removed.
Ipv4Address neighborMainAddr
Main address of a neighbor node.
Ipv4Address twoHopNeighborAddr
Main address of a 2-hop neighbor with a symmetric link to nb_main_addr.
Status
Neighbor Type and Link Type at the four less significative digits.
Time time
Time at which this tuple expires and must be removed.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:38
Ipv4Address ifaceAddr
Interface address of a node.
Ipv4Address neighborMainAddr
Main address of a neighbor.
Ipv4Address address
Originator address of the message.
Ipv4Address gatewayAddr
Main address of the gateway.
An Interface Association Tuple.
bool retransmitted
Indicates whether the message has been retransmitted or not.
The type "list of interface addresses".
uint16_t sequenceNumber
Message sequence number.
Time expirationTime
Time at which this tuple expires and must be removed.
std::vector< Ipv4Address > ifaceList
List of interfaces which the message has been received on.