22 #include "ns3/lte-asn1-header.h"
92 size_t dataSize =
data.size ();
93 uint8_t pendingBits = dataSize;
108 if (dataSize <= 65536)
120 mask = (mask >> 1) & (~mask);
131 while (pendingBits > 0)
142 while (pendingBits > 0)
145 mask = (mask >> 1) & (~mask);
153 uint8_t octetToWrite = 0;
156 octetToWrite |= (
data[pendingBits - j]) ? mask : 0;
157 mask = (mask << 1) & (~mask);
168 printf (
"FRAGMENTATION NEEDED!\n");
175 SerializeBitset<N> (
data);
181 SerializeBitstring<1> (
data);
186 SerializeBitstring<2> (
data);
191 SerializeBitstring<8> (
data);
196 SerializeBitstring<10> (
data);
201 SerializeBitstring<16> (
data);
206 SerializeBitstring<27> (
data);
211 SerializeBitstring<28> (
data);
216 SerializeBitstring<32> (
data);
223 (value) ? val.set () : val.reset ();
224 SerializeBitset<1> (val);
230 if (isExtensionMarkerPresent)
235 SerializeBitstring<N> (optionalOrDefaultMask);
240 SerializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent);
245 SerializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent);
250 SerializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent);
255 SerializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent);
260 SerializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent);
265 SerializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent);
270 SerializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent);
275 SerializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent);
280 SerializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent);
285 SerializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent);
290 SerializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent);
307 if(isExtensionMarkerPresent)
329 long int nComp = nmin;
332 "Integer " << n <<
" is outside range [" << nmin <<
", " << nmax <<
"]");
335 int range = nmax - nmin + 1;
346 int requiredBits = std::ceil (std::log (range) / std::log (2.0));
348 switch (requiredBits)
351 SerializeBitset<1> (std::bitset<1> (n));
354 SerializeBitset<2> (std::bitset<2> (n));
357 SerializeBitset<3> (std::bitset<3> (n));
360 SerializeBitset<4> (std::bitset<4> (n));
363 SerializeBitset<5> (std::bitset<5> (n));
366 SerializeBitset<6> (std::bitset<6> (n));
369 SerializeBitset<7> (std::bitset<7> (n));
372 SerializeBitset<8> (std::bitset<8> (n));
375 SerializeBitset<9> (std::bitset<9> (n));
378 SerializeBitset<10> (std::bitset<10> (n));
381 SerializeBitset<11> (std::bitset<11> (n));
384 SerializeBitset<12> (std::bitset<12> (n));
387 SerializeBitset<13> (std::bitset<13> (n));
390 SerializeBitset<14> (std::bitset<14> (n));
393 SerializeBitset<15> (std::bitset<15> (n));
396 SerializeBitset<16> (std::bitset<16> (n));
399 SerializeBitset<17> (std::bitset<17> (n));
402 SerializeBitset<18> (std::bitset<18> (n));
405 SerializeBitset<19> (std::bitset<19> (n));
408 SerializeBitset<20> (std::bitset<20> (n));
412 std::cout <<
"SerializeInteger " << requiredBits <<
" Out of range!!" << std::endl;
454 while (bitsToRead > 0)
456 uint8_t octet = bIterator.
ReadU8 ();
461 for (
int j = 0; j < 8; j++)
463 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
475 while (bitsToRead > 0)
477 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
490 return DeserializeBitset<N> (
data,bIterator);
495 return DeserializeBitstring<1> (
data,bIterator);
500 return DeserializeBitstring<2> (
data,bIterator);
505 return DeserializeBitstring<8> (
data,bIterator);
510 return DeserializeBitstring<10> (
data,bIterator);
515 return DeserializeBitstring<16> (
data,bIterator);
520 return DeserializeBitstring<27> (
data,bIterator);
525 return DeserializeBitstring<28> (
data,bIterator);
530 return DeserializeBitstring<32> (
data,bIterator);
535 std::bitset<1> readBit;
536 bIterator = DeserializeBitset<1> (&readBit,bIterator);
537 *value = (readBit[0] == 1);
551 int range = nmax - nmin + 1;
558 int requiredBits = std::ceil (std::log (range) / std::log (2.0));
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;
581 switch (requiredBits)
584 bIterator = DeserializeBitset<1> (&bitsRead1,bIterator);
585 *n = (int)bitsRead1.to_ulong ();
588 bIterator = DeserializeBitset<2> (&bitsRead2,bIterator);
589 *n = (int)bitsRead2.to_ulong ();
592 bIterator = DeserializeBitset<3> (&bitsRead3,bIterator);
593 *n = (int)bitsRead3.to_ulong ();
596 bIterator = DeserializeBitset<4> (&bitsRead4,bIterator);
597 *n = (int)bitsRead4.to_ulong ();
600 bIterator = DeserializeBitset<5> (&bitsRead5,bIterator);
601 *n = (int)bitsRead5.to_ulong ();
604 bIterator = DeserializeBitset<6> (&bitsRead6,bIterator);
605 *n = (int)bitsRead6.to_ulong ();
608 bIterator = DeserializeBitset<7> (&bitsRead7,bIterator);
609 *n = (int)bitsRead7.to_ulong ();
612 bIterator = DeserializeBitset<8> (&bitsRead8,bIterator);
613 *n = (int)bitsRead8.to_ulong ();
616 bIterator = DeserializeBitset<9> (&bitsRead9,bIterator);
617 *n = (int)bitsRead9.to_ulong ();
620 bIterator = DeserializeBitset<10> (&bitsRead10,bIterator);
621 *n = (int)bitsRead10.to_ulong ();
624 bIterator = DeserializeBitset<11> (&bitsRead11,bIterator);
625 *n = (int)bitsRead11.to_ulong ();
628 bIterator = DeserializeBitset<12> (&bitsRead12,bIterator);
629 *n = (int)bitsRead12.to_ulong ();
632 bIterator = DeserializeBitset<13> (&bitsRead13,bIterator);
633 *n = (int)bitsRead13.to_ulong ();
636 bIterator = DeserializeBitset<14> (&bitsRead14,bIterator);
637 *n = (int)bitsRead14.to_ulong ();
640 bIterator = DeserializeBitset<15> (&bitsRead15,bIterator);
641 *n = (int)bitsRead15.to_ulong ();
644 bIterator = DeserializeBitset<16> (&bitsRead16,bIterator);
645 *n = (int)bitsRead16.to_ulong ();
648 bIterator = DeserializeBitset<17> (&bitsRead17,bIterator);
649 *n = (int)bitsRead17.to_ulong ();
652 bIterator = DeserializeBitset<18> (&bitsRead18,bIterator);
653 *n = (int)bitsRead18.to_ulong ();
656 bIterator = DeserializeBitset<19> (&bitsRead19,bIterator);
657 *n = (int)bitsRead19.to_ulong ();
660 bIterator = DeserializeBitset<20> (&bitsRead20,bIterator);
661 *n = (int)bitsRead20.to_ulong ();
665 std::cout <<
"SerializeInteger Out of range!!" << std::endl;
677 if (isExtensionMarkerPresent)
693 if (isExtensionMarkerPresent)
698 bIterator = DeserializeBitset<N> (optionalOrDefaultMask,bIterator);
704 return DeserializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
709 return DeserializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
714 return DeserializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
719 return DeserializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
724 return DeserializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
729 return DeserializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
734 return DeserializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
739 return DeserializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
744 return DeserializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
749 return DeserializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
754 return DeserializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
iterator in a Buffer instance
void Write(uint8_t const *buffer, uint32_t size)
void WriteU8(uint8_t data)
void Prev(void)
go backward by one byte
uint32_t GetSize(void) const
void AddAtEnd(uint32_t end)
Buffer::Iterator End(void) const
Buffer::Iterator Begin(void) const
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.