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  NS_ASSERT_MSG (nmin <= n && n <= nmax,
325  "Integer " << n << " is outside range [" << nmin << ", " << nmax << "]");
326 
327  // Clause 11.5.3 ITU-T X.691
328  int range = nmax - nmin + 1;
329  // Subtract nmin to n
330  n -= nmin;
331 
332  // Clause 11.5.4 ITU-T X.691
333  if (range <= 1)
334  {
335  return;
336  }
337 
338  // Clause 11.5.6 ITU-T X.691
339  int requiredBits = std::ceil (std::log (range) / std::log (2.0));
340 
341  switch (requiredBits)
342  {
343  case 1:
344  SerializeBitset<1> (std::bitset<1> (n));
345  break;
346  case 2:
347  SerializeBitset<2> (std::bitset<2> (n));
348  break;
349  case 3:
350  SerializeBitset<3> (std::bitset<3> (n));
351  break;
352  case 4:
353  SerializeBitset<4> (std::bitset<4> (n));
354  break;
355  case 5:
356  SerializeBitset<5> (std::bitset<5> (n));
357  break;
358  case 6:
359  SerializeBitset<6> (std::bitset<6> (n));
360  break;
361  case 7:
362  SerializeBitset<7> (std::bitset<7> (n));
363  break;
364  case 8:
365  SerializeBitset<8> (std::bitset<8> (n));
366  break;
367  case 9:
368  SerializeBitset<9> (std::bitset<9> (n));
369  break;
370  case 10:
371  SerializeBitset<10> (std::bitset<10> (n));
372  break;
373  case 11:
374  SerializeBitset<11> (std::bitset<11> (n));
375  break;
376  case 12:
377  SerializeBitset<12> (std::bitset<12> (n));
378  break;
379  case 13:
380  SerializeBitset<13> (std::bitset<13> (n));
381  break;
382  case 14:
383  SerializeBitset<14> (std::bitset<14> (n));
384  break;
385  case 15:
386  SerializeBitset<15> (std::bitset<15> (n));
387  break;
388  case 16:
389  SerializeBitset<16> (std::bitset<16> (n));
390  break;
391  case 17:
392  SerializeBitset<17> (std::bitset<17> (n));
393  break;
394  case 18:
395  SerializeBitset<18> (std::bitset<18> (n));
396  break;
397  case 19:
398  SerializeBitset<19> (std::bitset<19> (n));
399  break;
400  case 20:
401  SerializeBitset<20> (std::bitset<20> (n));
402  break;
403  default:
404  {
405  std::cout << "SerializeInteger " << requiredBits << " Out of range!!" << std::endl;
406  exit (1);
407  }
408  }
409 }
410 
412 {
413  // Clause 18 ITU-T X.691
414  return;
415 }
416 
418 {
420  {
422  SerializeBitset<8> (std::bitset<8> (m_serializationPendingBits));
423  }
424  m_isDataSerialized = true;
425 }
426 
427 template <int N>
429 {
430 
431  int bitsToRead = N;
432  uint8_t mask;
433 
434  // Read bits from pending bits
436  {
437  while (bitsToRead > 0 && m_numSerializationPendingBits > 0)
438  {
439  data->set (bitsToRead - 1,(m_serializationPendingBits & 0x80) ? 1 : 0);
440  bitsToRead--;
443  }
444  }
445 
446  // Read bits from buffer
447  while (bitsToRead > 0)
448  {
449  uint8_t octet = bIterator.ReadU8 ();
450  // If 8 bits can be allocated to the bitset, set the bits
451  if (bitsToRead >= 8)
452  {
453  mask = 0x80;
454  for (int j = 0; j < 8; j++)
455  {
456  data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
457  bitsToRead--;
458  mask = mask >> 1;
459  }
460  }
461 
462  // Otherwise, we'll have to save the remaining bits
463  else
464  {
465  mask = 0x80;
466  m_numSerializationPendingBits = 8 - bitsToRead;
467  m_serializationPendingBits = octet << bitsToRead;
468  while (bitsToRead > 0)
469  {
470  data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
471  bitsToRead--;
472  mask = mask >> 1;
473  }
474  }
475  }
476 
477  return bIterator;
478 }
479 
480 template <int N>
482 {
483  return DeserializeBitset<N> (data,bIterator);
484 }
485 
487 {
488  return DeserializeBitstring<1> (data,bIterator);
489 }
490 
492 {
493  return DeserializeBitstring<2> (data,bIterator);
494 }
495 
497 {
498  return DeserializeBitstring<8> (data,bIterator);
499 }
500 
502 {
503  return DeserializeBitstring<10> (data,bIterator);
504 }
505 
507 {
508  return DeserializeBitstring<16> (data,bIterator);
509 }
510 
512 {
513  return DeserializeBitstring<27> (data,bIterator);
514 }
515 
517 {
518  return DeserializeBitstring<28> (data,bIterator);
519 }
520 
522 {
523  return DeserializeBitstring<32> (data,bIterator);
524 }
525 
527 {
528  std::bitset<1> readBit;
529  bIterator = DeserializeBitset<1> (&readBit,bIterator);
530  *value = (readBit[0] == 1) ? true : false;
531  return bIterator;
532 }
533 
535 {
536  // Misusage check: Ensure nmax>nmin ...
537  if (nmin > nmax)
538  {
539  int aux = nmin;
540  nmin = nmax;
541  nmax = aux;
542  }
543 
544  int range = nmax - nmin + 1;
545 
546  if (range == 1)
547  {
548  return bIterator;
549  }
550 
551  int requiredBits = std::ceil (std::log (range) / std::log (2.0));
552 
553  std::bitset<1> bitsRead1;
554  std::bitset<2> bitsRead2;
555  std::bitset<3> bitsRead3;
556  std::bitset<4> bitsRead4;
557  std::bitset<5> bitsRead5;
558  std::bitset<6> bitsRead6;
559  std::bitset<7> bitsRead7;
560  std::bitset<8> bitsRead8;
561  std::bitset<9> bitsRead9;
562  std::bitset<10> bitsRead10;
563  std::bitset<11> bitsRead11;
564  std::bitset<12> bitsRead12;
565  std::bitset<13> bitsRead13;
566  std::bitset<14> bitsRead14;
567  std::bitset<15> bitsRead15;
568  std::bitset<16> bitsRead16;
569  std::bitset<17> bitsRead17;
570  std::bitset<18> bitsRead18;
571  std::bitset<19> bitsRead19;
572  std::bitset<20> bitsRead20;
573 
574  switch (requiredBits)
575  {
576  case 1:
577  bIterator = DeserializeBitset<1> (&bitsRead1,bIterator);
578  *n = (int)bitsRead1.to_ulong ();
579  break;
580  case 2:
581  bIterator = DeserializeBitset<2> (&bitsRead2,bIterator);
582  *n = (int)bitsRead2.to_ulong ();
583  break;
584  case 3:
585  bIterator = DeserializeBitset<3> (&bitsRead3,bIterator);
586  *n = (int)bitsRead3.to_ulong ();
587  break;
588  case 4:
589  bIterator = DeserializeBitset<4> (&bitsRead4,bIterator);
590  *n = (int)bitsRead4.to_ulong ();
591  break;
592  case 5:
593  bIterator = DeserializeBitset<5> (&bitsRead5,bIterator);
594  *n = (int)bitsRead5.to_ulong ();
595  break;
596  case 6:
597  bIterator = DeserializeBitset<6> (&bitsRead6,bIterator);
598  *n = (int)bitsRead6.to_ulong ();
599  break;
600  case 7:
601  bIterator = DeserializeBitset<7> (&bitsRead7,bIterator);
602  *n = (int)bitsRead7.to_ulong ();
603  break;
604  case 8:
605  bIterator = DeserializeBitset<8> (&bitsRead8,bIterator);
606  *n = (int)bitsRead8.to_ulong ();
607  break;
608  case 9:
609  bIterator = DeserializeBitset<9> (&bitsRead9,bIterator);
610  *n = (int)bitsRead9.to_ulong ();
611  break;
612  case 10:
613  bIterator = DeserializeBitset<10> (&bitsRead10,bIterator);
614  *n = (int)bitsRead10.to_ulong ();
615  break;
616  case 11:
617  bIterator = DeserializeBitset<11> (&bitsRead11,bIterator);
618  *n = (int)bitsRead11.to_ulong ();
619  break;
620  case 12:
621  bIterator = DeserializeBitset<12> (&bitsRead12,bIterator);
622  *n = (int)bitsRead12.to_ulong ();
623  break;
624  case 13:
625  bIterator = DeserializeBitset<13> (&bitsRead13,bIterator);
626  *n = (int)bitsRead13.to_ulong ();
627  break;
628  case 14:
629  bIterator = DeserializeBitset<14> (&bitsRead14,bIterator);
630  *n = (int)bitsRead14.to_ulong ();
631  break;
632  case 15:
633  bIterator = DeserializeBitset<15> (&bitsRead15,bIterator);
634  *n = (int)bitsRead15.to_ulong ();
635  break;
636  case 16:
637  bIterator = DeserializeBitset<16> (&bitsRead16,bIterator);
638  *n = (int)bitsRead16.to_ulong ();
639  break;
640  case 17:
641  bIterator = DeserializeBitset<17> (&bitsRead17,bIterator);
642  *n = (int)bitsRead17.to_ulong ();
643  break;
644  case 18:
645  bIterator = DeserializeBitset<18> (&bitsRead18,bIterator);
646  *n = (int)bitsRead18.to_ulong ();
647  break;
648  case 19:
649  bIterator = DeserializeBitset<19> (&bitsRead19,bIterator);
650  *n = (int)bitsRead19.to_ulong ();
651  break;
652  case 20:
653  bIterator = DeserializeBitset<20> (&bitsRead20,bIterator);
654  *n = (int)bitsRead20.to_ulong ();
655  break;
656  default:
657  {
658  std::cout << "SerializeInteger Out of range!!" << std::endl;
659  exit (1);
660  }
661  }
662 
663  *n += nmin;
664 
665  return bIterator;
666 }
667 
668 Buffer::Iterator Asn1Header::DeserializeChoice (int numOptions, bool isExtensionMarkerPresent, int *selectedOption, Buffer::Iterator bIterator)
669 {
670  if (isExtensionMarkerPresent)
671  {
672  bool marker;
673  bIterator = DeserializeBoolean (&marker,bIterator);
674  }
675  return DeserializeInteger (selectedOption,0,numOptions - 1,bIterator);
676 }
677 
678 Buffer::Iterator Asn1Header::DeserializeEnum (int numElems, int *selectedElem, Buffer::Iterator bIterator)
679 {
680  return DeserializeInteger (selectedElem,0,numElems - 1,bIterator);
681 }
682 
683 template <int N>
684 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<N> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
685 {
686  if (isExtensionMarkerPresent)
687  {
688  bool dummy;
689  bIterator = DeserializeBoolean (&dummy,bIterator);
690  }
691  bIterator = DeserializeBitset<N> (optionalOrDefaultMask,bIterator);
692  return bIterator;
693 }
694 
695 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<0> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
696 {
697  return DeserializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
698 }
699 
700 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<1> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
701 {
702  return DeserializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
703 }
704 
705 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<2> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
706 {
707  return DeserializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
708 }
709 
710 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<3> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
711 {
712  return DeserializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
713 }
714 
715 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<4> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
716 {
717  return DeserializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
718 }
719 
720 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<5> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
721 {
722  return DeserializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
723 }
724 
725 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<6> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
726 {
727  return DeserializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
728 }
729 
730 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<7> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
731 {
732  return DeserializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
733 }
734 
735 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<9> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
736 {
737  return DeserializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
738 }
739 
740 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<10> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
741 {
742  return DeserializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
743 }
744 
745 Buffer::Iterator Asn1Header::DeserializeSequence (std::bitset<11> *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
746 {
747  return DeserializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
748 }
749 
751 {
752  return bIterator;
753 }
754 
755 Buffer::Iterator Asn1Header::DeserializeSequenceOf (int *numElems, int nMax, int nMin, Buffer::Iterator bIterator)
756 {
757  return DeserializeInteger (numElems,nMin,nMax,bIterator);
758 }
759 
760 } // namespace ns3
Protocol header serialization and deserialization.
Definition: header.h:42
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
void SerializeSequenceOf(int numElems, int nMax, int nMin) const
Serialize a Sequence.
Buffer::Iterator DeserializeChoice(int numOptions, bool isExtensionMarkerPresent, int *selectedOption, Buffer::Iterator bIterator)
Deserialize a Choice (set of options)
Buffer::Iterator DeserializeNull(Buffer::Iterator bIterator)
Deserialize nothing (null op)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
uint8_t m_numSerializationPendingBits
number of pending bits
void SerializeBoolean(bool value) const
Serialize a bool.
void SerializeBitset(std::bitset< N > data) const
Serialize a bitset.
Buffer::Iterator DeserializeSequence(std::bitset< N > *optionalOrDefaultMask, bool isExtensionMarkerPresent, Buffer::Iterator bIterator)
Deserialize a sequence.
bool m_isDataSerialized
true if data is serialized
iterator in a Buffer instance
Definition: buffer.h:98
void SerializeNull() const
Serialize nothing (null op)
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
Buffer::Iterator DeserializeBoolean(bool *value, Buffer::Iterator bIterator)
Deserialize a boolean.
virtual ~Asn1Header()
void Prev(void)
go backward by one byte
Definition: buffer.h:851
uint8_t m_serializationPendingBits
pending bits
uint32_t GetSerializedSize(void) const
Buffer::Iterator DeserializeEnum(int numElems, int *selectedElem, Buffer::Iterator bIterator)
Deserialize an Enum.
Buffer::Iterator DeserializeInteger(int *n, int nmin, int nmax, Buffer::Iterator bIterator)
Deserialize an integer.
uint8_t data[writeSize]
Buffer::Iterator End(void) const
Definition: buffer.h:1075
Buffer m_serializationResult
serialization result
virtual void PreSerialize(void) const =0
This function serializes class attributes to m_serializationResult local Buffer.
Buffer::Iterator Begin(void) const
Definition: buffer.h:1069
void SerializeInteger(int n, int nmin, int nmax) const
Serialize an Integer.
void AddAtEnd(uint32_t end)
Definition: buffer.cc:354
Buffer::Iterator DeserializeBitset(std::bitset< N > *data, Buffer::Iterator bIterator)
Deserialize a bitset.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
uint32_t GetSize(void) const
Definition: buffer.h:1063
void SerializeBitstring(std::bitset< N > bitstring) const
Serialize a bitstring.
void WriteOctet(uint8_t octet) const
Function to write in m_serializationResult, after resizing its size.
void WriteU8(uint8_t data)
Definition: buffer.h:869
void SerializeSequence(std::bitset< N > optionalOrDefaultMask, bool isExtensionMarkerPresent) const
Serialize a sequence.
Buffer::Iterator DeserializeSequenceOf(int *numElems, int nMax, int nMin, Buffer::Iterator bIterator)
Deserialize a Sequence.
uint8_t ReadU8(void)
Definition: buffer.h:1021
void Write(uint8_t const *buffer, uint32_t size)
Definition: buffer.cc:956
void FinalizeSerialization() const
Finalizes an in progress serialization.
a unique identifier for an interface.
Definition: type-id.h:58
void Serialize(Buffer::Iterator bIterator) const
static TypeId GetTypeId(void)
Get the type ID.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
void SerializeChoice(int numOptions, int selectedOption, bool isExtensionMarkerPresent) const
Serialize a Choice (set of options)
void SerializeEnum(int numElems, int selectedElem) const
Serialize an Enum.
Buffer::Iterator DeserializeBitstring(std::bitset< N > *bitstring, Buffer::Iterator bIterator)
Deserialize a bitstring.