A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
olsr-repositories.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 
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
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
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
155  {
156  return (a.neighborMainAddr == b.neighborMainAddr
158  }
159 
162  {
166  Time expirationTime; // previously called 'time_'
167  };
168 
169  static inline bool
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
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
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  {
238  };
239 
240  static inline bool
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
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 */