A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
icmpv6-header.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007-2009 Strasbourg University
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7 * Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
8 * David Gross <gdavid.devel@gmail.com>
9 */
10
11#include "icmpv6-header.h"
12
13#include "ns3/address-utils.h"
14#include "ns3/assert.h"
15#include "ns3/log.h"
16
17namespace ns3
18{
19
20NS_LOG_COMPONENT_DEFINE("Icmpv6Header");
21
22NS_OBJECT_ENSURE_REGISTERED(Icmpv6Header);
23
24TypeId
26{
27 static TypeId tid = TypeId("ns3::Icmpv6Header")
29 .SetGroupName("Internet")
30 .AddConstructor<Icmpv6Header>();
31 return tid;
32}
33
36{
37 NS_LOG_FUNCTION(this);
38 return GetTypeId();
39}
40
42 : m_calcChecksum(true),
43 m_checksum(0),
44 m_type(0),
45 m_code(0)
46{
47 NS_LOG_FUNCTION(this);
48}
49
54
55uint8_t
57{
58 NS_LOG_FUNCTION(this);
59 return m_type;
60}
61
62void
64{
65 NS_LOG_FUNCTION(this << static_cast<uint32_t>(type));
66 m_type = type;
67}
68
69uint8_t
71{
72 NS_LOG_FUNCTION(this);
73 return m_code;
74}
75
76void
78{
79 NS_LOG_FUNCTION(this << static_cast<uint32_t>(code));
80 m_code = code;
81}
82
83uint16_t
85{
86 NS_LOG_FUNCTION(this);
87 return m_checksum;
88}
89
90void
91Icmpv6Header::SetChecksum(uint16_t checksum)
92{
93 NS_LOG_FUNCTION(this << checksum);
94 m_checksum = checksum;
95}
96
97void
98Icmpv6Header::Print(std::ostream& os) const
99{
100 NS_LOG_FUNCTION(this << &os);
101 os << "( type = " << (uint32_t)m_type << " code = " << (uint32_t)m_code
102 << " checksum = " << (uint32_t)m_checksum << ")";
103}
104
107{
108 NS_LOG_FUNCTION(this);
109 return 4;
110}
111
114{
115 NS_LOG_FUNCTION(this << &start);
116 Buffer::Iterator i = start;
117
118 m_type = i.ReadU8();
119 m_code = i.ReadU8();
121#if 0
122 i.ReadU32 (); /* padding */
123#endif
124 return GetSerializedSize();
125}
126
127void
129{
130 NS_LOG_FUNCTION(this << &start);
131 Buffer::Iterator i = start;
132
133 i.WriteU8(m_type);
134 i.WriteU8(m_code);
135 i.WriteU16(0);
136#if 0
137 i.WriteU32 (0); /* padding */
138#endif
139
140 if (m_calcChecksum)
141 {
142 i = start;
143 uint16_t checksum = i.CalculateIpChecksum(i.GetSize(), m_checksum);
144 i = start;
145 i.Next(2);
146 i.WriteU16(checksum);
147 }
148}
149
150void
152 Ipv6Address dst,
153 uint16_t length,
154 uint8_t protocol)
155{
156 NS_LOG_FUNCTION(this << src << dst << length << static_cast<uint32_t>(protocol));
157
158 Buffer buf = Buffer(40);
159 uint8_t tmp[16];
161
162 buf.AddAtStart(40);
163 it = buf.Begin();
164
165 src.Serialize(tmp);
166 it.Write(tmp, 16); /* source IPv6 address */
167 dst.Serialize(tmp);
168 it.Write(tmp, 16); /* destination IPv6 address */
169 it.WriteU16(0); /* length */
170 it.WriteU8(length >> 8); /* length */
171 it.WriteU8(length & 0xff); /* length */
172 it.WriteU16(0); /* zero */
173 it.WriteU8(0); /* zero */
174 it.WriteU8(protocol); /* next header */
175
176 it = buf.Begin();
178}
179
181
190
191TypeId
193{
194 static TypeId tid = TypeId("ns3::Icmpv6NS")
196 .SetGroupName("Internet")
197 .AddConstructor<Icmpv6NS>();
198 return tid;
199}
200
201TypeId
203{
204 NS_LOG_FUNCTION(this);
205 return GetTypeId();
206}
207
209{
210 NS_LOG_FUNCTION(this << target);
212 SetCode(0);
213 SetReserved(0);
214 SetIpv6Target(target);
215 m_checksum = 0;
216
217 /* test */
218 /*
219 m_reserved = 0xdeadbeef;
220 */
221}
222
227
230{
231 NS_LOG_FUNCTION(this);
232 return m_reserved;
233}
234
235void
237{
238 NS_LOG_FUNCTION(this << reserved);
239 m_reserved = reserved;
240}
241
244{
245 NS_LOG_FUNCTION(this);
246 return m_target;
247}
248
249void
251{
252 NS_LOG_FUNCTION(this << target);
253 m_target = target;
254}
255
256void
257Icmpv6NS::Print(std::ostream& os) const
258{
259 NS_LOG_FUNCTION(this << &os);
260 os << "( type = " << (uint32_t)GetType() << " (NS) code = " << (uint32_t)GetCode()
261 << " target = " << m_target << " checksum = " << (uint32_t)GetChecksum() << ")";
262}
263
266{
267 NS_LOG_FUNCTION(this);
268 return 24;
269}
270
271void
273{
274 NS_LOG_FUNCTION(this << &start);
275 uint8_t buff_target[16];
276 uint16_t checksum = 0;
277 Buffer::Iterator i = start;
278
279 i.WriteU8(GetType());
280 i.WriteU8(GetCode());
281 i.WriteU16(0);
283 m_target.Serialize(buff_target);
284 i.Write(buff_target, 16);
285
286 if (m_calcChecksum)
287 {
288 i = start;
289 checksum = i.CalculateIpChecksum(i.GetSize(), m_checksum);
290 i = start;
291 i.Next(2);
292 i.WriteU16(checksum);
293 }
294}
295
298{
299 NS_LOG_FUNCTION(this << &start);
300 uint8_t buf[16];
301 Buffer::Iterator i = start;
302
303 SetType(i.ReadU8());
304 SetCode(i.ReadU8());
305 m_checksum = i.ReadU16();
307 i.Read(buf, 16);
308 m_target.Set(buf);
309
310 return GetSerializedSize();
311}
312
314
315TypeId
317{
318 static TypeId tid = TypeId("ns3::Icmpv6NA")
320 .SetGroupName("Internet")
321 .AddConstructor<Icmpv6NA>();
322 return tid;
323}
324
325TypeId
327{
328 NS_LOG_FUNCTION(this);
329 return GetTypeId();
330}
331
333{
334 NS_LOG_FUNCTION(this);
336 SetCode(0);
337 SetReserved(0);
338 SetFlagR(false);
339 SetFlagS(false);
340 SetFlagO(false);
341 m_checksum = 0;
342}
343
348
351{
352 NS_LOG_FUNCTION(this);
353 return m_reserved;
354}
355
356void
358{
359 NS_LOG_FUNCTION(this << reserved);
360 m_reserved = reserved;
361}
362
365{
366 NS_LOG_FUNCTION(this);
367 return m_target;
368}
369
370bool
372{
373 NS_LOG_FUNCTION(this);
374 return m_flagR;
375}
376
377void
379{
380 NS_LOG_FUNCTION(this << r);
381 m_flagR = r;
382}
383
384bool
386{
387 NS_LOG_FUNCTION(this);
388 return m_flagS;
389}
390
391void
393{
394 NS_LOG_FUNCTION(this << s);
395 m_flagS = s;
396}
397
398bool
400{
401 NS_LOG_FUNCTION(this);
402 return m_flagO;
403}
404
405void
407{
408 NS_LOG_FUNCTION(this << o);
409 m_flagO = o;
410}
411
412void
414{
415 NS_LOG_FUNCTION(this << target);
416 m_target = target;
417}
418
419void
420Icmpv6NA::Print(std::ostream& os) const
421{
422 NS_LOG_FUNCTION(this << &os);
423 os << "( type = " << (uint32_t)GetType() << " (NA) code = " << (uint32_t)GetCode()
424 << " checksum = " << (uint32_t)GetChecksum() << ")";
425}
426
429{
430 NS_LOG_FUNCTION(this);
431 return 24;
432}
433
434void
436{
437 NS_LOG_FUNCTION(this << &start);
438 uint8_t buff_target[16];
439 uint16_t checksum = 0;
440 Buffer::Iterator i = start;
441 uint32_t reserved = m_reserved;
442
443 i.WriteU8(GetType());
444 i.WriteU8(GetCode());
445 i.WriteU16(0);
446
447 if (m_flagR)
448 {
449 reserved |= (uint32_t)(1 << 31);
450 }
451
452 if (m_flagS)
453 {
454 reserved |= (uint32_t)(1 << 30);
455 }
456
457 if (m_flagO)
458 {
459 reserved |= (uint32_t)(1 << 29);
460 }
461
462 i.WriteHtonU32(reserved);
463 m_target.Serialize(buff_target);
464 i.Write(buff_target, 16);
465
466 if (m_calcChecksum)
467 {
468 i = start;
469 checksum = i.CalculateIpChecksum(i.GetSize(), GetChecksum());
470 i = start;
471 i.Next(2);
472 i.WriteU16(checksum);
473 }
474}
475
478{
479 NS_LOG_FUNCTION(this << &start);
480 uint8_t buf[16];
481 Buffer::Iterator i = start;
482
483 SetType(i.ReadU8());
484 SetCode(i.ReadU8());
485 m_checksum = i.ReadU16();
487
488 m_flagR = false;
489 m_flagS = false;
490 m_flagO = false;
491
492 if (m_reserved & (1 << 31))
493 {
494 m_flagR = true;
495 }
496
497 if (m_reserved & (1 << 30))
498 {
499 m_flagS = true;
500 }
501
502 if (m_reserved & (1 << 29))
503 {
504 m_flagO = true;
505 }
506
507 i.Read(buf, 16);
508 m_target.Set(buf);
509
510 return GetSerializedSize();
511}
512
514
515TypeId
517{
518 static TypeId tid = TypeId("ns3::Icmpv6RA")
520 .SetGroupName("Internet")
521 .AddConstructor<Icmpv6RA>();
522 return tid;
523}
524
525TypeId
527{
528 NS_LOG_FUNCTION(this);
529 return GetTypeId();
530}
531
533{
534 NS_LOG_FUNCTION(this);
536 SetCode(0);
537 SetFlagM(false);
538 SetFlagO(false);
539 SetFlagH(false);
541 SetLifeTime(0);
544}
545
550
551void
553{
554 NS_LOG_FUNCTION(this << static_cast<uint32_t>(m));
555 m_curHopLimit = m;
556}
557
558uint8_t
560{
561 NS_LOG_FUNCTION(this);
562 return m_curHopLimit;
563}
564
565uint16_t
567{
568 NS_LOG_FUNCTION(this);
569 return m_LifeTime;
570}
571
574{
575 NS_LOG_FUNCTION(this);
576 return m_ReachableTime;
577}
578
585
586void
588{
589 NS_LOG_FUNCTION(this << l);
590 m_LifeTime = l;
591}
592
593void
599
600void
606
607bool
609{
610 NS_LOG_FUNCTION(this);
611 return m_flagM;
612}
613
614void
616{
617 NS_LOG_FUNCTION(this << m);
618 m_flagM = m;
619}
620
621bool
623{
624 NS_LOG_FUNCTION(this);
625 return m_flagO;
626}
627
628void
630{
631 NS_LOG_FUNCTION(this << o);
632 m_flagO = o;
633}
634
635bool
637{
638 NS_LOG_FUNCTION(this);
639 return m_flagH;
640}
641
642void
644{
645 NS_LOG_FUNCTION(this << h);
646 m_flagH = h;
647}
648
649void
650Icmpv6RA::Print(std::ostream& os) const
651{
652 NS_LOG_FUNCTION(this << &os);
653 os << "( type = " << (uint32_t)GetType() << " (RA) code = " << (uint32_t)GetCode()
654 << " checksum = " << (uint32_t)GetChecksum() << ")";
655}
656
659{
660 NS_LOG_FUNCTION(this);
661 return 16;
662}
663
664void
666{
667 NS_LOG_FUNCTION(this << &start);
668 uint16_t checksum = 0;
669 Buffer::Iterator i = start;
670 uint8_t flags = 0;
671
672 i.WriteU8(GetType());
673 i.WriteU8(GetCode());
674 i.WriteHtonU16(0);
676
677 if (m_flagM)
678 {
679 flags |= (uint8_t)(1 << 7);
680 }
681
682 if (m_flagO)
683 {
684 flags |= (uint8_t)(1 << 6);
685 }
686
687 if (m_flagH)
688 {
689 flags |= (uint8_t)(1 << 5);
690 }
691 i.WriteU8(flags);
695
696 i = start;
697 checksum = i.CalculateIpChecksum(i.GetSize(), GetChecksum());
698
699 i = start;
700 i.Next(2);
701 i.WriteU16(checksum);
702}
703
706{
707 NS_LOG_FUNCTION(this << &start);
708 Buffer::Iterator i = start;
709
710 SetType(i.ReadU8());
711 SetCode(i.ReadU8());
712 m_checksum = i.ReadU16();
714 uint8_t flags = i.ReadU8();
715 m_flagM = false;
716 m_flagO = false;
717 m_flagH = false;
718
719 if (flags & (1 << 7))
720 {
721 m_flagM = true;
722 }
723
724 if (flags & (1 << 6))
725 {
726 m_flagO = true;
727 }
728
729 if (flags & (1 << 5))
730 {
731 m_flagH = true;
732 }
736
737 return GetSerializedSize();
738}
739
741
742TypeId
744{
745 static TypeId tid = TypeId("ns3::Icmpv6RS")
747 .SetGroupName("Internet")
748 .AddConstructor<Icmpv6RS>();
749 return tid;
750}
751
752TypeId
754{
755 NS_LOG_FUNCTION(this);
756 return GetTypeId();
757}
758
766
771
774{
775 NS_LOG_FUNCTION(this);
776 return m_reserved;
777}
778
779void
781{
782 NS_LOG_FUNCTION(this << reserved);
783 m_reserved = reserved;
784}
785
786void
787Icmpv6RS::Print(std::ostream& os) const
788{
789 NS_LOG_FUNCTION(this << &os);
790 os << "( type = " << (uint32_t)GetType() << " (RS) code = " << (uint32_t)GetCode()
791 << " checksum = " << (uint32_t)GetChecksum() << ")";
792}
793
796{
797 NS_LOG_FUNCTION(this);
798 return 8;
799}
800
801void
803{
804 NS_LOG_FUNCTION(this << &start);
805
806 uint16_t checksum = 0;
807 Buffer::Iterator i = start;
808
809 i.WriteU8(GetType());
810 i.WriteU8(GetCode());
811 i.WriteU16(0);
813
814 if (m_calcChecksum)
815 {
816 i = start;
817 checksum = i.CalculateIpChecksum(i.GetSize(), GetChecksum());
818
819 i = start;
820 i.Next(2);
821 i.WriteU16(checksum);
822 }
823}
824
827{
828 NS_LOG_FUNCTION(this << &start);
829 Buffer::Iterator i = start;
830
831 SetType(i.ReadU8());
832 SetCode(i.ReadU8());
833 m_checksum = i.ReadU16();
835
836 return GetSerializedSize();
837}
838
840
841TypeId
843{
844 static TypeId tid = TypeId("ns3::Icmpv6Redirection")
846 .SetGroupName("Internet")
847 .AddConstructor<Icmpv6Redirection>();
848 return tid;
849}
850
851TypeId
853{
854 NS_LOG_FUNCTION(this);
855 return GetTypeId();
856}
857
859 : m_target(Ipv6Address("")),
860 m_destination(Ipv6Address("")),
861 m_reserved(0)
862{
863 NS_LOG_FUNCTION(this);
865 SetCode(0);
866 m_checksum = 0;
867}
868
873
874void
876{
877 NS_LOG_FUNCTION(this << reserved);
878 m_reserved = reserved;
879}
880
883{
884 NS_LOG_FUNCTION(this);
885 return m_reserved;
886}
887
890{
891 NS_LOG_FUNCTION(this);
892 return m_target;
893}
894
895void
897{
898 NS_LOG_FUNCTION(this << target);
899 m_target = target;
900}
901
904{
905 NS_LOG_FUNCTION(this);
906 return m_destination;
907}
908
909void
911{
912 NS_LOG_FUNCTION(this << destination);
913 m_destination = destination;
914}
915
916void
917Icmpv6Redirection::Print(std::ostream& os) const
918{
919 NS_LOG_FUNCTION(this << &os);
920 os << "( type = " << (uint32_t)GetType() << " (Redirection) code = " << (uint32_t)GetCode()
921 << " checksum = " << (uint32_t)GetChecksum() << " target = " << m_target
922 << " destination = " << m_destination << ")";
923}
924
927{
928 NS_LOG_FUNCTION(this);
929 return 40;
930}
931
932void
934{
935 NS_LOG_FUNCTION(this << &start);
936 uint8_t buff[16];
937 uint16_t checksum = 0;
938 Buffer::Iterator i = start;
939
940 i.WriteU8(GetType());
941 i.WriteU8(GetCode());
942 i.WriteU16(checksum);
944
945 m_target.Serialize(buff);
946 i.Write(buff, 16);
947
949 i.Write(buff, 16);
950
951 if (m_calcChecksum)
952 {
953 i = start;
954 checksum = i.CalculateIpChecksum(i.GetSize(), GetChecksum());
955
956 i = start;
957 i.Next(2);
958 i.WriteU16(checksum);
959 }
960}
961
964{
965 NS_LOG_FUNCTION(this << &start);
966 uint8_t buff[16];
967 Buffer::Iterator i = start;
968
969 SetType(i.ReadU8());
970 SetCode(i.ReadU8());
971 m_checksum = i.ReadU16();
972 SetReserved(i.ReadU32());
973
974 i.Read(buff, 16);
975 m_target.Set(buff);
976
977 i.Read(buff, 16);
978 m_destination.Set(buff);
979
980 return GetSerializedSize();
981}
982
984
985TypeId
987{
988 static TypeId tid = TypeId("ns3::Icmpv6Echo")
990 .SetGroupName("Internet")
991 .AddConstructor<Icmpv6Echo>();
992 return tid;
993}
994
995TypeId
997{
998 NS_LOG_FUNCTION(this);
999 return GetTypeId();
1000}
1001
1003{
1004 NS_LOG_FUNCTION(this);
1006 SetCode(0);
1007 m_checksum = 0;
1008 SetId(0);
1009 SetSeq(0);
1010}
1011
1013{
1014 NS_LOG_FUNCTION(this << request);
1016 SetCode(0);
1017 m_checksum = 0;
1018 SetId(0);
1019 SetSeq(0);
1020}
1021
1026
1027uint16_t
1029{
1030 NS_LOG_FUNCTION(this);
1031 return m_id;
1032}
1033
1034void
1036{
1037 NS_LOG_FUNCTION(this << id);
1038 m_id = id;
1039}
1040
1041uint16_t
1043{
1044 NS_LOG_FUNCTION(this);
1045 return m_seq;
1046}
1047
1048void
1050{
1051 NS_LOG_FUNCTION(this << seq);
1052 m_seq = seq;
1053}
1054
1055void
1056Icmpv6Echo::Print(std::ostream& os) const
1057{
1058 NS_LOG_FUNCTION(this << &os);
1059 os << "( type = " << (GetType() == 128 ? "128 (Request)" : "129 (Reply)")
1060 << " Id = " << (uint32_t)GetId() << " SeqNo = " << (uint32_t)GetSeq()
1061 << " checksum = " << (uint32_t)GetChecksum() << ")";
1062}
1063
1066{
1067 NS_LOG_FUNCTION(this);
1068 return 8;
1069}
1070
1071void
1073{
1074 NS_LOG_FUNCTION(this << &start);
1075 uint16_t checksum = 0;
1076 Buffer::Iterator i = start;
1077
1078 i.WriteU8(GetType());
1079 i.WriteU8(GetCode());
1080 i.WriteHtonU16(0);
1081
1082 i.WriteHtonU16(m_id);
1084
1085 if (m_calcChecksum)
1086 {
1087 i = start;
1088 checksum = i.CalculateIpChecksum(i.GetSize(), GetChecksum());
1089 i = start;
1090 i.Next(2);
1091 i.WriteU16(checksum);
1092 }
1093}
1094
1097{
1098 NS_LOG_FUNCTION(this << &start);
1099 Buffer::Iterator i = start;
1100
1101 SetType(i.ReadU8());
1102 SetCode(i.ReadU8());
1103 m_checksum = i.ReadU16();
1104
1105 m_id = i.ReadNtohU16();
1106 m_seq = i.ReadNtohU16();
1107 return GetSerializedSize();
1108}
1109
1111
1112TypeId
1114{
1115 static TypeId tid = TypeId("ns3::Icmpv6DestinationUnreachable")
1117 .SetGroupName("Internet")
1118 .AddConstructor<Icmpv6DestinationUnreachable>();
1119 return tid;
1120}
1121
1122TypeId
1128
1135
1140
1141void
1143{
1144 NS_LOG_FUNCTION(this << *p);
1145 NS_ASSERT(p->GetSize() <= 1280);
1146 m_packet = p->Copy();
1147}
1148
1149void
1151{
1152 NS_LOG_FUNCTION(this << &os);
1153 os << "( type = " << (uint32_t)GetType()
1154 << " (Destination Unreachable) code = " << (uint32_t)GetCode()
1155 << " checksum = " << (uint32_t)GetChecksum() << ")";
1156}
1157
1160{
1161 NS_LOG_FUNCTION(this);
1162 // The real size of the header is 8 + m_packet->GetSize ()
1163 // HOWEVER we just serialize the first 8 bytes, as the rest is serialized separately.
1164 return 8;
1165}
1166
1167void
1169{
1170 NS_LOG_FUNCTION(this << &start);
1171 uint16_t checksum = 0;
1172 Buffer::Iterator i = start;
1173
1174 Buffer secondaryBuffer;
1175 secondaryBuffer.AddAtStart(8 + m_packet->GetSize());
1176 Buffer::Iterator iter = secondaryBuffer.Begin();
1177
1178 iter.WriteU8(GetType());
1179 iter.WriteU8(GetCode());
1180 iter.WriteU16(0);
1181 iter.WriteU32(0);
1182
1183 uint32_t size = m_packet->GetSize();
1184 auto buf = new uint8_t[size];
1185 m_packet->CopyData(buf, size);
1186 iter.Write(buf, size);
1187 delete[] buf;
1188
1189 iter = secondaryBuffer.Begin();
1190 checksum = iter.CalculateIpChecksum(iter.GetSize(), GetChecksum());
1191
1192 i.WriteU8(GetType());
1193 i.WriteU8(GetCode());
1194 i.WriteU16(checksum);
1195 i.WriteU32(0);
1196}
1197
1200{
1201 NS_LOG_FUNCTION(this << &start);
1202 Buffer::Iterator i = start;
1203
1204 SetType(i.ReadU8());
1205 SetCode(i.ReadU8());
1206 m_checksum = i.ReadU16();
1207 i.ReadU32();
1208
1209 return GetSerializedSize();
1210}
1211
1213
1214TypeId
1216{
1217 static TypeId tid = TypeId("ns3::Icmpv6TooBig")
1219 .SetGroupName("Internet")
1220 .AddConstructor<Icmpv6TooBig>();
1221 return tid;
1222}
1223
1224TypeId
1226{
1227 NS_LOG_FUNCTION(this);
1228 return GetTypeId();
1229}
1230
1232 : m_packet(nullptr),
1233 m_mtu(0)
1234{
1235 NS_LOG_FUNCTION(this);
1237}
1238
1243
1244void
1246{
1247 NS_LOG_FUNCTION(this << *p);
1248 NS_ASSERT(p->GetSize() <= 1280);
1249 m_packet = p->Copy();
1250}
1251
1254{
1255 NS_LOG_FUNCTION(this);
1256 return m_mtu;
1257}
1258
1259void
1261{
1262 NS_LOG_FUNCTION(this << mtu);
1263 m_mtu = mtu;
1264}
1265
1266void
1267Icmpv6TooBig::Print(std::ostream& os) const
1268{
1269 NS_LOG_FUNCTION(this << &os);
1270 os << "( type = " << (uint32_t)GetType() << " (Too Big) code = " << (uint32_t)GetCode()
1271 << " checksum = " << (uint32_t)GetChecksum() << " mtu = " << (uint32_t)GetMtu() << ")";
1272}
1273
1276{
1277 NS_LOG_FUNCTION(this);
1278 // The real size of the header is 8 + m_packet->GetSize ()
1279 // HOWEVER we just serialize the first 8 bytes, as the rest is serialized separately.
1280 return 8;
1281}
1282
1283void
1285{
1286 NS_LOG_FUNCTION(this << &start);
1287 uint16_t checksum = 0;
1288 Buffer::Iterator i = start;
1289
1290 Buffer secondaryBuffer;
1291 secondaryBuffer.AddAtStart(8 + m_packet->GetSize());
1292 Buffer::Iterator iter = secondaryBuffer.Begin();
1293
1294 iter.WriteU8(GetType());
1295 iter.WriteU8(GetCode());
1296 iter.WriteU16(0);
1297 iter.WriteHtonU32(GetMtu());
1298
1299 uint32_t size = m_packet->GetSize();
1300 auto buf = new uint8_t[size];
1301 m_packet->CopyData(buf, size);
1302 iter.Write(buf, size);
1303 delete[] buf;
1304
1305 iter = secondaryBuffer.Begin();
1306 checksum = iter.CalculateIpChecksum(iter.GetSize(), GetChecksum());
1307
1308 i.WriteU8(GetType());
1309 i.WriteU8(GetCode());
1310 i.WriteU16(checksum);
1311 i.WriteHtonU32(GetMtu());
1312}
1313
1316{
1317 NS_LOG_FUNCTION(this << &start);
1318 Buffer::Iterator i = start;
1319
1320 SetType(i.ReadU8());
1321 SetCode(i.ReadU8());
1322 m_checksum = i.ReadU16();
1323 SetMtu(i.ReadNtohU32());
1324
1325 return GetSerializedSize();
1326}
1327
1329
1330TypeId
1332{
1333 static TypeId tid = TypeId("ns3::Icmpv6TimeExceeded")
1335 .SetGroupName("Internet")
1336 .AddConstructor<Icmpv6TimeExceeded>();
1337 return tid;
1338}
1339
1340TypeId
1342{
1343 NS_LOG_FUNCTION(this);
1344 return GetTypeId();
1345}
1346
1348 : m_packet(nullptr)
1349{
1350 NS_LOG_FUNCTION(this);
1352}
1353
1358
1359void
1361{
1362 NS_LOG_FUNCTION(this << *p);
1363 NS_ASSERT(p->GetSize() <= 1280);
1364 m_packet = p->Copy();
1365}
1366
1367void
1368Icmpv6TimeExceeded::Print(std::ostream& os) const
1369{
1370 NS_LOG_FUNCTION(this << &os);
1371 os << "( type = " << (uint32_t)GetType()
1372 << " (Destination Unreachable) code = " << (uint32_t)GetCode()
1373 << " checksum = " << (uint32_t)GetChecksum() << ")";
1374}
1375
1378{
1379 NS_LOG_FUNCTION(this);
1380 // The real size of the header is 8 + m_packet->GetSize ()
1381 // HOWEVER we just serialize the first 8 bytes, as the rest is serialized separately.
1382 return 8;
1383}
1384
1385void
1387{
1388 NS_LOG_FUNCTION(this << &start);
1389 uint16_t checksum = 0;
1390 Buffer::Iterator i = start;
1391
1392 Buffer secondaryBuffer;
1393 secondaryBuffer.AddAtStart(8 + m_packet->GetSize());
1394 Buffer::Iterator iter = secondaryBuffer.Begin();
1395
1396 iter.WriteU8(GetType());
1397 iter.WriteU8(GetCode());
1398 iter.WriteU16(0);
1399 iter.WriteU32(0);
1400
1401 uint32_t size = m_packet->GetSize();
1402 auto buf = new uint8_t[size];
1403 m_packet->CopyData(buf, size);
1404 iter.Write(buf, size);
1405 delete[] buf;
1406
1407 iter = secondaryBuffer.Begin();
1408 checksum = iter.CalculateIpChecksum(iter.GetSize(), GetChecksum());
1409
1410 i.WriteU8(GetType());
1411 i.WriteU8(GetCode());
1412 i.WriteU16(checksum);
1413 i.WriteU32(0);
1414}
1415
1418{
1419 NS_LOG_FUNCTION(this << &start);
1420 Buffer::Iterator i = start;
1421
1422 SetType(i.ReadU8());
1423 SetCode(i.ReadU8());
1424 m_checksum = i.ReadU16();
1425 i.ReadU32();
1426
1427 return GetSerializedSize();
1428}
1429
1431
1432TypeId
1434{
1435 static TypeId tid = TypeId("ns3::Icmpv6ParameterError")
1437 .SetGroupName("Internet")
1438 .AddConstructor<Icmpv6ParameterError>();
1439 return tid;
1440}
1441
1442TypeId
1444{
1445 NS_LOG_FUNCTION(this);
1446 return GetTypeId();
1447}
1448
1450 : m_packet(nullptr),
1451 m_ptr(0)
1452{
1453 NS_LOG_FUNCTION(this);
1455}
1456
1461
1462void
1464{
1465 NS_LOG_FUNCTION(this << *p);
1466 NS_ASSERT(p->GetSize() <= 1280);
1467 m_packet = p->Copy();
1468}
1469
1472{
1473 NS_LOG_FUNCTION(this);
1474 return m_ptr;
1475}
1476
1477void
1479{
1480 NS_LOG_FUNCTION(this << ptr);
1481 m_ptr = ptr;
1482}
1483
1484void
1485Icmpv6ParameterError::Print(std::ostream& os) const
1486{
1487 NS_LOG_FUNCTION(this << &os);
1488 os << "( type = " << (uint32_t)GetType()
1489 << " (Destination Unreachable) code = " << (uint32_t)GetCode()
1490 << " checksum = " << (uint32_t)GetChecksum() << " ptr = " << (uint32_t)GetPtr() << ")";
1491}
1492
1495{
1496 NS_LOG_FUNCTION(this);
1497 // The real size of the header is 8 + m_packet->GetSize ()
1498 // HOWEVER we just serialize the first 8 bytes, as the rest is serialized separately.
1499 return 8;
1500}
1501
1502void
1504{
1505 NS_LOG_FUNCTION(this << &start);
1506 uint16_t checksum = 0;
1507 Buffer::Iterator i = start;
1508
1509 Buffer secondaryBuffer;
1510 secondaryBuffer.AddAtStart(8 + m_packet->GetSize());
1511 Buffer::Iterator iter = secondaryBuffer.Begin();
1512
1513 iter.WriteU8(GetType());
1514 iter.WriteU8(GetCode());
1515 iter.WriteU16(0);
1516 iter.WriteHtonU32(GetPtr());
1517
1518 uint32_t size = m_packet->GetSize();
1519 auto buf = new uint8_t[size];
1520 m_packet->CopyData(buf, size);
1521 iter.Write(buf, size);
1522 delete[] buf;
1523
1524 iter = secondaryBuffer.Begin();
1525 checksum = iter.CalculateIpChecksum(iter.GetSize(), GetChecksum());
1526
1527 i.WriteU8(GetType());
1528 i.WriteU8(GetCode());
1529 i.WriteU16(checksum);
1530 i.WriteHtonU32(GetPtr());
1531}
1532
1535{
1536 NS_LOG_FUNCTION(this << &start);
1537 Buffer::Iterator i = start;
1538
1539 SetType(i.ReadU8());
1540 SetCode(i.ReadU8());
1541 m_checksum = i.ReadU16();
1542 SetPtr(i.ReadNtohU32());
1543
1544 return GetSerializedSize();
1545}
1546
1548
1549TypeId
1551{
1552 static TypeId tid = TypeId("ns3::Icmpv6OptionHeader")
1553 .SetParent<Header>()
1554 .SetGroupName("Internet")
1555 .AddConstructor<Icmpv6OptionHeader>();
1556 return tid;
1557}
1558
1559TypeId
1561{
1562 NS_LOG_FUNCTION(this);
1563 return GetTypeId();
1564}
1565
1567{
1568 NS_LOG_FUNCTION(this);
1569 /** \todo */
1570 m_type = 0;
1571 m_len = 0;
1572}
1573
1578
1579uint8_t
1581{
1582 NS_LOG_FUNCTION(this);
1583 return m_type;
1584}
1585
1586void
1588{
1589 NS_LOG_FUNCTION(this << static_cast<uint32_t>(type));
1590 m_type = type;
1591}
1592
1593uint8_t
1595{
1596 NS_LOG_FUNCTION(this);
1597 return m_len;
1598}
1599
1600void
1602{
1603 NS_LOG_FUNCTION(this << static_cast<uint32_t>(len));
1604 m_len = len;
1605}
1606
1607void
1608Icmpv6OptionHeader::Print(std::ostream& os) const
1609{
1610 NS_LOG_FUNCTION(this << &os);
1611 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ")";
1612}
1613
1616{
1617 NS_LOG_FUNCTION(this);
1618 return m_len * 8;
1619}
1620
1623{
1624 NS_LOG_FUNCTION(this << &start);
1625 return GetSerializedSize();
1626}
1627
1628void
1630{
1631 NS_LOG_FUNCTION(this << &start);
1632}
1633
1635
1636TypeId
1638{
1639 static TypeId tid = TypeId("ns3::Icmpv6OptionMtu")
1641 .SetGroupName("Internet")
1642 .AddConstructor<Icmpv6OptionMtu>();
1643 return tid;
1644}
1645
1646TypeId
1648{
1649 NS_LOG_FUNCTION(this);
1650 return GetTypeId();
1651}
1652
1660
1662 : m_mtu(mtu)
1663{
1664 NS_LOG_FUNCTION(this << mtu);
1666 SetLength(1);
1667 SetReserved(0);
1668}
1669
1674
1675uint16_t
1677{
1678 NS_LOG_FUNCTION(this);
1679 return m_reserved;
1680}
1681
1682void
1684{
1685 NS_LOG_FUNCTION(this << reserved);
1686 m_reserved = reserved;
1687}
1688
1691{
1692 NS_LOG_FUNCTION(this);
1693 return m_mtu;
1694}
1695
1696void
1698{
1699 NS_LOG_FUNCTION(this << mtu);
1700 m_mtu = mtu;
1701}
1702
1703void
1704Icmpv6OptionMtu::Print(std::ostream& os) const
1705{
1706 NS_LOG_FUNCTION(this << &os);
1707 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
1708 << " MTU = " << m_mtu << ")";
1709}
1710
1713{
1714 NS_LOG_FUNCTION(this);
1715 return 8; /* m_len = 1 so the real size is multiple by 8 */
1716}
1717
1718void
1720{
1721 NS_LOG_FUNCTION(this << &start);
1722 Buffer::Iterator i = start;
1723 i.WriteU8(GetType());
1724 i.WriteU8(GetLength());
1726 i.WriteHtonU32(GetMtu());
1727}
1728
1731{
1732 NS_LOG_FUNCTION(this << &start);
1733 Buffer::Iterator i = start;
1734 SetType(i.ReadU8());
1735 SetLength(i.ReadU8());
1737 SetMtu(i.ReadNtohU32());
1738 return GetSerializedSize();
1739}
1740
1742
1743TypeId
1745{
1746 static TypeId tid = TypeId("ns3::Icmpv6OptionPrefixInformation")
1748 .SetGroupName("Internet")
1749 .AddConstructor<Icmpv6OptionPrefixInformation>();
1750 return tid;
1751}
1752
1753TypeId
1759
1772
1774{
1775 NS_LOG_FUNCTION(this << prefix << static_cast<uint32_t>(prefixlen));
1777 SetLength(4);
1778 SetPrefix(prefix);
1779 SetPrefixLength(prefixlen);
1780 SetValidTime(0);
1782 SetFlags(0);
1783 SetReserved(0);
1784}
1785
1790
1791uint8_t
1797
1798void
1800{
1801 NS_LOG_FUNCTION(this << static_cast<uint32_t>(prefixLength));
1802 NS_ASSERT(prefixLength <= 128);
1803 m_prefixLength = prefixLength;
1804}
1805
1806uint8_t
1808{
1809 NS_LOG_FUNCTION(this);
1810 return m_flags;
1811}
1812
1813void
1815{
1816 NS_LOG_FUNCTION(this);
1817 m_flags = flags;
1818}
1819
1826
1827void
1829{
1830 NS_LOG_FUNCTION(this << validTime);
1831 m_validTime = validTime;
1832}
1833
1840
1841void
1843{
1844 NS_LOG_FUNCTION(this << preferredTime);
1845 m_preferredTime = preferredTime;
1846}
1847
1854
1855void
1857{
1858 NS_LOG_FUNCTION(this << reserved);
1859 m_reserved = reserved;
1860}
1861
1864{
1865 NS_LOG_FUNCTION(this);
1866 return m_prefix;
1867}
1868
1869void
1871{
1872 NS_LOG_FUNCTION(this << prefix);
1873 m_prefix = prefix;
1874}
1875
1876void
1878{
1879 NS_LOG_FUNCTION(this << &os);
1880 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << " prefix "
1881 << m_prefix << ")";
1882}
1883
1886{
1887 NS_LOG_FUNCTION(this);
1888 return 32;
1889}
1890
1891void
1893{
1894 NS_LOG_FUNCTION(this << &start);
1895 Buffer::Iterator i = start;
1896 uint8_t buf[16];
1897
1898 memset(buf, 0x00, sizeof(buf));
1899
1900 i.WriteU8(GetType());
1901 i.WriteU8(GetLength());
1903 i.WriteU8(m_flags);
1907 m_prefix.GetBytes(buf);
1908 i.Write(buf, 16);
1909}
1910
1913{
1914 NS_LOG_FUNCTION(this << &start);
1915 Buffer::Iterator i = start;
1916 uint8_t buf[16];
1917
1918 SetType(i.ReadU8());
1919 SetLength(i.ReadU8());
1921 SetFlags(i.ReadU8());
1925 i.Read(buf, 16);
1926
1927 Ipv6Address prefix(buf);
1928 SetPrefix(prefix);
1929
1930 return GetSerializedSize();
1931}
1932
1934
1935TypeId
1937{
1938 static TypeId tid = TypeId("ns3::Icmpv6OptionLinkLayerAddress")
1940 .SetGroupName("Internet")
1941 .AddConstructor<Icmpv6OptionLinkLayerAddress>();
1942 return tid;
1943}
1944
1945TypeId
1951
1958
1964
1966{
1967 NS_LOG_FUNCTION(this << source << addr);
1970 SetAddress(addr);
1971
1972 uint8_t len = (2 + m_addr.GetLength()) / 8;
1973 if ((2 + m_addr.GetLength()) % 8)
1974 {
1975 len++;
1976 }
1977 SetLength(len);
1978}
1979
1984
1985Address
1987{
1988 NS_LOG_FUNCTION(this);
1989 return m_addr;
1990}
1991
1992void
1994{
1995 NS_LOG_FUNCTION(this << addr);
1996 m_addr = addr;
1997}
1998
1999void
2001{
2002 NS_LOG_FUNCTION(this << &os);
2003 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength()
2004 << " L2 Address = " << m_addr << ")";
2005}
2006
2009{
2010 NS_LOG_FUNCTION(this);
2011 uint8_t nb = GetLength() * 8;
2012 return nb;
2013}
2014
2015void
2017{
2018 NS_LOG_FUNCTION(this << &start);
2019 Buffer::Iterator i = start;
2020 uint8_t mac[32];
2021
2022 i.WriteU8(GetType());
2023 i.WriteU8(GetLength());
2024 m_addr.CopyTo(mac);
2025 i.Write(mac, m_addr.GetLength());
2026
2027 uint8_t len = GetLength() * 8 - (2 + m_addr.GetLength());
2028 for (uint8_t nb = 0; nb < len; nb++)
2029 {
2030 i.WriteU8(0);
2031 }
2032}
2033
2036{
2037 NS_LOG_FUNCTION(this << &start);
2038 Buffer::Iterator i = start;
2039 uint8_t mac[32];
2040
2041 SetType(i.ReadU8());
2042 SetLength(i.ReadU8());
2043 // -fstrict-overflow sensitive, see bug 1868
2044 NS_ASSERT(GetLength() * 8 <= 32 + 2);
2045 i.Read(mac, (GetLength() * 8) - 2);
2046
2047 m_addr.CopyFrom(mac, (GetLength() * 8) - 2);
2048
2049 return GetSerializedSize();
2050}
2051
2053
2054TypeId
2056{
2057 static TypeId tid = TypeId("ns3::Icmpv6OptionRedirected")
2059 .SetGroupName("Internet")
2060 .AddConstructor<Icmpv6OptionRedirected>();
2061 return tid;
2062}
2063
2064TypeId
2066{
2067 NS_LOG_FUNCTION(this);
2068 return GetTypeId();
2069}
2070
2077
2083
2084void
2086{
2087 NS_LOG_FUNCTION(this << *packet);
2088 NS_ASSERT(packet->GetSize() <= 1280);
2089 m_packet = packet->Copy();
2090 SetLength(1 + (m_packet->GetSize() / 8));
2091}
2092
2093void
2094Icmpv6OptionRedirected::Print(std::ostream& os) const
2095{
2096 NS_LOG_FUNCTION(this << &os);
2097 os << "( type = " << (uint32_t)GetType() << " length = " << (uint32_t)GetLength() << ")";
2098}
2099
2102{
2103 NS_LOG_FUNCTION(this);
2104 return 8 + m_packet->GetSize();
2105}
2106
2107void
2109{
2110 NS_LOG_FUNCTION(this << &start);
2111 Buffer::Iterator i = start;
2112
2113 i.WriteU8(GetType());
2114 i.WriteU8(GetLength());
2115 // Reserved
2116 i.WriteU16(0);
2117 i.WriteU32(0);
2118
2119 uint32_t size = m_packet->GetSize();
2120 auto buf = new uint8_t[size];
2121 m_packet->CopyData(buf, size);
2122 i.Write(buf, size);
2123 delete[] buf;
2124}
2125
2128{
2129 NS_LOG_FUNCTION(this << &start);
2130 Buffer::Iterator i = start;
2131
2132 SetType(i.ReadU8());
2133 uint8_t length = i.ReadU8();
2134 SetLength(length);
2135 i.ReadU16();
2136 i.ReadU32();
2137
2138 uint32_t len2 = (GetLength() - 1) * 8;
2139 auto buff = new uint8_t[len2];
2140 i.Read(buff, len2);
2141 m_packet = Create<Packet>(buff, len2);
2142 delete[] buff;
2143
2144 return GetSerializedSize();
2145}
2146
2147} /* namespace ns3 */
a polymophic address class
Definition address.h:90
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition address.cc:95
uint8_t GetLength() const
Get the length of the underlying address.
Definition address.cc:67
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition address.cc:75
iterator in a Buffer instance
Definition buffer.h:89
void WriteU32(uint32_t data)
Definition buffer.cc:857
uint16_t CalculateIpChecksum(uint16_t size)
Calculate the checksum.
Definition buffer.cc:1124
void WriteU8(uint8_t data)
Definition buffer.h:870
void Write(const uint8_t *buffer, uint32_t size)
Definition buffer.cc:937
void WriteU16(uint16_t data)
Definition buffer.cc:848
void Read(uint8_t *buffer, uint32_t size)
Definition buffer.cc:1114
void WriteHtonU16(uint16_t data)
Definition buffer.h:904
uint32_t ReadNtohU32()
Definition buffer.h:967
uint32_t ReadU32()
Definition buffer.cc:955
void WriteHtonU32(uint32_t data)
Definition buffer.h:922
uint16_t ReadNtohU16()
Definition buffer.h:943
uint32_t GetSize() const
Definition buffer.cc:1155
uint16_t ReadU16()
Definition buffer.h:1024
void Next()
go forward by one byte
Definition buffer.h:842
automatically resized byte buffer
Definition buffer.h:83
void AddAtStart(uint32_t start)
Definition buffer.cc:303
Buffer::Iterator Begin() const
Definition buffer.h:1063
Protocol header serialization and deserialization.
Definition header.h:33
ICMPv6 Error Destination Unreachable header.
uint32_t GetSerializedSize() const override
Get the serialized size.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
~Icmpv6DestinationUnreachable() override
Destructor.
void Print(std::ostream &os) const override
Print information.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
Ptr< Packet > m_packet
The incorrect Packet.
static TypeId GetTypeId()
Get the UID of this class.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
ICMPv6 Echo message.
static TypeId GetTypeId()
Get the UID of this class.
void SetId(uint16_t id)
Set the ID of the packet.
uint16_t m_seq
Sequence number (to distinguish response).
Icmpv6Echo()
Default constructor.
~Icmpv6Echo() override
Destructor.
uint16_t m_id
ID of the packet (to distinguish response between many ping program).
uint16_t GetId() const
Get the ID of the packet.
void Print(std::ostream &os) const override
Print information.
void SetSeq(uint16_t seq)
Set the sequence number.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint16_t GetSeq() const
Get the sequence number.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 header.
uint8_t GetCode() const
Get the code field.
uint8_t GetType() const
Get the type field.
Icmpv6Header()
Constructor.
uint8_t m_code
The code.
uint16_t GetChecksum() const
Get the checksum.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
uint16_t m_checksum
The checksum.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void CalculatePseudoHeaderChecksum(Ipv6Address src, Ipv6Address dst, uint16_t length, uint8_t protocol)
Calculate pseudo header checksum for IPv6.
void SetCode(uint8_t code)
Set the code field.
uint8_t m_type
The type.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetType(uint8_t type)
Set the type.
@ ICMPV6_ERROR_DESTINATION_UNREACHABLE
~Icmpv6Header() override
Destructor.
void SetChecksum(uint16_t checksum)
Set the checksum.
void Print(std::ostream &os) const override
Print information.
bool m_calcChecksum
Checksum enable or not.
ICMPv6 Neighbor Advertisement header.
bool GetFlagS() const
Get the S flag.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
bool m_flagS
The O flag.
uint32_t m_reserved
The reserved value.
~Icmpv6NA() override
Destructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetFlagS(bool s)
Set the S flag.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
void SetFlagR(bool r)
Set the R flag.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
bool GetFlagR() const
Get the R flag.
uint32_t GetSerializedSize() const override
Get the serialized size.
bool GetFlagO() const
Get the O flag.
void SetFlagO(bool o)
Set the O flag.
Icmpv6NA()
Constructor.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
bool m_flagR
The R flag.
void SetReserved(uint32_t reserved)
Set the reserved field.
void Print(std::ostream &os) const override
Print information.
static TypeId GetTypeId()
Get the UID of this class.
Ipv6Address m_target
The IPv6 target address.
bool m_flagO
The M flag.
uint32_t GetReserved() const
Get the reserved field.
ICMPv6 Neighbor Solicitation header.
uint32_t m_reserved
The reserved value.
uint32_t GetSerializedSize() const override
Get the serialized size.
void SetIpv6Target(Ipv6Address target)
Set the IPv6 target field.
uint32_t GetReserved() const
Get the reserved field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
Ipv6Address m_target
The IPv6 target address.
void SetReserved(uint32_t reserved)
Set the reserved field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Ipv6Address GetIpv6Target() const
Get the IPv6 target field.
~Icmpv6NS() override
Destructor.
Icmpv6NS()
Constructor.
ICMPv6 option header.
void SetType(uint8_t type)
Set the type of the option.
Icmpv6OptionHeader()
Constructor.
void Print(std::ostream &os) const override
Print information.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint8_t m_len
The length.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint8_t m_type
The type.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
uint8_t GetType() const
Get the type of the option.
~Icmpv6OptionHeader() override
Destructor.
void SetLength(uint8_t len)
Set the length of the option.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint8_t GetLength() const
Get the length of the option in 8 bytes unit.
ICMPv6 MTU option.
~Icmpv6OptionMtu() override
Destructor.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint16_t m_reserved
The reserved value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
void SetReserved(uint16_t reserved)
Set the reserved field.
uint32_t GetMtu() const
Get the MTU.
static TypeId GetTypeId()
Get the UID of this class.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void Print(std::ostream &os) const override
Print information.
void SetMtu(uint32_t mtu)
Set the MTU.
uint32_t m_mtu
The MTU value.
Icmpv6OptionMtu()
Constructor.
uint16_t GetReserved() const
Get the reserved field.
ICMPv6 Option Prefix Information.
uint32_t GetValidTime() const
Get the valid time of the information.
uint8_t m_prefixLength
The length of the prefix.
void SetReserved(uint32_t reserved)
Set the reserved field (normally it will be 0x00000000).
void SetValidTime(uint32_t validTime)
Set the valid time of the information.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetPrefix(Ipv6Address prefix)
Set the IPv6 prefix.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
Ipv6Address GetPrefix() const
Get the IPv6 prefix.
void SetFlags(uint8_t flags)
Set the flags.
void Print(std::ostream &os) const override
Print information.
uint32_t GetSerializedSize() const override
Get the serialized size.
~Icmpv6OptionPrefixInformation() override
Destructor.
void SetPrefixLength(uint8_t prefixLength)
Set the prefix length.
Ipv6Address m_prefix
The prefix value.
uint32_t m_reserved
The reserved field.
uint8_t GetPrefixLength() const
Get the prefix length.
void SetPreferredTime(uint32_t preferredTime)
Set the preferred time of the information.
uint32_t m_preferredTime
The preferred time.
uint8_t GetFlags() const
Get the flags.
uint32_t GetReserved() const
Get the reserved field.
uint32_t m_validTime
The valid time.
static TypeId GetTypeId()
Get the UID of this class.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t GetPreferredTime() const
Get the preferred time of the information.
ICMPv6 redirected option.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
~Icmpv6OptionRedirected() override
Destructor.
Ptr< Packet > m_packet
The redirected packet.
void Print(std::ostream &os) const override
Print information.
uint32_t GetSerializedSize() const override
Get the serialized size.
static TypeId GetTypeId()
Get the UID of this class.
void SetPacket(Ptr< Packet > packet)
Set the redirected packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 Error Parameter Error header.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t m_ptr
The pointer field.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
static TypeId GetTypeId()
Get the UID of this class.
void SetPtr(uint32_t ptr)
Set the pointer field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
~Icmpv6ParameterError() override
Destructor.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
The incorrect packet.
uint32_t GetPtr() const
Get the pointer field.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
ICMPv6 Router Advertisement header.
void Print(std::ostream &os) const override
Print information.
Icmpv6RA()
Constructor.
void SetLifeTime(uint16_t l)
Set the node Life time (Neighbor Discovery).
bool m_flagM
The M flag.
uint32_t GetRetransmissionTime() const
Get the node Retransmission time (Neighbor Discovery).
bool m_flagO
The O flag.
void SetFlagH(bool h)
Set the H flag.
void SetRetransmissionTime(uint32_t r)
Set the node Retransmission time (Neighbor Discovery).
void SetCurHopLimit(uint8_t m)
Set the IPv6 maximum number of jumps.
void SetFlagO(bool o)
Set the O flag.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
void SetFlagM(bool m)
Set the M flag.
void SetReachableTime(uint32_t r)
Set the node Reachable time (Neighbor Discovery).
static TypeId GetTypeId()
Get the UID of this class.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t m_RetransmissionTimer
The retransmission timer.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint16_t GetLifeTime() const
Get the node Life time (Neighbor Discovery).
uint32_t GetReachableTime() const
Get the node Reachable time (Neighbor Discovery).
uint8_t GetCurHopLimit() const
Get the IPv6 maximum number of jumps.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
bool GetFlagO() const
Get the O flag.
uint16_t m_LifeTime
The lifetime value.
bool GetFlagM() const
Get the M flag.
uint8_t m_curHopLimit
The max jumps.
uint32_t m_ReachableTime
The reachable time value.
bool m_flagH
The H flag.
~Icmpv6RA() override
Destructor.
bool GetFlagH() const
Get the H flag.
ICMPv6 Router Solicitation header.
void SetReserved(uint32_t reserved)
Set the reserved field.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
~Icmpv6RS() override
Destructor.
uint32_t GetReserved() const
Get the reserved field.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t m_reserved
The reserved value.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
Icmpv6RS()
Constructor.
ICMPv6 Redirection header.
Ipv6Address m_target
IPv6 target address.
Ipv6Address GetTarget() const
Get the IPv6 target address.
Ipv6Address m_destination
IPv6 destination address.
uint32_t GetReserved() const
Get the reserved field.
uint32_t GetSerializedSize() const override
Get the serialized size.
~Icmpv6Redirection() override
Destructor.
void Print(std::ostream &os) const override
Print information.
Icmpv6Redirection()
Constructor.
void SetDestination(Ipv6Address destination)
Set the IPv6 destination address.
void SetReserved(uint32_t reserved)
Set the reserved field.
Ipv6Address GetDestination() const
Get the IPv6 destination address.
void SetTarget(Ipv6Address target)
Set the IPv6 target address.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
static TypeId GetTypeId()
Get the UID of this class.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t m_reserved
Reserved value.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
ICMPv6 Error Time Exceeded header.
uint32_t GetSerializedSize() const override
Get the serialized size.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
~Icmpv6TimeExceeded() override
Destructor.
Icmpv6TimeExceeded()
Constructor.
static TypeId GetTypeId()
Get the UID of this class.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
The incorrect packet.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
ICMPv6 Error Too Big header.
static TypeId GetTypeId()
Get the UID of this class.
void SetMtu(uint32_t mtu)
Set the MTU.
void Print(std::ostream &os) const override
Print information.
Ptr< Packet > m_packet
the incorrect packet.
Icmpv6TooBig()
Constructor.
TypeId GetInstanceTypeId() const override
Get the instance type ID.
uint32_t GetSerializedSize() const override
Get the serialized size.
~Icmpv6TooBig() override
Destructor.
void SetPacket(Ptr< Packet > p)
Set the incorrect packet.
uint32_t Deserialize(Buffer::Iterator start) override
Deserialize the packet.
uint32_t m_mtu
The MTU value.
void Serialize(Buffer::Iterator start) const override
Serialize the packet.
uint32_t GetMtu() const
Get the MTU field.
Describes an IPv6 address.
void GetBytes(uint8_t buf[16]) const
Get the bytes corresponding to the address.
void Set(const char *address)
Sets an Ipv6Address by parsing the input C-string.
void Serialize(uint8_t buf[16]) const
Serialize this address to a 16-byte buffer.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition packet.h:850
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Definition packet.cc:389
Smart pointer class similar to boost::intrusive_ptr.
a unique identifier for an interface.
Definition type-id.h:48
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition object-base.h:35
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.