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)
325 "Integer " <<
n <<
" is outside range [" << nmin <<
", " << nmax <<
"]");
328 int range = nmax - nmin + 1;
339 int requiredBits = std::ceil (std::log (range) / std::log (2.0));
341 switch (requiredBits)
344 SerializeBitset<1> (std::bitset<1> (
n));
347 SerializeBitset<2> (std::bitset<2> (
n));
350 SerializeBitset<3> (std::bitset<3> (
n));
353 SerializeBitset<4> (std::bitset<4> (
n));
356 SerializeBitset<5> (std::bitset<5> (
n));
359 SerializeBitset<6> (std::bitset<6> (
n));
362 SerializeBitset<7> (std::bitset<7> (
n));
365 SerializeBitset<8> (std::bitset<8> (
n));
368 SerializeBitset<9> (std::bitset<9> (
n));
371 SerializeBitset<10> (std::bitset<10> (
n));
374 SerializeBitset<11> (std::bitset<11> (
n));
377 SerializeBitset<12> (std::bitset<12> (
n));
380 SerializeBitset<13> (std::bitset<13> (
n));
383 SerializeBitset<14> (std::bitset<14> (
n));
386 SerializeBitset<15> (std::bitset<15> (
n));
389 SerializeBitset<16> (std::bitset<16> (
n));
392 SerializeBitset<17> (std::bitset<17> (
n));
395 SerializeBitset<18> (std::bitset<18> (
n));
398 SerializeBitset<19> (std::bitset<19> (
n));
401 SerializeBitset<20> (std::bitset<20> (
n));
405 std::cout <<
"SerializeInteger " << requiredBits <<
" Out of range!!" << std::endl;
447 while (bitsToRead > 0)
449 uint8_t octet = bIterator.
ReadU8 ();
454 for (
int j = 0; j < 8; j++)
456 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
468 while (bitsToRead > 0)
470 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0);
483 return DeserializeBitset<N> (
data,bIterator);
488 return DeserializeBitstring<1> (
data,bIterator);
493 return DeserializeBitstring<2> (
data,bIterator);
498 return DeserializeBitstring<8> (
data,bIterator);
503 return DeserializeBitstring<10> (
data,bIterator);
508 return DeserializeBitstring<16> (
data,bIterator);
513 return DeserializeBitstring<27> (
data,bIterator);
518 return DeserializeBitstring<28> (
data,bIterator);
523 return DeserializeBitstring<32> (
data,bIterator);
528 std::bitset<1> readBit;
529 bIterator = DeserializeBitset<1> (&readBit,bIterator);
530 *value = (readBit[0] == 1) ?
true :
false;
544 int range = nmax - nmin + 1;
551 int requiredBits = std::ceil (std::log (range) / std::log (2.0));
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;
574 switch (requiredBits)
577 bIterator = DeserializeBitset<1> (&bitsRead1,bIterator);
578 *
n = (int)bitsRead1.to_ulong ();
581 bIterator = DeserializeBitset<2> (&bitsRead2,bIterator);
582 *
n = (int)bitsRead2.to_ulong ();
585 bIterator = DeserializeBitset<3> (&bitsRead3,bIterator);
586 *
n = (int)bitsRead3.to_ulong ();
589 bIterator = DeserializeBitset<4> (&bitsRead4,bIterator);
590 *
n = (int)bitsRead4.to_ulong ();
593 bIterator = DeserializeBitset<5> (&bitsRead5,bIterator);
594 *
n = (int)bitsRead5.to_ulong ();
597 bIterator = DeserializeBitset<6> (&bitsRead6,bIterator);
598 *
n = (int)bitsRead6.to_ulong ();
601 bIterator = DeserializeBitset<7> (&bitsRead7,bIterator);
602 *
n = (int)bitsRead7.to_ulong ();
605 bIterator = DeserializeBitset<8> (&bitsRead8,bIterator);
606 *
n = (int)bitsRead8.to_ulong ();
609 bIterator = DeserializeBitset<9> (&bitsRead9,bIterator);
610 *
n = (int)bitsRead9.to_ulong ();
613 bIterator = DeserializeBitset<10> (&bitsRead10,bIterator);
614 *
n = (int)bitsRead10.to_ulong ();
617 bIterator = DeserializeBitset<11> (&bitsRead11,bIterator);
618 *
n = (int)bitsRead11.to_ulong ();
621 bIterator = DeserializeBitset<12> (&bitsRead12,bIterator);
622 *
n = (int)bitsRead12.to_ulong ();
625 bIterator = DeserializeBitset<13> (&bitsRead13,bIterator);
626 *
n = (int)bitsRead13.to_ulong ();
629 bIterator = DeserializeBitset<14> (&bitsRead14,bIterator);
630 *
n = (int)bitsRead14.to_ulong ();
633 bIterator = DeserializeBitset<15> (&bitsRead15,bIterator);
634 *
n = (int)bitsRead15.to_ulong ();
637 bIterator = DeserializeBitset<16> (&bitsRead16,bIterator);
638 *
n = (int)bitsRead16.to_ulong ();
641 bIterator = DeserializeBitset<17> (&bitsRead17,bIterator);
642 *
n = (int)bitsRead17.to_ulong ();
645 bIterator = DeserializeBitset<18> (&bitsRead18,bIterator);
646 *
n = (int)bitsRead18.to_ulong ();
649 bIterator = DeserializeBitset<19> (&bitsRead19,bIterator);
650 *
n = (int)bitsRead19.to_ulong ();
653 bIterator = DeserializeBitset<20> (&bitsRead20,bIterator);
654 *
n = (int)bitsRead20.to_ulong ();
658 std::cout <<
"SerializeInteger Out of range!!" << std::endl;
670 if (isExtensionMarkerPresent)
686 if (isExtensionMarkerPresent)
691 bIterator = DeserializeBitset<N> (optionalOrDefaultMask,bIterator);
697 return DeserializeSequence<0> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
702 return DeserializeSequence<1> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
707 return DeserializeSequence<2> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
712 return DeserializeSequence<3> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
717 return DeserializeSequence<4> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
722 return DeserializeSequence<5> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
727 return DeserializeSequence<6> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
732 return DeserializeSequence<7> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
737 return DeserializeSequence<9> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
742 return DeserializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
747 return DeserializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent,bIterator);
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
iterator in a Buffer instance
void Prev(void)
go backward by one byte
void AddAtEnd(uint32_t end)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Buffer::Iterator End(void) const
void WriteU8(uint8_t data)
uint32_t GetSize(void) const
void Write(uint8_t const *buffer, uint32_t size)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Buffer::Iterator Begin(void) const