A Discrete-Event Network Simulator
API
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 
27 namespace ns3
28 {
29 
30 NS_LOG_COMPONENT_DEFINE("Asn1Header");
31 
32 NS_OBJECT_ENSURE_REGISTERED(Asn1Header);
33 
34 TypeId
36 {
37  static TypeId tid = TypeId("ns3::Asn1Header").SetParent<Header>().SetGroupName("Lte");
38  return tid;
39 }
40 
41 TypeId
43 {
44  return GetTypeId();
45 }
46 
48 {
51  m_isDataSerialized = false;
52 }
53 
55 {
56 }
57 
58 uint32_t
60 {
61  if (!m_isDataSerialized)
62  {
63  PreSerialize();
64  }
66 }
67 
68 void
70 {
71  if (!m_isDataSerialized)
72  {
73  PreSerialize();
74  }
76 }
77 
78 void
79 Asn1Header::WriteOctet(uint8_t octet) const
80 {
83  bIterator.Prev();
84  bIterator.WriteU8(octet);
85 }
86 
87 template <int N>
88 void
89 Asn1Header::SerializeBitset(std::bitset<N> data) const
90 {
91  size_t dataSize = data.size();
92  uint8_t pendingBits = dataSize;
93  uint8_t mask = 1;
94  int j;
95 
96  // No extension marker (Clause 16.7 ITU-T X.691),
97  // as 3GPP TS 36.331 does not use it in its IE's.
98 
99  // Clause 16.8 ITU-T X.691
100  if (dataSize == 0)
101  {
102  return;
103  }
104 
105  // Clause 16.9 ITU-T X.691
106  // Clause 16.10 ITU-T X.691
107  if (dataSize <= 65536)
108  {
109  // If there are bits pending to be processed,
110  // append first bits in data to complete an octet.
112  {
113  mask = 0x80 >> m_numSerializationPendingBits;
114  while (pendingBits > 0 && m_numSerializationPendingBits < 8)
115  {
116  m_serializationPendingBits |= (data[pendingBits - 1]) ? mask : 0;
117  pendingBits--;
119  mask = (mask >> 1) & (~mask);
120  }
121 
123  {
127  }
128  }
129 
130  while (pendingBits > 0)
131  {
132  mask = 1;
133  j = 8;
134 
135  // If there are less than 8 remaining bits,
136  // store it to m_serializationPendingBits.
137  if (pendingBits < 8)
138  {
139  mask = 0x80;
140  m_numSerializationPendingBits = pendingBits;
141  while (pendingBits > 0)
142  {
143  m_serializationPendingBits |= (data[pendingBits - 1]) ? mask : 0;
144  mask = (mask >> 1) & (~mask);
145  pendingBits--;
146  }
147  }
148 
149  // Write the data to buffer
150  else
151  {
152  uint8_t octetToWrite = 0;
153  for (; j > 0; j--)
154  {
155  octetToWrite |= (data[pendingBits - j]) ? mask : 0;
156  mask = (mask << 1) & (~mask);
157  }
158  WriteOctet(octetToWrite);
159  pendingBits -= 8;
160  }
161  }
162  }
163 
164  // Clause 16.11 ITU-T X.691
165  else
166  {
167  NS_LOG_DEBUG("Fragmentation needed!");
168  }
169 }
170 
171 template <int N>
172 void
174 {
175  SerializeBitset<N>(data);
176 }
177 
178 void
180 {
181  SerializeBitstring<1>(data);
182 }
183 
184 void
186 {
187  SerializeBitstring<2>(data);
188 }
189 
190 void
192 {
193  SerializeBitstring<8>(data);
194 }
195 
196 void
197 Asn1Header::SerializeBitstring(std::bitset<10> data) const
198 {
199  SerializeBitstring<10>(data);
200 }
201 
202 void
203 Asn1Header::SerializeBitstring(std::bitset<16> data) const
204 {
205  SerializeBitstring<16>(data);
206 }
207 
208 void
209 Asn1Header::SerializeBitstring(std::bitset<27> data) const
210 {
211  SerializeBitstring<27>(data);
212 }
213 
214 void
215 Asn1Header::SerializeBitstring(std::bitset<28> data) const
216 {
217  SerializeBitstring<28>(data);
218 }
219 
220 void
221 Asn1Header::SerializeBitstring(std::bitset<32> data) const
222 {
223  SerializeBitstring<32>(data);
224 }
225 
226 void
228 {
229  // Clause 12 ITU-T X.691
230  std::bitset<1> val;
231  (value) ? val.set() : val.reset();
232  SerializeBitset<1>(val);
233 }
234 
235 template <int N>
236 void
237 Asn1Header::SerializeSequence(std::bitset<N> optionalOrDefaultMask,
238  bool isExtensionMarkerPresent) const
239 {
240  if (isExtensionMarkerPresent)
241  {
242  // Extension marker present, but no extension
243  SerializeBoolean(false);
244  }
245  SerializeBitstring<N>(optionalOrDefaultMask);
246 }
247 
248 void
249 Asn1Header::SerializeSequence(std::bitset<0> optionalOrDefaultMask,
250  bool isExtensionMarkerPresent) const
251 {
252  SerializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent);
253 }
254 
255 void
256 Asn1Header::SerializeSequence(std::bitset<1> optionalOrDefaultMask,
257  bool isExtensionMarkerPresent) const
258 {
259  SerializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent);
260 }
261 
262 void
263 Asn1Header::SerializeSequence(std::bitset<2> optionalOrDefaultMask,
264  bool isExtensionMarkerPresent) const
265 {
266  SerializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent);
267 }
268 
269 void
270 Asn1Header::SerializeSequence(std::bitset<3> optionalOrDefaultMask,
271  bool isExtensionMarkerPresent) const
272 {
273  SerializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent);
274 }
275 
276 void
277 Asn1Header::SerializeSequence(std::bitset<4> optionalOrDefaultMask,
278  bool isExtensionMarkerPresent) const
279 {
280  SerializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent);
281 }
282 
283 void
284 Asn1Header::SerializeSequence(std::bitset<5> optionalOrDefaultMask,
285  bool isExtensionMarkerPresent) const
286 {
287  SerializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent);
288 }
289 
290 void
291 Asn1Header::SerializeSequence(std::bitset<6> optionalOrDefaultMask,
292  bool isExtensionMarkerPresent) const
293 {
294  SerializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent);
295 }
296 
297 void
298 Asn1Header::SerializeSequence(std::bitset<7> optionalOrDefaultMask,
299  bool isExtensionMarkerPresent) const
300 {
301  SerializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent);
302 }
303 
304 void
305 Asn1Header::SerializeSequence(std::bitset<9> optionalOrDefaultMask,
306  bool isExtensionMarkerPresent) const
307 {
308  SerializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent);
309 }
310 
311 void
312 Asn1Header::SerializeSequence(std::bitset<10> optionalOrDefaultMask,
313  bool isExtensionMarkerPresent) const
314 {
315  SerializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent);
316 }
317 
318 void
319 Asn1Header::SerializeSequence(std::bitset<11> optionalOrDefaultMask,
320  bool isExtensionMarkerPresent) const
321 {
322  SerializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent);
323 }
324 
325 void
326 Asn1Header::SerializeSequenceOf(int numElems, int nMax, int nMin) const
327 {
328  // Clause 20.6 ITU-T X.691
329  SerializeInteger(numElems, nMin, nMax);
330 }
331 
332 void
333 Asn1Header::SerializeEnum(int numElems, int selectedElem) const
334 {
335  // Clause 14 ITU-T X.691
336  SerializeInteger(selectedElem, 0, numElems - 1);
337 }
338 
339 void
340 Asn1Header::SerializeChoice(int numOptions, int selectedOption, bool isExtensionMarkerPresent) const
341 {
342  if (isExtensionMarkerPresent)
343  {
344  // Never extended attributes
345  SerializeBoolean(false);
346  }
347 
348  // Clause 23.4 ITU-T X.691
349  if (numOptions < 2)
350  {
351  return;
352  }
353 
354  SerializeInteger(selectedOption, 0, numOptions - 1);
355 }
356 
357 void
358 Asn1Header::SerializeInteger(int n, int nmin, int nmax) const
359 {
360  // The following is equivalent to:
361  // NS_ASSERT_MSG (nmin <= n && n <= nmax,
362  // "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
363  // This is a workaround to gcc-7 aggressive optimization, see #346, and can be dropped
364  // once gcc-7 will not be anymore supported.
365  long int nComp = nmin;
366  nComp -= n;
367  NS_ASSERT_MSG(nComp <= 0 && n <= nmax,
368  "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
369 
370  // Clause 11.5.3 ITU-T X.691
371  int range = nmax - nmin + 1;
372  // Subtract nmin to n
373  n -= nmin;
374 
375  // Clause 11.5.4 ITU-T X.691
376  if (range <= 1)
377  {
378  return;
379  }
380 
381  // Clause 11.5.6 ITU-T X.691
382  int requiredBits = std::ceil(std::log(range) / std::log(2.0));
383 
384  switch (requiredBits)
385  {
386  case 1:
387  SerializeBitset<1>(std::bitset<1>(n));
388  break;
389  case 2:
390  SerializeBitset<2>(std::bitset<2>(n));
391  break;
392  case 3:
393  SerializeBitset<3>(std::bitset<3>(n));
394  break;
395  case 4:
396  SerializeBitset<4>(std::bitset<4>(n));
397  break;
398  case 5:
399  SerializeBitset<5>(std::bitset<5>(n));
400  break;
401  case 6:
402  SerializeBitset<6>(std::bitset<6>(n));
403  break;
404  case 7:
405  SerializeBitset<7>(std::bitset<7>(n));
406  break;
407  case 8:
408  SerializeBitset<8>(std::bitset<8>(n));
409  break;
410  case 9:
411  SerializeBitset<9>(std::bitset<9>(n));
412  break;
413  case 10:
414  SerializeBitset<10>(std::bitset<10>(n));
415  break;
416  case 11:
417  SerializeBitset<11>(std::bitset<11>(n));
418  break;
419  case 12:
420  SerializeBitset<12>(std::bitset<12>(n));
421  break;
422  case 13:
423  SerializeBitset<13>(std::bitset<13>(n));
424  break;
425  case 14:
426  SerializeBitset<14>(std::bitset<14>(n));
427  break;
428  case 15:
429  SerializeBitset<15>(std::bitset<15>(n));
430  break;
431  case 16:
432  SerializeBitset<16>(std::bitset<16>(n));
433  break;
434  case 17:
435  SerializeBitset<17>(std::bitset<17>(n));
436  break;
437  case 18:
438  SerializeBitset<18>(std::bitset<18>(n));
439  break;
440  case 19:
441  SerializeBitset<19>(std::bitset<19>(n));
442  break;
443  case 20:
444  SerializeBitset<20>(std::bitset<20>(n));
445  break;
446  default: {
447  std::cout << "SerializeInteger " << requiredBits << " Out of range!!" << std::endl;
448  exit(1);
449  }
450  }
451 }
452 
453 void
455 {
456  // Clause 18 ITU-T X.691
457 }
458 
459 void
461 {
463  {
465  SerializeBitset<8>(std::bitset<8>(m_serializationPendingBits));
466  }
467  m_isDataSerialized = true;
468 }
469 
470 template <int N>
473 {
474  int bitsToRead = N;
475  uint8_t mask;
476 
477  // Read bits from pending bits
479  {
480  while (bitsToRead > 0 && m_numSerializationPendingBits > 0)
481  {
482  data->set(bitsToRead - 1, (m_serializationPendingBits & 0x80) ? 1 : 0);
483  bitsToRead--;
486  }
487  }
488 
489  // Read bits from buffer
490  while (bitsToRead > 0)
491  {
492  uint8_t octet = bIterator.ReadU8();
493  // If 8 bits can be allocated to the bitset, set the bits
494  if (bitsToRead >= 8)
495  {
496  mask = 0x80;
497  for (int j = 0; j < 8; j++)
498  {
499  data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
500  bitsToRead--;
501  mask = mask >> 1;
502  }
503  }
504 
505  // Otherwise, we'll have to save the remaining bits
506  else
507  {
508  mask = 0x80;
509  m_numSerializationPendingBits = 8 - bitsToRead;
510  m_serializationPendingBits = octet << bitsToRead;
511  while (bitsToRead > 0)
512  {
513  data->set(bitsToRead - 1, (octet & mask) ? 1 : 0);
514  bitsToRead--;
515  mask = mask >> 1;
516  }
517  }
518  }
519 
520  return bIterator;
521 }
522 
523 template <int N>
526 {
527  return DeserializeBitset<N>(data, bIterator);
528 }
529 
532 {
533  return DeserializeBitstring<1>(data, bIterator);
534 }
535 
538 {
539  return DeserializeBitstring<2>(data, bIterator);
540 }
541 
544 {
545  return DeserializeBitstring<8>(data, bIterator);
546 }
547 
550 {
551  return DeserializeBitstring<10>(data, bIterator);
552 }
553 
556 {
557  return DeserializeBitstring<16>(data, bIterator);
558 }
559 
562 {
563  return DeserializeBitstring<27>(data, bIterator);
564 }
565 
568 {
569  return DeserializeBitstring<28>(data, bIterator);
570 }
571 
574 {
575  return DeserializeBitstring<32>(data, bIterator);
576 }
577 
580 {
581  std::bitset<1> readBit;
582  bIterator = DeserializeBitset<1>(&readBit, bIterator);
583  *value = (readBit[0] == 1);
584  return bIterator;
585 }
586 
588 Asn1Header::DeserializeInteger(int* n, int nmin, int nmax, Buffer::Iterator bIterator)
589 {
590  // Misusage check: Ensure nmax>nmin ...
591  if (nmin > nmax)
592  {
593  int aux = nmin;
594  nmin = nmax;
595  nmax = aux;
596  }
597 
598  int range = nmax - nmin + 1;
599 
600  if (range == 1)
601  {
602  return bIterator;
603  }
604 
605  int requiredBits = std::ceil(std::log(range) / std::log(2.0));
606 
607  std::bitset<1> bitsRead1;
608  std::bitset<2> bitsRead2;
609  std::bitset<3> bitsRead3;
610  std::bitset<4> bitsRead4;
611  std::bitset<5> bitsRead5;
612  std::bitset<6> bitsRead6;
613  std::bitset<7> bitsRead7;
614  std::bitset<8> bitsRead8;
615  std::bitset<9> bitsRead9;
616  std::bitset<10> bitsRead10;
617  std::bitset<11> bitsRead11;
618  std::bitset<12> bitsRead12;
619  std::bitset<13> bitsRead13;
620  std::bitset<14> bitsRead14;
621  std::bitset<15> bitsRead15;
622  std::bitset<16> bitsRead16;
623  std::bitset<17> bitsRead17;
624  std::bitset<18> bitsRead18;
625  std::bitset<19> bitsRead19;
626  std::bitset<20> bitsRead20;
627 
628  switch (requiredBits)
629  {
630  case 1:
631  bIterator = DeserializeBitset<1>(&bitsRead1, bIterator);
632  *n = (int)bitsRead1.to_ulong();
633  break;
634  case 2:
635  bIterator = DeserializeBitset<2>(&bitsRead2, bIterator);
636  *n = (int)bitsRead2.to_ulong();
637  break;
638  case 3:
639  bIterator = DeserializeBitset<3>(&bitsRead3, bIterator);
640  *n = (int)bitsRead3.to_ulong();
641  break;
642  case 4:
643  bIterator = DeserializeBitset<4>(&bitsRead4, bIterator);
644  *n = (int)bitsRead4.to_ulong();
645  break;
646  case 5:
647  bIterator = DeserializeBitset<5>(&bitsRead5, bIterator);
648  *n = (int)bitsRead5.to_ulong();
649  break;
650  case 6:
651  bIterator = DeserializeBitset<6>(&bitsRead6, bIterator);
652  *n = (int)bitsRead6.to_ulong();
653  break;
654  case 7:
655  bIterator = DeserializeBitset<7>(&bitsRead7, bIterator);
656  *n = (int)bitsRead7.to_ulong();
657  break;
658  case 8:
659  bIterator = DeserializeBitset<8>(&bitsRead8, bIterator);
660  *n = (int)bitsRead8.to_ulong();
661  break;
662  case 9:
663  bIterator = DeserializeBitset<9>(&bitsRead9, bIterator);
664  *n = (int)bitsRead9.to_ulong();
665  break;
666  case 10:
667  bIterator = DeserializeBitset<10>(&bitsRead10, bIterator);
668  *n = (int)bitsRead10.to_ulong();
669  break;
670  case 11:
671  bIterator = DeserializeBitset<11>(&bitsRead11, bIterator);
672  *n = (int)bitsRead11.to_ulong();
673  break;
674  case 12:
675  bIterator = DeserializeBitset<12>(&bitsRead12, bIterator);
676  *n = (int)bitsRead12.to_ulong();
677  break;
678  case 13:
679  bIterator = DeserializeBitset<13>(&bitsRead13, bIterator);
680  *n = (int)bitsRead13.to_ulong();
681  break;
682  case 14:
683  bIterator = DeserializeBitset<14>(&bitsRead14, bIterator);
684  *n = (int)bitsRead14.to_ulong();
685  break;
686  case 15:
687  bIterator = DeserializeBitset<15>(&bitsRead15, bIterator);
688  *n = (int)bitsRead15.to_ulong();
689  break;
690  case 16:
691  bIterator = DeserializeBitset<16>(&bitsRead16, bIterator);
692  *n = (int)bitsRead16.to_ulong();
693  break;
694  case 17:
695  bIterator = DeserializeBitset<17>(&bitsRead17, bIterator);
696  *n = (int)bitsRead17.to_ulong();
697  break;
698  case 18:
699  bIterator = DeserializeBitset<18>(&bitsRead18, bIterator);
700  *n = (int)bitsRead18.to_ulong();
701  break;
702  case 19:
703  bIterator = DeserializeBitset<19>(&bitsRead19, bIterator);
704  *n = (int)bitsRead19.to_ulong();
705  break;
706  case 20:
707  bIterator = DeserializeBitset<20>(&bitsRead20, bIterator);
708  *n = (int)bitsRead20.to_ulong();
709  break;
710  default: {
711  std::cout << "SerializeInteger Out of range!!" << std::endl;
712  exit(1);
713  }
714  }
715 
716  *n += nmin;
717 
718  return bIterator;
719 }
720 
723  bool isExtensionMarkerPresent,
724  int* selectedOption,
725  Buffer::Iterator bIterator)
726 {
727  if (isExtensionMarkerPresent)
728  {
729  bool marker;
730  bIterator = DeserializeBoolean(&marker, bIterator);
731  }
732  return DeserializeInteger(selectedOption, 0, numOptions - 1, bIterator);
733 }
734 
736 Asn1Header::DeserializeEnum(int numElems, int* selectedElem, Buffer::Iterator bIterator)
737 {
738  return DeserializeInteger(selectedElem, 0, numElems - 1, bIterator);
739 }
740 
741 template <int N>
743 Asn1Header::DeserializeSequence(std::bitset<N>* optionalOrDefaultMask,
744  bool isExtensionMarkerPresent,
745  Buffer::Iterator bIterator)
746 {
747  if (isExtensionMarkerPresent)
748  {
749  bool dummy;
750  bIterator = DeserializeBoolean(&dummy, bIterator);
751  }
752  bIterator = DeserializeBitset<N>(optionalOrDefaultMask, bIterator);
753  return bIterator;
754 }
755 
757 Asn1Header::DeserializeSequence(std::bitset<0>* optionalOrDefaultMask,
758  bool isExtensionMarkerPresent,
759  Buffer::Iterator bIterator)
760 {
761  return DeserializeSequence<0>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
762 }
763 
765 Asn1Header::DeserializeSequence(std::bitset<1>* optionalOrDefaultMask,
766  bool isExtensionMarkerPresent,
767  Buffer::Iterator bIterator)
768 {
769  return DeserializeSequence<1>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
770 }
771 
773 Asn1Header::DeserializeSequence(std::bitset<2>* optionalOrDefaultMask,
774  bool isExtensionMarkerPresent,
775  Buffer::Iterator bIterator)
776 {
777  return DeserializeSequence<2>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
778 }
779 
781 Asn1Header::DeserializeSequence(std::bitset<3>* optionalOrDefaultMask,
782  bool isExtensionMarkerPresent,
783  Buffer::Iterator bIterator)
784 {
785  return DeserializeSequence<3>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
786 }
787 
789 Asn1Header::DeserializeSequence(std::bitset<4>* optionalOrDefaultMask,
790  bool isExtensionMarkerPresent,
791  Buffer::Iterator bIterator)
792 {
793  return DeserializeSequence<4>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
794 }
795 
797 Asn1Header::DeserializeSequence(std::bitset<5>* optionalOrDefaultMask,
798  bool isExtensionMarkerPresent,
799  Buffer::Iterator bIterator)
800 {
801  return DeserializeSequence<5>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
802 }
803 
805 Asn1Header::DeserializeSequence(std::bitset<6>* optionalOrDefaultMask,
806  bool isExtensionMarkerPresent,
807  Buffer::Iterator bIterator)
808 {
809  return DeserializeSequence<6>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
810 }
811 
813 Asn1Header::DeserializeSequence(std::bitset<7>* optionalOrDefaultMask,
814  bool isExtensionMarkerPresent,
815  Buffer::Iterator bIterator)
816 {
817  return DeserializeSequence<7>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
818 }
819 
821 Asn1Header::DeserializeSequence(std::bitset<9>* optionalOrDefaultMask,
822  bool isExtensionMarkerPresent,
823  Buffer::Iterator bIterator)
824 {
825  return DeserializeSequence<9>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
826 }
827 
829 Asn1Header::DeserializeSequence(std::bitset<10>* optionalOrDefaultMask,
830  bool isExtensionMarkerPresent,
831  Buffer::Iterator bIterator)
832 {
833  return DeserializeSequence<10>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
834 }
835 
837 Asn1Header::DeserializeSequence(std::bitset<11>* optionalOrDefaultMask,
838  bool isExtensionMarkerPresent,
839  Buffer::Iterator bIterator)
840 {
841  return DeserializeSequence<11>(optionalOrDefaultMask, isExtensionMarkerPresent, bIterator);
842 }
843 
846 {
847  return bIterator;
848 }
849 
851 Asn1Header::DeserializeSequenceOf(int* numElems, int nMax, int nMin, Buffer::Iterator bIterator)
852 {
853  return DeserializeInteger(numElems, nMin, nMax, bIterator);
854 }
855 
856 } // 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:948
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:931
#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_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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]