lp: consistently use uint32_t for TLV types
Change-Id: I880043b634476eaaafa35b49f6b3f93210ae5ecf
This commit is contained in:
1 parent
152ef44da9
commit
581dd52b0d
7 files changed
+30
-33
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 Regents of the University of California.
|
||||
* Copyright (c) 2013-2023 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,15 +22,17 @@
|
||||
#ifndef NDN_CXX_ENCODING_TLV_NFD_HPP
|
||||
#define NDN_CXX_ENCODING_TLV_NFD_HPP
|
||||
|
||||
#include "ndn-cxx/encoding/tlv.hpp"
|
||||
#include "ndn-cxx/encoding/nfd-constants.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace ndn {
|
||||
namespace tlv {
|
||||
namespace nfd {
|
||||
|
||||
// NFD Management protocol
|
||||
enum {
|
||||
/**
|
||||
* @brief TLV-TYPE numbers defined by the NFD Management protocol.
|
||||
* @sa https://redmine.named-data.net/projects/nfd/wiki/Management
|
||||
*/
|
||||
enum : uint32_t {
|
||||
// ControlParameters
|
||||
ControlParameters = 104,
|
||||
FaceId = 105,
|
||||
@@ -100,7 +102,7 @@ enum {
|
||||
|
||||
// RIB Management
|
||||
RibEntry = 128,
|
||||
Route = 129
|
||||
Route = 129,
|
||||
};
|
||||
|
||||
} // namespace nfd
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2021 Regents of the University of California.
|
||||
* Copyright (c) 2013-2023 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,14 +22,14 @@
|
||||
#ifndef NDN_CXX_ENCODING_TLV_SECURITY_HPP
|
||||
#define NDN_CXX_ENCODING_TLV_SECURITY_HPP
|
||||
|
||||
#include "ndn-cxx/encoding/tlv.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
namespace ndn {
|
||||
namespace tlv {
|
||||
namespace security {
|
||||
|
||||
/**
|
||||
* @brief TLV-TYPE numbers for SafeBag and related elements
|
||||
* @brief TLV-TYPE numbers for SafeBag and related elements.
|
||||
* @sa <a href="../specs/safe-bag.html">SafeBag Format</a>
|
||||
*/
|
||||
enum : uint32_t {
|
||||
|
||||
@@ -169,14 +169,14 @@ struct EncodeHelper<TAG, TlvType, std::pair<Buffer::const_iterator, Buffer::cons
|
||||
* \tparam DECODER_TAG selects a specialization of DecodeHelper.
|
||||
* \tparam ENCODER_TAG selects a specialization of EncodeHelper.
|
||||
*/
|
||||
template<typename LOCATION, typename VALUE, uint64_t TYPE, bool REPEATABLE = false,
|
||||
template<typename LOCATION, typename VALUE, uint32_t TYPE, bool REPEATABLE = false,
|
||||
typename DECODER_TAG = VALUE, typename ENCODER_TAG = VALUE>
|
||||
class FieldDecl
|
||||
{
|
||||
public:
|
||||
using FieldLocation = LOCATION;
|
||||
using ValueType = VALUE;
|
||||
using TlvType = std::integral_constant<uint64_t, TYPE>;
|
||||
using TlvType = std::integral_constant<uint32_t, TYPE>;
|
||||
using IsRepeatable = std::bool_constant<REPEATABLE>;
|
||||
|
||||
/** \brief Decode a field.
|
||||
|
||||
@@ -55,13 +55,13 @@ class Fragment : public Base
|
||||
} // namespace field_location_tags
|
||||
|
||||
/**
|
||||
* \brief Concept check for fields.
|
||||
* \brief Concept check for NDNLPv2 fields.
|
||||
*/
|
||||
template<class X>
|
||||
struct Field
|
||||
{
|
||||
static_assert(std::is_base_of_v<field_location_tags::Base, typename X::FieldLocation>, "");
|
||||
static_assert(std::is_same_v<typename X::TlvType::value_type, uint64_t>, "");
|
||||
static_assert(std::is_same_v<typename X::TlvType::value_type, uint32_t>, "");
|
||||
static_assert(std::is_same_v<typename X::IsRepeatable::value_type, bool>, "");
|
||||
static_assert(std::is_default_constructible_v<typename X::ValueType>, "");
|
||||
static_assert(std::is_copy_constructible_v<typename X::ValueType>, "");
|
||||
|
||||
@@ -55,10 +55,10 @@ public:
|
||||
FieldInfo() noexcept = default;
|
||||
|
||||
explicit
|
||||
FieldInfo(uint64_t tlv) noexcept;
|
||||
FieldInfo(uint32_t type) noexcept;
|
||||
|
||||
public:
|
||||
uint64_t tlvType = 0; ///< TLV-TYPE of the field; 0 if field does not exist
|
||||
uint32_t tlvType = 0; ///< TLV-TYPE of the field; 0 if field does not exist
|
||||
bool isRecognized = false; ///< is this field known
|
||||
bool canIgnore = false; ///< can this unknown field be ignored
|
||||
bool isRepeatable = false; ///< is the field repeatable
|
||||
@@ -84,8 +84,8 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
FieldInfo::FieldInfo(uint64_t tlv) noexcept
|
||||
: tlvType(tlv)
|
||||
FieldInfo::FieldInfo(uint32_t type) noexcept
|
||||
: tlvType(type)
|
||||
{
|
||||
boost::mpl::for_each<FieldSet>(boost::bind(ExtractFieldInfo(), this, _1));
|
||||
if (!isRecognized) {
|
||||
@@ -104,10 +104,7 @@ compareFieldSortOrder(const FieldInfo& first, const FieldInfo& second) noexcept
|
||||
|
||||
} // namespace
|
||||
|
||||
Packet::Packet()
|
||||
: m_wire(Block(tlv::LpPacket))
|
||||
{
|
||||
}
|
||||
Packet::Packet() = default;
|
||||
|
||||
Packet::Packet(const Block& wire)
|
||||
{
|
||||
@@ -170,7 +167,7 @@ Packet::wireDecode(const Block& wire)
|
||||
}
|
||||
|
||||
bool
|
||||
Packet::comparePos(uint64_t first, const Block& second) noexcept
|
||||
Packet::comparePos(uint32_t first, const Block& second) noexcept
|
||||
{
|
||||
FieldInfo firstInfo(first);
|
||||
FieldInfo secondInfo(second.type());
|
||||
|
||||
@@ -202,10 +202,10 @@ public: // field access
|
||||
|
||||
private:
|
||||
static bool
|
||||
comparePos(uint64_t first, const Block& second) noexcept;
|
||||
comparePos(uint32_t first, const Block& second) noexcept;
|
||||
|
||||
private:
|
||||
mutable Block m_wire;
|
||||
mutable Block m_wire{tlv::LpPacket};
|
||||
};
|
||||
|
||||
} // namespace lp
|
||||
|
||||
+7
-9
@@ -1,6 +1,6 @@
|
||||
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
||||
/*
|
||||
* Copyright (c) 2013-2022 Regents of the University of California.
|
||||
* Copyright (c) 2013-2023 Regents of the University of California.
|
||||
*
|
||||
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
|
||||
*
|
||||
@@ -22,6 +22,8 @@
|
||||
#ifndef NDN_CXX_LP_TLV_HPP
|
||||
#define NDN_CXX_LP_TLV_HPP
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace ndn {
|
||||
namespace lp {
|
||||
/**
|
||||
@@ -30,9 +32,10 @@ namespace lp {
|
||||
namespace tlv {
|
||||
|
||||
/**
|
||||
* \brief TLV-TYPE numbers for NDNLPv2.
|
||||
* @brief TLV-TYPE numbers for NDNLPv2.
|
||||
* @sa https://redmine.named-data.net/projects/nfd/wiki/NDNLPv2#TLV-TYPE-Number-Assignments
|
||||
*/
|
||||
enum {
|
||||
enum : uint32_t {
|
||||
LpPacket = 100,
|
||||
Fragment = 80,
|
||||
Sequence = 81,
|
||||
@@ -50,28 +53,23 @@ enum {
|
||||
TxSequence = 840,
|
||||
NonDiscovery = 844,
|
||||
PrefixAnnouncement = 848,
|
||||
};
|
||||
|
||||
enum {
|
||||
/**
|
||||
* \brief Lower bound of 1-octet header field.
|
||||
*/
|
||||
HEADER1_MIN = 81,
|
||||
|
||||
/**
|
||||
* \brief Upper bound of 1-octet header field.
|
||||
*/
|
||||
HEADER1_MAX = 99,
|
||||
|
||||
/**
|
||||
* \brief Lower bound of 3-octet header field.
|
||||
*/
|
||||
HEADER3_MIN = 800,
|
||||
|
||||
/**
|
||||
* \brief Upper bound of 3-octet header field.
|
||||
*/
|
||||
HEADER3_MAX = 959
|
||||
HEADER3_MAX = 959,
|
||||
};
|
||||
|
||||
} // namespace tlv
|
||||
|
||||
Reference in new issue
Block a user