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.h
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
#ifndef ICMPV6_HEADER_H
24
#define ICMPV6_HEADER_H
25
26
#include "ns3/header.h"
27
#include "ns3/ipv6-address.h"
28
#include "ns3/packet.h"
29
30
namespace
ns3
31
{
32
37
class
Icmpv6Header
:
public
Header
38
{
39
public
:
44
enum
Type_e
45
{
46
ICMPV6_ERROR_DESTINATION_UNREACHABLE
= 1,
47
ICMPV6_ERROR_PACKET_TOO_BIG
,
48
ICMPV6_ERROR_TIME_EXCEEDED
,
49
ICMPV6_ERROR_PARAMETER_ERROR
,
50
ICMPV6_ECHO_REQUEST
= 128,
51
ICMPV6_ECHO_REPLY
,
52
ICMPV6_SUBSCRIBE_REQUEST
,
53
ICMPV6_SUBSCRIBE_REPORT
,
54
ICMPV6_SUBSCRIVE_END
,
55
ICMPV6_ND_ROUTER_SOLICITATION
,
56
ICMPV6_ND_ROUTER_ADVERTISEMENT
,
57
ICMPV6_ND_NEIGHBOR_SOLICITATION
,
58
ICMPV6_ND_NEIGHBOR_ADVERTISEMENT
,
59
ICMPV6_ND_REDIRECTION
,
60
ICMPV6_ROUTER_RENUMBER
,
61
ICMPV6_INFORMATION_REQUEST
,
62
ICMPV6_INFORMATION_RESPONSE
,
63
ICMPV6_INVERSE_ND_SOLICITATION
,
64
ICMPV6_INVERSE_ND_ADVERSTISEMENT
,
65
ICMPV6_MLDV2_SUBSCRIBE_REPORT
,
66
ICMPV6_MOBILITY_HA_DISCOVER_REQUEST
,
67
ICMPV6_MOBILITY_HA_DISCOVER_RESPONSE
,
68
ICMPV6_MOBILITY_MOBILE_PREFIX_SOLICITATION
,
69
ICMPV6_SECURE_ND_CERTIFICATE_PATH_SOLICITATION
,
70
ICMPV6_SECURE_ND_CERTIFICATE_PATH_ADVERTISEMENT
,
71
ICMPV6_EXPERIMENTAL_MOBILITY
72
};
73
78
enum
OptionType_e
79
{
80
ICMPV6_OPT_LINK_LAYER_SOURCE
= 1,
81
ICMPV6_OPT_LINK_LAYER_TARGET
,
82
ICMPV6_OPT_PREFIX
,
83
ICMPV6_OPT_REDIRECTED
,
84
ICMPV6_OPT_MTU
85
};
86
91
enum
ErrorDestinationUnreachable_e
92
{
93
ICMPV6_NO_ROUTE
= 0,
94
ICMPV6_ADM_PROHIBITED
,
95
ICMPV6_NOT_NEIGHBOUR
,
96
ICMPV6_ADDR_UNREACHABLE
,
97
ICMPV6_PORT_UNREACHABLE
98
};
99
104
enum
ErrorTimeExceeded_e
105
{
106
ICMPV6_HOPLIMIT
= 0,
107
ICMPV6_FRAGTIME
108
};
109
114
enum
ErrorParameterError_e
115
{
116
ICMPV6_MALFORMED_HEADER
= 0,
117
ICMPV6_UNKNOWN_NEXT_HEADER
,
118
ICMPV6_UNKNOWN_OPTION
119
};
120
125
static
TypeId
GetTypeId
();
126
131
virtual
TypeId
GetInstanceTypeId
()
const
;
132
136
Icmpv6Header
();
137
141
virtual
~Icmpv6Header
();
142
147
uint8_t
GetType
()
const
;
148
153
void
SetType
(uint8_t type);
154
159
uint8_t
GetCode
()
const
;
160
165
void
SetCode
(uint8_t code);
166
171
uint16_t
GetChecksum
()
const
;
172
177
void
SetChecksum
(uint16_t checksum);
178
183
virtual
void
Print
(std::ostream& os)
const
;
184
189
virtual
uint32_t
GetSerializedSize
()
const
;
190
195
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
196
202
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start
);
203
212
void
CalculatePseudoHeaderChecksum
(
Ipv6Address
src,
Ipv6Address
dst, uint16_t length, uint8_t protocol);
213
214
protected
:
218
bool
m_calcChecksum
;
219
223
uint16_t
m_checksum
;
224
225
private
:
229
uint8_t
m_type
;
230
234
uint8_t
m_code
;
235
};
236
241
class
Icmpv6OptionHeader
:
public
Header
242
{
243
public
:
248
static
TypeId
GetTypeId
();
249
254
virtual
TypeId
GetInstanceTypeId
()
const
;
255
259
Icmpv6OptionHeader
();
260
264
virtual
~Icmpv6OptionHeader
();
265
270
uint8_t
GetType
()
const
;
271
276
void
SetType
(uint8_t type);
277
282
uint8_t
GetLength
()
const
;
283
288
void
SetLength
(uint8_t len);
289
294
virtual
void
Print
(std::ostream& os)
const
;
295
300
virtual
uint32_t
GetSerializedSize
()
const
;
301
306
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
307
313
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
314
315
private
:
319
uint8_t
m_type
;
320
324
uint8_t
m_len
;
325
};
326
331
class
Icmpv6NS
:
public
Icmpv6Header
332
{
333
public
:
338
Icmpv6NS
(
Ipv6Address
target);
339
343
Icmpv6NS
();
344
348
virtual
~Icmpv6NS
();
349
354
static
TypeId
GetTypeId
();
355
360
virtual
TypeId
GetInstanceTypeId
()
const
;
361
366
uint32_t
GetReserved
()
const
;
367
372
void
SetReserved
(uint32_t reserved);
373
378
Ipv6Address
GetIpv6Target
()
const
;
379
384
void
SetIpv6Target
(
Ipv6Address
target);
385
390
virtual
void
Print
(std::ostream& os)
const
;
391
396
virtual
uint32_t
GetSerializedSize
()
const
;
397
402
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
403
409
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
410
411
private
:
412
416
uint32_t
m_reserved
;
417
421
Ipv6Address
m_target
;
422
};
423
428
class
Icmpv6NA
:
public
Icmpv6Header
429
{
430
public
:
434
Icmpv6NA
();
435
439
virtual
~Icmpv6NA
();
440
445
static
TypeId
GetTypeId
();
446
451
virtual
TypeId
GetInstanceTypeId
()
const
;
452
457
uint32_t
GetReserved
()
const
;
458
463
void
SetReserved
(uint32_t reserved);
464
469
Ipv6Address
GetIpv6Target
()
const
;
470
475
void
SetIpv6Target
(
Ipv6Address
target);
476
481
bool
GetFlagR
()
const
;
482
487
void
SetFlagR
(
bool
r);
488
493
bool
GetFlagS
()
const
;
494
499
void
SetFlagS
(
bool
s);
500
505
bool
GetFlagO
()
const
;
506
511
void
SetFlagO
(
bool
o);
512
517
virtual
void
Print
(std::ostream& os)
const
;
518
523
virtual
uint32_t
GetSerializedSize
()
const
;
524
529
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
530
536
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
537
538
private
:
542
bool
m_flagR
;
543
547
bool
m_flagS
;
548
552
bool
m_flagO
;
553
557
uint32_t
m_reserved
;
558
562
Ipv6Address
m_target
;
563
};
564
569
class
Icmpv6RA
:
public
Icmpv6Header
570
{
571
public
:
575
Icmpv6RA
();
576
580
virtual
~Icmpv6RA
();
581
586
static
TypeId
GetTypeId
();
587
592
virtual
TypeId
GetInstanceTypeId
()
const
;
593
598
void
SetCurHopLimit
(uint8_t m);
599
604
uint8_t
GetCurHopLimit
()
const
;
605
610
void
SetLifeTime
(uint16_t l);
611
616
uint16_t
GetLifeTime
()
const
;
617
622
void
SetReachableTime
(uint32_t r);
623
628
uint32_t
GetReachableTime
()
const
;
629
634
void
SetRetransmissionTime
(uint32_t r);
635
640
uint32_t
GetRetransmissionTime
()
const
;
641
646
bool
GetFlagM
()
const
;
647
652
void
SetFlagM
(
bool
m);
653
658
bool
GetFlagO
()
const
;
659
664
void
SetFlagO
(
bool
o);
665
670
bool
GetFlagH
()
const
;
671
676
void
SetFlagH
(
bool
h);
677
682
virtual
void
Print
(std::ostream& os)
const
;
683
688
uint8_t
GetFlags
()
const
;
689
694
void
SetFlags
(uint8_t f);
695
700
virtual
uint32_t
GetSerializedSize
()
const
;
701
706
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
707
713
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
714
715
private
:
719
bool
m_flagM
;
720
724
bool
m_flagO
;
725
729
bool
m_flagH
;
730
734
uint8_t
m_flags
;
735
739
uint16_t
m_LifeTime
;
740
744
uint32_t
m_ReachableTime
;
745
749
uint32_t
m_RetransmissionTimer
;
750
754
uint8_t
m_curHopLimit
;
755
};
756
761
class
Icmpv6RS
:
public
Icmpv6Header
762
{
763
public
:
767
Icmpv6RS
();
768
772
virtual
~Icmpv6RS
();
773
778
static
TypeId
GetTypeId
();
779
784
virtual
TypeId
GetInstanceTypeId
()
const
;
785
790
uint32_t
GetReserved
()
const
;
791
796
void
SetReserved
(uint32_t reserved);
797
802
virtual
void
Print
(std::ostream& os)
const
;
803
808
virtual
uint32_t
GetSerializedSize
()
const
;
809
814
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
815
821
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
822
823
private
:
827
uint32_t
m_reserved
;
828
};
829
834
class
Icmpv6Redirection
:
public
Icmpv6Header
835
{
836
public
:
840
Icmpv6Redirection
();
841
845
virtual
~Icmpv6Redirection
();
846
851
static
TypeId
GetTypeId
();
852
857
virtual
TypeId
GetInstanceTypeId
()
const
;
858
863
Ipv6Address
GetTarget
()
const
;
864
869
void
SetTarget
(
Ipv6Address
target);
870
875
Ipv6Address
GetDestination
()
const
;
876
881
void
SetDestination
(
Ipv6Address
destination);
882
887
virtual
void
Print
(std::ostream& os)
const
;
888
893
virtual
uint32_t
GetSerializedSize
()
const
;
894
899
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
900
906
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
907
912
uint32_t
GetReserved
()
const
;
913
918
void
SetReserved
(uint32_t reserved);
919
920
private
:
924
Ipv6Address
m_target
;
925
929
Ipv6Address
m_destination
;
930
934
uint32_t
m_reserved
;
935
};
936
941
class
Icmpv6Echo
:
public
Icmpv6Header
942
{
943
public
:
948
static
TypeId
GetTypeId
();
949
954
virtual
TypeId
GetInstanceTypeId
()
const
;
955
959
Icmpv6Echo
();
960
965
Icmpv6Echo
(
bool
request);
966
970
virtual
~Icmpv6Echo
();
971
976
uint16_t
GetId
()
const
;
977
982
void
SetId
(uint16_t
id
);
983
988
uint16_t
GetSeq
()
const
;
989
994
void
SetSeq
(uint16_t seq);
995
1000
virtual
void
Print
(std::ostream& os)
const
;
1001
1006
virtual
uint32_t
GetSerializedSize
()
const
;
1007
1012
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1013
1019
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1020
1021
private
:
1025
uint16_t
m_id
;
1026
1030
uint16_t
m_seq
;
1031
};
1032
1037
class
Icmpv6DestinationUnreachable
:
public
Icmpv6Header
1038
{
1039
public
:
1043
Icmpv6DestinationUnreachable
();
1044
1048
virtual
~Icmpv6DestinationUnreachable
();
1049
1054
static
TypeId
GetTypeId
();
1055
1060
virtual
TypeId
GetInstanceTypeId
()
const
;
1061
1066
Ptr<Packet>
GetPacket
()
const
;
1067
1072
void
SetPacket
(
Ptr<Packet>
p);
1073
1078
virtual
void
Print
(std::ostream& os)
const
;
1079
1084
virtual
uint32_t
GetSerializedSize
()
const
;
1085
1090
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1091
1097
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1098
1099
private
:
1103
Ptr<Packet>
m_packet
;
1104
};
1105
1110
class
Icmpv6TooBig
:
public
Icmpv6Header
1111
{
1112
public
:
1116
Icmpv6TooBig
();
1117
1121
virtual
~Icmpv6TooBig
();
1122
1127
static
TypeId
GetTypeId
();
1128
1133
virtual
TypeId
GetInstanceTypeId
()
const
;
1134
1139
Ptr<Packet>
GetPacket
()
const
;
1140
1145
void
SetPacket
(
Ptr<Packet>
p);
1146
1151
uint32_t
GetMtu
()
const
;
1152
1157
void
SetMtu
(uint32_t mtu);
1158
1163
virtual
void
Print
(std::ostream& os)
const
;
1164
1169
virtual
uint32_t
GetSerializedSize
()
const
;
1170
1175
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1176
1182
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1183
1184
private
:
1185
1189
Ptr<Packet>
m_packet
;
1190
1194
uint32_t
m_mtu
;
1195
};
1196
1201
class
Icmpv6TimeExceeded
:
public
Icmpv6Header
1202
{
1203
public
:
1207
Icmpv6TimeExceeded
();
1208
1212
virtual
~Icmpv6TimeExceeded
();
1213
1218
static
TypeId
GetTypeId
();
1219
1224
virtual
TypeId
GetInstanceTypeId
()
const
;
1225
1230
Ptr<Packet>
GetPacket
()
const
;
1231
1236
void
SetPacket
(
Ptr<Packet>
p);
1237
1242
virtual
void
Print
(std::ostream& os)
const
;
1243
1248
virtual
uint32_t
GetSerializedSize
()
const
;
1249
1254
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1255
1261
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1262
1263
private
:
1264
1268
Ptr<Packet>
m_packet
;
1269
};
1270
1275
class
Icmpv6ParameterError
:
public
Icmpv6Header
1276
{
1277
public
:
1281
Icmpv6ParameterError
();
1282
1286
virtual
~Icmpv6ParameterError
();
1287
1292
static
TypeId
GetTypeId
();
1293
1298
virtual
TypeId
GetInstanceTypeId
()
const
;
1299
1304
Ptr<Packet>
GetPacket
()
const
;
1305
1310
void
SetPacket
(
Ptr<Packet>
p);
1311
1316
uint32_t
GetPtr
()
const
;
1317
1322
void
SetPtr
(uint32_t ptr);
1323
1328
virtual
void
Print
(std::ostream& os)
const
;
1329
1334
virtual
uint32_t
GetSerializedSize
()
const
;
1335
1340
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1341
1347
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1348
1349
private
:
1350
1354
Ptr<Packet>
m_packet
;
1355
1359
uint32_t
m_ptr
;
1360
};
1361
1366
class
Icmpv6OptionMtu
:
public
Icmpv6OptionHeader
1367
{
1368
public
:
1372
Icmpv6OptionMtu
();
1373
1378
Icmpv6OptionMtu
(uint32_t mtu);
1379
1383
virtual
~Icmpv6OptionMtu
();
1384
1389
static
TypeId
GetTypeId
();
1390
1395
virtual
TypeId
GetInstanceTypeId
()
const
;
1396
1401
uint16_t
GetReserved
()
const
;
1402
1407
void
SetReserved
(uint16_t reserved);
1408
1413
uint32_t
GetMtu
()
const
;
1414
1419
void
SetMtu
(uint32_t mtu);
1420
1425
virtual
void
Print
(std::ostream& os)
const
;
1426
1431
virtual
uint32_t
GetSerializedSize
()
const
;
1432
1437
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1438
1444
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1445
1446
private
:
1450
uint16_t
m_reserved
;
1451
1455
uint32_t
m_mtu
;
1456
};
1457
1462
class
Icmpv6OptionPrefixInformation
:
public
Icmpv6OptionHeader
1463
{
1464
public
:
1468
Icmpv6OptionPrefixInformation
();
1469
1475
Icmpv6OptionPrefixInformation
(
Ipv6Address
network, uint8_t prefixlen);
1476
1480
virtual
~Icmpv6OptionPrefixInformation
();
1481
1486
static
TypeId
GetTypeId
();
1487
1492
virtual
TypeId
GetInstanceTypeId
()
const
;
1493
1498
uint8_t
GetPrefixLength
()
const
;
1499
1504
void
SetPrefixLength
(uint8_t prefixLength);
1505
1510
uint8_t
GetFlags
()
const
;
1511
1516
void
SetFlags
(uint8_t flags);
1517
1522
uint32_t
GetValidTime
()
const
;
1523
1528
void
SetValidTime
(uint32_t validTime);
1529
1534
uint32_t
GetPreferredTime
()
const
;
1535
1540
void
SetPreferredTime
(uint32_t preferredTime);
1541
1546
uint32_t
GetReserved
()
const
;
1547
1552
void
SetReserved
(uint32_t reserved);
1553
1558
Ipv6Address
GetPrefix
()
const
;
1559
1564
void
SetPrefix
(
Ipv6Address
prefix);
1565
1570
virtual
void
Print
(std::ostream& os)
const
;
1571
1576
virtual
uint32_t
GetSerializedSize
()
const
;
1577
1582
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1583
1589
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1590
1591
private
:
1595
Ipv6Address
m_prefix
;
1596
1600
uint8_t
m_prefixLength
;
1601
1605
uint8_t
m_flags
;
1606
1610
uint32_t
m_validTime
;
1611
1615
uint32_t
m_preferredTime
;
1616
1620
uint32_t
m_reserved
;
1621
};
1622
1627
class
Icmpv6OptionLinkLayerAddress
:
public
Icmpv6OptionHeader
1628
{
1629
public
:
1634
Icmpv6OptionLinkLayerAddress
(
bool
source);
1635
1640
static
TypeId
GetTypeId
();
1641
1646
virtual
TypeId
GetInstanceTypeId
(
void
)
const
;
1647
1653
Icmpv6OptionLinkLayerAddress
(
bool
source,
Address
addr);
1654
1658
Icmpv6OptionLinkLayerAddress
();
1659
1663
virtual
~Icmpv6OptionLinkLayerAddress
();
1664
1669
Address
GetAddress
()
const
;
1670
1675
void
SetAddress
(
Address
addr);
1676
1681
virtual
void
Print
(std::ostream& os)
const
;
1682
1687
virtual
uint32_t
GetSerializedSize
()
const
;
1688
1693
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1694
1700
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1701
1702
private
:
1706
Address
m_addr
;
1707
};
1708
1713
class
Icmpv6OptionRedirected
:
public
Icmpv6OptionHeader
1714
{
1715
public
:
1720
static
TypeId
GetTypeId
();
1721
1726
virtual
TypeId
GetInstanceTypeId
()
const
;
1727
1731
Icmpv6OptionRedirected
();
1732
1736
virtual
~Icmpv6OptionRedirected
();
1737
1742
Ptr<Packet>
GetPacket
()
const
;
1743
1748
void
SetPacket
(
Ptr<Packet>
packet);
1749
1754
virtual
void
Print
(std::ostream& os)
const
;
1755
1760
virtual
uint32_t
GetSerializedSize
()
const
;
1761
1766
virtual
void
Serialize
(
Buffer::Iterator
start
)
const
;
1767
1773
virtual
uint32_t
Deserialize
(
Buffer::Iterator
start);
1774
1775
private
:
1779
Ptr<Packet>
m_packet
;
1780
};
1781
1782
}
/* namespace ns3 */
1783
1784
#endif
/* ICMPV6_HEADER_H */
1785
src
internet
model
icmpv6-header.h
Generated on Fri Dec 21 2012 19:00:36 for ns-3 by
1.8.1.2