A Discrete-Event Network Simulator
API
lte-asn1-header.cc
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Lluis Parcerisa <lparcerisa@cttc.cat>
19  */
20 
21 #include "ns3/log.h"
22 #include "ns3/lte-asn1-header.h"
23 
24 #include <stdio.h>
25 #include <sstream>
26 #include <cmath>
27 
28 namespace ns3 {
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")
38  .SetParent<Header> ()
39  .SetGroupName("Lte")
40  ;
41  return tid;
42 }
43 
44 TypeId
46 {
47  return GetTypeId ();
48 }
49 
51 {
54  m_isDataSerialized = false;
55 }
56 
58 {
59 }
60 
61 uint32_t
63 {
64  if (!m_isDataSerialized)
65  {
66  PreSerialize ();
67  }
69 }
70 
72 {
73  if (!m_isDataSerialized)
74  {
75  PreSerialize ();
76  }
78 }
79 
80 void Asn1Header::WriteOctet (uint8_t octet) const
81 {
84  bIterator.Prev ();
85  bIterator.WriteU8 (octet);
86 }
87 
88 template <int N>
89 void Asn1Header::SerializeBitset (std::bitset<N> data) const
90 {
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 
172 template <int N>
173 void Asn1Header::SerializeBitstring (std::bitset<N> data) const
174 {
175  SerializeBitset<N> (data);
176 }
177 
178 
179 void Asn1Header::SerializeBitstring (std::bitset<1> data) const
180 {
181  SerializeBitstring<1> (data);
182 }
183 
184 void Asn1Header::SerializeBitstring (std::bitset<2> data) const
185 {
186  SerializeBitstring<2> (data);
187 }
188 
189 void Asn1Header::SerializeBitstring (std::bitset<8> data) const
190 {
191  SerializeBitstring<8> (data);
192 }
193 
194 void Asn1Header::SerializeBitstring (std::bitset<10> data) const
195 {
196  SerializeBitstring<10> (data);
197 }
198 
199 void Asn1Header::SerializeBitstring (std::bitset<16> data) const
200 {
201  SerializeBitstring<16> (data);
202 }
203 
204 void Asn1Header::SerializeBitstring (std::bitset<27> data) const
205 {
206  SerializeBitstring<27> (data);
207 }
208 
209 void Asn1Header::SerializeBitstring (std::bitset<28> data) const
210 {
211  SerializeBitstring<28> (data);
212 }
213 
214 void Asn1Header::SerializeBitstring (std::bitset<32> data) const
215 {
216  SerializeBitstring<32> (data);
217 }
218 
219 void Asn1Header::SerializeBoolean (bool value) const
220 {
221  // Clause 12 ITU-T X.691
222  std::bitset<1> val;
223  (value) ? val.set () : val.reset ();
224  SerializeBitset<1> (val);
225 }
226 
227 template <int N>
228 void Asn1Header::SerializeSequence (std::bitset<N> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
229 {
230  if (isExtensionMarkerPresent)
231  {
232  // Extension marker present, but no extension
233  SerializeBoolean (false);
234  }
235  SerializeBitstring<N> (optionalOrDefaultMask);
236 }
237 
238 void Asn1Header::SerializeSequence (std::bitset<0> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
239 {
240  SerializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent);
241 }
242 
243 void Asn1Header::SerializeSequence (std::bitset<1> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
244 {
245  SerializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent);
246 }
247 
248 void Asn1Header::SerializeSequence (std::bitset<2> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
249 {
250  SerializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent);
251 }
252 
253 void Asn1Header::SerializeSequence (std::bitset<3> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
254 {
255  SerializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent);
256 }
257 
258 void Asn1Header::SerializeSequence (std::bitset<4> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
259 {
260  SerializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent);
261 }
262 
263 void Asn1Header::SerializeSequence (std::bitset<5> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
264 {
265  SerializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent);
266 }
267 
268 void Asn1Header::SerializeSequence (std::bitset<6> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
269 {
270  SerializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent);
271 }
272 
273 void Asn1Header::SerializeSequence (std::bitset<7> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
274 {
275  SerializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent);
276 }
277 
278 void Asn1Header::SerializeSequence (std::bitset<9> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
279 {
280  SerializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent);
281 }
282 
283 void Asn1Header::SerializeSequence (std::bitset<10> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
284 {
285  SerializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent);
286 }
287 
288 void Asn1Header::SerializeSequence (std::bitset<11> optionalOrDefaultMask, bool isExtensionMarkerPresent) const
289 {
290  SerializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent);
291 }
292 
293 void Asn1Header::SerializeSequenceOf (int numElems, int nMax, int nMin) const
294 {
295  // Clause 20.6 ITU-T X.691
296  SerializeInteger (numElems, nMin, nMax);
297 }
298 
299 void Asn1Header::SerializeEnum (int numElems, int selectedElem) const
300 {
301  // Clause 14 ITU-T X.691
302  SerializeInteger (selectedElem, 0, numElems - 1);
303 }
304 
305 void Asn1Header::SerializeChoice (int numOptions, int selectedOption, bool isExtensionMarkerPresent) const
306 {
307  if(isExtensionMarkerPresent)
308  {
309  // Never extended attributes
310  SerializeBoolean(false);
311  }
312 
313  // Clause 23.4 ITU-T X.691
314  if (numOptions < 2)
315  {
316  return;
317  }
318 
319  SerializeInteger (selectedOption,0,numOptions - 1);
320 }
321 
322 void Asn1Header::SerializeInteger (int n, int nmin, int nmax) const
323 {
324  // The following is equivalent to:
325  // NS_ASSERT_MSG (nmin <= n && n <= nmax,
326  // "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
327  // This is a workaround to gcc-7 aggressive optimization, see #346, and can be dropped
328  // once gcc-7 will not be anymore supported.
329  long int nComp = nmin;
330  nComp -= n;
331  NS_ASSERT_MSG (nComp <= 0 && n <= nmax,
332  "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
333 
334  // Clause 11.5.3 ITU-T X.691
335  int range = nmax - nmin + 1;
336  // Subtract nmin to n
337  n -= nmin;
338 
339  // Clause 11.5.4 ITU-T X.691
340  if (range <= 1)
341  {
342  return;
343  }
344 
345  // Clause 11.5.6 ITU-T X.691
346  int requiredBits = std::ceil (std::log (range) / std::log (2.0));
347 
348  switch (requiredBits)
349  {
350  case 1:
351  SerializeBitset<1> (std::bitset<1> (n));
352  break;
353  case 2:
354  SerializeBitset<2> (std::bitset<2> (n));
355  break;
356  case 3:
357  SerializeBitset<3> (std::bitset<3> (n));
358  break;
359  case 4:
360  SerializeBitset<4> (std::bitset<4> (n));
361  break;
362  case 5:
363  SerializeBitset<5> (std::bitset<5> (n));
364  break;
365  case 6:
366  SerializeBitset<6> (std::bitset<6> (n));
367  break;
368  case 7:
369  SerializeBitset<7> (std::bitset<7> (n));
370  break;
371  case 8:
372  SerializeBitset<8> (std::bitset<8> (n));
373  break;
374  case 9:
375  SerializeBitset<9> (std::bitset<9> (n));
376  break;
377  case 10:
378  SerializeBitset<10> (std::bitset<10> (n));
379  break;
380  case 11:
381  SerializeBitset<11> (std::bitset<11> (n));
382  break;
383  case 12:
384  SerializeBitset<12> (std::bitset<12> (n));
385  break;
386  case 13:
387  SerializeBitset<13> (std::bitset<13> (n));
388  break;
389  case 14:
390  SerializeBitset<14> (std::bitset<14> (n));
391  break;
392  case 15:
393  SerializeBitset<15> (std::bitset<15> (n));
394  break;
395  case 16:
396  SerializeBitset<16> (std::bitset<16> (n));
397  break;
398  case 17:
399  SerializeBitset<17> (std::bitset<17> (n));
400  break;
401  case 18:
402  SerializeBitset<18> (std::bitset<18> (n));
403  break;
404  case 19:
405  SerializeBitset<19> (std::bitset<19> (n));
406  break;
407  case 20:
408  SerializeBitset<20> (std::bitset<20> (n));
409  break;
410  default:
411  {
412  std::cout << "SerializeInteger " << requiredBits << " Out of range!!" << std::endl;
413  exit (1);
414  }
415  }
416 }
417 
419 {
420  // Clause 18 ITU-T X.691
421  return;
422 }
423 
425 {
427  {
429  SerializeBitset<8> (std::bitset<8> (m_serializationPendingBits));
430  }
431  m_isDataSerialized = true;
432 }
433 
434 template <int N>
436 {
437 
438  int bitsToRead = N;
439  uint8_t mask;
440 
441  // Read bits from pending bits
443  {
444  while (bitsToRead > 0 && m_numSerializationPendingBits > 0)
445  {
446  data->set (bitsToRead - 1,(m_serializationPendingBits & 0x80) ? 1 : 0);
447  bitsToRead--;
450  }
451  }
452 
453  // Read bits from buffer
454  while (bitsToRead > 0)
455  {
456  uint8_t octet = bIterator.ReadU8 ();
457  // If 8 bits can be allocated to the bitset, set the bits
458  if (bitsToRead >= 8)
459  {
460  mask = 0x80;
461  for (int j = 0; j < 8; j++)
462  {
463  data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
464  bitsToRead--;
465  mask = mask >> 1;
466  }
467  }
468 
469  // Otherwise, we'll have to save the remaining bits
470  else
471  {
472  mask = 0x80;
473  m_numSerializationPendingBits = 8 - bitsToRead;
474  m_serializationPendingBits = octet << bitsToRead;
475  while (bitsToRead > 0)
476  {
477  data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
478  bitsToRead--;
479  mask = mask >> 1;
480  }
481  }
482  }
483 
484  return bIterator;
485 }
486 
487 template <int N>
489 {
490  return DeserializeBitset<N> (data,bIterator);
491 }
492 
494 {
495  return DeserializeBitstring<1> (data,bIterator);
496 }
497 
499 {
500  return DeserializeBitstring<2> (data,bIterator);
501 }
502 
504 {
505  return DeserializeBitstring<8> (data,bIterator);
506 }
507 
509 {
510  return DeserializeBitstring<10> (data,bIterator);
511 }
512 
514 {
515  return DeserializeBitstring<16> (data,bIterator);
516 }
517 
519 {
520  return DeserializeBitstring<27> (data,bIterator);
521 }
522 
524 {
525  return DeserializeBitstring<28> (data,bIterator);
526 }
527 
529 {
530  return DeserializeBitstring<32> (data,bIterator);
531 }
532 
534 {
535  std::bitset<1> readBit;
536  bIterator = DeserializeBitset<1> (&readBit,bIterator);
537  *value = (readBit[0] == 1);
538  return bIterator;
539 }
540 
541 Buffer::Iterator Asn1Header::DeserializeInteger (int *n, int nmin, int nmax, Buffer::Iterator bIterator)
542 {
543  // Misusage check: Ensure nmax>nmin ...
544  if (nmin > nmax)
545  {
546  int aux = nmin;
547  nmin = nmax;
548  nmax = aux;
549  }
550 
551  int range = nmax - nmin + 1;
552 
553  if (range == 1)
554  {
555  return bIterator;
556  }
557 
558  int requiredBits = std::ceil (std::log (range) / std::log (2.0));
559 
560  std::bitset<1> bitsRead1;
561  std::bitset<2> bitsRead2;
562  std::bitset<3> bitsRead3;
563  std::bitset<4> bitsRead4;
564  std::bitset<5> bitsRead5;
565  std::bitset<6> bitsRead6;
566  std::bitset<7> bitsRead7;
567  std::bitset<8> bitsRead8;
568  std::bitset<9> bitsRead9;
569  std::bitset<10> bitsRead10;
570  std::bitset<11> bitsRead11;
571  std::bitset<12> bitsRead12;
572  std::bitset<13> bitsRead13;
573  std::bitset<14> bitsRead14;
574  std::bitset<15> bitsRead15;
575  std::bitset<16> bitsRead16;
576  std::bitset<17> bitsRead17;
577  std::bitset<18> bitsRead18;
578  std::bitset<19> bitsRead19;
579  std::bitset<20> bitsRead20;
580 
581  switch (requiredBits)
582  {
583  case 1:
584  bIterator = DeserializeBitset<1> (&bitsRead1,bIterator);
585  *n = (int)bitsRead1.to_ulong ();
586  break;
587  case 2:
588  bIterator = DeserializeBitset<2> (&bitsRead2,bIterator);
589  *n = (int)bitsRead2.to_ulong ();
590  break;
591  case 3:
592  bIterator = DeserializeBitset<3> (&bitsRead3,bIterator);
593  *n = (int)bitsRead3.to_ulong ();
594  break;
595  case 4:
596  bIterator = DeserializeBitset<4> (&bitsRead4,bIterator);
597  *n = (int)bitsRead4.to_ulong ();
598  break;
599  case 5:
600  bIterator = DeserializeBitset<5> (&bitsRead5,bIterator);
601  *n = (int)bitsRead5.to_ulong ();
602  break;
603  case 6:
604  bIterator = DeserializeBitset<6> (&bitsRead6,bIterator);
605  *n = (int)bitsRead6.to_ulong ();
606  break;
607  case 7:
608  bIterator = DeserializeBitset<7> (&bitsRead7,bIterator);
609  *n = (int)bitsRead7.to_ulong ();
610  break;
611  case 8:
612  bIterator = DeserializeBitset<8> (&bitsRead8,bIterator);
613  *n = (int)bitsRead8.to_ulong ();
614  break;
615  case 9:
616  bIterator = DeserializeBitset<9> (&bitsRead9,bIterator);
617  *n = (int)bitsRead9.to_ulong ();
618  break;
619  case 10:
620  bIterator = DeserializeBitset<10> (&bitsRead10,bIterator);
621  *n = (int)bitsRead10.to_ulong ();
622  break;
623  case 11:
624  bIterator = DeserializeBitset<11> (&bitsRead11,bIterator);
625  *n = (int)bitsRead11.to_ulong ();
626  break;
627  case 12:
628  bIterator = DeserializeBitset<12> (&bitsRead12,bIterator);
629  *n = (int)bitsRead12.to_ulong ();
630  break;
631  case 13:
632  bIterator = DeserializeBitset<13> (&bitsRead13,bIterator);
633  *n = (int)bitsRead13.to_ulong ();
634  break;
635  case 14:
636  bIterator = DeserializeBitset<14> (&bitsRead14,bIterator);
637  *n = (int)bitsRead14.to_ulong ();
638  break;
639  case 15:
640  bIterator = DeserializeBitset<15> (&bitsRead15,bIterator);
641  *n = (int)bitsRead15.to_ulong ();
642  break;
643  case 16:
644  bIterator = DeserializeBitset<16> (&bitsRead16,bIterator);
645  *n = (int)bitsRead16.to_ulong ();
646  break;
647  case 17:
648  bIterator = DeserializeBitset<17> (&bitsRead17,bIterator);
649  *n = (int)bitsRead17.to_ulong ();
650  break;
651  case 18:
652  bIterator = DeserializeBitset<18> (&bitsRead18,bIterator);
653  *n = (int)bitsRead18.to_ulong ();
654  break;
655  case 19:
656  bIterator = DeserializeBitset<19> (&bitsRead19,bIterator);
657  *n = (int)bitsRead19.to_ulong ();
658  break;
659  case 20:
660  bIterator = DeserializeBitset<20> (&bitsRead20,bIterator);
661  *n = (int)bitsRead20.to_ulong ();
662  break;
663  default:
664  {
665  std::cout << "SerializeInteger Out of range!!" << std::endl;
666  exit (1);
667  }
668  }
669 
670  *n += nmin;
671 
672  return bIterator;
673 }
674 
675 Buffer::Iterator Asn1Header::DeserializeChoice (int numOptions, bool isExtensionMarkerPresent, int *selectedOption, Buffer::Iterator bIterator)
676 {
677  if (isExtensionMarkerPresent)
678  {
679  bool marker;
680  bIterator = DeserializeBoolean (&marker,bIterator);
681  }
682  return DeserializeInteger (selectedOption,0,numOptions - 1,bIterator);
683 }
684 
685 Buffer::Iterator Asn1Header::DeserializeEnum (int numElems, int *selectedElem, Buffer::Iterator bIterator)
686 {
687  return DeserializeInteger (selectedElem,0,numElems - 1,bIterator);
688 }
689 
690 template <int N>
691 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<N> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
692 {
693  if (isExtensionMarkerPresent)
694  {
695  bool dummy;
696  bIterator = DeserializeBoolean (&dummy,bIterator);
697  }
698  bIterator = DeserializeBitset<N> (optionalOrDefaultMask,bIterator);
699  return bIterator;
700 }
701 
702 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<0> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
703 {
704  return DeserializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
705 }
706 
707 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<1> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
708 {
709  return DeserializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
710 }
711 
712 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<2> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
713 {
714  return DeserializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
715 }
716 
717 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<3> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
718 {
719  return DeserializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
720 }
721 
722 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<4> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
723 {
724  return DeserializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
725 }
726 
727 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<5> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
728 {
729  return DeserializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
730 }
731 
732 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<6> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
733 {
734  return DeserializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
735 }
736 
737 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<7> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
738 {
739  return DeserializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
740 }
741 
742 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<9> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
743 {
744  return DeserializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
745 }
746 
747 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<10> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
748 {
749  return DeserializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
750 }
751 
752 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<11> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
753 {
754  return DeserializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
755 }
756 
758 {
759  return bIterator;
760 }
761 
762 Buffer::Iterator Asn1Header::DeserializeSequenceOf (int *numElems, int nMax, int nMin, Buffer::Iterator bIterator)
763 {
764  return DeserializeInteger (numElems,nMin,nMax,bIterator);
765 }
766 
767 } // 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)
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.
void SerializeBitstring(std::bitset< N > bitstring) const
Serialize a bitstring.
Buffer::Iterator DeserializeEnum(int numElems, int *selectedElem, Buffer::Iterator bIterator)
Deserialize an Enum.
virtual ~Asn1Header()
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.
void SerializeInteger(int n, int nmin, int nmax) const
Serialize an Integer.
virtual void PreSerialize(void) const =0
This function serializes class attributes to m_serializationResult local Buffer.
Buffer::Iterator DeserializeBoolean(bool *value, Buffer::Iterator bIterator)
Deserialize a boolean.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
static TypeId GetTypeId(void)
Get the type ID.
void Serialize(Buffer::Iterator bIterator) const
uint32_t GetSerializedSize(void) const
uint8_t m_serializationPendingBits
pending bits
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:99
void Write(uint8_t const *buffer, uint32_t size)
Definition: buffer.cc:954
void WriteU8(uint8_t data)
Definition: buffer.h:869
uint8_t ReadU8(void)
Definition: buffer.h:1021
void Prev(void)
go backward by one byte
Definition: buffer.h:851
uint32_t GetSize(void) const
Definition: buffer.h:1063
void AddAtEnd(uint32_t end)
Definition: buffer.cc:354
Buffer::Iterator End(void) const
Definition: buffer.h:1075
Buffer::Iterator Begin(void) const
Definition: buffer.h:1069
Protocol header serialization and deserialization.
Definition: header.h:43
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#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:88
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint8_t data[writeSize]