Exemplo n.º 1
0
uint32_t
readType(Iterator& begin, const Iterator& end)
{
  uint64_t type = readVarNumber(begin, end);
  if (type > std::numeric_limits<uint32_t>::max()) {
    BOOST_THROW_EXCEPTION(Error("TLV-TYPE number exceeds allowed maximum"));
  }

  return static_cast<uint32_t>(type);
}
Exemplo n.º 2
0
inline uint32_t
readType(InputIterator& begin, const InputIterator& end)
{
  uint64_t type = readVarNumber(begin, end);
  if (type > std::numeric_limits<uint32_t>::max())
    {
      throw Error("TLV type code exceeds allowed maximum");
    }

  return static_cast<uint32_t>(type);
}
Exemplo n.º 3
0
bool
readType(Iterator& begin, const Iterator& end, uint32_t& type)
{
  uint64_t number = 0;
  bool isOk = readVarNumber(begin, end, number);
  if (!isOk || number > std::numeric_limits<uint32_t>::max()) {
    return false;
  }

  type = static_cast<uint32_t>(number);
  return true;
}
Exemplo n.º 4
0
inline uint64_t
readVarNumber(InputIterator& begin, const InputIterator& end)
{
  if (begin == end)
    BOOST_THROW_EXCEPTION(Error("Empty buffer during TLV processing"));

  uint64_t value;
  bool isOk = readVarNumber(begin, end, value);
  if (!isOk)
    BOOST_THROW_EXCEPTION(Error("Insufficient data during TLV processing"));

  return value;
}