LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) | 3 * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 Buffer::Iterator bIterator = m_serializationResult.End (); | 83 Buffer::Iterator bIterator = m_serializationResult.End (); |
84 bIterator.Prev (); | 84 bIterator.Prev (); |
85 bIterator.WriteU8 (octet); | 85 bIterator.WriteU8 (octet); |
86 } | 86 } |
87 | 87 |
88 template <int N> | 88 template <int N> |
89 void Asn1Header::SerializeBitset (std::bitset<N> data) const | 89 void Asn1Header::SerializeBitset (std::bitset<N> data) const |
90 { | 90 { |
91 | 91 |
92 size_t dataSize = data.size (); | 92 size_t dataSize = data.size (); |
93 uint8_t pendingBits = (uint8_t)dataSize; | 93 uint8_t pendingBits = static_cast<uint8_t>(dataSize); |
94 uint8_t mask = 1; | 94 uint8_t mask = 1; |
95 int j; | 95 int j; |
96 | 96 |
97 // No extension marker (Clause 16.7 ITU-T X.691), | 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. | 98 // as 3GPP TS 36.331 does not use it in its IE's. |
99 | 99 |
100 // Clause 16.8 ITU-T X.691 | 100 // Clause 16.8 ITU-T X.691 |
101 if (dataSize == 0) | 101 if (dataSize == 0) |
102 { | 102 { |
103 return; | 103 return; |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 void Asn1Header::SerializeSequence (std::bitset<10> optionalOrDefaultMask, bool
isExtensionMarkerPresent) const | 283 void Asn1Header::SerializeSequence (std::bitset<10> optionalOrDefaultMask, bool
isExtensionMarkerPresent) const |
284 { | 284 { |
285 SerializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent); | 285 SerializeSequence<10> (optionalOrDefaultMask,isExtensionMarkerPresent); |
286 } | 286 } |
287 | 287 |
288 void Asn1Header::SerializeSequence (std::bitset<11> optionalOrDefaultMask, bool
isExtensionMarkerPresent) const | 288 void Asn1Header::SerializeSequence (std::bitset<11> optionalOrDefaultMask, bool
isExtensionMarkerPresent) const |
289 { | 289 { |
290 SerializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent); | 290 SerializeSequence<11> (optionalOrDefaultMask,isExtensionMarkerPresent); |
291 } | 291 } |
292 | 292 |
293 void Asn1Header::SerializeSequenceOf (int numElems, int nMax, int nMin) const | 293 void Asn1Header::SerializeSequenceOf (size_t numElems, int nMax, int nMin) const |
294 { | 294 { |
295 // Clause 20.6 ITU-T X.691 | 295 // Clause 20.6 ITU-T X.691 |
296 SerializeInteger (numElems, nMin, nMax); | 296 SerializeInteger (static_cast<int>(numElems), nMin, nMax); |
297 } | 297 } |
298 | 298 |
299 void Asn1Header::SerializeEnum (int numElems, int selectedElem) const | 299 void Asn1Header::SerializeEnum (int numElems, int selectedElem) const |
300 { | 300 { |
301 // Clause 14 ITU-T X.691 | 301 // Clause 14 ITU-T X.691 |
302 SerializeInteger (selectedElem, 0, numElems - 1); | 302 SerializeInteger (selectedElem, 0, numElems - 1); |
303 } | 303 } |
304 | 304 |
305 void Asn1Header::SerializeChoice (int numOptions, int selectedOption, bool isExt
ensionMarkerPresent) const | 305 void Asn1Header::SerializeChoice (int numOptions, int selectedOption, bool isExt
ensionMarkerPresent) const |
306 { | 306 { |
(...skipping 27 matching lines...) Expand all Loading... |
334 // Substract nmin to n | 334 // Substract nmin to n |
335 n -= nmin; | 335 n -= nmin; |
336 | 336 |
337 // Clause 11.5.4 ITU-T X.691 | 337 // Clause 11.5.4 ITU-T X.691 |
338 if (range <= 1) | 338 if (range <= 1) |
339 { | 339 { |
340 return; | 340 return; |
341 } | 341 } |
342 | 342 |
343 // Clause 11.5.6 ITU-T X.691 | 343 // Clause 11.5.6 ITU-T X.691 |
344 int requiredBits = (int)std::ceil (std::log (range) / std::log (2.0)); | 344 int requiredBits = static_cast<int>(std::ceil (std::log (range) / std::log (2.
0))); |
345 | 345 |
346 switch (requiredBits) | 346 switch (requiredBits) |
347 { | 347 { |
348 case 1: | 348 case 1: |
349 SerializeBitset<1> (std::bitset<1> (n)); | 349 SerializeBitset<1> (std::bitset<1> (n)); |
350 break; | 350 break; |
351 case 2: | 351 case 2: |
352 SerializeBitset<2> (std::bitset<2> (n)); | 352 SerializeBitset<2> (std::bitset<2> (n)); |
353 break; | 353 break; |
354 case 3: | 354 case 3: |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0); | 461 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0); |
462 bitsToRead--; | 462 bitsToRead--; |
463 mask = mask >> 1; | 463 mask = mask >> 1; |
464 } | 464 } |
465 } | 465 } |
466 | 466 |
467 // Otherwise, we'll have to save the remaining bits | 467 // Otherwise, we'll have to save the remaining bits |
468 else | 468 else |
469 { | 469 { |
470 mask = 0x80; | 470 mask = 0x80; |
471 m_numSerializationPendingBits = (uint8_t)(8 - bitsToRead); | 471 m_numSerializationPendingBits = static_cast<uint8_t>(8 - bitsToRead); |
472 m_serializationPendingBits = octet << bitsToRead; | 472 m_serializationPendingBits = octet << bitsToRead; |
473 while (bitsToRead > 0) | 473 while (bitsToRead > 0) |
474 { | 474 { |
475 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0); | 475 data->set (bitsToRead - 1,(octet & mask) ? 1 : 0); |
476 bitsToRead--; | 476 bitsToRead--; |
477 mask = mask >> 1; | 477 mask = mask >> 1; |
478 } | 478 } |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 nmax = aux; | 546 nmax = aux; |
547 } | 547 } |
548 | 548 |
549 int range = nmax - nmin + 1; | 549 int range = nmax - nmin + 1; |
550 | 550 |
551 if (range == 1) | 551 if (range == 1) |
552 { | 552 { |
553 return bIterator; | 553 return bIterator; |
554 } | 554 } |
555 | 555 |
556 int requiredBits = (int)std::ceil (std::log (range) / std::log (2.0)); | 556 int requiredBits = static_cast<int>(std::ceil (std::log (range) / std::log (2.
0))); |
557 | 557 |
558 std::bitset<1> bitsRead1; | 558 std::bitset<1> bitsRead1; |
559 std::bitset<2> bitsRead2; | 559 std::bitset<2> bitsRead2; |
560 std::bitset<3> bitsRead3; | 560 std::bitset<3> bitsRead3; |
561 std::bitset<4> bitsRead4; | 561 std::bitset<4> bitsRead4; |
562 std::bitset<5> bitsRead5; | 562 std::bitset<5> bitsRead5; |
563 std::bitset<6> bitsRead6; | 563 std::bitset<6> bitsRead6; |
564 std::bitset<7> bitsRead7; | 564 std::bitset<7> bitsRead7; |
565 std::bitset<8> bitsRead8; | 565 std::bitset<8> bitsRead8; |
566 std::bitset<9> bitsRead9; | 566 std::bitset<9> bitsRead9; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 { | 756 { |
757 return bIterator; | 757 return bIterator; |
758 } | 758 } |
759 | 759 |
760 Buffer::Iterator Asn1Header::DeserializeSequenceOf (int *numElems, int nMax, int
nMin, Buffer::Iterator bIterator) | 760 Buffer::Iterator Asn1Header::DeserializeSequenceOf (int *numElems, int nMax, int
nMin, Buffer::Iterator bIterator) |
761 { | 761 { |
762 return DeserializeInteger (numElems,nMin,nMax,bIterator); | 762 return DeserializeInteger (numElems,nMin,nMax,bIterator); |
763 } | 763 } |
764 | 764 |
765 } // namespace ns3 | 765 } // namespace ns3 |
LEFT | RIGHT |