A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
41
struct
IfaceAssocTuple
42
{
44
Ipv4Address
ifaceAddr
;
46
Ipv4Address
mainAddr
;
48
Time
time
;
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
{
71
Ipv4Address
localIfaceAddr
;
73
Ipv4Address
neighborIfaceAddr
;
75
Time
symTime
;
77
Time
asymTime
;
79
Time
time
;
80
};
81
82
static
inline
bool
83
operator ==
(
const
LinkTuple
&a,
const
LinkTuple
&b)
84
{
85
return
(a.
localIfaceAddr
== b.
localIfaceAddr
86
&& a.
neighborIfaceAddr
== b.
neighborIfaceAddr
);
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
102
struct
NeighborTuple
103
{
105
Ipv4Address
neighborMainAddr
;
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
133
struct
TwoHopNeighborTuple
134
{
136
Ipv4Address
neighborMainAddr
;
138
Ipv4Address
twoHopNeighborAddr
;
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
157
&& a.
twoHopNeighborAddr
== b.
twoHopNeighborAddr
);
158
}
159
161
struct
MprSelectorTuple
162
{
164
Ipv4Address
mainAddr
;
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
180
struct
DuplicateTuple
181
{
183
Ipv4Address
address
;
185
uint16_t
sequenceNumber
;
187
bool
retransmitted
;
189
std::vector<Ipv4Address>
ifaceList
;
191
Time
expirationTime
;
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
202
struct
TopologyTuple
203
{
205
Ipv4Address
destAddr
;
207
Ipv4Address
lastAddr
;
209
uint16_t
sequenceNumber
;
211
Time
expirationTime
;
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
257
struct
AssociationTuple
258
{
260
Ipv4Address
gatewayAddr
;
262
Ipv4Address
networkAddr
;
264
Ipv4Mask
netmask
;
266
Time
expirationTime
;
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 */
src
olsr
model
olsr-repositories.h
Generated on Tue Oct 9 2012 16:45:45 for ns-3 by
1.8.1.2