A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
lte-asn1-header.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Lluis Parcerisa <lparcerisa@cttc.cat>
18 */
19
20#include "lte-asn1-header.h"
21
22#include "ns3/log.h"
23
24#include <cmath>
25#include <sstream>
26#include <stdio.h>
27
28namespace ns3
29{
30
31NS_LOG_COMPONENT_DEFINE("Asn1Header");
32
34
35TypeId
37{
38 static TypeId tid = TypeId("ns3::Asn1Header").SetParent<Header>().SetGroupName("Lte");
39 return tid;
40}
41
44{
45 return GetTypeId();
46}
47
49{
52 m_isDataSerialized = false;
53}
54
56{
57}
58
61{
63 {
65 }
67}
68
69void
71{
73 {
75 }
77}
78
79void
80Asn1Header::WriteOctet(uint8_t octet) const
81{
84 bIterator.Prev();
85 bIterator.WriteU8(octet);
86}
87
88template <int N>
89void
90Asn1Header::SerializeBitset(std::bitset<N> data) const
91{
92 size_t dataSize = data.size();
93 uint8_t pendingBits = dataSize;
94 uint8_t mask = 1;
95 int j;
96
97 // No extension marker (Clause 16.7 ITU-T X.691),
98 // as 3GPP TS 36.331 does not use it in its IE's.
99
100 // Clause 16.8 ITU-T X.691
101 if (dataSize == 0)
102 {
103 return;
104 }
105
106 // Clause 16.9 ITU-T X.691
107 // Clause 16.10 ITU-T X.691
108 if (dataSize <= 65536)
109 {
110 // If there are bits pending to be processed,
111 // append first bits in data to complete an octet.
113 {
114 mask = 0x80 >> m_numSerializationPendingBits;
115 while (pendingBits > 0 && m_numSerializationPendingBits < 8)
116 {
117 m_serializationPendingBits |= (data[pendingBits - 1]) ? mask : 0;
118 pendingBits--;
120 mask = (mask >> 1) & (~mask);
121 }
122
124 {
128 }
129 }
130
131 while (pendingBits > 0)
132 {
133 mask = 1;
134 j = 8;
135
136 // If there are less than 8 remaining bits,
137 // store it to m_serializationPendingBits.
138 if (pendingBits < 8)
139 {
140 mask = 0x80;
141 m_numSerializationPendingBits = pendingBits;
142 while (pendingBits > 0)
143 {
144 m_serializationPendingBits |= (data[pendingBits - 1]) ? mask : 0;
145 mask = (mask >> 1) & (~mask);
146 pendingBits--;
147 }
148 }
149
150 // Write the data to buffer
151 else
152 {
153 uint8_t octetToWrite = 0;
154 for (; j > 0; j--)
155 {
156 octetToWrite |= (data[pendingBits - j]) ? mask : 0;
157 mask = (mask << 1) & (~mask);
158 }
159 WriteOctet(octetToWrite);
160 pendingBits -= 8;
161 }
162 }
163 }
164
165 // Clause 16.11 ITU-T X.691
166 else
167 {
168 printf("FRAGMENTATION NEEDED!\n");
169 }
170}
171
172template <int N>
173void
175{
176 SerializeBitset<N>(data);
177}
178
179void
181{
182 SerializeBitstring<1>(data);
183}
184
185void
187{
188 SerializeBitstring<2>(data);
189}
190
191void
193{
194 SerializeBitstring<8>(data);
195}
196
197void
199{
200 SerializeBitstring<10>(data);
201}
202
203void
205{
206 SerializeBitstring<16>(data);
207}
208
209void
211{
212 SerializeBitstring<27>(data);
213}
214
215void
217{
218 SerializeBitstring<28>(data);
219}
220
221void
223{
224 SerializeBitstring<32>(data);
225}
226
227void
229{
230 // Clause 12 ITU-T X.691
231 std::bitset<1> val;
232 (value) ? val.set() : val.reset();
233 SerializeBitset<1>(val);
234}
235
236template <int N>
237void
238Asn1Header::SerializeSequence(std::bitset<N> optionalOrDefaultMask,
239 bool isExtensionMarkerPresent) const
240{
241 if (isExtensionMarkerPresent)
242 {
243 // Extension marker present, but no extension
244 SerializeBoolean(false);
245 }
246 SerializeBitstring<N>(optionalOrDefaultMask);
247}
248
249void
250Asn1Header::SerializeSequence(std::bitset<0> optionalOrDefaultMask,
251 bool isExtensionMarkerPresent) const
252{
253 SerializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent);
254}
255
256void
257Asn1Header::SerializeSequence(std::bitset<1> optionalOrDefaultMask,
258 bool isExtensionMarkerPresent) const
259{
260 SerializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent);
261}
262
263void
264Asn1Header::SerializeSequence(std::bitset<2> optionalOrDefaultMask,
265 bool isExtensionMarkerPresent) const
266{
267 SerializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent);
268}
269
270void
271Asn1Header::SerializeSequence(std::bitset<3> optionalOrDefaultMask,
272 bool isExtensionMarkerPresent) const
273{
274 SerializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent);
275}
276
277void
278Asn1Header::SerializeSequence(std::bitset<4> optionalOrDefaultMask,
279 bool isExtensionMarkerPresent) const
280{
281 SerializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent);
282}
283
284void
285Asn1Header::SerializeSequence(std::bitset<5> optionalOrDefaultMask,
286 bool isExtensionMarkerPresent) const
287{
288 SerializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent);
289}
290
291void
292Asn1Header::SerializeSequence(std::bitset<6> optionalOrDefaultMask,
293 bool isExtensionMarkerPresent) const
294{
295 SerializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent);
296}
297
298void
299Asn1Header::SerializeSequence(std::bitset<7> optionalOrDefaultMask,
300 bool isExtensionMarkerPresent) const
301{
302 SerializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent);
303}
304
305void
306Asn1Header::SerializeSequence(std::bitset<9> optionalOrDefaultMask,
307 bool isExtensionMarkerPresent) const
308{
309 SerializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent);
310}
311
312void
313Asn1Header::SerializeSequence(std::bitset<10> optionalOrDefaultMask,
314 bool isExtensionMarkerPresent) const
315{
316 SerializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent);
317}
318
319void
320Asn1Header::SerializeSequence(std::bitset<11> optionalOrDefaultMask,
321 bool isExtensionMarkerPresent) const
322{
323 SerializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent);
324}
325
326void
327Asn1Header::SerializeSequenceOf(int numElems, int nMax, int nMin) const
328{
329 // Clause 20.6 ITU-T X.691
330 SerializeInteger(numElems, nMin, nMax);
331}
332
333void
334Asn1Header::SerializeEnum(int numElems, int selectedElem) const
335{
336 // Clause 14 ITU-T X.691
337 SerializeInteger(selectedElem, 0, numElems - 1);
338}
339
340void
341Asn1Header::SerializeChoice(int numOptions, int selectedOption, bool isExtensionMarkerPresent) const
342{
343 if (isExtensionMarkerPresent)
344 {
345 // Never extended attributes
346 SerializeBoolean(false);
347 }
348
349 // Clause 23.4 ITU-T X.691
350 if (numOptions < 2)
351 {
352 return;
353 }
354
355 SerializeInteger(selectedOption, 0, numOptions - 1);
356}
357
358void
359Asn1Header::SerializeInteger(int n, int nmin, int nmax) const
360{
361 // The following is equivalent to:
362 // NS_ASSERT_MSG (nmin <= n && n <= nmax,
363 // "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
364 // This is a workaround to gcc-7 aggressive optimization, see #346, and can be dropped
365 // once gcc-7 will not be anymore supported.
366 long int nComp = nmin;
367 nComp -= n;
368 NS_ASSERT_MSG(nComp <= 0 && n <= nmax,
369 "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
370
371 // Clause 11.5.3 ITU-T X.691
372 int range = nmax - nmin + 1;
373 // Subtract nmin to n
374 n -= nmin;
375
376 // Clause 11.5.4 ITU-T X.691
377 if (range <= 1)
378 {
379 return;
380 }
381
382 // Clause 11.5.6 ITU-T X.691
383 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
384
385 switch (requiredBits)
386 {
387 case 1:
388 SerializeBitset<1>(std::bitset<1>(n));
389 break;
390 case 2:
391 SerializeBitset<2>(std::bitset<2>(n));
392 break;
393 case 3:
394 SerializeBitset<3>(std::bitset<3>(n));
395 break;
396 case 4:
397 SerializeBitset<4>(std::bitset<4>(n));
398 break;
399 case 5:
400 SerializeBitset<5>(std::bitset<5>(n));
401 break;
402 case 6:
403 SerializeBitset<6>(std::bitset<6>(n));
404 break;
405 case 7:
406 SerializeBitset<7>(std::bitset<7>(n));
407 break;
408 case 8:
409 SerializeBitset<8>(std::bitset<8>(n));
410 break;
411 case 9:
412 SerializeBitset<9>(std::bitset<9>(n));
413 break;
414 case 10:
415 SerializeBitset<10>(std::bitset<10>(n));
416 break;
417 case 11:
418 SerializeBitset<11>(std::bitset<11>(n));
419 break;
420 case 12:
421 SerializeBitset<12>(std::bitset<12>(n));
422 break;
423 case 13:
424 SerializeBitset<13>(std::bitset<13>(n));
425 break;
426 case 14:
427 SerializeBitset<14>(std::bitset<14>(n));
428 break;
429 case 15:
430 SerializeBitset<15>(std::bitset<15>(n));
431 break;
432 case 16:
433 SerializeBitset<16>(std::bitset<16>(n));
434 break;
435 case 17:
436 SerializeBitset<17>(std::bitset<17>(n));
437 break;
438 case 18:
439 SerializeBitset<18>(std::bitset<18>(n));
440 break;
441 case 19:
442 SerializeBitset<19>(std::bitset<19>(n));
443 break;
444 case 20:
445 SerializeBitset<20>(std::bitset<20>(n));
446 break;
447 default: {
448 std::cout << "SerializeInteger " << requiredBits << " Out of range!!" << std::endl;
449 exit(1);
450 }
451 }
452}
453
454void
456{
457 // Clause 18 ITU-T X.691
458}
459
460void
462{
464 {
466 SerializeBitset<8>(std::bitset<8>(m_serializationPendingBits));
467 }
468 m_isDataSerialized = true;
469}
470
471template <int N>
474{
475 int bitsToRead = N;
476 uint8_t mask;
477
478 // Read bits from pending bits
480 {
481 while (bitsToRead > 0 && m_numSerializationPendingBits > 0)
482 {
483 data->set(bitsToRead - 1, (m_serializationPendingBits & 0x80) ? 1 : 0);
484 bitsToRead--;
487 }
488 }
489
490 // Read bits from buffer
491 while (bitsToRead > 0)
492 {
493 uint8_t octet = bIterator.ReadU8();
494 // If 8 bits can be allocated to the bitset, set the bits
495 if (bitsToRead >= 8)
496 {
497 mask = 0x80;
498 for (int j = 0; j < 8; j++)
499 {
500 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
501 bitsToRead--;
502 mask = mask >> 1;
503 }
504 }
505
506 // Otherwise, we'll have to save the remaining bits
507 else
508 {
509 mask = 0x80;
510 m_numSerializationPendingBits = 8 - bitsToRead;
511 m_serializationPendingBits = octet << bitsToRead;
512 while (bitsToRead > 0)
513 {
514 data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
515 bitsToRead--;
516 mask = mask >> 1;
517 }
518 }
519 }
520
521 return bIterator;
522}
523
524template <int N>
527{
528 return DeserializeBitset<N>(data, bIterator);
529}
530
533{
534 return DeserializeBitstring<1>(data, bIterator);
535}
536
539{
540 return DeserializeBitstring<2>(data, bIterator);
541}
542
545{
546 return DeserializeBitstring<8>(data, bIterator);
547}
548
551{
552 return DeserializeBitstring<10>(data, bIterator);
553}
554
557{
558 return DeserializeBitstring<16>(data, bIterator);
559}
560
563{
564 return DeserializeBitstring<27>(data, bIterator);
565}
566
569{
570 return DeserializeBitstring<28>(data, bIterator);
571}
572
575{
576 return DeserializeBitstring<32>(data, bIterator);
577}
578
581{
582 std::bitset<1> readBit;
583 bIterator = DeserializeBitset<1>(&readBit, bIterator);
584 *value = (readBit[0] == 1);
585 return bIterator;
586}
587
589Asn1Header::DeserializeInteger(int* n, int nmin, int nmax, Buffer::Iterator bIterator)
590{
591 // Misusage check: Ensure nmax>nmin ...
592 if (nmin > nmax)
593 {
594 int aux = nmin;
595 nmin = nmax;
596 nmax = aux;
597 }
598
599 int range = nmax - nmin + 1;
600
601 if (range == 1)
602 {
603 return bIterator;
604 }
605
606 int requiredBits = std::ceil(std::log(range) / std::log(2.0));
607
608 std::bitset<1> bitsRead1;
609 std::bitset<2> bitsRead2;
610 std::bitset<3> bitsRead3;
611 std::bitset<4> bitsRead4;
612 std::bitset<5> bitsRead5;
613 std::bitset<6> bitsRead6;
614 std::bitset<7> bitsRead7;
615 std::bitset<8> bitsRead8;
616 std::bitset<9> bitsRead9;
617 std::bitset<10> bitsRead10;
618 std::bitset<11> bitsRead11;
619 std::bitset<12> bitsRead12;
620 std::bitset<13> bitsRead13;
621 std::bitset<14> bitsRead14;
622 std::bitset<15> bitsRead15;
623 std::bitset<16> bitsRead16;
624 std::bitset<17> bitsRead17;
625 std::bitset<18> bitsRead18;
626 std::bitset<19> bitsRead19;
627 std::bitset<20> bitsRead20;
628
629 switch (requiredBits)
630 {
631 case 1:
632 bIterator = DeserializeBitset<1>(&bitsRead1, bIterator);
633 *n = (int)bitsRead1.to_ulong();
634 break;
635 case 2:
636 bIterator = DeserializeBitset<2>(&bitsRead2, bIterator);
637 *n = (int)bitsRead2.to_ulong();
638 break;
639 case 3:
640 bIterator = DeserializeBitset<3>(&bitsRead3, bIterator);
641 *n = (int)bitsRead3.to_ulong();
642 break;
643 case 4:
644 bIterator = DeserializeBitset<4>(&bitsRead4, bIterator);
645 *n = (int)bitsRead4.to_ulong();
646 break;
647 case 5:
648 bIterator = DeserializeBitset<5>(&bitsRead5, bIterator);
649 *n = (int)bitsRead5.to_ulong();
650 break;
651 case 6:
652 bIterator = DeserializeBitset<6>(&bitsRead6, bIterator);
653 *n = (int)bitsRead6.to_ulong();
654 break;
655 case 7:
656 bIterator = DeserializeBitset<7>(&bitsRead7, bIterator);
657 *n = (int)bitsRead7.to_ulong();
658 break;
659 case 8:
660 bIterator = DeserializeBitset<8>(&bitsRead8, bIterator);
661 *n = (int)bitsRead8.to_ulong();
662 break;
663 case 9:
664 bIterator = DeserializeBitset<9>(&bitsRead9, bIterator);
665 *n = (int)bitsRead9.to_ulong();
666 break;
667 case 10:
668 bIterator = DeserializeBitset<10>(&bitsRead10, bIterator);
669 *n = (int)bitsRead10.to_ulong();
670 break;
671 case 11:
672 bIterator = DeserializeBitset<11>(&bitsRead11, bIterator);
673 *n = (int)bitsRead11.to_ulong();
674 break;
675 case 12:
676 bIterator = DeserializeBitset<12>(&bitsRead12, bIterator);
677 *n = (int)bitsRead12.to_ulong();
678 break;
679 case 13:
680 bIterator = DeserializeBitset<13>(&bitsRead13, bIterator);
681 *n = (int)bitsRead13.to_ulong();
682 break;
683 case 14:
684 bIterator = DeserializeBitset<14>(&bitsRead14, bIterator);
685 *n = (int)bitsRead14.to_ulong();
686 break;
687 case 15:
688 bIterator = DeserializeBitset<15>(&bitsRead15, bIterator);
689 *n = (int)bitsRead15.to_ulong();
690 break;
691 case 16:
692 bIterator = DeserializeBitset<16>(&bitsRead16, bIterator);
693 *n = (int)bitsRead16.to_ulong();
694 break;
695 case 17:
696 bIterator = DeserializeBitset<17>(&bitsRead17, bIterator);
697 *n = (int)bitsRead17.to_ulong();
698 break;
699 case 18:
700 bIterator = DeserializeBitset<18>(&bitsRead18, bIterator);
701 *n = (int)bitsRead18.to_ulong();
702 break;
703 case 19:
704 bIterator = DeserializeBitset<19>(&bitsRead19, bIterator);
705 *n = (int)bitsRead19.to_ulong();
706 break;
707 case 20:
708 bIterator = DeserializeBitset<20>(&bitsRead20, bIterator);
709 *n = (int)bitsRead20.to_ulong();
710 break;
711 default: {
712 std::cout << "SerializeInteger Out of range!!" << std::endl;
713 exit(1);
714 }
715 }
716
717 *n += nmin;
718
719 return bIterator;
720}
721
724 bool isExtensionMarkerPresent,
725 int* selectedOption,
726 Buffer::Iterator bIterator)
727{
728 if (isExtensionMarkerPresent)
729 {
730 bool marker;
731 bIterator = DeserializeBoolean(&marker, bIterator);
732 }
733 return DeserializeInteger(selectedOption, 0, numOptions - 1, bIterator);
734}
735
737Asn1Header::DeserializeEnum(int numElems, int* selectedElem, Buffer::Iterator bIterator)
738{
739 return DeserializeInteger(selectedElem, 0, numElems - 1, bIterator);
740}
741
742template <int N>
744Asn1Header::DeserializeSequence(std::bitset<N>* optionalOrDefaultMask,
745 bool isExtensionMarkerPresent,
746 Buffer::Iterator bIterator)
747{
748 if (isExtensionMarkerPresent)
749 {
750 bool dummy;
751 bIterator = DeserializeBoolean(&dummy, bIterator);
752 }
753 bIterator = DeserializeBitset<N>(optionalOrDefaultMask, bIterator);
754 return bIterator;
755}
756
758Asn1Header::DeserializeSequence(std::bitset<0>* optionalOrDefaultMask,
759 bool isExtensionMarkerPresent,
760 Buffer::Iterator bIterator)
761{
762 return DeserializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
763}
764
766Asn1Header::DeserializeSequence(std::bitset<1>* optionalOrDefaultMask,
767 bool isExtensionMarkerPresent,
768 Buffer::Iterator bIterator)
769{
770 return DeserializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
771}
772
774Asn1Header::DeserializeSequence(std::bitset<2>* optionalOrDefaultMask,
775 bool isExtensionMarkerPresent,
776 Buffer::Iterator bIterator)
777{
778 return DeserializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
779}
780
782Asn1Header::DeserializeSequence(std::bitset<3>* optionalOrDefaultMask,
783 bool isExtensionMarkerPresent,
784 Buffer::Iterator bIterator)
785{
786 return DeserializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
787}
788
790Asn1Header::DeserializeSequence(std::bitset<4>* optionalOrDefaultMask,
791 bool isExtensionMarkerPresent,
792 Buffer::Iterator bIterator)
793{
794 return DeserializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
795}
796
798Asn1Header::DeserializeSequence(std::bitset<5>* optionalOrDefaultMask,
799 bool isExtensionMarkerPresent,
800 Buffer::Iterator bIterator)
801{
802 return DeserializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
803}
804
806Asn1Header::DeserializeSequence(std::bitset<6>* optionalOrDefaultMask,
807 bool isExtensionMarkerPresent,
808 Buffer::Iterator bIterator)
809{
810 return DeserializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
811}
812
814Asn1Header::DeserializeSequence(std::bitset<7>* optionalOrDefaultMask,
815 bool isExtensionMarkerPresent,
816 Buffer::Iterator bIterator)
817{
818 return DeserializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
819}
820
822Asn1Header::DeserializeSequence(std::bitset<9>* optionalOrDefaultMask,
823 bool isExtensionMarkerPresent,
824 Buffer::Iterator bIterator)
825{
826 return DeserializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
827}
828
830Asn1Header::DeserializeSequence(std::bitset<10>* optionalOrDefaultMask,
831 bool isExtensionMarkerPresent,
832 Buffer::Iterator bIterator)
833{
834 return DeserializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
835}
836
838Asn1Header::DeserializeSequence(std::bitset<11>* optionalOrDefaultMask,
839 bool isExtensionMarkerPresent,
840 Buffer::Iterator bIterator)
841{
842 return DeserializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
843}
844
847{
848 return bIterator;
849}
850
852Asn1Header::DeserializeSequenceOf(int* numElems, int nMax, int nMin, Buffer::Iterator bIterator)
853{
854 return DeserializeInteger(numElems, nMin, nMax, bIterator);
855}
856
857} // namespace ns3
Buffer::Iterator DeserializeBitset(std::bitset< N > *data, Buffer::Iterator bIterator)
Deserialize a bitset.
Buffer::Iterator DeserializeChoice(int numOptions, bool isExtensionMarkerPresent, int *selectedOption, Buffer::Iterator bIterator)
Deserialize a Choice (set of options)
static TypeId GetTypeId()
Get the type ID.
Buffer::Iterator DeserializeSequenceOf(int *numElems, int nMax, int nMin, Buffer::Iterator bIterator)
Deserialize a Sequence.
Buffer::Iterator DeserializeNull(Buffer::Iterator bIterator)
Deserialize nothing (null op)
void WriteOctet(uint8_t octet) const
Function to write in m_serializationResult, after resizing its size.
void SerializeBitset(std::bitset< N > data) const
Serialize a bitset.
Buffer::Iterator DeserializeInteger(int *n, int nmin, int nmax, Buffer::Iterator bIterator)
Deserialize an integer.
TypeId GetInstanceTypeId() const override
Get the most derived TypeId for this Object.
void SerializeBitstring(std::bitset< N > bitstring) const
Serialize a bitstring.
Buffer::Iterator DeserializeEnum(int numElems, int *selectedElem, Buffer::Iterator bIterator)
Deserialize an Enum.
virtual void PreSerialize() const =0
This function serializes class attributes to m_serializationResult local Buffer.
Buffer::Iterator DeserializeSequence(std::bitset< N > *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
Deserialize a sequence.
uint8_t m_numSerializationPendingBits
number of pending bits
void SerializeSequence(std::bitset< N > optionalOrDefaultMask, bool isExtensionMarkerPresent) const
Serialize a sequence.
void SerializeChoice(int numOptions, int selectedOption, bool isExtensionMarkerPresent) const
Serialize a Choice (set of options)
Buffer m_serializationResult
serialization result
void FinalizeSerialization() const
Finalizes an in progress serialization.
~Asn1Header() override
void SerializeInteger(int n, int nmin, int nmax) const
Serialize an Integer.
Buffer::Iterator DeserializeBoolean(bool *value, Buffer::Iterator bIterator)
Deserialize a boolean.
uint8_t m_serializationPendingBits
pending bits
uint32_t GetSerializedSize() const override
void Serialize(Buffer::Iterator bIterator) const override
void SerializeBoolean(bool value) const
Serialize a bool.
Buffer::Iterator DeserializeBitstring(std::bitset< N > *bitstring, Buffer::Iterator bIterator)
Deserialize a bitstring.
void SerializeNull() const
Serialize nothing (null op)
bool m_isDataSerialized
true if data is serialized
void SerializeSequenceOf(int numElems, int nMax, int nMin) const
Serialize a Sequence.
void SerializeEnum(int numElems, int selectedElem) const
Serialize an Enum.
iterator in a Buffer instance
Definition: buffer.h:100
uint8_t ReadU8()
Definition: buffer.h:1027
void WriteU8(uint8_t data)
Definition: buffer.h:881
void Write(const uint8_t *buffer, uint32_t size)
Definition: buffer.cc:954
void Prev()
go backward by one byte
Definition: buffer.h:860
uint32_t GetSize() const
Definition: buffer.h:1068
Buffer::Iterator Begin() const
Definition: buffer.h:1074
void AddAtEnd(uint32_t end)
Definition: buffer.cc:360
Buffer::Iterator End() const
Definition: buffer.h:1081
Protocol header serialization and deserialization.
Definition: header.h:44
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t data[writeSize]