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
icmpv6-header.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2007-2009 Strasbourg University
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
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
* Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
20
* David Gross <gdavid.devel@gmail.com>
21
*/
22
23
#include "ns3/assert.h"
24
#include "ns3/address-utils.h"
25
#include "ns3/log.h"
26
27
#include "
icmpv6-header.h
"
28
29
NS_LOG_COMPONENT_DEFINE
(
"Icmpv6Header"
);
30
31
namespace
ns3
32
{
33
34
NS_OBJECT_ENSURE_REGISTERED
(Icmpv6Header);
35
36
TypeId
Icmpv6Header::GetTypeId
()
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6Header"
)
39
.
SetParent
<
Header
> ()
40
.AddConstructor<Icmpv6Header> ()
41
;
42
return
tid;
43
}
44
45
TypeId
Icmpv6Header::GetInstanceTypeId
()
const
46
{
47
NS_LOG_FUNCTION
(
this
);
48
return
GetTypeId
();
49
}
50
51
Icmpv6Header::Icmpv6Header
()
52
: m_calcChecksum (true),
53
m_checksum (0),
54
m_type (0),
55
m_code (0)
56
{
57
NS_LOG_FUNCTION
(
this
);
58
}
59
60
Icmpv6Header::~Icmpv6Header
()
61
{
62
NS_LOG_FUNCTION
(
this
);
63
}
64
65
uint8_t
Icmpv6Header::GetType
()
const
66
{
67
NS_LOG_FUNCTION
(
this
);
68
return
m_type
;
69
}
70
71
void
Icmpv6Header::SetType
(uint8_t type)
72
{
73
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (type));
74
m_type
= type;
75
}
76
77
uint8_t
Icmpv6Header::GetCode
()
const
78
{
79
NS_LOG_FUNCTION
(
this
);
80
return
m_code
;
81
}
82
83
void
Icmpv6Header::SetCode
(uint8_t code)
84
{
85
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (code));
86
m_code
= code;
87
}
88
89
uint16_t
Icmpv6Header::GetChecksum
()
const
90
{
91
NS_LOG_FUNCTION
(
this
);
92
return
m_checksum
;
93
}
94
95
void
Icmpv6Header::SetChecksum
(uint16_t checksum)
96
{
97
NS_LOG_FUNCTION
(
this
<< checksum);
98
m_checksum
= checksum;
99
}
100
101
void
Icmpv6Header::Print
(std::ostream& os)
const
102
{
103
NS_LOG_FUNCTION
(
this
<< &os);
104
os <<
"( type = "
<< (uint32_t)
m_type
<<
" code = "
<< (uint32_t)
m_code
<<
" checksum = "
<< (uint32_t)
m_checksum
<<
")"
;
105
}
106
107
uint32_t
Icmpv6Header::GetSerializedSize
()
const
108
{
109
NS_LOG_FUNCTION
(
this
);
110
return
4;
111
}
112
113
uint32_t
Icmpv6Header::Deserialize
(
Buffer::Iterator
start
)
114
{
115
NS_LOG_FUNCTION
(
this
<< &start);
116
Buffer::Iterator
i =
start
;
117
118
m_type
= i.
ReadU8
();
119
m_code
= i.
ReadU8
();
120
m_checksum
= i.
ReadNtohU16
();
121
#if 0
122
i.
ReadU32
();
/* padding */
123
#endif
124
return
GetSerializedSize
();
125
}
126
127
void
Icmpv6Header::Serialize
(
Buffer::Iterator
start
)
const
128
{
129
NS_LOG_FUNCTION
(
this
<< &start);
130
Buffer::Iterator
i =
start
;
131
132
i.
WriteU8
(
m_type
);
133
i.
WriteU8
(
m_code
);
134
i.
WriteU16
(0);
135
#if 0
136
i.
WriteU32
(0);
/* padding */
137
#endif
138
139
if
(
m_calcChecksum
)
140
{
141
i =
start
;
142
uint16_t checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
m_checksum
);
143
i =
start
;
144
i.
Next
(2);
145
i.
WriteU16
(checksum);
146
}
147
}
148
149
void
Icmpv6Header::CalculatePseudoHeaderChecksum
(
Ipv6Address
src,
Ipv6Address
dst, uint16_t length, uint8_t protocol)
150
{
151
NS_LOG_FUNCTION
(
this
<< src << dst << length << static_cast<uint32_t> (protocol));
152
153
Buffer
buf =
Buffer
(40);
154
uint8_t tmp[16];
155
Buffer::Iterator
it;
156
157
buf.
AddAtStart
(40);
158
it = buf.
Begin
();
159
160
src.
Serialize
(tmp);
161
it.
Write
(tmp, 16);
/* source IPv6 address */
162
dst.
Serialize
(tmp);
163
it.
Write
(tmp, 16);
/* destination IPv6 address */
164
it.
WriteU16
(0);
/* length */
165
it.
WriteU8
(length >> 8);
/* length */
166
it.
WriteU8
(length & 0xff);
/* length */
167
it.
WriteU16
(0);
/* zero */
168
it.
WriteU8
(0);
/* zero */
169
it.
WriteU8
(protocol);
/* next header */
170
171
it = buf.
Begin
();
172
m_checksum
= ~(it.
CalculateIpChecksum
(40));
173
}
174
175
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6NS
);
176
177
Icmpv6NS::Icmpv6NS
()
178
{
179
NS_LOG_FUNCTION
(
this
);
180
SetType
(
ICMPV6_ND_NEIGHBOR_SOLICITATION
);
181
SetCode
(0);
182
SetReserved
(0);
183
m_checksum
= 0;
184
}
185
186
TypeId
Icmpv6NS::GetTypeId
()
187
{
188
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6NS"
)
189
.
SetParent
<
Icmpv6Header
> ()
190
.AddConstructor<Icmpv6NS> ()
191
;
192
return
tid;
193
}
194
195
TypeId
Icmpv6NS::GetInstanceTypeId
()
const
196
{
197
NS_LOG_FUNCTION
(
this
);
198
return
GetTypeId
();
199
}
200
201
Icmpv6NS::Icmpv6NS
(
Ipv6Address
target)
202
{
203
NS_LOG_FUNCTION
(
this
<< target);
204
SetType
(
ICMPV6_ND_NEIGHBOR_SOLICITATION
);
205
SetCode
(0);
206
SetReserved
(0);
207
SetIpv6Target
(target);
208
m_checksum
= 0;
209
210
/* test */
211
/*
212
m_reserved = 0xdeadbeef;
213
*/
214
}
215
216
Icmpv6NS::~Icmpv6NS
()
217
{
218
NS_LOG_FUNCTION
(
this
);
219
}
220
221
uint32_t
Icmpv6NS::GetReserved
()
const
222
{
223
NS_LOG_FUNCTION
(
this
);
224
return
m_reserved
;
225
}
226
227
void
Icmpv6NS::SetReserved
(uint32_t reserved)
228
{
229
NS_LOG_FUNCTION
(
this
<< reserved);
230
m_reserved
= reserved;
231
}
232
233
Ipv6Address
Icmpv6NS::GetIpv6Target
()
const
234
{
235
NS_LOG_FUNCTION
(
this
);
236
return
m_target
;
237
}
238
239
void
Icmpv6NS::SetIpv6Target
(
Ipv6Address
target)
240
{
241
NS_LOG_FUNCTION
(
this
<< target);
242
m_target
= target;
243
}
244
245
void
Icmpv6NS::Print
(std::ostream& os)
const
246
{
247
NS_LOG_FUNCTION
(
this
<< &os);
248
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (NS) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
249
}
250
251
uint32_t
Icmpv6NS::GetSerializedSize
()
const
252
{
253
NS_LOG_FUNCTION
(
this
);
254
return
24;
255
}
256
257
void
Icmpv6NS::Serialize
(
Buffer::Iterator
start
)
const
258
{
259
NS_LOG_FUNCTION
(
this
<< &start);
260
uint8_t buff_target[16];
261
uint16_t checksum = 0;
262
Buffer::Iterator
i =
start
;
263
264
i.
WriteU8
(
GetType
());
265
i.
WriteU8
(
GetCode
());
266
i.
WriteU16
(0);
267
i.
WriteHtonU32
(
m_reserved
);
268
m_target
.
Serialize
(buff_target);
269
i.
Write
(buff_target, 16);
270
271
if
(
m_calcChecksum
)
272
{
273
i =
start
;
274
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
m_checksum
);
275
i =
start
;
276
i.
Next
(2);
277
i.
WriteU16
(checksum);
278
}
279
}
280
281
uint32_t
Icmpv6NS::Deserialize
(
Buffer::Iterator
start
)
282
{
283
NS_LOG_FUNCTION
(
this
<< &start);
284
uint8_t buf[16];
285
Buffer::Iterator
i =
start
;
286
287
SetType
(i.
ReadU8
());
288
SetCode
(i.
ReadU8
());
289
m_checksum
= i.
ReadU16
();
290
m_reserved
= i.
ReadNtohU32
();
291
i.
Read
(buf, 16);
292
m_target
.
Set
(buf);
293
294
return
GetSerializedSize
();
295
}
296
297
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6NA
);
298
299
TypeId
Icmpv6NA::GetTypeId
()
300
{
301
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6NA"
)
302
.
SetParent
<
Icmpv6Header
> ()
303
.AddConstructor<Icmpv6NA> ()
304
;
305
return
tid;
306
}
307
308
TypeId
Icmpv6NA::GetInstanceTypeId
()
const
309
{
310
NS_LOG_FUNCTION
(
this
);
311
return
GetTypeId
();
312
}
313
314
Icmpv6NA::Icmpv6NA
()
315
{
316
NS_LOG_FUNCTION
(
this
);
317
SetType
(
ICMPV6_ND_NEIGHBOR_ADVERTISEMENT
);
318
SetCode
(0);
319
SetReserved
(0);
320
SetFlagR
(0);
321
SetFlagS
(0);
322
SetFlagO
(0);
323
m_checksum
= 0;
324
}
325
326
Icmpv6NA::~Icmpv6NA
()
327
{
328
NS_LOG_FUNCTION
(
this
);
329
}
330
331
uint32_t
Icmpv6NA::GetReserved
()
const
332
{
333
NS_LOG_FUNCTION
(
this
);
334
return
m_reserved
;
335
}
336
337
void
Icmpv6NA::SetReserved
(uint32_t reserved)
338
{
339
NS_LOG_FUNCTION
(
this
<< reserved);
340
m_reserved
= reserved;
341
}
342
343
Ipv6Address
Icmpv6NA::GetIpv6Target
()
const
344
{
345
NS_LOG_FUNCTION
(
this
);
346
return
m_target
;
347
}
348
349
bool
Icmpv6NA::GetFlagR
()
const
350
{
351
NS_LOG_FUNCTION
(
this
);
352
return
m_flagR
;
353
}
354
355
void
Icmpv6NA::SetFlagR
(
bool
r)
356
{
357
NS_LOG_FUNCTION
(
this
<< r);
358
m_flagR
= r;
359
}
360
361
bool
Icmpv6NA::GetFlagS
()
const
362
{
363
NS_LOG_FUNCTION
(
this
);
364
return
m_flagS
;
365
}
366
367
void
Icmpv6NA::SetFlagS
(
bool
s)
368
{
369
NS_LOG_FUNCTION
(
this
<< s);
370
m_flagS
= s;
371
}
372
373
bool
Icmpv6NA::GetFlagO
()
const
374
{
375
NS_LOG_FUNCTION
(
this
);
376
return
m_flagO
;
377
}
378
379
void
Icmpv6NA::SetFlagO
(
bool
o)
380
{
381
NS_LOG_FUNCTION
(
this
<< o);
382
m_flagO
= o;
383
}
384
385
void
Icmpv6NA::SetIpv6Target
(
Ipv6Address
target)
386
{
387
NS_LOG_FUNCTION
(
this
<< target);
388
m_target
= target;
389
}
390
391
void
Icmpv6NA::Print
(std::ostream& os)
const
392
{
393
NS_LOG_FUNCTION
(
this
<< &os);
394
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (NA) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
395
}
396
397
uint32_t
Icmpv6NA::GetSerializedSize
()
const
398
{
399
NS_LOG_FUNCTION
(
this
);
400
return
24;
401
}
402
403
void
Icmpv6NA::Serialize
(
Buffer::Iterator
start
)
const
404
{
405
NS_LOG_FUNCTION
(
this
<< &start);
406
uint8_t buff_target[16];
407
uint16_t checksum = 0;
408
Buffer::Iterator
i =
start
;
409
uint32_t reserved =
m_reserved
;
410
411
i.
WriteU8
(
GetType
());
412
i.
WriteU8
(
GetCode
());
413
i.
WriteU16
(0);
414
415
if
(
m_flagR
)
416
{
417
reserved |= (uint32_t)(1 << 31);
418
}
419
420
if
(
m_flagS
)
421
{
422
reserved |= (uint32_t)(1<< 30);
423
}
424
425
if
(
m_flagO
)
426
{
427
reserved |= (uint32_t)(1<< 29);
428
}
429
430
i.
WriteHtonU32
(reserved);
431
m_target
.
Serialize
(buff_target);
432
i.
Write
(buff_target, 16);
433
434
if
(
m_calcChecksum
)
435
{
436
i =
start
;
437
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
438
i =
start
;
439
i.
Next
(2);
440
i.
WriteU16
(checksum);
441
}
442
}
443
444
uint32_t
Icmpv6NA::Deserialize
(
Buffer::Iterator
start
)
445
{
446
NS_LOG_FUNCTION
(
this
<< &start);
447
uint8_t buf[16];
448
Buffer::Iterator
i =
start
;
449
450
SetType
(i.
ReadU8
());
451
SetCode
(i.
ReadU8
());
452
m_checksum
= i.
ReadU16
();
453
m_reserved
= i.
ReadNtohU32
();
454
455
m_flagR
=
false
;
456
m_flagS
=
false
;
457
m_flagO
=
false
;
458
459
if
(
m_reserved
& (1 << 31))
460
{
461
m_flagR
=
true
;
462
}
463
464
if
(
m_reserved
& (1 << 30))
465
{
466
m_flagS
=
true
;
467
}
468
469
if
(
m_reserved
& (1 << 29))
470
{
471
m_flagO
=
true
;
472
}
473
474
i.
Read
(buf, 16);
475
m_target
.
Set
(buf);
476
477
return
GetSerializedSize
();
478
}
479
480
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6RA
);
481
482
TypeId
Icmpv6RA::GetTypeId
()
483
{
484
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6RA"
)
485
.
SetParent
<
Icmpv6Header
> ()
486
.AddConstructor<Icmpv6RA> ()
487
;
488
return
tid;
489
}
490
491
TypeId
Icmpv6RA::GetInstanceTypeId
()
const
492
{
493
NS_LOG_FUNCTION
(
this
);
494
return
GetTypeId
();
495
}
496
497
Icmpv6RA::Icmpv6RA
()
498
{
499
NS_LOG_FUNCTION
(
this
);
500
SetType
(
ICMPV6_ND_ROUTER_ADVERTISEMENT
);
501
SetCode
(0);
502
SetFlags
(0);
503
SetFlagM
(0);
504
SetFlagO
(0);
505
SetFlagH
(0);
506
SetCurHopLimit
(0);
507
SetLifeTime
(0);
508
SetRetransmissionTime
(0);
509
SetReachableTime
(0);
510
}
511
512
Icmpv6RA::~Icmpv6RA
()
513
{
514
NS_LOG_FUNCTION
(
this
);
515
}
516
517
void
Icmpv6RA::SetCurHopLimit
(uint8_t m)
518
{
519
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (m));
520
m_curHopLimit
= m;
521
}
522
523
uint8_t
Icmpv6RA::GetCurHopLimit
()
const
524
{
525
NS_LOG_FUNCTION
(
this
);
526
return
m_curHopLimit
;
527
}
528
529
uint16_t
Icmpv6RA::GetLifeTime
()
const
530
{
531
NS_LOG_FUNCTION
(
this
);
532
return
m_LifeTime
;
533
}
534
535
uint32_t
Icmpv6RA::GetReachableTime
()
const
536
{
537
NS_LOG_FUNCTION
(
this
);
538
return
m_ReachableTime
;
539
}
540
541
uint32_t
Icmpv6RA::GetRetransmissionTime
()
const
542
{
543
NS_LOG_FUNCTION
(
this
);
544
return
m_RetransmissionTimer
;
545
}
546
547
void
Icmpv6RA::SetLifeTime
(uint16_t l)
548
{
549
NS_LOG_FUNCTION
(
this
<< l);
550
m_LifeTime
= l;
551
}
552
553
void
Icmpv6RA::SetReachableTime
(uint32_t r)
554
{
555
NS_LOG_FUNCTION
(
this
<< r);
556
m_ReachableTime
= r;
557
}
558
559
void
Icmpv6RA::SetRetransmissionTime
(uint32_t r)
560
{
561
NS_LOG_FUNCTION
(
this
<< r);
562
m_RetransmissionTimer
= r;
563
}
564
565
bool
Icmpv6RA::GetFlagM
()
const
566
{
567
NS_LOG_FUNCTION
(
this
);
568
return
m_flagM
;
569
}
570
571
void
Icmpv6RA::SetFlagM
(
bool
m)
572
{
573
NS_LOG_FUNCTION
(
this
<< m);
574
m_flagM
= m;
575
}
576
577
bool
Icmpv6RA::GetFlagO
()
const
578
{
579
NS_LOG_FUNCTION
(
this
);
580
return
m_flagO
;
581
}
582
583
void
Icmpv6RA::SetFlagO
(
bool
o)
584
{
585
NS_LOG_FUNCTION
(
this
<< o);
586
m_flagO
= o;
587
}
588
589
bool
Icmpv6RA::GetFlagH
()
const
590
{
591
NS_LOG_FUNCTION
(
this
);
592
return
m_flagH
;
593
}
594
595
void
Icmpv6RA::SetFlagH
(
bool
h)
596
{
597
NS_LOG_FUNCTION
(
this
<< h);
598
m_flagH
= h;
599
}
600
601
uint8_t
Icmpv6RA::GetFlags
()
const
602
{
603
NS_LOG_FUNCTION
(
this
);
604
return
m_flags
;
605
}
606
607
void
Icmpv6RA::SetFlags
(uint8_t f)
608
{
609
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (f));
610
m_flags
= f;
611
}
612
613
void
Icmpv6RA::Print
(std::ostream& os)
const
614
{
615
NS_LOG_FUNCTION
(
this
<< &os);
616
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (RA) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
617
}
618
619
uint32_t
Icmpv6RA::GetSerializedSize
()
const
620
{
621
NS_LOG_FUNCTION
(
this
);
622
return
16;
623
}
624
625
void
Icmpv6RA::Serialize
(
Buffer::Iterator
start
)
const
626
{
627
NS_LOG_FUNCTION
(
this
<< &start);
628
uint16_t checksum = 0;
629
Buffer::Iterator
i =
start
;
630
uint8_t flags = 0;
631
632
i.
WriteU8
(
GetType
());
633
i.
WriteU8
(
GetCode
());
634
i.
WriteHtonU16
(0);
635
i.
WriteU8
(
m_curHopLimit
);
636
637
if
(
m_flagM
)
638
{
639
flags |= (uint8_t)(1<< 7);
640
}
641
642
if
(
m_flagO
)
643
{
644
flags |= (uint8_t)(1<< 6);
645
}
646
647
if
(
m_flagH
)
648
{
649
flags |= (uint8_t)(1<< 5);
650
}
651
i.
WriteU8
(flags);
652
i.
WriteHtonU16
(
GetLifeTime
());
653
i.
WriteHtonU32
(
GetReachableTime
());
654
i.
WriteHtonU32
(
GetRetransmissionTime
());
655
656
i =
start
;
657
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
658
659
i =
start
;
660
i.
Next
(2);
661
i.
WriteU16
(checksum);
662
}
663
664
uint32_t
Icmpv6RA::Deserialize
(
Buffer::Iterator
start
)
665
{
666
NS_LOG_FUNCTION
(
this
<< &start);
667
Buffer::Iterator
i =
start
;
668
669
SetType
(i.
ReadU8
());
670
SetCode
(i.
ReadU8
());
671
m_checksum
= i.
ReadU16
();
672
SetCurHopLimit
(i.
ReadU8
());
673
m_flags
= i.
ReadU8
();
674
m_flagM
=
false
;
675
m_flagO
=
false
;
676
m_flagH
=
false
;
677
678
if
(m_flags & (1 << 7))
679
{
680
m_flagM
=
true
;
681
}
682
683
if
(m_flags & (1 << 6))
684
{
685
m_flagO
=
true
;
686
}
687
688
if
(m_flags & (1 << 5))
689
{
690
m_flagH
=
true
;
691
}
692
SetLifeTime
(i.
ReadNtohU16
());
693
SetReachableTime
(i.
ReadNtohU32
());
694
SetRetransmissionTime
(i.
ReadNtohU32
());
695
696
return
GetSerializedSize
();
697
}
698
699
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6RS
);
700
701
TypeId
Icmpv6RS::GetTypeId
()
702
{
703
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6RS"
)
704
.
SetParent
<
Icmpv6Header
> ()
705
.AddConstructor<Icmpv6RS> ()
706
;
707
return
tid;
708
}
709
710
TypeId
Icmpv6RS::GetInstanceTypeId
()
const
711
{
712
NS_LOG_FUNCTION
(
this
);
713
return
GetTypeId
();
714
}
715
716
Icmpv6RS::Icmpv6RS
()
717
{
718
NS_LOG_FUNCTION
(
this
);
719
SetType
(
ICMPV6_ND_ROUTER_SOLICITATION
);
720
SetCode
(0);
721
SetReserved
(0);
722
}
723
724
Icmpv6RS::~Icmpv6RS
()
725
{
726
NS_LOG_FUNCTION
(
this
);
727
}
728
729
uint32_t
Icmpv6RS::GetReserved
()
const
730
{
731
NS_LOG_FUNCTION
(
this
);
732
return
m_reserved
;
733
}
734
735
void
Icmpv6RS::SetReserved
(uint32_t reserved)
736
{
737
NS_LOG_FUNCTION
(
this
<< reserved);
738
m_reserved
= reserved;
739
}
740
741
void
Icmpv6RS::Print
(std::ostream& os)
const
742
{
743
NS_LOG_FUNCTION
(
this
<< &os);
744
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (RS) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
745
}
746
747
uint32_t
Icmpv6RS::GetSerializedSize
()
const
748
{
749
NS_LOG_FUNCTION
(
this
);
750
return
8;
751
}
752
753
void
Icmpv6RS::Serialize
(
Buffer::Iterator
start
)
const
754
{
755
NS_LOG_FUNCTION
(
this
<< &start);
756
NS_LOG_FUNCTION_NOARGS
();
757
uint16_t checksum = 0;
758
Buffer::Iterator
i =
start
;
759
760
i.
WriteU8
(
GetType
());
761
i.
WriteU8
(
GetCode
());
762
i.
WriteU16
(0);
763
i.
WriteHtonU32
(
m_reserved
);
764
765
if
(
m_calcChecksum
)
766
{
767
i =
start
;
768
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
769
770
i =
start
;
771
i.
Next
(2);
772
i.
WriteU16
(checksum);
773
}
774
}
775
776
uint32_t
Icmpv6RS::Deserialize
(
Buffer::Iterator
start
)
777
{
778
NS_LOG_FUNCTION
(
this
<< &start);
779
Buffer::Iterator
i =
start
;
780
781
SetType
(i.
ReadU8
());
782
SetCode
(i.
ReadU8
());
783
m_checksum
= i.
ReadU16
();
784
m_reserved
= i.
ReadNtohU32
();
785
786
return
GetSerializedSize
();
787
}
788
789
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6Redirection
);
790
791
TypeId
Icmpv6Redirection::GetTypeId
()
792
{
793
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6Redirection"
)
794
.
SetParent
<
Icmpv6Header
> ()
795
.AddConstructor<Icmpv6Redirection> ()
796
;
797
return
tid;
798
}
799
800
TypeId
Icmpv6Redirection::GetInstanceTypeId
()
const
801
{
802
NS_LOG_FUNCTION
(
this
);
803
return
GetTypeId
();
804
}
805
806
Icmpv6Redirection::Icmpv6Redirection
()
807
: m_target (
Ipv6Address
(
""
)),
808
m_destination (
Ipv6Address
(
""
)),
809
m_reserved (0)
810
{
811
NS_LOG_FUNCTION
(
this
);
812
SetType
(
ICMPV6_ND_REDIRECTION
);
813
SetCode
(0);
814
m_checksum
= 0;
815
}
816
817
Icmpv6Redirection::~Icmpv6Redirection
()
818
{
819
NS_LOG_FUNCTION
(
this
);
820
}
821
822
void
Icmpv6Redirection::SetReserved
(uint32_t reserved)
823
{
824
NS_LOG_FUNCTION
(
this
<< reserved);
825
m_reserved
= reserved;
826
}
827
828
uint32_t
Icmpv6Redirection::GetReserved
()
const
829
{
830
NS_LOG_FUNCTION
(
this
);
831
return
m_reserved
;
832
}
833
834
Ipv6Address
Icmpv6Redirection::GetTarget
()
const
835
{
836
NS_LOG_FUNCTION
(
this
);
837
return
m_target
;
838
}
839
840
void
Icmpv6Redirection::SetTarget
(
Ipv6Address
target)
841
{
842
NS_LOG_FUNCTION
(
this
<< target);
843
m_target
= target;
844
}
845
846
Ipv6Address
Icmpv6Redirection::GetDestination
()
const
847
{
848
NS_LOG_FUNCTION
(
this
);
849
return
m_destination
;
850
}
851
852
void
Icmpv6Redirection::SetDestination
(
Ipv6Address
destination)
853
{
854
NS_LOG_FUNCTION
(
this
<< destination);
855
m_destination
= destination;
856
}
857
858
void
Icmpv6Redirection::Print
(std::ostream& os)
const
859
{
860
NS_LOG_FUNCTION
(
this
<< &os);
861
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (Redirection) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
" target = "
<<
m_target
<<
" destination = "
<<
m_destination
<<
")"
;
862
}
863
864
uint32_t
Icmpv6Redirection::GetSerializedSize
()
const
865
{
866
NS_LOG_FUNCTION
(
this
);
867
return
40;
868
}
869
870
void
Icmpv6Redirection::Serialize
(
Buffer::Iterator
start
)
const
871
{
872
NS_LOG_FUNCTION
(
this
<< &start);
873
uint8_t buff[16];
874
uint16_t checksum = 0;
875
Buffer::Iterator
i =
start
;
876
877
i.
WriteU8
(
GetType
());
878
i.
WriteU8
(
GetCode
());
879
i.
WriteU16
(checksum);
880
i.
WriteU32
(
m_reserved
);
881
882
m_target
.
Serialize
(buff);
883
i.
Write
(buff, 16);
884
885
m_destination
.
Serialize
(buff);
886
i.
Write
(buff, 16);
887
888
if
(
m_calcChecksum
)
889
{
890
i =
start
;
891
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
892
893
i =
start
;
894
i.
Next
(2);
895
i.
WriteU16
(checksum);
896
}
897
}
898
899
uint32_t
Icmpv6Redirection::Deserialize
(
Buffer::Iterator
start
)
900
{
901
NS_LOG_FUNCTION
(
this
<< &start);
902
uint8_t buff[16];
903
Buffer::Iterator
i =
start
;
904
905
SetType
(i.
ReadU8
());
906
SetCode
(i.
ReadU8
());
907
m_checksum
= i.
ReadU16
();
908
SetReserved
(i.
ReadU32
());
909
910
i.
Read
(buff, 16);
911
m_target
.
Set
(buff);
912
913
i.
Read
(buff, 16);
914
m_destination
.
Set
(buff);
915
916
return
GetSerializedSize
();
917
}
918
919
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6Echo
);
920
921
TypeId
Icmpv6Echo::GetTypeId
()
922
{
923
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6Echo"
)
924
.
SetParent
<
Icmpv6Header
> ()
925
.AddConstructor<Icmpv6Echo> ()
926
;
927
return
tid;
928
}
929
930
TypeId
Icmpv6Echo::GetInstanceTypeId
()
const
931
{
932
NS_LOG_FUNCTION
(
this
);
933
return
GetTypeId
();
934
}
935
936
Icmpv6Echo::Icmpv6Echo
()
937
{
938
NS_LOG_FUNCTION
(
this
);
939
SetType
(
Icmpv6Header::ICMPV6_ECHO_REQUEST
);
940
SetCode
(0);
941
m_checksum
= 0;
942
SetId
(0);
943
SetSeq
(0);
944
}
945
946
Icmpv6Echo::Icmpv6Echo
(
bool
request)
947
{
948
NS_LOG_FUNCTION
(
this
<< request);
949
SetType
(request ?
Icmpv6Header::ICMPV6_ECHO_REQUEST
:
Icmpv6Header::ICMPV6_ECHO_REPLY
);
950
SetCode
(0);
951
m_checksum
= 0;
952
SetId
(0);
953
SetSeq
(0);
954
}
955
956
Icmpv6Echo::~Icmpv6Echo
()
957
{
958
NS_LOG_FUNCTION
(
this
);
959
}
960
961
uint16_t
Icmpv6Echo::GetId
()
const
962
{
963
NS_LOG_FUNCTION
(
this
);
964
return
m_id
;
965
}
966
967
void
Icmpv6Echo::SetId
(uint16_t
id
)
968
{
969
NS_LOG_FUNCTION
(
this
<<
id
);
970
m_id
= id;
971
}
972
973
uint16_t
Icmpv6Echo::GetSeq
()
const
974
{
975
NS_LOG_FUNCTION
(
this
);
976
return
m_seq
;
977
}
978
979
void
Icmpv6Echo::SetSeq
(uint16_t seq)
980
{
981
NS_LOG_FUNCTION
(
this
<< seq);
982
m_seq
= seq;
983
}
984
985
void
Icmpv6Echo::Print
(std::ostream& os)
const
986
{
987
NS_LOG_FUNCTION
(
this
<< &os);
988
os <<
"( type = "
<< (
GetType
() == 128 ?
"128 (Request)"
:
"129 (Reply)"
) <<
989
" code = "
<< (uint32_t)
GetCode
() <<
990
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
991
}
992
993
uint32_t
Icmpv6Echo::GetSerializedSize
()
const
994
{
995
NS_LOG_FUNCTION
(
this
);
996
return
8;
997
}
998
999
void
Icmpv6Echo::Serialize
(
Buffer::Iterator
start
)
const
1000
{
1001
NS_LOG_FUNCTION
(
this
<< &start);
1002
uint16_t checksum = 0;
1003
Buffer::Iterator
i =
start
;
1004
1005
i.
WriteU8
(
GetType
());
1006
i.
WriteU8
(
GetCode
());
1007
i.
WriteHtonU16
(0);
1008
1009
i.
WriteHtonU16
(
m_id
);
1010
i.
WriteHtonU16
(
m_seq
);
1011
1012
if
(
m_calcChecksum
)
1013
{
1014
i =
start
;
1015
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
1016
i =
start
;
1017
i.
Next
(2);
1018
i.
WriteU16
(checksum);
1019
}
1020
}
1021
1022
uint32_t
Icmpv6Echo::Deserialize
(
Buffer::Iterator
start
)
1023
{
1024
NS_LOG_FUNCTION
(
this
<< &start);
1025
Buffer::Iterator
i =
start
;
1026
1027
SetType
(i.
ReadU8
());
1028
SetCode
(i.
ReadU8
());
1029
m_checksum
= i.
ReadU16
();
1030
1031
m_id
= i.
ReadNtohU16
();
1032
m_seq
= i.
ReadNtohU16
();
1033
return
GetSerializedSize
();
1034
}
1035
1036
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6DestinationUnreachable
);
1037
1038
TypeId
Icmpv6DestinationUnreachable::GetTypeId
()
1039
{
1040
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6DestinationUnreachable"
)
1041
.
SetParent
<
Icmpv6Header
> ()
1042
.AddConstructor<Icmpv6DestinationUnreachable> ()
1043
;
1044
return
tid;
1045
}
1046
1047
TypeId
Icmpv6DestinationUnreachable::GetInstanceTypeId
()
const
1048
{
1049
NS_LOG_FUNCTION
(
this
);
1050
return
GetTypeId
();
1051
}
1052
1053
Icmpv6DestinationUnreachable::Icmpv6DestinationUnreachable
()
1054
: m_packet (0)
1055
{
1056
NS_LOG_FUNCTION
(
this
);
1057
SetType
(
ICMPV6_ERROR_DESTINATION_UNREACHABLE
);
1058
}
1059
1060
Icmpv6DestinationUnreachable::~Icmpv6DestinationUnreachable
()
1061
{
1062
NS_LOG_FUNCTION
(
this
);
1063
}
1064
1065
Ptr<Packet>
Icmpv6DestinationUnreachable::GetPacket
()
const
1066
{
1067
NS_LOG_FUNCTION
(
this
);
1068
return
m_packet
;
1069
}
1070
1071
void
Icmpv6DestinationUnreachable::SetPacket
(
Ptr<Packet>
p)
1072
{
1073
NS_LOG_FUNCTION
(
this
<< *p);
1074
NS_ASSERT
(p->
GetSize
() <= 1280);
1075
m_packet
= p;
1076
}
1077
1078
void
Icmpv6DestinationUnreachable::Print
(std::ostream& os)
const
1079
{
1080
NS_LOG_FUNCTION
(
this
<< &os);
1081
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (Destination Unreachable) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
1082
}
1083
1084
uint32_t
Icmpv6DestinationUnreachable::GetSerializedSize
()
const
1085
{
1086
NS_LOG_FUNCTION
(
this
);
1087
return
8 +
m_packet
->
GetSize
();
1088
}
1089
1090
void
Icmpv6DestinationUnreachable::Serialize
(
Buffer::Iterator
start
)
const
1091
{
1092
NS_LOG_FUNCTION
(
this
<< &start);
1093
uint16_t checksum = 0;
1094
Buffer::Iterator
i =
start
;
1095
1096
i.
WriteU8
(
GetType
());
1097
i.
WriteU8
(
GetCode
());
1098
i.
WriteHtonU16
(0);
1099
i.
WriteHtonU32
(0);
1100
1101
uint32_t size =
m_packet
->
GetSize
();
1102
uint8_t *buf =
new
uint8_t[size];
1103
m_packet
->
CopyData
(buf, size);
1104
i.
Write
(buf, size);
1105
delete
[] buf;
1106
1107
i =
start
;
1108
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
1109
1110
i =
start
;
1111
i.
Next
(2);
1112
i.
WriteU16
(checksum);
1113
}
1114
1115
uint32_t
Icmpv6DestinationUnreachable::Deserialize
(
Buffer::Iterator
start
)
1116
{
1117
NS_LOG_FUNCTION
(
this
<< &start);
1118
uint16_t length = start.
GetSize
() - 8;
1119
uint8_t*
data
=
new
uint8_t[length];
1120
Buffer::Iterator
i =
start
;
1121
1122
SetType
(i.
ReadU8
());
1123
SetCode
(i.
ReadU8
());
1124
m_checksum
= i.
ReadU16
();
1125
i.
ReadNtohU32
();
1126
i.
Read
(data, length);
1127
m_packet
= Create<Packet> (
data
, length);
1128
1129
delete
[]
data
;
1130
return
GetSerializedSize
();
1131
}
1132
1133
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6TooBig
);
1134
1135
TypeId
Icmpv6TooBig::GetTypeId
()
1136
{
1137
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6TooBig"
)
1138
.
SetParent
<
Icmpv6Header
> ()
1139
.AddConstructor<Icmpv6TooBig> ()
1140
;
1141
return
tid;
1142
}
1143
1144
TypeId
Icmpv6TooBig::GetInstanceTypeId
()
const
1145
{
1146
NS_LOG_FUNCTION
(
this
);
1147
return
GetTypeId
();
1148
}
1149
1150
Icmpv6TooBig::Icmpv6TooBig
()
1151
: m_packet (0),
1152
m_mtu (0)
1153
{
1154
NS_LOG_FUNCTION
(
this
);
1155
SetType
(
ICMPV6_ERROR_PACKET_TOO_BIG
);
1156
}
1157
1158
Icmpv6TooBig::~Icmpv6TooBig
()
1159
{
1160
NS_LOG_FUNCTION
(
this
);
1161
}
1162
1163
Ptr<Packet>
Icmpv6TooBig::GetPacket
()
const
1164
{
1165
NS_LOG_FUNCTION
(
this
);
1166
return
m_packet
;
1167
}
1168
1169
void
Icmpv6TooBig::SetPacket
(
Ptr<Packet>
p)
1170
{
1171
NS_LOG_FUNCTION
(
this
<< *p);
1172
NS_ASSERT
(p->
GetSize
() <= 1280);
1173
m_packet
= p;
1174
}
1175
1176
uint32_t
Icmpv6TooBig::GetMtu
()
const
1177
{
1178
NS_LOG_FUNCTION
(
this
);
1179
return
m_mtu
;
1180
}
1181
1182
void
Icmpv6TooBig::SetMtu
(uint32_t mtu)
1183
{
1184
NS_LOG_FUNCTION
(
this
<< mtu);
1185
m_mtu
= mtu;
1186
}
1187
1188
void
Icmpv6TooBig::Print
(std::ostream& os)
const
1189
{
1190
NS_LOG_FUNCTION
(
this
<< &os);
1191
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (Too Big) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
" mtu = "
<< (uint32_t)
GetMtu
() <<
")"
;
1192
}
1193
1194
uint32_t
Icmpv6TooBig::GetSerializedSize
()
const
1195
{
1196
NS_LOG_FUNCTION
(
this
);
1197
return
8 +
m_packet
->
GetSize
();
1198
}
1199
1200
void
Icmpv6TooBig::Serialize
(
Buffer::Iterator
start
)
const
1201
{
1202
NS_LOG_FUNCTION
(
this
<< &start);
1203
uint16_t checksum = 0;
1204
Buffer::Iterator
i =
start
;
1205
1206
i.
WriteU8
(
GetType
());
1207
i.
WriteU8
(
GetCode
());
1208
i.
WriteHtonU16
(0);
1209
i.
WriteHtonU32
(
GetMtu
());
1210
1211
uint32_t size =
m_packet
->
GetSize
();
1212
uint8_t *buf =
new
uint8_t[size];
1213
m_packet
->
CopyData
(buf, size);
1214
i.
Write
(buf, size);
1215
delete
[] buf;
1216
1217
i =
start
;
1218
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
1219
1220
i =
start
;
1221
i.
Next
(2);
1222
i.
WriteU16
(checksum);
1223
}
1224
1225
uint32_t
Icmpv6TooBig::Deserialize
(
Buffer::Iterator
start
)
1226
{
1227
NS_LOG_FUNCTION
(
this
<< &start);
1228
uint16_t length = start.
GetSize
() - 8;
1229
uint8_t*
data
=
new
uint8_t[length];
1230
Buffer::Iterator
i =
start
;
1231
1232
SetType
(i.
ReadU8
());
1233
SetCode
(i.
ReadU8
());
1234
m_checksum
= i.
ReadU16
();
1235
SetMtu
(i.
ReadNtohU32
());
1236
i.
Read
(data, length);
1237
m_packet
= Create<Packet> (
data
, length);
1238
1239
delete
[]
data
;
1240
return
GetSerializedSize
();
1241
}
1242
1243
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6TimeExceeded
);
1244
1245
TypeId
Icmpv6TimeExceeded::GetTypeId
()
1246
{
1247
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6TimeExceeded"
)
1248
.
SetParent
<
Icmpv6Header
> ()
1249
.AddConstructor<Icmpv6TimeExceeded> ()
1250
;
1251
return
tid;
1252
}
1253
1254
TypeId
Icmpv6TimeExceeded::GetInstanceTypeId
()
const
1255
{
1256
NS_LOG_FUNCTION
(
this
);
1257
return
GetTypeId
();
1258
}
1259
1260
Icmpv6TimeExceeded::Icmpv6TimeExceeded
()
1261
: m_packet (0)
1262
{
1263
NS_LOG_FUNCTION
(
this
);
1264
SetType
(
ICMPV6_ERROR_TIME_EXCEEDED
);
1265
}
1266
1267
Icmpv6TimeExceeded::~Icmpv6TimeExceeded
()
1268
{
1269
NS_LOG_FUNCTION
(
this
);
1270
}
1271
1272
Ptr<Packet>
Icmpv6TimeExceeded::GetPacket
()
const
1273
{
1274
NS_LOG_FUNCTION
(
this
);
1275
return
m_packet
;
1276
}
1277
1278
void
Icmpv6TimeExceeded::SetPacket
(
Ptr<Packet>
p)
1279
{
1280
NS_LOG_FUNCTION
(
this
<< *p);
1281
NS_ASSERT
(p->
GetSize
() <= 1280);
1282
m_packet
= p;
1283
}
1284
1285
void
Icmpv6TimeExceeded::Print
(std::ostream& os)
const
1286
{
1287
NS_LOG_FUNCTION
(
this
<< &os);
1288
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (Destination Unreachable) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
")"
;
1289
}
1290
1291
uint32_t
Icmpv6TimeExceeded::GetSerializedSize
()
const
1292
{
1293
NS_LOG_FUNCTION
(
this
);
1294
return
8 +
m_packet
->
GetSize
();
1295
}
1296
1297
void
Icmpv6TimeExceeded::Serialize
(
Buffer::Iterator
start
)
const
1298
{
1299
NS_LOG_FUNCTION
(
this
<< &start);
1300
1301
uint16_t checksum = 0;
1302
Buffer::Iterator
i =
start
;
1303
1304
i.
WriteU8
(
GetType
());
1305
i.
WriteU8
(
GetCode
());
1306
i.
WriteHtonU16
(0);
1307
i.
WriteHtonU32
(0);
1308
1309
uint32_t size =
m_packet
->
GetSize
();
1310
uint8_t *buf =
new
uint8_t[size];
1311
m_packet
->
CopyData
(buf, size);
1312
i.
Write
(buf, size);
1313
delete
[] buf;
1314
1315
i =
start
;
1316
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
1317
1318
i =
start
;
1319
i.
Next
(2);
1320
i.
WriteU16
(checksum);
1321
}
1322
1323
uint32_t
Icmpv6TimeExceeded::Deserialize
(
Buffer::Iterator
start
)
1324
{
1325
NS_LOG_FUNCTION
(
this
<< &start);
1326
1327
uint16_t length = start.
GetSize
() - 8;
1328
uint8_t*
data
=
new
uint8_t[length];
1329
Buffer::Iterator
i =
start
;
1330
1331
SetType
(i.
ReadU8
());
1332
SetCode
(i.
ReadU8
());
1333
m_checksum
= i.
ReadU16
();
1334
i.
ReadNtohU32
();
1335
i.
Read
(data, length);
1336
m_packet
= Create<Packet> (
data
, length);
1337
1338
delete
[]
data
;
1339
return
GetSerializedSize
();
1340
}
1341
1342
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6ParameterError
);
1343
1344
TypeId
Icmpv6ParameterError::GetTypeId
()
1345
{
1346
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6ParameterError"
)
1347
.
SetParent
<
Icmpv6Header
> ()
1348
.AddConstructor<Icmpv6ParameterError> ()
1349
;
1350
return
tid;
1351
}
1352
1353
TypeId
Icmpv6ParameterError::GetInstanceTypeId
()
const
1354
{
1355
NS_LOG_FUNCTION
(
this
);
1356
return
GetTypeId
();
1357
}
1358
1359
Icmpv6ParameterError::Icmpv6ParameterError
()
1360
: m_packet (0),
1361
m_ptr (0)
1362
{
1363
NS_LOG_FUNCTION
(
this
);
1364
SetType
(
ICMPV6_ERROR_PARAMETER_ERROR
);
1365
}
1366
1367
Icmpv6ParameterError::~Icmpv6ParameterError
()
1368
{
1369
NS_LOG_FUNCTION
(
this
);
1370
}
1371
1372
Ptr<Packet>
Icmpv6ParameterError::GetPacket
()
const
1373
{
1374
NS_LOG_FUNCTION
(
this
);
1375
return
m_packet
;
1376
}
1377
1378
void
Icmpv6ParameterError::SetPacket
(
Ptr<Packet>
p)
1379
{
1380
NS_LOG_FUNCTION
(
this
<< *p);
1381
NS_ASSERT
(p->
GetSize
() <= 1280);
1382
m_packet
= p;
1383
}
1384
1385
uint32_t
Icmpv6ParameterError::GetPtr
()
const
1386
{
1387
NS_LOG_FUNCTION
(
this
);
1388
return
m_ptr
;
1389
}
1390
1391
void
Icmpv6ParameterError::SetPtr
(uint32_t ptr)
1392
{
1393
NS_LOG_FUNCTION
(
this
<< ptr);
1394
m_ptr
= ptr;
1395
}
1396
1397
void
Icmpv6ParameterError::Print
(std::ostream& os)
const
1398
{
1399
NS_LOG_FUNCTION
(
this
<< &os);
1400
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" (Destination Unreachable) code = "
<< (uint32_t)
GetCode
() <<
" checksum = "
<< (uint32_t)
GetChecksum
() <<
" ptr = "
<< (uint32_t)
GetPtr
() <<
")"
;
1401
}
1402
1403
uint32_t
Icmpv6ParameterError::GetSerializedSize
()
const
1404
{
1405
NS_LOG_FUNCTION
(
this
);
1406
return
8 +
m_packet
->
GetSize
();
1407
}
1408
1409
void
Icmpv6ParameterError::Serialize
(
Buffer::Iterator
start
)
const
1410
{
1411
NS_LOG_FUNCTION
(
this
<< &start);
1412
uint16_t checksum = 0;
1413
Buffer::Iterator
i =
start
;
1414
1415
i.
WriteU8
(
GetType
());
1416
i.
WriteU8
(
GetCode
());
1417
i.
WriteHtonU16
(0);
1418
i.
WriteHtonU32
(
GetPtr
());
1419
1420
uint32_t size =
m_packet
->
GetSize
();
1421
uint8_t *buf =
new
uint8_t[size];
1422
m_packet
->
CopyData
(buf, size);
1423
i.
Write
(buf, size);
1424
delete
[] buf;
1425
1426
i =
start
;
1427
checksum = i.
CalculateIpChecksum
(i.
GetSize
(),
GetChecksum
());
1428
1429
i =
start
;
1430
i.
Next
(2);
1431
i.
WriteU16
(checksum);
1432
}
1433
1434
uint32_t
Icmpv6ParameterError::Deserialize
(
Buffer::Iterator
start
)
1435
{
1436
NS_LOG_FUNCTION
(
this
<< &start);
1437
uint16_t length = start.
GetSize
() - 8;
1438
uint8_t*
data
=
new
uint8_t[length];
1439
Buffer::Iterator
i =
start
;
1440
1441
SetType
(i.
ReadU8
());
1442
SetCode
(i.
ReadU8
());
1443
m_checksum
= i.
ReadU16
();
1444
SetPtr
(i.
ReadNtohU32
());
1445
i.
Read
(data, length);
1446
m_packet
= Create<Packet> (
data
, length);
1447
delete
[]
data
;
1448
1449
return
GetSerializedSize
();
1450
}
1451
1452
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6OptionHeader
);
1453
1454
TypeId
Icmpv6OptionHeader::GetTypeId
()
1455
{
1456
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6OptionHeader"
)
1457
.
SetParent
<
Header
> ()
1458
.AddConstructor<Icmpv6OptionHeader> ()
1459
;
1460
return
tid;
1461
}
1462
1463
TypeId
Icmpv6OptionHeader::GetInstanceTypeId
()
const
1464
{
1465
NS_LOG_FUNCTION
(
this
);
1466
return
GetTypeId
();
1467
}
1468
1469
1470
Icmpv6OptionHeader::Icmpv6OptionHeader
()
1471
{
1472
NS_LOG_FUNCTION
(
this
);
1473
/* TODO */
1474
m_type
= 0;
1475
m_len
= 0;
1476
}
1477
1478
Icmpv6OptionHeader::~Icmpv6OptionHeader
()
1479
{
1480
NS_LOG_FUNCTION
(
this
);
1481
}
1482
1483
uint8_t
Icmpv6OptionHeader::GetType
()
const
1484
{
1485
NS_LOG_FUNCTION_NOARGS
();
1486
return
m_type
;
1487
}
1488
1489
void
Icmpv6OptionHeader::SetType
(uint8_t type)
1490
{
1491
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (type));
1492
m_type
= type;
1493
}
1494
1495
uint8_t
Icmpv6OptionHeader::GetLength
()
const
1496
{
1497
NS_LOG_FUNCTION
(
this
);
1498
return
m_len
;
1499
}
1500
1501
void
Icmpv6OptionHeader::SetLength
(uint8_t len)
1502
{
1503
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (len));
1504
m_len
= len;
1505
}
1506
1507
void
Icmpv6OptionHeader::Print
(std::ostream& os)
const
1508
{
1509
NS_LOG_FUNCTION
(
this
<< &os);
1510
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" length = "
<< (uint32_t)
GetLength
() <<
")"
;
1511
}
1512
1513
uint32_t
Icmpv6OptionHeader::GetSerializedSize
()
const
1514
{
1515
NS_LOG_FUNCTION
(
this
);
1516
return
m_len
*8;
1517
}
1518
1519
uint32_t
Icmpv6OptionHeader::Deserialize
(
Buffer::Iterator
start
)
1520
{
1521
NS_LOG_FUNCTION
(
this
<< &start);
1522
return
GetSerializedSize
();
1523
}
1524
1525
void
Icmpv6OptionHeader::Serialize
(
Buffer::Iterator
start
)
const
1526
{
1527
NS_LOG_FUNCTION
(
this
<< &start);
1528
}
1529
1530
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6OptionMtu
);
1531
1532
TypeId
Icmpv6OptionMtu::GetTypeId
()
1533
{
1534
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6OptionMtu"
)
1535
.
SetParent
<
Icmpv6OptionHeader
> ()
1536
.AddConstructor<Icmpv6OptionMtu> ()
1537
;
1538
return
tid;
1539
}
1540
1541
TypeId
Icmpv6OptionMtu::GetInstanceTypeId
()
const
1542
{
1543
NS_LOG_FUNCTION
(
this
);
1544
return
GetTypeId
();
1545
}
1546
1547
Icmpv6OptionMtu::Icmpv6OptionMtu
()
1548
{
1549
NS_LOG_FUNCTION
(
this
);
1550
SetType
(
Icmpv6Header::ICMPV6_OPT_MTU
);
1551
SetLength
(1);
1552
SetReserved
(0);
1553
}
1554
1555
Icmpv6OptionMtu::Icmpv6OptionMtu
(uint32_t mtu)
1556
: m_mtu (mtu)
1557
{
1558
NS_LOG_FUNCTION
(
this
<< mtu);
1559
SetType
(
Icmpv6Header::ICMPV6_OPT_MTU
);
1560
SetLength
(1);
1561
SetReserved
(0);
1562
}
1563
1564
Icmpv6OptionMtu::~Icmpv6OptionMtu
()
1565
{
1566
NS_LOG_FUNCTION
(
this
);
1567
}
1568
1569
uint16_t
Icmpv6OptionMtu::GetReserved
()
const
1570
{
1571
NS_LOG_FUNCTION
(
this
);
1572
return
m_reserved
;
1573
}
1574
1575
void
Icmpv6OptionMtu::SetReserved
(uint16_t reserved)
1576
{
1577
NS_LOG_FUNCTION
(
this
<< reserved);
1578
m_reserved
= reserved;
1579
}
1580
1581
uint32_t
Icmpv6OptionMtu::GetMtu
()
const
1582
{
1583
NS_LOG_FUNCTION
(
this
);
1584
return
m_mtu
;
1585
}
1586
1587
void
Icmpv6OptionMtu::SetMtu
(uint32_t mtu)
1588
{
1589
NS_LOG_FUNCTION
(
this
<< mtu);
1590
m_mtu
= mtu;
1591
}
1592
1593
void
Icmpv6OptionMtu::Print
(std::ostream& os)
const
1594
{
1595
NS_LOG_FUNCTION
(
this
<< &os);
1596
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" length = "
<< (uint32_t)
GetLength
() <<
" MTU = "
<<
m_mtu
<<
")"
;
1597
}
1598
1599
uint32_t
Icmpv6OptionMtu::GetSerializedSize
()
const
1600
{
1601
NS_LOG_FUNCTION
(
this
);
1602
return
8;
/* m_len = 1 so the real size is multiple by 8 */
1603
}
1604
1605
void
Icmpv6OptionMtu::Serialize
(
Buffer::Iterator
start
)
const
1606
{
1607
NS_LOG_FUNCTION
(
this
<< &start);
1608
Buffer::Iterator
i =
start
;
1609
i.
WriteU8
(
GetType
());
1610
i.
WriteU8
(
GetLength
());
1611
i.
WriteHtonU16
(
GetReserved
());
1612
i.
WriteHtonU32
(
GetMtu
());
1613
}
1614
1615
uint32_t
Icmpv6OptionMtu::Deserialize
(
Buffer::Iterator
start
)
1616
{
1617
NS_LOG_FUNCTION
(
this
<< &start);
1618
Buffer::Iterator
i =
start
;
1619
SetType
(i.
ReadU8
());
1620
SetLength
(i.
ReadU8
());
1621
SetReserved
(i.
ReadNtohU16
());
1622
SetMtu
(i.
ReadNtohU32
());
1623
return
GetSerializedSize
();
1624
}
1625
1626
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6OptionPrefixInformation
);
1627
1628
TypeId
Icmpv6OptionPrefixInformation::GetTypeId
()
1629
{
1630
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6OptionPrefixInformation"
)
1631
.
SetParent
<
Icmpv6OptionHeader
> ()
1632
.AddConstructor<Icmpv6OptionPrefixInformation> ()
1633
;
1634
return
tid;
1635
}
1636
1637
TypeId
Icmpv6OptionPrefixInformation::GetInstanceTypeId
()
const
1638
{
1639
NS_LOG_FUNCTION
(
this
);
1640
return
GetTypeId
();
1641
}
1642
1643
Icmpv6OptionPrefixInformation::Icmpv6OptionPrefixInformation
()
1644
{
1645
NS_LOG_FUNCTION
(
this
);
1646
SetType
(
Icmpv6Header::ICMPV6_OPT_PREFIX
);
1647
SetLength
(4);
1648
SetPrefix
(
Ipv6Address
(
"::"
));
1649
SetPrefixLength
(0);
1650
SetValidTime
(0);
1651
SetPreferredTime
(0);
1652
SetFlags
(0);
1653
SetReserved
(0);
1654
}
1655
1656
Icmpv6OptionPrefixInformation::Icmpv6OptionPrefixInformation
(
Ipv6Address
prefix, uint8_t prefixlen)
1657
{
1658
NS_LOG_FUNCTION
(
this
<< prefix << static_cast<uint32_t> (prefixlen));
1659
SetType
(
Icmpv6Header::ICMPV6_OPT_PREFIX
);
1660
SetLength
(4);
1661
SetPrefix
(prefix);
1662
SetPrefixLength
(prefixlen);
1663
SetValidTime
(0);
1664
SetPreferredTime
(0);
1665
SetFlags
(0);
1666
SetReserved
(0);
1667
}
1668
1669
Icmpv6OptionPrefixInformation::~Icmpv6OptionPrefixInformation
()
1670
{
1671
NS_LOG_FUNCTION
(
this
);
1672
}
1673
1674
uint8_t
Icmpv6OptionPrefixInformation::GetPrefixLength
()
const
1675
{
1676
NS_LOG_FUNCTION
(
this
);
1677
return
m_prefixLength
;
1678
}
1679
1680
void
Icmpv6OptionPrefixInformation::SetPrefixLength
(uint8_t prefixLength)
1681
{
1682
NS_LOG_FUNCTION
(
this
<< static_cast<uint32_t> (prefixLength));
1683
NS_ASSERT
(prefixLength <= 128);
1684
m_prefixLength
= prefixLength;
1685
}
1686
1687
uint8_t
Icmpv6OptionPrefixInformation::GetFlags
()
const
1688
{
1689
NS_LOG_FUNCTION
(
this
);
1690
return
m_flags
;
1691
}
1692
1693
void
Icmpv6OptionPrefixInformation::SetFlags
(uint8_t flags)
1694
{
1695
NS_LOG_FUNCTION
(
this
);
1696
m_flags
= flags;
1697
}
1698
1699
uint32_t
Icmpv6OptionPrefixInformation::GetValidTime
()
const
1700
{
1701
NS_LOG_FUNCTION
(
this
);
1702
return
m_validTime
;
1703
}
1704
1705
void
Icmpv6OptionPrefixInformation::SetValidTime
(uint32_t validTime)
1706
{
1707
NS_LOG_FUNCTION
(
this
<< validTime);
1708
m_validTime
= validTime;
1709
}
1710
1711
uint32_t
Icmpv6OptionPrefixInformation::GetPreferredTime
()
const
1712
{
1713
NS_LOG_FUNCTION
(
this
);
1714
return
m_preferredTime
;
1715
}
1716
1717
void
Icmpv6OptionPrefixInformation::SetPreferredTime
(uint32_t preferredTime)
1718
{
1719
NS_LOG_FUNCTION
(
this
<< preferredTime);
1720
m_preferredTime
= preferredTime;
1721
}
1722
1723
uint32_t
Icmpv6OptionPrefixInformation::GetReserved
()
const
1724
{
1725
NS_LOG_FUNCTION
(
this
);
1726
return
m_preferredTime
;
1727
}
1728
1729
void
Icmpv6OptionPrefixInformation::SetReserved
(uint32_t reserved)
1730
{
1731
NS_LOG_FUNCTION
(
this
<< reserved);
1732
m_reserved
= reserved;
1733
}
1734
1735
Ipv6Address
Icmpv6OptionPrefixInformation::GetPrefix
()
const
1736
{
1737
NS_LOG_FUNCTION
(
this
);
1738
return
m_prefix
;
1739
}
1740
1741
void
Icmpv6OptionPrefixInformation::SetPrefix
(
Ipv6Address
prefix)
1742
{
1743
NS_LOG_FUNCTION
(
this
<< prefix);
1744
m_prefix
= prefix;
1745
}
1746
1747
void
Icmpv6OptionPrefixInformation::Print
(std::ostream& os)
const
1748
{
1749
NS_LOG_FUNCTION
(
this
<< &os);
1750
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" length = "
<< (uint32_t)
GetLength
() <<
" prefix "
<<
m_prefix
<<
")"
;
1751
}
1752
1753
uint32_t
Icmpv6OptionPrefixInformation::GetSerializedSize
()
const
1754
{
1755
NS_LOG_FUNCTION
(
this
);
1756
return
32;
1757
}
1758
1759
void
Icmpv6OptionPrefixInformation::Serialize
(
Buffer::Iterator
start
)
const
1760
{
1761
NS_LOG_FUNCTION
(
this
<< &start);
1762
Buffer::Iterator
i =
start
;
1763
uint8_t buf[16];
1764
1765
memset (buf, 0x00,
sizeof
(buf));
1766
1767
i.
WriteU8
(
GetType
());
1768
i.
WriteU8
(
GetLength
());
1769
i.
WriteU8
(
m_prefixLength
);
1770
i.
WriteU8
(
m_flags
);
1771
i.
WriteHtonU32
(
m_validTime
);
1772
i.
WriteHtonU32
(
m_preferredTime
);
1773
i.
WriteHtonU32
(
m_reserved
);
1774
m_prefix
.
GetBytes
(buf);
1775
i.
Write
(buf, 16);
1776
}
1777
1778
uint32_t
Icmpv6OptionPrefixInformation::Deserialize
(
Buffer::Iterator
start
)
1779
{
1780
NS_LOG_FUNCTION
(
this
<< &start);
1781
Buffer::Iterator
i =
start
;
1782
uint8_t buf[16];
1783
1784
SetType
(i.
ReadU8
());
1785
SetLength
(i.
ReadU8
());
1786
SetPrefixLength
(i.
ReadU8
());
1787
SetFlags
(i.
ReadU8
());
1788
SetValidTime
(i.
ReadNtohU32
());
1789
SetPreferredTime
(i.
ReadNtohU32
());
1790
SetReserved
(i.
ReadNtohU32
());
1791
i.
Read
(buf, 16);
1792
1793
Ipv6Address
prefix (buf);
1794
SetPrefix
(prefix);
1795
1796
return
GetSerializedSize
();
1797
}
1798
1799
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6OptionLinkLayerAddress
);
1800
1801
TypeId
Icmpv6OptionLinkLayerAddress::GetTypeId
()
1802
{
1803
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6OptionLinkLayerAddress"
)
1804
.
SetParent
<
Icmpv6OptionHeader
> ()
1805
.AddConstructor<Icmpv6OptionLinkLayerAddress> ()
1806
;
1807
return
tid;
1808
}
1809
1810
TypeId
Icmpv6OptionLinkLayerAddress::GetInstanceTypeId
()
const
1811
{
1812
NS_LOG_FUNCTION
(
this
);
1813
return
GetTypeId
();
1814
}
1815
1816
Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress
(
bool
source)
1817
{
1818
NS_LOG_FUNCTION
(
this
<< source);
1819
SetType
(source ?
Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE
:
Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET
);
1820
}
1821
1822
Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress
()
1823
{
1824
NS_LOG_FUNCTION
(
this
);
1825
SetType
(
Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE
);
1826
}
1827
1828
Icmpv6OptionLinkLayerAddress::Icmpv6OptionLinkLayerAddress
(
bool
source,
Address
addr)
1829
{
1830
NS_LOG_FUNCTION
(
this
<< source << addr);
1831
SetType
(source ?
Icmpv6Header::ICMPV6_OPT_LINK_LAYER_SOURCE
:
Icmpv6Header::ICMPV6_OPT_LINK_LAYER_TARGET
);
1832
SetAddress
(addr);
1833
1834
uint8_t len = (2 +
m_addr
.
GetLength
()) / 8;
1835
if
( (2 +
m_addr
.
GetLength
()) % 8 )
1836
{
1837
len ++;
1838
}
1839
SetLength
(len);
1840
}
1841
1842
Icmpv6OptionLinkLayerAddress::~Icmpv6OptionLinkLayerAddress
()
1843
{
1844
NS_LOG_FUNCTION
(
this
);
1845
}
1846
1847
Address
Icmpv6OptionLinkLayerAddress::GetAddress
()
const
1848
{
1849
NS_LOG_FUNCTION
(
this
);
1850
return
m_addr
;
1851
}
1852
1853
void
Icmpv6OptionLinkLayerAddress::SetAddress
(
Address
addr)
1854
{
1855
NS_LOG_FUNCTION
(
this
<< addr);
1856
m_addr
= addr;
1857
}
1858
1859
void
Icmpv6OptionLinkLayerAddress::Print
(std::ostream& os)
const
1860
{
1861
NS_LOG_FUNCTION
(
this
<< &os);
1862
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" length = "
<< (uint32_t)
GetLength
() <<
" L2 Address = "
<<
m_addr
<<
")"
;
1863
}
1864
1865
uint32_t
Icmpv6OptionLinkLayerAddress::GetSerializedSize
()
const
1866
{
1867
NS_LOG_FUNCTION
(
this
);
1868
uint8_t nb =
GetLength
() * 8;
1869
return
nb;
1870
}
1871
1872
void
Icmpv6OptionLinkLayerAddress::Serialize
(
Buffer::Iterator
start
)
const
1873
{
1874
NS_LOG_FUNCTION
(
this
<< &start);
1875
Buffer::Iterator
i =
start
;
1876
uint8_t mac[32];
1877
1878
i.
WriteU8
(
GetType
());
1879
i.
WriteU8
(
GetLength
());
1880
m_addr
.
CopyTo
(mac);
1881
i.
Write
(mac,
m_addr
.
GetLength
());
1882
1883
uint8_t len =
GetLength
()*8 - (2 +
m_addr
.
GetLength
());
1884
for
(uint8_t nb = 0; nb<len; nb++)
1885
{
1886
i.
WriteU8
(0);
1887
}
1888
}
1889
1890
uint32_t
Icmpv6OptionLinkLayerAddress::Deserialize
(
Buffer::Iterator
start
)
1891
{
1892
NS_LOG_FUNCTION
(
this
<< &start);
1893
Buffer::Iterator
i =
start
;
1894
uint8_t mac[32];
1895
1896
SetType
(i.
ReadU8
());
1897
SetLength
(i.
ReadU8
());
1898
i.
Read
(mac, (
GetLength
() * 8) - 2);
1899
1900
m_addr
.
CopyFrom
(mac, (
GetLength
() * 8)-2);
1901
1902
return
GetSerializedSize
();
1903
}
1904
1905
NS_OBJECT_ENSURE_REGISTERED
(
Icmpv6OptionRedirected
);
1906
1907
TypeId
Icmpv6OptionRedirected::GetTypeId
()
1908
{
1909
static
TypeId
tid =
TypeId
(
"ns3::Icmpv6OptionRedirected"
)
1910
.
SetParent
<
Icmpv6OptionHeader
> ()
1911
.AddConstructor<Icmpv6OptionRedirected> ()
1912
;
1913
return
tid;
1914
}
1915
1916
TypeId
Icmpv6OptionRedirected::GetInstanceTypeId
()
const
1917
{
1918
NS_LOG_FUNCTION
(
this
);
1919
return
GetTypeId
();
1920
}
1921
1922
Icmpv6OptionRedirected::Icmpv6OptionRedirected
()
1923
: m_packet (0)
1924
{
1925
NS_LOG_FUNCTION
(
this
);
1926
SetType
(
Icmpv6Header::ICMPV6_OPT_REDIRECTED
);
1927
}
1928
1929
Icmpv6OptionRedirected::~Icmpv6OptionRedirected
()
1930
{
1931
NS_LOG_FUNCTION
(
this
);
1932
m_packet
= 0;
1933
}
1934
1935
Ptr<Packet>
Icmpv6OptionRedirected::GetPacket
()
const
1936
{
1937
NS_LOG_FUNCTION
(
this
);
1938
return
m_packet
;
1939
}
1940
1941
void
Icmpv6OptionRedirected::SetPacket
(
Ptr<Packet>
packet)
1942
{
1943
NS_LOG_FUNCTION
(
this
<< *packet);
1944
NS_ASSERT
(packet->
GetSize
() <= 1280);
1945
m_packet
= packet;
1946
SetLength
(1 + (m_packet->GetSize () / 8));
1947
}
1948
1949
void
Icmpv6OptionRedirected::Print
(std::ostream& os)
const
1950
{
1951
NS_LOG_FUNCTION
(
this
<< &os);
1952
os <<
"( type = "
<< (uint32_t)
GetType
() <<
" length = "
<< (uint32_t)
GetLength
() <<
")"
;
1953
}
1954
1955
uint32_t
Icmpv6OptionRedirected::GetSerializedSize
()
const
1956
{
1957
NS_LOG_FUNCTION
(
this
);
1958
return
8 +
m_packet
->
GetSize
();
1959
}
1960
1961
void
Icmpv6OptionRedirected::Serialize
(
Buffer::Iterator
start
)
const
1962
{
1963
NS_LOG_FUNCTION
(
this
<< &start);
1964
Buffer::Iterator
i =
start
;
1965
1966
i.
WriteU8
(
GetType
());
1967
i.
WriteU8
(
GetLength
());
1968
// Reserved
1969
i.
WriteU16
(0);
1970
i.
WriteU32
(0);
1971
1972
uint32_t size =
m_packet
->
GetSize
();
1973
uint8_t *buf =
new
uint8_t[size];
1974
m_packet
->
CopyData
(buf, size);
1975
i.
Write
(buf, size);
1976
delete
[] buf;
1977
}
1978
1979
uint32_t
Icmpv6OptionRedirected::Deserialize
(
Buffer::Iterator
start
)
1980
{
1981
NS_LOG_FUNCTION
(
this
<< &start);
1982
Buffer::Iterator
i =
start
;
1983
1984
SetType
(i.
ReadU8
());
1985
uint8_t length = i.
ReadU8
();
1986
SetLength
(length);
1987
i.
ReadU16
();
1988
i.
ReadU32
();
1989
1990
uint32_t len2 = (
GetLength
() - 1) * 8;
1991
uint8_t* buff =
new
uint8_t[len2];
1992
i.
Read
(buff, len2);
1993
m_packet
= Create<Packet> (buff, len2);
1994
delete
[] buff;
1995
1996
return
GetSerializedSize
();
1997
}
1998
1999
}
/* namespace ns3 */
2000
src
internet
model
icmpv6-header.cc
Generated on Tue May 14 2013 11:08:21 for ns-3 by
1.8.1.2