summaryrefslogtreecommitdiffstats
path: root/libtransport/includes
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes')
-rw-r--r--libtransport/includes/hicn/transport/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/auth/CMakeLists.txt4
-rw-r--r--libtransport/includes/hicn/transport/auth/common.h2
-rw-r--r--libtransport/includes/hicn/transport/auth/crypto_hash.h151
-rw-r--r--libtransport/includes/hicn/transport/auth/crypto_hash_type.h35
-rw-r--r--libtransport/includes/hicn/transport/auth/crypto_hasher.h70
-rw-r--r--libtransport/includes/hicn/transport/auth/crypto_suite.h39
-rw-r--r--libtransport/includes/hicn/transport/auth/identity.h23
-rw-r--r--libtransport/includes/hicn/transport/auth/signer.h69
-rw-r--r--libtransport/includes/hicn/transport/auth/verifier.h144
-rw-r--r--libtransport/includes/hicn/transport/core/CMakeLists.txt3
-rw-r--r--libtransport/includes/hicn/transport/core/asio_wrapper.h (renamed from libtransport/includes/hicn/transport/security/key_id.h)15
-rw-r--r--libtransport/includes/hicn/transport/core/connector_stats.h13
-rw-r--r--libtransport/includes/hicn/transport/core/content_object.h8
-rw-r--r--libtransport/includes/hicn/transport/core/endpoint.h5
-rw-r--r--libtransport/includes/hicn/transport/core/global_object_pool.h4
-rw-r--r--libtransport/includes/hicn/transport/core/interest.h10
-rw-r--r--libtransport/includes/hicn/transport/core/io_module.h6
-rw-r--r--libtransport/includes/hicn/transport/core/packet.h40
-rw-r--r--libtransport/includes/hicn/transport/errors/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/http/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/interfaces/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/interfaces/callbacks.h2
-rw-r--r--libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h2
-rw-r--r--libtransport/includes/hicn/transport/interfaces/portal.h12
-rw-r--r--libtransport/includes/hicn/transport/interfaces/rtc_socket_producer.h32
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_consumer.h8
-rw-r--r--libtransport/includes/hicn/transport/interfaces/socket_producer.h8
-rw-r--r--libtransport/includes/hicn/transport/interfaces/statistics.h24
-rw-r--r--libtransport/includes/hicn/transport/interfaces/verification_policy.h33
-rw-r--r--libtransport/includes/hicn/transport/portability/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/portability/c_portability.h8
-rw-r--r--libtransport/includes/hicn/transport/portability/portability.h43
-rw-r--r--libtransport/includes/hicn/transport/portability/win_portability.h1
-rw-r--r--libtransport/includes/hicn/transport/security/CMakeLists.txt27
-rw-r--r--libtransport/includes/hicn/transport/security/crypto_hash.h119
-rw-r--r--libtransport/includes/hicn/transport/security/crypto_hash_type.h31
-rw-r--r--libtransport/includes/hicn/transport/security/crypto_hasher.h68
-rw-r--r--libtransport/includes/hicn/transport/security/crypto_suite.h36
-rw-r--r--libtransport/includes/hicn/transport/security/identity.h61
-rw-r--r--libtransport/includes/hicn/transport/security/signer.h85
-rw-r--r--libtransport/includes/hicn/transport/security/verifier.h94
-rw-r--r--libtransport/includes/hicn/transport/utils/CMakeLists.txt2
-rw-r--r--libtransport/includes/hicn/transport/utils/event_thread.h6
-rw-r--r--libtransport/includes/hicn/transport/utils/fixed_block_allocator.h21
-rw-r--r--libtransport/includes/hicn/transport/utils/linux.h2
-rw-r--r--libtransport/includes/hicn/transport/utils/log.h1056
-rw-r--r--libtransport/includes/hicn/transport/utils/membuf.h4
-rw-r--r--libtransport/includes/hicn/transport/utils/move_wrapper.h3
-rw-r--r--libtransport/includes/hicn/transport/utils/object_pool.h3
-rw-r--r--libtransport/includes/hicn/transport/utils/singleton.h6
51 files changed, 402 insertions, 2046 deletions
diff --git a/libtransport/includes/hicn/transport/CMakeLists.txt b/libtransport/includes/hicn/transport/CMakeLists.txt
index ca53bdffd..eb339fb5a 100644
--- a/libtransport/includes/hicn/transport/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
include(GNUInstallDirs)
set(ASIO_STANDALONE 1)
diff --git a/libtransport/includes/hicn/transport/auth/CMakeLists.txt b/libtransport/includes/hicn/transport/auth/CMakeLists.txt
index d855125b0..1e9fe4698 100644
--- a/libtransport/includes/hicn/transport/auth/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/auth/CMakeLists.txt
@@ -11,13 +11,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/common.h
${CMAKE_CURRENT_SOURCE_DIR}/crypto_hash.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_hash_type.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_hasher.h
${CMAKE_CURRENT_SOURCE_DIR}/crypto_suite.h
${CMAKE_CURRENT_SOURCE_DIR}/identity.h
${CMAKE_CURRENT_SOURCE_DIR}/key_id.h
diff --git a/libtransport/includes/hicn/transport/auth/common.h b/libtransport/includes/hicn/transport/auth/common.h
index 911bcbc6a..fb0e82eb7 100644
--- a/libtransport/includes/hicn/transport/auth/common.h
+++ b/libtransport/includes/hicn/transport/auth/common.h
@@ -20,8 +20,6 @@
namespace transport {
namespace auth {
-using Hash = std::vector<uint8_t>;
-using HashEntry = std::pair<CryptoHashType, Hash>;
using PacketPtr = core::Packet *;
using Suffix = uint32_t;
diff --git a/libtransport/includes/hicn/transport/auth/crypto_hash.h b/libtransport/includes/hicn/transport/auth/crypto_hash.h
index 26c251b38..90f1627e9 100644
--- a/libtransport/includes/hicn/transport/auth/crypto_hash.h
+++ b/libtransport/includes/hicn/transport/auth/crypto_hash.h
@@ -16,105 +16,86 @@
#pragma once
#include <hicn/transport/errors/runtime_exception.h>
-#include <hicn/transport/portability/portability.h>
-#include <hicn/transport/auth/crypto_hash_type.h>
-#include <hicn/transport/utils/array.h>
+#include <hicn/transport/utils/membuf.h>
-extern "C" {
-#include <parc/security/parc_CryptoHash.h>
-};
+#include <iomanip>
-#include <cstring>
-#include <unordered_map>
+extern "C" {
+#include <openssl/evp.h>
+}
namespace transport {
namespace auth {
-class CryptoHasher;
+typedef const EVP_MD *(*CryptoHashEVP)(void);
-struct EnumClassHash {
- template <typename T>
- std::size_t operator()(T t) const {
- return static_cast<std::size_t>(t);
- }
+enum class CryptoHashType : uint8_t {
+ UNKNOWN,
+ SHA256,
+ SHA512,
+ BLAKE2B512,
+ BLAKE2S256,
};
-static std::unordered_map<CryptoHashType, std::size_t, EnumClassHash>
- hash_size_map = {{CryptoHashType::SHA_256, 32},
- {CryptoHashType::CRC32C, 4},
- {CryptoHashType::SHA_512, 64}};
+class CryptoHash {
+ public:
+ // Constructors
+ CryptoHash();
+ CryptoHash(const CryptoHash &other);
+ CryptoHash(CryptoHash &&other);
+ CryptoHash(CryptoHashType hash_type);
+ CryptoHash(const uint8_t *hash, std::size_t size, CryptoHashType hash_type);
+ CryptoHash(const std::vector<uint8_t> &hash, CryptoHashType hash_type);
-class Signer;
-class Verifier;
+ // Destructor
+ ~CryptoHash() = default;
-class CryptoHash {
- friend class CryptoHasher;
- friend class Signer;
- friend class Verifier;
+ // Operators
+ CryptoHash &operator=(const CryptoHash &other);
+ bool operator==(const CryptoHash &other) const;
- public:
- CryptoHash() : hash_(nullptr) {}
-
- CryptoHash(const CryptoHash& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
- }
-
- CryptoHash(CryptoHash&& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
- }
-
- template <typename T>
- CryptoHash(const T* buffer, std::size_t length, CryptoHashType hash_type) {
- hash_ = parcCryptoHash_CreateFromArray(
- static_cast<PARCCryptoHashType>(hash_type), buffer, length);
- }
-
- ~CryptoHash() {
- if (hash_) {
- parcCryptoHash_Release(&hash_);
- }
- }
-
- CryptoHash& operator=(const CryptoHash& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
-
- return *this;
- }
-
- template <typename T>
- utils::Array<T> getDigest() const {
- return utils::Array<T>(
- static_cast<T*>(parcBuffer_Overlay(parcCryptoHash_GetDigest(hash_), 0)),
- parcBuffer_Remaining(parcCryptoHash_GetDigest(hash_)));
- }
-
- CryptoHashType getType() {
- return static_cast<CryptoHashType>(parcCryptoHash_GetDigestType(hash_));
- }
-
- template <typename T>
- static bool compareBinaryDigest(const T* digest1, const T* digest2,
- CryptoHashType hash_type) {
- if (hash_size_map.find(hash_type) == hash_size_map.end()) {
- return false;
- }
-
- return !static_cast<bool>(
- std::memcmp(digest1, digest2, hash_size_map[hash_type]));
- }
-
- TRANSPORT_ALWAYS_INLINE void display() {
- parcBuffer_Display(parcCryptoHash_GetDigest(hash_), 2);
- }
+ // Compute the hash of given buffer
+ void computeDigest(const uint8_t *buffer, std::size_t len);
+ void computeDigest(const std::vector<uint8_t> &buffer);
+
+ // Compute the hash of given membuf
+ void computeDigest(const utils::MemBuf *buffer);
+
+ // Return the computed hash
+ std::vector<uint8_t> getDigest() const;
+
+ // Return the computed hash as a string
+ std::string getStringDigest() const;
+
+ // Return hash type
+ CryptoHashType getType() const;
+
+ // Return hash size
+ std::size_t getSize() const;
+
+ // Change hash type
+ void setType(CryptoHashType hash_type);
+
+ // Print hash to stdout
+ void display();
+
+ // Reset hash
+ void reset();
+
+ // Return OpenSSL EVP function associated to a given hash type
+ static CryptoHashEVP getEVP(CryptoHashType hash_type);
+
+ // Return hash size
+ static std::size_t getSize(CryptoHashType hash_type);
+
+ // Compare two raw buffers
+ static bool compareDigest(const uint8_t *h1, const uint8_t *h2,
+ CryptoHashType hash_type);
private:
- PARCCryptoHash* hash_;
+ CryptoHashType digest_type_;
+ std::vector<uint8_t> digest_;
+ std::size_t digest_size_;
};
} // namespace auth
diff --git a/libtransport/includes/hicn/transport/auth/crypto_hash_type.h b/libtransport/includes/hicn/transport/auth/crypto_hash_type.h
deleted file mode 100644
index 9d792624e..000000000
--- a/libtransport/includes/hicn/transport/auth/crypto_hash_type.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-extern "C" {
-#include <parc/security/parc_CryptoHashType.h>
-};
-
-#include <cstdint>
-
-namespace transport {
-namespace auth {
-
-enum class CryptoHashType : uint8_t {
- SHA_256 = PARCCryptoHashType_SHA256,
- SHA_512 = PARCCryptoHashType_SHA512,
- CRC32C = PARCCryptoHashType_CRC32C,
- NULL_HASH = PARCCryptoHashType_NULL
-};
-
-} // namespace auth
-} // namespace transport
diff --git a/libtransport/includes/hicn/transport/auth/crypto_hasher.h b/libtransport/includes/hicn/transport/auth/crypto_hasher.h
deleted file mode 100644
index ada1a6ee8..000000000
--- a/libtransport/includes/hicn/transport/auth/crypto_hasher.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/auth/crypto_hash.h>
-
-extern "C" {
-#include <parc/security/parc_CryptoHasher.h>
-};
-
-namespace transport {
-namespace auth {
-
-class CryptoHasher {
- public:
- CryptoHasher(CryptoHashType hash_type)
- : hasher_(parcCryptoHasher_Create(
- static_cast<PARCCryptoHashType>(hash_type))),
- managed_(true) {}
-
- CryptoHasher(PARCCryptoHasher* hasher) : hasher_(hasher), managed_(false) {}
-
- ~CryptoHasher() {
- if (managed_) {
- parcCryptoHasher_Release(&hasher_);
- }
- }
-
- CryptoHasher& init() {
- if (parcCryptoHasher_Init(hasher_) == -1) {
- throw errors::RuntimeException("Cryptohash init failed.");
- }
-
- return *this;
- }
-
- template <typename T>
- CryptoHasher& updateBytes(const T* buffer, std::size_t length) {
- if (parcCryptoHasher_UpdateBytes(hasher_, buffer, length) == -1) {
- throw errors::RuntimeException("Cryptohash updateBytes failed.");
- }
- return *this;
- }
-
- CryptoHash finalize() {
- CryptoHash hash;
- hash.hash_ = parcCryptoHasher_Finalize(hasher_);
- return hash;
- }
-
- private:
- PARCCryptoHasher* hasher_;
- bool managed_;
-};
-
-} // namespace auth
-} // namespace transport
diff --git a/libtransport/includes/hicn/transport/auth/crypto_suite.h b/libtransport/includes/hicn/transport/auth/crypto_suite.h
index 11df6ac06..d0f1de395 100644
--- a/libtransport/includes/hicn/transport/auth/crypto_suite.h
+++ b/libtransport/includes/hicn/transport/auth/crypto_suite.h
@@ -15,25 +15,40 @@
#pragma once
-extern "C" {
-#include <parc/security/parc_CryptoSuite.h>
-};
+#include <hicn/transport/auth/crypto_hash.h>
-#include <cstdint>
+extern "C" {
+#include <openssl/obj_mac.h>
+}
namespace transport {
namespace auth {
enum class CryptoSuite : uint8_t {
- RSA_SHA256 = PARCCryptoSuite_RSA_SHA256,
- DSA_SHA256 = PARCCryptoSuite_DSA_SHA256,
- RSA_SHA512 = PARCCryptoSuite_RSA_SHA512,
- HMAC_SHA256 = PARCCryptoSuite_HMAC_SHA256,
- HMAC_SHA512 = PARCCryptoSuite_HMAC_SHA512,
- NULL_CRC32C = PARCCryptoSuite_NULL_CRC32C,
- ECDSA_256K1 = PARCCryptoSuite_ECDSA_SHA256,
- UNKNOWN = PARCCryptoSuite_UNKNOWN
+ UNKNOWN,
+ ECDSA_BLAKE2B512,
+ ECDSA_BLAKE2S256,
+ ECDSA_SHA256,
+ ECDSA_SHA512,
+ RSA_BLAKE2B512,
+ RSA_BLAKE2S256,
+ RSA_SHA256,
+ RSA_SHA512,
+ HMAC_BLAKE2B512,
+ HMAC_BLAKE2S256,
+ HMAC_SHA256,
+ HMAC_SHA512,
+ DSA_BLAKE2B512,
+ DSA_BLAKE2S256,
+ DSA_SHA256,
+ DSA_SHA512,
};
+// Return the suite associated to the given NID
+CryptoSuite getSuite(int nid);
+
+// Return the hash type associated to the given suite
+CryptoHashType getHashType(CryptoSuite suite);
+
} // namespace auth
} // namespace transport
diff --git a/libtransport/includes/hicn/transport/auth/identity.h b/libtransport/includes/hicn/transport/auth/identity.h
index 19157952e..be072f5d3 100644
--- a/libtransport/includes/hicn/transport/auth/identity.h
+++ b/libtransport/includes/hicn/transport/auth/identity.h
@@ -15,14 +15,17 @@
#pragma once
+#include <errno.h>
+#include <fcntl.h>
#include <hicn/transport/auth/signer.h>
+#include <unistd.h>
extern "C" {
-#include <parc/security/parc_Identity.h>
-#include <parc/security/parc_IdentityFile.h>
-#include <parc/security/parc_Pkcs12KeyStore.h>
-#include <parc/security/parc_Security.h>
-};
+#include <openssl/pkcs12.h>
+#include <openssl/rand.h>
+#include <openssl/x509.h>
+#include <openssl/x509v3.h>
+}
namespace transport {
namespace auth {
@@ -54,12 +57,20 @@ class Identity {
// Return the key store password.
std::string getPassword() const;
+ std::shared_ptr<X509> getCertificate() const;
+
+ std::shared_ptr<EVP_PKEY> getPrivateKey() const;
+
// Generate a new random identity.
static Identity generateIdentity(const std::string &subject_name = "");
private:
- PARCIdentity *identity_;
+ static void free_key(EVP_PKEY *T) { EVP_PKEY_free(T); }
+
+ std::string pwd_;
+ std::string filename_;
std::shared_ptr<AsymmetricSigner> signer_;
+ std::shared_ptr<X509> cert_;
};
} // namespace auth
diff --git a/libtransport/includes/hicn/transport/auth/signer.h b/libtransport/includes/hicn/transport/auth/signer.h
index fd5c4e6c6..405dd83cf 100644
--- a/libtransport/includes/hicn/transport/auth/signer.h
+++ b/libtransport/includes/hicn/transport/auth/signer.h
@@ -16,62 +16,79 @@
#pragma once
#include <hicn/transport/auth/common.h>
+#include <hicn/transport/auth/crypto_hash.h>
+#include <hicn/transport/auth/crypto_suite.h>
#include <hicn/transport/errors/errors.h>
+#include <hicn/transport/utils/membuf.h>
extern "C" {
-#include <parc/security/parc_PublicKeySigner.h>
-#include <parc/security/parc_Security.h>
-#include <parc/security/parc_Signer.h>
-#include <parc/security/parc_SymmetricKeySigner.h>
+#include <openssl/evp.h>
+#include <openssl/hmac.h>
}
namespace transport {
namespace auth {
+class Identity;
class Signer {
// The base class from which all signer classes derive.
+ friend class Identity;
+
public:
Signer();
- Signer(PARCSigner *signer);
-
virtual ~Signer();
// Sign a packet.
virtual void signPacket(PacketPtr packet);
+ virtual void signBuffer(const std::vector<uint8_t> &buffer);
+ virtual void signBuffer(const utils::MemBuf *buffer);
+
+ // Return the signature.
+ std::vector<uint8_t> getSignature() const;
- // Set the signer object used to sign packets.
- void setSigner(PARCSigner *signer);
+ // Return the signature size in bytes.
+ virtual std::size_t getSignatureSize() const;
- // Return the signature size.
- size_t getSignatureSize() const;
+ // Return the field size necessary to hold the signature. The field size is
+ // always a multiple of 4. Use this function when allocating the signature
+ // packet header.
+ virtual std::size_t getSignatureFieldSize() const;
// Return the crypto suite associated to the signer.
- CryptoSuite getCryptoSuite() const;
+ CryptoSuite getSuite() const;
// Return the hash algorithm associated to the signer.
- CryptoHashType getCryptoHashType() const;
+ CryptoHashType getHashType() const;
- // Return the PARC signer.
- PARCSigner *getParcSigner() const;
+ protected:
+ CryptoSuite suite_;
+ std::vector<uint8_t> signature_;
+ std::size_t signature_len_;
+ std::shared_ptr<EVP_PKEY> key_;
+ CryptoHash key_id_;
+};
- // Return the PARC key store containing the signer key.
- PARCKeyStore *getParcKeyStore() const;
+class VoidSigner : public Signer {
+ // This class is the default socket signer. It does not sign packet.
+ public:
+ VoidSigner() = default;
- protected:
- PARCSigner *signer_;
- PARCKeyId *key_id_;
+ void signPacket(PacketPtr packet) override;
+ void signBuffer(const std::vector<uint8_t> &buffer) override;
+ void signBuffer(const utils::MemBuf *buffer) override;
};
class AsymmetricSigner : public Signer {
- // This class uses asymmetric verification to sign packets. The public key
- // must be given from a PARCKeyStore.
+ // This class uses asymmetric verification to sign packets.
public:
AsymmetricSigner() = default;
- AsymmetricSigner(PARCSigner *signer) : Signer(signer){};
// Construct an AsymmetricSigner from a key store and a given crypto suite.
- AsymmetricSigner(CryptoSuite suite, PARCKeyStore *key_store);
+ AsymmetricSigner(CryptoSuite suite, std::shared_ptr<EVP_PKEY> key,
+ std::shared_ptr<EVP_PKEY> pub_key);
+
+ std::size_t getSignatureFieldSize() const override;
};
class SymmetricSigner : public Signer {
@@ -79,12 +96,8 @@ class SymmetricSigner : public Signer {
// key is derived from a passphrase.
public:
SymmetricSigner() = default;
- SymmetricSigner(PARCSigner *signer) : Signer(signer){};
-
- // Construct an SymmetricSigner from a key store and a given crypto suite.
- SymmetricSigner(CryptoSuite suite, PARCKeyStore *key_store);
- // Construct an AsymmetricSigner from a passphrase and a given crypto suite.
+ // Construct a SymmetricSigner from a passphrase and a given crypto suite.
SymmetricSigner(CryptoSuite suite, const std::string &passphrase);
};
diff --git a/libtransport/includes/hicn/transport/auth/verifier.h b/libtransport/includes/hicn/transport/auth/verifier.h
index e6e561918..6321d4ed5 100644
--- a/libtransport/includes/hicn/transport/auth/verifier.h
+++ b/libtransport/includes/hicn/transport/auth/verifier.h
@@ -21,26 +21,26 @@
#include <hicn/transport/errors/errors.h>
#include <hicn/transport/interfaces/callbacks.h>
-#include <algorithm>
-
extern "C" {
-#include <parc/security/parc_CertificateFactory.h>
-#include <parc/security/parc_InMemoryVerifier.h>
-#include <parc/security/parc_Security.h>
-#include <parc/security/parc_SymmetricKeySigner.h>
-#include <parc/security/parc_Verifier.h>
+#include <openssl/evp.h>
+#include <openssl/hmac.h>
+#include <openssl/pem.h>
+#include <openssl/x509.h>
}
namespace transport {
namespace auth {
class Verifier {
- // The base class from which all verifier classes derive.
+ // The base Verifier class.
public:
- // The VerificationFailedCallback will be called by the transport if a data
- // packet (either a manifest or a content object) cannot be verified. The
- // application decides what to do then by returning a VerificationPolicy
- // object.
+ using SuffixMap = std::unordered_map<Suffix, CryptoHash>;
+ using PolicyMap = std::unordered_map<Suffix, VerificationPolicy>;
+
+ // The VerificationFailedCallback will be called by the transport if a
+ // data packet (either a manifest or a content object) was not validated.
+ // The application decides what to do then by returning a
+ // VerificationPolicy object.
using VerificationFailedCallback = std::function<auth::VerificationPolicy(
const core::ContentObject &content_object, std::error_code ec)>;
@@ -52,39 +52,41 @@ class Verifier {
virtual ~Verifier();
- // Verify a single packet and return whether or not the packet signature is
- // valid.
+ // Verify a single packet or buffer.
virtual bool verifyPacket(PacketPtr packet);
-
- // Verify a batch of packets. Return a vector with the same size as the packet
- // list, element i of that vector will contain the VerificationPolicy for
- // packet i.
- virtual std::vector<VerificationPolicy> verifyPackets(
- const std::vector<PacketPtr> &packets);
+ virtual bool verifyBuffer(const std::vector<uint8_t> &buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) = 0;
+ virtual bool verifyBuffer(const utils::MemBuf *buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) = 0;
+
+ // Verify a batch of packets. Return a mapping from packet suffixes to their
+ // VerificationPolicy.
+ virtual PolicyMap verifyPackets(const std::vector<PacketPtr> &packets);
VerificationPolicy verifyPackets(PacketPtr packet) {
- return verifyPackets(std::vector<PacketPtr>{packet}).front();
+ return verifyPackets(std::vector<PacketPtr>{packet})
+ .at(packet->getName().getSuffix());
}
+ // Verify that a set of packet hashes are present in another set of hashes
+ // that was extracted from manifests. Return a mapping from packet suffixes to
+ // their VerificationPolicy.
+ virtual PolicyMap verifyHashes(const SuffixMap &packet_map,
+ const SuffixMap &suffix_map);
+
// Verify that a batch of packets are valid using a map from packet suffixes
- // to hashes. A packet is considered valid if its hash correspond to the hash
- // present in the map. Return a vector with the same size as the packet list,
- // element i of that vector will contain the VerificationPolicy for packet i.
- virtual std::vector<VerificationPolicy> verifyPackets(
- const std::vector<PacketPtr> &packets,
- const std::unordered_map<Suffix, HashEntry> &suffix_map);
- VerificationPolicy verifyPackets(
- PacketPtr packet,
- const std::unordered_map<Suffix, HashEntry> &suffix_map) {
- return verifyPackets(std::vector<PacketPtr>{packet}, suffix_map).front();
+ // to hashes. A packet is considered valid if its hash is present in the map.
+ // Return a mapping from packet suffixes to their VerificationPolicy.
+ virtual PolicyMap verifyPackets(const std::vector<PacketPtr> &packets,
+ const SuffixMap &suffix_map);
+ VerificationPolicy verifyPackets(PacketPtr packet,
+ const SuffixMap &suffix_map) {
+ return verifyPackets(std::vector<PacketPtr>{packet}, suffix_map)
+ .at(packet->getName().getSuffix());
}
- // Add a general PARC key which can be used to verify packet signatures.
- void addKey(PARCKey *key);
-
- // Set the hasher object used to compute packet hashes.
- void setHasher(PARCCryptoHasher *hasher);
-
- // Set the callback for the case packet verification fails.
+ // Set the callback called when packet verification fails.
void setVerificationFailedCallback(
VerificationFailedCallback verification_failed_cb,
const std::vector<VerificationPolicy> &failed_policies =
@@ -94,50 +96,62 @@ class Verifier {
void getVerificationFailedCallback(
VerificationFailedCallback **verification_failed_cb);
- static size_t getSignatureSize(const PacketPtr);
-
protected:
- PARCCryptoHasher *hasher_;
- PARCVerifier *verifier_;
VerificationFailedCallback verification_failed_cb_;
std::vector<VerificationPolicy> failed_policies_;
- // Internally compute a packet hash using the hasher object.
- virtual CryptoHash computeHash(PacketPtr packet);
-
// Call VerificationFailedCallback if it is set and update the packet policy.
void callVerificationFailedCallback(PacketPtr packet,
VerificationPolicy &policy);
};
class VoidVerifier : public Verifier {
- // This class is the default socket verifier. It ignores completely the packet
- // signature and always returns true.
+ // This class is the default socket verifier. It ignores any packet signature
+ // and always returns true.
public:
bool verifyPacket(PacketPtr packet) override;
+ bool verifyBuffer(const std::vector<uint8_t> &buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
+ bool verifyBuffer(const utils::MemBuf *buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
- std::vector<VerificationPolicy> verifyPackets(
- const std::vector<PacketPtr> &packets) override;
+ PolicyMap verifyPackets(const std::vector<PacketPtr> &packets) override;
- std::vector<VerificationPolicy> verifyPackets(
- const std::vector<PacketPtr> &packets,
- const std::unordered_map<Suffix, HashEntry> &suffix_map) override;
+ PolicyMap verifyPackets(const std::vector<PacketPtr> &packets,
+ const SuffixMap &suffix_map) override;
};
class AsymmetricVerifier : public Verifier {
// This class uses asymmetric verification to validate packets. The public key
- // can be set directly or extracted from a certificate.
+ // can be directly set or extracted from a certificate.
public:
AsymmetricVerifier() = default;
- // Add a public key to the verifier.
- AsymmetricVerifier(PARCKey *pub_key);
+ // Construct an AsymmetricVerifier from an asymmetric key.
+ AsymmetricVerifier(std::shared_ptr<EVP_PKEY> key);
// Construct an AsymmetricVerifier from a certificate file.
AsymmetricVerifier(const std::string &cert_path);
+ AsymmetricVerifier(std::shared_ptr<X509> cert);
+
+ // Set the asymmetric key.
+ void setKey(std::shared_ptr<EVP_PKEY> key);
+
+ // Extract the public key from a certificate.
+ void useCertificate(const std::string &cert_path);
+ void useCertificate(std::shared_ptr<X509> cert);
- // Extract the public key of a certificate file.
- void setCertificate(const std::string &cert_path);
+ bool verifyBuffer(const std::vector<uint8_t> &buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
+ bool verifyBuffer(const utils::MemBuf *buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
+
+ private:
+ std::shared_ptr<EVP_PKEY> key_;
};
class SymmetricVerifier : public Verifier {
@@ -149,20 +163,18 @@ class SymmetricVerifier : public Verifier {
// Construct a SymmetricVerifier from a passphrase.
SymmetricVerifier(const std::string &passphrase);
- ~SymmetricVerifier();
-
// Create and set a symmetric key from a passphrase.
void setPassphrase(const std::string &passphrase);
- // Construct a signer object. Passphrase must be set beforehand.
- void setSigner(const PARCCryptoSuite &suite);
-
- virtual std::vector<VerificationPolicy> verifyPackets(
- const std::vector<PacketPtr> &packets) override;
+ bool verifyBuffer(const std::vector<uint8_t> &buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
+ bool verifyBuffer(const utils::MemBuf *buffer,
+ const std::vector<uint8_t> &signature,
+ CryptoHashType hash_type) override;
protected:
- PARCBuffer *passphrase_;
- PARCSigner *signer_;
+ std::shared_ptr<EVP_PKEY> key_;
};
} // namespace auth
diff --git a/libtransport/includes/hicn/transport/core/CMakeLists.txt b/libtransport/includes/hicn/transport/core/CMakeLists.txt
index 2553b7dcd..14c795a7a 100644
--- a/libtransport/includes/hicn/transport/core/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/core/CMakeLists.txt
@@ -11,9 +11,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/asio_wrapper.h
${CMAKE_CURRENT_SOURCE_DIR}/content_object.h
${CMAKE_CURRENT_SOURCE_DIR}/interest.h
${CMAKE_CURRENT_SOURCE_DIR}/name.h
diff --git a/libtransport/includes/hicn/transport/security/key_id.h b/libtransport/includes/hicn/transport/core/asio_wrapper.h
index d67b73d7a..78cad35dc 100644
--- a/libtransport/includes/hicn/transport/security/key_id.h
+++ b/libtransport/includes/hicn/transport/core/asio_wrapper.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -15,11 +15,14 @@
#pragma once
-#include <cstdint>
-#include <utility>
+#include <hicn/transport/portability/portability.h>
-namespace utils {
+TRANSPORT_PUSH_WARNING
+TRANSPORT_CLANG_DISABLE_WARNING("-Wdeprecated-declarations")
-using KeyId = std::pair<uint8_t*, uint8_t>;
+#ifndef ASIO_STANDALONE
+#define ASIO_STANDALONE
+#endif
+#include <asio.hpp>
-}
+TRANSPORT_POP_WARNING
diff --git a/libtransport/includes/hicn/transport/core/connector_stats.h b/libtransport/includes/hicn/transport/core/connector_stats.h
index 1985331e9..fff370d02 100644
--- a/libtransport/includes/hicn/transport/core/connector_stats.h
+++ b/libtransport/includes/hicn/transport/core/connector_stats.h
@@ -1,5 +1,16 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
#pragma once
diff --git a/libtransport/includes/hicn/transport/core/content_object.h b/libtransport/includes/hicn/transport/core/content_object.h
index 805bc814c..38baafc69 100644
--- a/libtransport/includes/hicn/transport/core/content_object.h
+++ b/libtransport/includes/hicn/transport/core/content_object.h
@@ -42,7 +42,7 @@ class ContentObject : public Packet {
std::size_t payload_size);
template <typename... Args>
- ContentObject(CopyBufferOp op, Args &&...args)
+ ContentObject(CopyBufferOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {
if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) <
0) {
@@ -51,7 +51,7 @@ class ContentObject : public Packet {
}
template <typename... Args>
- ContentObject(WrapBufferOp op, Args &&...args)
+ ContentObject(WrapBufferOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {
if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) <
0) {
@@ -60,7 +60,7 @@ class ContentObject : public Packet {
}
template <typename... Args>
- ContentObject(CreateOp op, Args &&...args)
+ ContentObject(CreateOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {
if (hicn_data_get_name(format_, packet_start_, name_.getStructReference()) <
0) {
@@ -82,8 +82,6 @@ class ContentObject : public Packet {
void setName(const Name &name) override;
- void setName(Name &&name) override;
-
uint32_t getPathLabel() const;
ContentObject &setPathLabel(uint32_t path_label);
diff --git a/libtransport/includes/hicn/transport/core/endpoint.h b/libtransport/includes/hicn/transport/core/endpoint.h
index 4a19744a7..cb6b0f562 100644
--- a/libtransport/includes/hicn/transport/core/endpoint.h
+++ b/libtransport/includes/hicn/transport/core/endpoint.h
@@ -15,10 +15,7 @@
#pragma once
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio.hpp>
+#include <hicn/transport/core/asio_wrapper.h>
namespace transport {
diff --git a/libtransport/includes/hicn/transport/core/global_object_pool.h b/libtransport/includes/hicn/transport/core/global_object_pool.h
index e0b6e373f..d7f3a9e41 100644
--- a/libtransport/includes/hicn/transport/core/global_object_pool.h
+++ b/libtransport/includes/hicn/transport/core/global_object_pool.h
@@ -71,7 +71,7 @@ class PacketManager
template <
typename PacketType, typename... Args,
typename = std::enable_if_t<std::is_base_of<Packet, PacketType>::value>>
- typename PacketType::Ptr getPacket(Args &&...args) {
+ typename PacketType::Ptr getPacket(Args &&... args) {
PacketType *memory = nullptr;
memory = reinterpret_cast<PacketType *>(memory_pool_.allocateBlock());
@@ -98,7 +98,7 @@ class PacketManager
template <typename PacketType, typename... Args>
typename PacketType::Ptr getPacketFromExistingBuffer(uint8_t *buffer,
std::size_t length,
- Args &&...args) {
+ Args &&... args) {
auto offset = offsetof(PacketStorage, align);
auto memory = reinterpret_cast<PacketType *>(buffer - offset);
utils::STLAllocator<PacketType, MemoryPool> allocator(memory,
diff --git a/libtransport/includes/hicn/transport/core/interest.h b/libtransport/includes/hicn/transport/core/interest.h
index b41b0c94a..a5b9cf375 100644
--- a/libtransport/includes/hicn/transport/core/interest.h
+++ b/libtransport/includes/hicn/transport/core/interest.h
@@ -25,6 +25,8 @@ namespace transport {
namespace core {
+const uint32_t MAX_AGGREGATED_INTEREST = 128;
+
class Interest
: public Packet /*, public std::enable_shared_from_this<Interest>*/ {
private:
@@ -47,7 +49,7 @@ class Interest
Interest(MemBuf &&buffer);
template <typename... Args>
- Interest(CopyBufferOp op, Args &&...args)
+ Interest(CopyBufferOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {
if (hicn_interest_get_name(format_, packet_start_,
name_.getStructReference()) < 0) {
@@ -56,7 +58,7 @@ class Interest
}
template <typename... Args>
- Interest(WrapBufferOp op, Args &&...args)
+ Interest(WrapBufferOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {
if (hicn_interest_get_name(format_, packet_start_,
name_.getStructReference()) < 0) {
@@ -65,7 +67,7 @@ class Interest
}
template <typename... Args>
- Interest(CreateOp op, Args &&...args)
+ Interest(CreateOp op, Args &&... args)
: Packet(op, std::forward<Args>(args)...) {}
/* Move constructor */
@@ -85,8 +87,6 @@ class Interest
void setName(const Name &name) override;
- void setName(Name &&name) override;
-
void setLocator(const ip_address_t &ip_address) override;
ip_address_t getLocator() const override;
diff --git a/libtransport/includes/hicn/transport/core/io_module.h b/libtransport/includes/hicn/transport/core/io_module.h
index d4c3bb03a..ea3cf4e16 100644
--- a/libtransport/includes/hicn/transport/core/io_module.h
+++ b/libtransport/includes/hicn/transport/core/io_module.h
@@ -15,6 +15,7 @@
#pragma once
+#include <hicn/transport/core/asio_wrapper.h>
#include <hicn/transport/core/connector.h>
#include <hicn/transport/core/packet.h>
#include <hicn/transport/core/prefix.h>
@@ -24,11 +25,6 @@
#include <deque>
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio/io_service.hpp>
-
namespace transport {
namespace core {
diff --git a/libtransport/includes/hicn/transport/core/packet.h b/libtransport/includes/hicn/transport/core/packet.h
index 68daea841..269a1571a 100644
--- a/libtransport/includes/hicn/transport/core/packet.h
+++ b/libtransport/includes/hicn/transport/core/packet.h
@@ -15,19 +15,28 @@
#pragma once
+#include <hicn/transport/auth/crypto_hash.h>
+#include <hicn/transport/auth/crypto_suite.h>
+#include <hicn/transport/auth/key_id.h>
#include <hicn/transport/core/name.h>
#include <hicn/transport/core/payload_type.h>
#include <hicn/transport/errors/malformed_packet_exception.h>
#include <hicn/transport/portability/portability.h>
-#include <hicn/transport/auth/crypto_hasher.h>
-#include <hicn/transport/auth/crypto_suite.h>
-#include <hicn/transport/auth/key_id.h>
#include <hicn/transport/utils/branch_prediction.h>
-#include <hicn/transport/utils/log.h>
#include <hicn/transport/utils/membuf.h>
#include <hicn/transport/utils/object_pool.h>
namespace transport {
+
+namespace auth {
+class Signer;
+class AsymmetricSigner;
+class SymmetricSigner;
+class Verifier;
+class AsymmetricVerifier;
+class SymmetricVerifier;
+} // namespace auth
+
namespace core {
/*
@@ -42,7 +51,11 @@ namespace core {
class Packet : public utils::MemBuf,
public std::enable_shared_from_this<Packet> {
friend class auth::Signer;
+ friend class auth::SymmetricSigner;
+ friend class auth::AsymmetricSigner;
friend class auth::Verifier;
+ friend class auth::AsymmetricVerifier;
+ friend class auth::SymmetricVerifier;
public:
using Ptr = std::shared_ptr<Packet>;
@@ -135,8 +148,6 @@ class Packet : public utils::MemBuf,
virtual void setName(const Name &name) = 0;
- virtual void setName(Name &&name) = 0;
-
virtual void setLifetime(uint32_t lifetime) = 0;
virtual uint32_t getLifetime() const = 0;
@@ -223,6 +234,7 @@ class Packet : public utils::MemBuf,
private:
virtual void resetForHash() = 0;
void setSignatureSize(std::size_t size_bytes);
+ void setSignatureSizeGap(std::size_t size_bytes);
void prependPayload(const uint8_t **buffer, std::size_t *size);
bool authenticationHeader() const { return _is_ah(format_); }
@@ -239,6 +251,22 @@ class Packet : public utils::MemBuf,
return size_bytes;
}
+ std::size_t getSignatureSizeGap() const {
+ uint8_t size_bytes;
+ int ret =
+ hicn_packet_get_signature_gap(format_, packet_start_, &size_bytes);
+
+ if (ret < 0) {
+ throw errors::RuntimeException("Packet without Authentication Header.");
+ }
+
+ return (size_t)size_bytes;
+ }
+
+ std::size_t getSignatureSizeReal() const {
+ return getSignatureSize() - getSignatureSizeGap();
+ }
+
uint8_t *getSignature() const;
protected:
diff --git a/libtransport/includes/hicn/transport/errors/CMakeLists.txt b/libtransport/includes/hicn/transport/errors/CMakeLists.txt
index 5b04ace10..1d35c5b34 100644
--- a/libtransport/includes/hicn/transport/errors/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/errors/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/not_implemented_exception.h
${CMAKE_CURRENT_SOURCE_DIR}/invalid_ip_address_exception.h
diff --git a/libtransport/includes/hicn/transport/http/CMakeLists.txt b/libtransport/includes/hicn/transport/http/CMakeLists.txt
index 9cf618c21..9f4cdaf39 100644
--- a/libtransport/includes/hicn/transport/http/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/http/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/client_connection.h
${CMAKE_CURRENT_SOURCE_DIR}/request.h
diff --git a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
index 08f880930..40623dfe1 100644
--- a/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/interfaces/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/socket_consumer.h
${CMAKE_CURRENT_SOURCE_DIR}/socket_producer.h
diff --git a/libtransport/includes/hicn/transport/interfaces/callbacks.h b/libtransport/includes/hicn/transport/interfaces/callbacks.h
index 95b4d1977..22e111799 100644
--- a/libtransport/includes/hicn/transport/interfaces/callbacks.h
+++ b/libtransport/includes/hicn/transport/interfaces/callbacks.h
@@ -15,8 +15,8 @@
#pragma once
-#include <hicn/transport/interfaces/statistics.h>
#include <hicn/transport/auth/policies.h>
+#include <hicn/transport/interfaces/statistics.h>
#include <functional>
#include <system_error>
diff --git a/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h b/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
index 7b284c520..d86744514 100644
--- a/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/p2psecure_socket_producer.h
@@ -15,8 +15,8 @@
#pragma once
-#include <hicn/transport/interfaces/socket_producer.h>
#include <hicn/transport/auth/identity.h>
+#include <hicn/transport/interfaces/socket_producer.h>
namespace transport {
diff --git a/libtransport/includes/hicn/transport/interfaces/portal.h b/libtransport/includes/hicn/transport/interfaces/portal.h
index 22c8591f4..66fc84256 100644
--- a/libtransport/includes/hicn/transport/interfaces/portal.h
+++ b/libtransport/includes/hicn/transport/interfaces/portal.h
@@ -15,14 +15,11 @@
#pragma once
+#include <hicn/transport/core/asio_wrapper.h>
#include <hicn/transport/core/content_object.h>
#include <hicn/transport/core/interest.h>
#include <hicn/transport/core/prefix.h>
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio/io_service.hpp>
#include <functional>
#define UNSET_CALLBACK 0
@@ -71,7 +68,7 @@ class Portal {
class ConsumerCallback {
public:
virtual void onContentObject(core::Interest &i, core::ContentObject &c) = 0;
- virtual void onTimeout(core::Interest::Ptr &&i) = 0;
+ virtual void onTimeout(core::Interest::Ptr &i, const core::Name &n) = 0;
virtual void onError(std::error_code ec) = 0;
};
@@ -87,7 +84,8 @@ class Portal {
using OnContentObjectCallback =
std::function<void(core::Interest &, core::ContentObject &)>;
- using OnInterestTimeoutCallback = std::function<void(core::Interest::Ptr &&)>;
+ using OnInterestTimeoutCallback =
+ std::function<void(core::Interest::Ptr &, const core::Name &)>;
Portal();
@@ -202,4 +200,4 @@ class Portal {
};
} // namespace interface
-} // namespace transport \ No newline at end of file
+} // namespace transport
diff --git a/libtransport/includes/hicn/transport/interfaces/rtc_socket_producer.h b/libtransport/includes/hicn/transport/interfaces/rtc_socket_producer.h
deleted file mode 100644
index 218240f83..000000000
--- a/libtransport/includes/hicn/transport/interfaces/rtc_socket_producer.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/interfaces/socket_producer.h>
-
-namespace transport {
-
-namespace interface {
-
-class RTCProducerSocket : public ProducerSocket {
- public:
- RTCProducerSocket();
- ~RTCProducerSocket() = default;
-};
-
-} // namespace interface
-
-} // end namespace transport
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
index 621e7ce6f..5e0e81b9f 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_consumer.h
@@ -15,18 +15,14 @@
#pragma once
+#include <hicn/transport/auth/verifier.h>
#include <hicn/transport/config.h>
+#include <hicn/transport/core/asio_wrapper.h>
#include <hicn/transport/core/name.h>
#include <hicn/transport/core/prefix.h>
#include <hicn/transport/interfaces/callbacks.h>
#include <hicn/transport/interfaces/socket_options_default_values.h>
#include <hicn/transport/interfaces/socket_options_keys.h>
-#include <hicn/transport/auth/verifier.h>
-
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio/io_service.hpp>
#define CONSUMER_FINISHED 0
#define CONSUMER_BUSY 1
diff --git a/libtransport/includes/hicn/transport/interfaces/socket_producer.h b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
index 302b03f3f..27b603dfe 100644
--- a/libtransport/includes/hicn/transport/interfaces/socket_producer.h
+++ b/libtransport/includes/hicn/transport/interfaces/socket_producer.h
@@ -15,18 +15,14 @@
#pragma once
+#include <hicn/transport/auth/signer.h>
#include <hicn/transport/config.h>
+#include <hicn/transport/core/asio_wrapper.h>
#include <hicn/transport/core/name.h>
#include <hicn/transport/core/prefix.h>
#include <hicn/transport/interfaces/callbacks.h>
#include <hicn/transport/interfaces/socket_options_default_values.h>
#include <hicn/transport/interfaces/socket_options_keys.h>
-#include <hicn/transport/auth/signer.h>
-
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio/io_service.hpp>
namespace transport {
diff --git a/libtransport/includes/hicn/transport/interfaces/statistics.h b/libtransport/includes/hicn/transport/interfaces/statistics.h
index 92c58da23..1ff6f3edd 100644
--- a/libtransport/includes/hicn/transport/interfaces/statistics.h
+++ b/libtransport/includes/hicn/transport/interfaces/statistics.h
@@ -49,11 +49,13 @@ class TransportStatistics {
interest_FEC_tx_(0),
bytes_FEC_received_(0),
lost_data_(0),
+ definitely_lost_data_(0),
recovered_data_(0),
status_(-1),
// avg_data_rtt_(0),
avg_pending_pkt_(0.0),
- received_nacks_(0) {}
+ received_nacks_(0),
+ received_fec_(0) {}
TRANSPORT_ALWAYS_INLINE void updateRetxCount(uint64_t retx) {
retx_count_ += retx;
@@ -96,6 +98,10 @@ class TransportStatistics {
lost_data_ += pkt;
}
+ TRANSPORT_ALWAYS_INLINE void updateDefinitelyLostData(uint64_t pkt) {
+ definitely_lost_data_ += pkt;
+ }
+
TRANSPORT_ALWAYS_INLINE void updateRecoveredData(uint64_t bytes) {
recovered_data_ += bytes;
}
@@ -110,6 +116,10 @@ class TransportStatistics {
received_nacks_ += nacks;
}
+ TRANSPORT_ALWAYS_INLINE void updateReceivedFEC(uint32_t pkt) {
+ received_fec_ += pkt;
+ }
+
TRANSPORT_ALWAYS_INLINE uint64_t getRetxCount() const { return retx_count_; }
TRANSPORT_ALWAYS_INLINE uint64_t getBytesRecv() const {
@@ -142,6 +152,10 @@ class TransportStatistics {
TRANSPORT_ALWAYS_INLINE uint64_t getLostData() const { return lost_data_; }
+ TRANSPORT_ALWAYS_INLINE uint64_t getDefinitelyLostData() const {
+ return definitely_lost_data_;
+ }
+
TRANSPORT_ALWAYS_INLINE uint64_t getBytesRecoveredData() const {
return recovered_data_;
}
@@ -156,6 +170,10 @@ class TransportStatistics {
return received_nacks_;
}
+ TRANSPORT_ALWAYS_INLINE uint32_t getReceivedFEC() const {
+ return received_fec_;
+ }
+
TRANSPORT_ALWAYS_INLINE void setAlpha(double val) { alpha_ = val; }
TRANSPORT_ALWAYS_INLINE void reset() {
@@ -168,11 +186,13 @@ class TransportStatistics {
interest_FEC_tx_ = 0;
bytes_FEC_received_ = 0;
lost_data_ = 0;
+ definitely_lost_data_ = 0;
recovered_data_ = 0;
status_ = 0;
// avg_data_rtt_ = 0;
avg_pending_pkt_ = 0;
received_nacks_ = 0;
+ received_fec_ = 0;
}
private:
@@ -187,10 +207,12 @@ class TransportStatistics {
uint64_t interest_FEC_tx_;
uint64_t bytes_FEC_received_;
uint64_t lost_data_;
+ uint64_t definitely_lost_data_;
uint64_t recovered_data_;
int status_; // transport status (e.g. sync status, congestion etc.)
double avg_pending_pkt_;
uint32_t received_nacks_;
+ uint32_t received_fec_;
};
} // namespace interface
diff --git a/libtransport/includes/hicn/transport/interfaces/verification_policy.h b/libtransport/includes/hicn/transport/interfaces/verification_policy.h
deleted file mode 100644
index cb5140ac1..000000000
--- a/libtransport/includes/hicn/transport/interfaces/verification_policy.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2020 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <cstdint>
-
-namespace transport {
-namespace interface {
-
-/**
- * This policy allows the application to tell the transport what to do in case
- * the verification of a content object fails.
- */
-enum class VerificationPolicy : std::uint8_t {
- DROP_PACKET,
- ACCEPT_PACKET,
- ABORT_SESSION
-};
-} // namespace interface
-} // namespace transport \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/portability/CMakeLists.txt b/libtransport/includes/hicn/transport/portability/CMakeLists.txt
index 469b11192..8094c0661 100644
--- a/libtransport/includes/hicn/transport/portability/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/portability/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/c_portability.h
${CMAKE_CURRENT_SOURCE_DIR}/portability.h
diff --git a/libtransport/includes/hicn/transport/portability/c_portability.h b/libtransport/includes/hicn/transport/portability/c_portability.h
index 9fe9ef90a..2675de000 100644
--- a/libtransport/includes/hicn/transport/portability/c_portability.h
+++ b/libtransport/includes/hicn/transport/portability/c_portability.h
@@ -34,3 +34,11 @@
#else
#define TRANSPORT_ALWAYS_INLINE inline
#endif
+
+// Unused
+#ifdef UNUSED
+#elif defined(__GNUC__) || defined(__clang__)
+#define UNUSED(x) (void)x
+#else
+#define UNUSED(x) x
+#endif
diff --git a/libtransport/includes/hicn/transport/portability/portability.h b/libtransport/includes/hicn/transport/portability/portability.h
index 539ce2d5a..24ef012f7 100644
--- a/libtransport/includes/hicn/transport/portability/portability.h
+++ b/libtransport/includes/hicn/transport/portability/portability.h
@@ -31,20 +31,41 @@ namespace portability {
constexpr bool little_endian_arch = __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__;
constexpr bool big_endian_arch = !little_endian_arch;
-#if defined(__GNUC__)
-#define _TRANSPORT_GNU_DISABLE_WARNING(warning) #warning
-#define TRANSPORT_GNU_DISABLE_WARNING(warning) \
- _Pragma(_TRANSPORT_GNU_DISABLE_WARNING(GCC diagnostic ignored warning))
-
+// Generalize warning push/pop.
+#if defined(__GNUC__) || defined(__clang__)
+// Clang & GCC
+#define TRANSPORT_PUSH_WARNING _Pragma("GCC diagnostic push")
+#define TRANSPORT_POP_WARNING _Pragma("GCC diagnostic pop")
+#define TRANSPORT_GNU_DISABLE_WARNING_INTERNAL2(warningName) #warningName
+#define TRANSPORT_GNU_DISABLE_WARNING(warningName) \
+ _Pragma(TRANSPORT_GNU_DISABLE_WARNING_INTERNAL2( \
+ GCC diagnostic ignored warningName))
#ifdef __clang__
-#define TRANSPORT_CLANG_DISABLE_WARNING(warning) \
- TRANSPORT_GNU_DISABLE_WARNING(warning)
-#define TRANSPORT_GCC_DISABLE_WARNING(warning)
+#define TRANSPORT_CLANG_DISABLE_WARNING(warningName) \
+ TRANSPORT_GNU_DISABLE_WARNING(warningName)
+#define TRANSPORT_GCC_DISABLE_WARNING(warningName)
#else
-#define TRANSPORT_CLANG_DISABLE_WARNING(warning)
-#define TRANSPORT_GCC_DISABLE_WARNING(warning) \
- TRANSPORT_GNU_DISABLE_WARNING(warning)
+#define TRANSPORT_CLANG_DISABLE_WARNING(warningName)
+#define TRANSPORT_GCC_DISABLE_WARNING(warningName) \
+ TRANSPORT_GNU_DISABLE_WARNING(warningName)
#endif
+#define TRANSPORT_MSVC_DISABLE_WARNING(warningNumber)
+#elif defined(_MSC_VER)
+#define TRANSPORT_PUSH_WARNING __pragma(warning(push))
+#define TRANSPORT_POP_WARNING __pragma(warning(pop))
+// Disable the GCC warnings.
+#define TRANSPORT_GNU_DISABLE_WARNING(warningName)
+#define TRANSPORT_GCC_DISABLE_WARNING(warningName)
+#define TRANSPORT_CLANG_DISABLE_WARNING(warningName)
+#define TRANSPORT_MSVC_DISABLE_WARNING(warningNumber) \
+ __pragma(warning(disable : warningNumber))
+#else
+#define TRANSPORT_PUSH_WARNING
+#define TRANSPORT_POP_WARNING
+#define TRANSPORT_GNU_DISABLE_WARNING(warningName)
+#define TRANSPORT_GCC_DISABLE_WARNING(warningName)
+#define TRANSPORT_CLANG_DISABLE_WARNING(warningName)
+#define TRANSPORT_MSVC_DISABLE_WARNING(warningNumber)
#endif
} // namespace portability
diff --git a/libtransport/includes/hicn/transport/portability/win_portability.h b/libtransport/includes/hicn/transport/portability/win_portability.h
index 246b734ad..24c7a932a 100644
--- a/libtransport/includes/hicn/transport/portability/win_portability.h
+++ b/libtransport/includes/hicn/transport/portability/win_portability.h
@@ -22,7 +22,6 @@
#endif
#include <fcntl.h>
#include <io.h>
-#include <parc/windows/parc_Utils.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
diff --git a/libtransport/includes/hicn/transport/security/CMakeLists.txt b/libtransport/includes/hicn/transport/security/CMakeLists.txt
deleted file mode 100644
index 58a96780b..000000000
--- a/libtransport/includes/hicn/transport/security/CMakeLists.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright (c) 2017-2019 Cisco and/or its affiliates.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
-list(APPEND HEADER_FILES
- ${CMAKE_CURRENT_SOURCE_DIR}/signer.h
- ${CMAKE_CURRENT_SOURCE_DIR}/verifier.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_hasher.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_suite.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_hash.h
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_hash_type.h
- ${CMAKE_CURRENT_SOURCE_DIR}/identity.h
- ${CMAKE_CURRENT_SOURCE_DIR}/key_id.h
-)
-
-set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/security/crypto_hash.h b/libtransport/includes/hicn/transport/security/crypto_hash.h
deleted file mode 100644
index 5a58f258b..000000000
--- a/libtransport/includes/hicn/transport/security/crypto_hash.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/errors/runtime_exception.h>
-#include <hicn/transport/portability/portability.h>
-#include <hicn/transport/security/crypto_hash_type.h>
-#include <hicn/transport/utils/array.h>
-
-extern "C" {
-#include <parc/security/parc_CryptoHash.h>
-};
-
-#include <cstring>
-#include <unordered_map>
-
-namespace utils {
-
-class CryptoHasher;
-
-struct EnumClassHash {
- template <typename T>
- std::size_t operator()(T t) const {
- return static_cast<std::size_t>(t);
- }
-};
-
-static std::unordered_map<CryptoHashType, std::size_t, EnumClassHash>
- hash_size_map = {{CryptoHashType::SHA_256, 32},
- {CryptoHashType::CRC32C, 4},
- {CryptoHashType::SHA_512, 64}};
-
-class Signer;
-class Verifier;
-
-class CryptoHash {
- friend class CryptoHasher;
- friend class Signer;
- friend class Verifier;
-
- public:
- CryptoHash() : hash_(nullptr) {}
-
- CryptoHash(const CryptoHash& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
- }
-
- CryptoHash(CryptoHash&& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
- }
-
- template <typename T>
- CryptoHash(const T* buffer, std::size_t length, CryptoHashType hash_type) {
- hash_ = parcCryptoHash_CreateFromArray(
- static_cast<PARCCryptoHashType>(hash_type), buffer, length);
- }
-
- ~CryptoHash() {
- if (hash_) {
- parcCryptoHash_Release(&hash_);
- }
- }
-
- CryptoHash& operator=(const CryptoHash& other) {
- if (other.hash_) {
- hash_ = parcCryptoHash_Acquire(other.hash_);
- }
-
- return *this;
- }
-
- template <typename T>
- utils::Array<T> getDigest() const {
- return utils::Array<T>(
- static_cast<T*>(parcBuffer_Overlay(parcCryptoHash_GetDigest(hash_), 0)),
- parcBuffer_Remaining(parcCryptoHash_GetDigest(hash_)));
- }
-
- CryptoHashType getType() {
- return static_cast<CryptoHashType>(parcCryptoHash_GetDigestType(hash_));
- }
-
- template <typename T>
- static bool compareBinaryDigest(const T* digest1, const T* digest2,
- CryptoHashType hash_type) {
- if (hash_size_map.find(hash_type) == hash_size_map.end()) {
- return false;
- }
-
- return !static_cast<bool>(
- std::memcmp(digest1, digest2, hash_size_map[hash_type]));
- }
-
- TRANSPORT_ALWAYS_INLINE void display() {
- parcBuffer_Display(parcCryptoHash_GetDigest(hash_), 2);
- }
-
- private:
- PARCCryptoHash* hash_;
-};
-
-} // namespace utils \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/security/crypto_hash_type.h b/libtransport/includes/hicn/transport/security/crypto_hash_type.h
deleted file mode 100644
index b7597e208..000000000
--- a/libtransport/includes/hicn/transport/security/crypto_hash_type.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-extern "C" {
-#include <parc/security/parc_CryptoHashType.h>
-};
-
-namespace utils {
-
-enum class CryptoHashType : uint8_t {
- SHA_256 = PARCCryptoHashType_SHA256,
- SHA_512 = PARCCryptoHashType_SHA512,
- CRC32C = PARCCryptoHashType_CRC32C,
- NULL_HASH = PARCCryptoHashType_NULL
-};
-
-} \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/security/crypto_hasher.h b/libtransport/includes/hicn/transport/security/crypto_hasher.h
deleted file mode 100644
index 9367c3bc8..000000000
--- a/libtransport/includes/hicn/transport/security/crypto_hasher.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/security/crypto_hash.h>
-
-extern "C" {
-#include <parc/security/parc_CryptoHasher.h>
-};
-
-namespace utils {
-
-class CryptoHasher {
- public:
- CryptoHasher(CryptoHashType hash_type)
- : hasher_(parcCryptoHasher_Create(
- static_cast<PARCCryptoHashType>(hash_type))),
- managed_(true) {}
-
- CryptoHasher(PARCCryptoHasher* hasher) : hasher_(hasher), managed_(false) {}
-
- ~CryptoHasher() {
- if (managed_) {
- parcCryptoHasher_Release(&hasher_);
- }
- }
-
- CryptoHasher& init() {
- if (parcCryptoHasher_Init(hasher_) == -1) {
- throw errors::RuntimeException("Cryptohash init failed.");
- }
-
- return *this;
- }
-
- template <typename T>
- CryptoHasher& updateBytes(const T* buffer, std::size_t length) {
- if (parcCryptoHasher_UpdateBytes(hasher_, buffer, length) == -1) {
- throw errors::RuntimeException("Cryptohash updateBytes failed.");
- }
- return *this;
- }
-
- CryptoHash finalize() {
- CryptoHash hash;
- hash.hash_ = parcCryptoHasher_Finalize(hasher_);
- return hash;
- }
-
- private:
- PARCCryptoHasher* hasher_;
- bool managed_;
-};
-
-} // namespace utils \ No newline at end of file
diff --git a/libtransport/includes/hicn/transport/security/crypto_suite.h b/libtransport/includes/hicn/transport/security/crypto_suite.h
deleted file mode 100644
index 017938f8f..000000000
--- a/libtransport/includes/hicn/transport/security/crypto_suite.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-extern "C" {
-#include <parc/security/parc_CryptoSuite.h>
-};
-
-#include <cstdint>
-
-namespace utils {
-
-enum class CryptoSuite : uint8_t {
- RSA_SHA256 = PARCCryptoSuite_RSA_SHA256,
- DSA_SHA256 = PARCCryptoSuite_DSA_SHA256,
- RSA_SHA512 = PARCCryptoSuite_RSA_SHA512,
- HMAC_SHA256 = PARCCryptoSuite_HMAC_SHA256,
- HMAC_SHA512 = PARCCryptoSuite_HMAC_SHA512,
- NULL_CRC32C = PARCCryptoSuite_NULL_CRC32C,
- ECDSA_256K1 = PARCCryptoSuite_ECDSA_SHA256,
- UNKNOWN = PARCCryptoSuite_UNKNOWN
-};
-}
diff --git a/libtransport/includes/hicn/transport/security/identity.h b/libtransport/includes/hicn/transport/security/identity.h
deleted file mode 100644
index a575af134..000000000
--- a/libtransport/includes/hicn/transport/security/identity.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/security/crypto_suite.h>
-#include <hicn/transport/security/signer.h>
-
-extern "C" {
-#include <parc/security/parc_Identity.h>
-#include <parc/security/parc_IdentityFile.h>
-#include <parc/security/parc_Pkcs12KeyStore.h>
-};
-
-#include <string>
-
-namespace utils {
-
-class Identity {
- public:
- Identity(const std::string &keystore_name,
- const std::string &keystore_password, CryptoSuite suite,
- unsigned int signature_length, unsigned int validity_days,
- const std::string &subject_name);
-
- Identity(const Identity &other);
-
- Identity(std::string &file_name, std::string &password,
- utils::CryptoHashType hash_algorithm);
-
- ~Identity();
-
- static Identity generateIdentity(const std::string &subject_name);
-
- std::string getFileName();
-
- std::string getPassword();
-
- std::shared_ptr<Signer> getSigner();
-
- size_t getSignatureLength() const;
-
- private:
- PARCIdentity *identity_;
- std::shared_ptr<Signer> signer_;
- utils::CryptoHashType hash_algorithm_;
-};
-
-} // namespace utils
diff --git a/libtransport/includes/hicn/transport/security/signer.h b/libtransport/includes/hicn/transport/security/signer.h
deleted file mode 100644
index 45bcdb516..000000000
--- a/libtransport/includes/hicn/transport/security/signer.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/core/packet.h>
-
-extern "C" {
-#include <parc/security/parc_CryptoHashType.h>
-#include <parc/security/parc_CryptoSuite.h>
-#include <parc/security/parc_KeyStore.h>
-#include <parc/security/parc_Signer.h>
-#include <parc/security/parc_SymmetricKeySigner.h>
-}
-
-namespace utils {
-
-using Packet = transport::core::Packet;
-
-/**
- * A signer can use a single key (asymmetric or symmetric) to sign a packet.
- */
-class Signer {
- friend class Identity;
-
- public:
- /**
- * Create a Signer
- *
- * @param keyStore A keystore containing a private key or simmetric key to
- * use to sign packet with this Signer.
- * @param suite CryptoSuite to use to verify the signature
- */
- Signer(PARCKeyStore *keyStore, CryptoSuite suite);
-
- /**
- * Create a Signer
- *
- * @param passphrase A string from which the symmetric key will be derived
- * @param suite CryptoSuite to use to verify the signature
- */
- Signer(const std::string &passphrase, CryptoSuite suite);
-
- Signer(const PARCSigner *signer, CryptoSuite suite);
-
- Signer(const PARCSigner *signer);
-
- ~Signer();
-
- /**
- * @brief Sign a packet
- *
- * This method is general and must be used for Public-private key signature,
- * HMAC and CRC.
- *
- * @param packet A pointer to the header of the packet to sign. Mutable
- * field in the packet must be set to 0.
- * @param key_id Indentifier of the key to use to generate the signature.
- */
- void sign(Packet &packet);
-
- size_t getSignatureLength();
-
- PARCKeyStore *getKeyStore();
-
- private:
- CryptoSuite suite_;
- PARCSigner *signer_ = nullptr;
- PARCKeyId *key_id_ = nullptr;
- size_t signature_length_;
-};
-
-} // namespace utils
diff --git a/libtransport/includes/hicn/transport/security/verifier.h b/libtransport/includes/hicn/transport/security/verifier.h
deleted file mode 100644
index 838868427..000000000
--- a/libtransport/includes/hicn/transport/security/verifier.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at:
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#pragma once
-
-#include <hicn/transport/core/packet.h>
-
-extern "C" {
-#include <parc/security/parc_CertificateFactory.h>
-#include <parc/security/parc_InMemoryVerifier.h>
-#include <parc/security/parc_KeyId.h>
-#include <parc/security/parc_Security.h>
-#include <parc/security/parc_SymmetricKeySigner.h>
-#include <parc/security/parc_Verifier.h>
-}
-
-namespace utils {
-
-using Packet = transport::core::Packet;
-
-/**
- * A verifier holds a crypto cache that contains all the keys to use for
- * verify signatures/hmacs.
- */
-class Verifier {
- public:
- Verifier();
-
- ~Verifier();
-
- /**
- * @brief Check if a key is already in this Verifier.
- *
- * A PARCVerifier contains a CryptoCache with a set of key to use for
- * verification purposes.
- *
- * @param keyId Identifier of the key to match in the CryptoCache of the
- * Verifier.
- * @return true if the key is found, false otherwise.
- */
- bool hasKey(PARCKeyId *keyId);
-
- /**
- * @brief Add a key to this Verifier
- *
- * @param key to add
- * @return true if the key was added successfully, false otherwise.
- */
- bool addKey(PARCKey *key);
-
- PARCKeyId *addKeyFromPassphrase(const std::string &passphrase,
- CryptoSuite suite);
-
- PARCKeyId *addKeyFromCertificate(const std::string &file_name);
-
- /**
- * @brief Verify a Signature
- *
- * This method is general and must be used for Public-private key signature,
- * HMAC and CRC.
- *
- * @param signature A pointer to the buffer holding the signature
- * @param sign_len Lenght of the signature (must be consistent with the type
- * of the key)
- * @param bufferSigned A pointer to the packet header signed with
- * signature. Mutable fields and the signature field in the packet must be
- * set to 0
- * @param buf_len Lenght of bufferSigned
- * @param suite CryptoSuite to use to verify the signature
- * @param key_id Indentifier of the key to use to verify the signature. The
- * key must be already present in the Verifier.
- */
- int verify(const Packet &packet);
-
- CryptoHash getPacketHash(const Packet &packet, CryptoHasher &hasher);
-
- private:
- PARCVerifier *verifier_ = nullptr;
- PARCSigner *signer_ = nullptr;
-};
-
-} // namespace utils
diff --git a/libtransport/includes/hicn/transport/utils/CMakeLists.txt b/libtransport/includes/hicn/transport/utils/CMakeLists.txt
index 7094601f4..75f727f03 100644
--- a/libtransport/includes/hicn/transport/utils/CMakeLists.txt
+++ b/libtransport/includes/hicn/transport/utils/CMakeLists.txt
@@ -11,8 +11,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
-
list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/array.h
${CMAKE_CURRENT_SOURCE_DIR}/string_tokenizer.h
diff --git a/libtransport/includes/hicn/transport/utils/event_thread.h b/libtransport/includes/hicn/transport/utils/event_thread.h
index bb6ab90ef..15ec1d62c 100644
--- a/libtransport/includes/hicn/transport/utils/event_thread.h
+++ b/libtransport/includes/hicn/transport/utils/event_thread.h
@@ -16,13 +16,9 @@
#pragma once
#include <hicn/transport/config.h>
+#include <hicn/transport/core/asio_wrapper.h>
#include <hicn/transport/errors/runtime_exception.h>
-#include <hicn/transport/utils/log.h>
-#ifndef ASIO_STANDALONE
-#define ASIO_STANDALONE
-#endif
-#include <asio.hpp>
#include <memory>
#include <thread>
diff --git a/libtransport/includes/hicn/transport/utils/fixed_block_allocator.h b/libtransport/includes/hicn/transport/utils/fixed_block_allocator.h
index b1df36493..298b6f9d1 100644
--- a/libtransport/includes/hicn/transport/utils/fixed_block_allocator.h
+++ b/libtransport/includes/hicn/transport/utils/fixed_block_allocator.h
@@ -35,7 +35,6 @@ class FixedBlockAllocator
if (!p_block) {
if (TRANSPORT_EXPECT_FALSE(current_pool_index_ >= max_objects_)) {
// Allocate new memory block
- TRANSPORT_LOGV("Allocating new block of %zu size", SIZE * OBJECTS);
p_pools_.emplace_front(
new typename std::aligned_storage<SIZE>::type[max_objects_]);
// reset current_pool_index_
@@ -151,10 +150,7 @@ class STLAllocator {
using value_type = T;
STLAllocator(pointer memory, Pool* memory_pool)
- : memory_(memory), pool_(memory_pool) {
- TRANSPORT_LOGV("Creating allocator. This: %p, memory: %p, memory_pool: %p",
- this, memory, memory_pool);
- }
+ : memory_(memory), pool_(memory_pool) {}
~STLAllocator() {}
@@ -173,28 +169,17 @@ class STLAllocator {
const_pointer address(const_reference x) const { return &x; }
pointer allocate(size_type n, pointer hint = 0) {
- TRANSPORT_LOGV(
- "Allocating memory (%zu). This: %p, memory: %p, memory_pool: %p", n,
- this, memory_, pool_);
return static_cast<pointer>(memory_);
}
- void deallocate(pointer p, size_type n) {
- TRANSPORT_LOGV("Deallocating memory. This: %p, memory: %p, memory_pool: %p",
- this, memory_, pool_);
- pool_->deallocateBlock(memory_);
- }
+ void deallocate(pointer p, size_type n) { pool_->deallocateBlock(memory_); }
template <typename... Args>
void construct(pointer p, Args&&... args) {
new (static_cast<pointer>(p)) T(std::forward<Args>(args)...);
}
- void destroy(pointer p) {
- TRANSPORT_LOGV("Destroying object. This: %p, memory: %p, memory_pool: %p",
- this, memory_, pool_);
- p->~T();
- }
+ void destroy(pointer p) { p->~T(); }
private:
void* memory_;
diff --git a/libtransport/includes/hicn/transport/utils/linux.h b/libtransport/includes/hicn/transport/utils/linux.h
index 105196fd2..4fbf5f01e 100644
--- a/libtransport/includes/hicn/transport/utils/linux.h
+++ b/libtransport/includes/hicn/transport/utils/linux.h
@@ -19,7 +19,6 @@
#include <arpa/inet.h>
#include <hicn/transport/portability/portability.h>
-#include <hicn/transport/utils/log.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <stdio.h>
@@ -49,7 +48,6 @@ static TRANSPORT_ALWAYS_INLINE int retrieveInterfaceAddress(
*address = *(struct sockaddr_in6 *)ifa->ifa_addr;
getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in6), addr,
sizeof(addr), NULL, 0, NI_NUMERICHOST);
- TRANSPORT_LOGI("Interface: %s\tAddress: %s", ifa->ifa_name, addr);
}
}
}
diff --git a/libtransport/includes/hicn/transport/utils/log.h b/libtransport/includes/hicn/transport/utils/log.h
index 3c4f1277a..0947b755e 100644
--- a/libtransport/includes/hicn/transport/utils/log.h
+++ b/libtransport/includes/hicn/transport/utils/log.h
@@ -13,1045 +13,35 @@
* limitations under the License.
*/
-/*
- * The MIT License (MIT)
- *
- * Copyright (c) 2017 wonder-mice
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
#pragma once
-/* To detect incompatible changes you can define TRANSPORT_LOG_VERSION_REQUIRED
- * to be the current value of TRANSPORT_LOG_VERSION before including this file
- * (or via compiler command line):
- *
- * #define TRANSPORT_LOG_VERSION_REQUIRED 4
- * #include <hicn/transport_log.h>
- *
- * Compilation will fail when included file has different version.
- */
-#define TRANSPORT_LOG_VERSION 4
-#if defined(TRANSPORT_LOG_VERSION_REQUIRED)
-#if TRANSPORT_LOG_VERSION_REQUIRED != TRANSPORT_LOG_VERSION
-#error different transport_log version required
-#endif
-#endif
-
-/* Log level guideline:
- * - TRANSPORT_LOG_FATAL - happened something impossible and absolutely
- * unexpected. Process can't continue and must be terminated. Example: division
- * by zero, unexpected modifications from other thread.
- * - TRANSPORT_LOG_ERROR - happened something possible, but highly unexpected.
- * The process is able to recover and continue execution. Example: out of memory
- * (could also be FATAL if not handled properly).
- * - TRANSPORT_LOG_WARN - happened something that *usually* should not happen
- * and significantly changes application behavior for some period of time.
- * Example: configuration file not found, auth error.
- * - TRANSPORT_LOG_INFO - happened significant life cycle event or major state
- * transition.
- * Example: app started, user logged in.
- * - TRANSPORT_LOG_DEBUG - minimal set of events that could help to reconstruct
- * the execution path. Usually disabled in release builds.
- * - TRANSPORT_LOG_VERBOSE - all other events. Usually disabled in release
- * builds.
- *
- * *Ideally*, log file of debugged, well tested, production ready application
- * should be empty or very small. Choosing a right log level is as important as
- * providing short and self descriptive log message.
- */
-#define TRANSPORT_LOG_VERBOSE 1
-#define TRANSPORT_LOG_DEBUG 2
-#define TRANSPORT_LOG_INFO 3
-#define TRANSPORT_LOG_WARN 4
-#define TRANSPORT_LOG_ERROR 5
-#define TRANSPORT_LOG_FATAL 6
-#define TRANSPORT_LOG_NONE 0xFF
-
-/* "Current" log level is a compile time check and has no runtime overhead. Log
- * level that is below current log level it said to be "disabled". Otherwise,
- * it's "enabled". Log messages that are disabled has no runtime overhead - they
- * are converted to no-op by preprocessor and then eliminated by compiler.
- * Current log level is configured per compilation module (.c/.cpp/.m file) by
- * defining TRANSPORT_LOG_DEF_LEVEL or TRANSPORT_LOG_LEVEL. TRANSPORT_LOG_LEVEL
- * has higer priority and when defined overrides value provided by
- * TRANSPORT_LOG_DEF_LEVEL.
- *
- * Common practice is to define default current log level with
- * TRANSPORT_LOG_DEF_LEVEL in build script (e.g. Makefile, CMakeLists.txt, gyp,
- * etc.) for the entire project or target:
- *
- * CC_ARGS := -DTRANSPORT_LOG_DEF_LEVEL=TRANSPORT_LOG_INFO
- *
- * And when necessary to override it with TRANSPORT_LOG_LEVEL in .c/.cpp/.m
- * files before including transport_log.h:
- *
- * #define TRANSPORT_LOG_LEVEL TRANSPORT_LOG_VERBOSE
- * #include <hicn/transport_log.h>
- *
- * If both TRANSPORT_LOG_DEF_LEVEL and TRANSPORT_LOG_LEVEL are undefined, then
- * TRANSPORT_LOG_INFO will be used for release builds (NDEBUG is defined) and
- * TRANSPORT_LOG_DEBUG otherwise (NDEBUG is not defined).
- */
-#if defined(TRANSPORT_LOG_LEVEL)
-#define _TRANSPORT_LOG_LEVEL TRANSPORT_LOG_LEVEL
-#elif defined(TRANSPORT_LOG_DEF_LEVEL)
-#define _TRANSPORT_LOG_LEVEL TRANSPORT_LOG_DEF_LEVEL
-#else
-#ifdef NDEBUG
-#define _TRANSPORT_LOG_LEVEL TRANSPORT_LOG_INFO
-#else
-#define _TRANSPORT_LOG_LEVEL TRANSPORT_LOG_DEBUG
-#endif
-#endif
-
-/* "Output" log level is a runtime check. When log level is below output log
- * level it said to be "turned off" (or just "off" for short). Otherwise it's
- * "turned on" (or just "on"). Log levels that were "disabled" (see
- * TRANSPORT_LOG_LEVEL and TRANSPORT_LOG_DEF_LEVEL) can't be "turned on", but
- * "enabled" log levels could be "turned off". Only messages with log level
- * which is "turned on" will reach output facility. All other messages will be
- * ignored (and their arguments will not be evaluated). Output log level is a
- * global property and configured per process using
- * transport_log_set_output_level() function which can be called at any time.
- *
- * Though in some cases it could be useful to configure output log level per
- * compilation module or per library. There are two ways to achieve that:
- * - Define TRANSPORT_LOG_OUTPUT_LEVEL to expresion that evaluates to desired
- * output log level.
- * - Copy transport_log.h and transport_log.c files into your library and build
- * it with TRANSPORT_LOG_LIBRARY_PREFIX defined to library specific prefix. See
- * TRANSPORT_LOG_LIBRARY_PREFIX for more details.
- *
- * When defined, TRANSPORT_LOG_OUTPUT_LEVEL must evaluate to integral value that
- * corresponds to desired output log level. Use it only when compilation module
- * is required to have output log level which is different from global output
- * log level set by transport_log_set_output_level() function. For other cases,
- * consider defining TRANSPORT_LOG_LEVEL or using
- * transport_log_set_output_level() function.
- *
- * Example:
- *
- * #define TRANSPORT_LOG_OUTPUT_LEVEL g_module_log_level
- * #include <hicn/transport_log.h>
- * static int g_module_log_level = TRANSPORT_LOG_INFO;
- * static void foo() {
- * TRANSPORT_LOGI("Will check g_module_log_level for output log level");
- * }
- * void debug_log(bool on) {
- * g_module_log_level = on? TRANSPORT_LOG_DEBUG: TRANSPORT_LOG_INFO;
- * }
- *
- * Note on performance. This expression will be evaluated each time message is
- * logged (except when message log level is "disabled" - see TRANSPORT_LOG_LEVEL
- * for details). Keep this expression as simple as possible, otherwise it will
- * not only add runtime overhead, but also will increase size of call site
- * (which will result in larger executable). The prefered way is to use integer
- * variable (as in example above). If structure must be used, log_level field
- * must be the first field in this structure:
- *
- * #define TRANSPORT_LOG_OUTPUT_LEVEL (g_config.log_level)
- * #include <hicn/transport_log.h>
- * struct config {
- * int log_level;
- * unsigned other_field;
- * [...]
- * };
- * static config g_config = {TRANSPORT_LOG_INFO, 0, ...};
- *
- * This allows compiler to generate more compact load instruction (no need to
- * specify offset since it's zero). Calling a function to get output log level
- * is generaly a bad idea, since it will increase call site size and runtime
- * overhead even further.
- */
-#if defined(TRANSPORT_LOG_OUTPUT_LEVEL)
-#define _TRANSPORT_LOG_OUTPUT_LEVEL TRANSPORT_LOG_OUTPUT_LEVEL
-#else
-#define _TRANSPORT_LOG_OUTPUT_LEVEL _transport_log_global_output_lvl
-#endif
-
-/* "Tag" is a compound string that could be associated with a log message. It
- * consists of tag prefix and tag (both are optional).
- *
- * Tag prefix is a global property and configured per process using
- * transport_log_set_tag_prefix() function. Tag prefix identifies context in
- * which component or module is running (e.g. process name). For example, the
- * same library could be used in both client and server processes that work on
- * the same machine. Tag prefix could be used to easily distinguish between
- * them. For more details about tag prefix see transport_log_set_tag_prefix()
- * function. Tag prefix
- *
- * Tag identifies component or module. It is configured per compilation module
- * (.c/.cpp/.m file) by defining TRANSPORT_LOG_TAG or TRANSPORT_LOG_DEF_TAG.
- * TRANSPORT_LOG_TAG has higer priority and when defined overrides value
- * provided by TRANSPORT_LOG_DEF_TAG. When defined, value must evaluate to
- * (const char *), so for strings double quotes must be used.
- *
- * Default tag could be defined with TRANSPORT_LOG_DEF_TAG in build script (e.g.
- * Makefile, CMakeLists.txt, gyp, etc.) for the entire project or target:
- *
- * CC_ARGS := -DTRANSPORT_LOG_DEF_TAG=\"MISC\"
- *
- * And when necessary could be overriden with TRANSPORT_LOG_TAG in .c/.cpp/.m
- * files before including transport_log.h:
- *
- * #define TRANSPORT_LOG_TAG "MAIN"
- * #include <hicn/transport_log.h>
- *
- * If both TRANSPORT_LOG_DEF_TAG and TRANSPORT_LOG_TAG are undefined no tag will
- * be added to the log message (tag prefix still could be added though).
- *
- * Output example:
- *
- * 04-29 22:43:20.244 40059 1299 I hello.MAIN Number of arguments: 1
- * | |
- * | +- tag (e.g. module)
- * +- tag prefix (e.g. process name)
- */
-#if defined(TRANSPORT_LOG_TAG)
-#define _TRANSPORT_LOG_TAG TRANSPORT_LOG_TAG
-#elif defined(TRANSPORT_LOG_DEF_TAG)
-#define _TRANSPORT_LOG_TAG TRANSPORT_LOG_DEF_TAG
-#else
-#define _TRANSPORT_LOG_TAG 0
-#endif
-
-/* Source location is part of a log line that describes location (function or
- * method name, file name and line number, e.g. "runloop@main.cpp:68") of a
- * log statement that produced it.
- * Source location formats are:
- * - TRANSPORT_LOG_SRCLOC_NONE - don't add source location to log line.
- * - TRANSPORT_LOG_SRCLOC_SHORT - add source location in short form (file and
- * line number, e.g. "@main.cpp:68").
- * - TRANSPORT_LOG_SRCLOC_LONG - add source location in long form (function or
- * method name, file and line number, e.g. "runloop@main.cpp:68").
- */
-#define TRANSPORT_LOG_SRCLOC_NONE 0
-#define TRANSPORT_LOG_SRCLOC_SHORT 1
-#define TRANSPORT_LOG_SRCLOC_LONG 2
-
-/* Source location format is configured per compilation module (.c/.cpp/.m
- * file) by defining TRANSPORT_LOG_DEF_SRCLOC or TRANSPORT_LOG_SRCLOC.
- * TRANSPORT_LOG_SRCLOC has higer priority and when defined overrides value
- * provided by TRANSPORT_LOG_DEF_SRCLOC.
- *
- * Common practice is to define default format with TRANSPORT_LOG_DEF_SRCLOC in
- * build script (e.g. Makefile, CMakeLists.txt, gyp, etc.) for the entire
- * project or target:
- *
- * CC_ARGS := -DTRANSPORT_LOG_DEF_SRCLOC=TRANSPORT_LOG_SRCLOC_LONG
- *
- * And when necessary to override it with TRANSPORT_LOG_SRCLOC in .c/.cpp/.m
- * files before including transport_log.h:
- *
- * #define TRANSPORT_LOG_SRCLOC TRANSPORT_LOG_SRCLOC_NONE
- * #include <hicn/transport_log.h>
- *
- * If both TRANSPORT_LOG_DEF_SRCLOC and TRANSPORT_LOG_SRCLOC are undefined, then
- * TRANSPORT_LOG_SRCLOC_NONE will be used for release builds (NDEBUG is defined)
- * and TRANSPORT_LOG_SRCLOC_LONG otherwise (NDEBUG is not defined).
- */
-#if defined(TRANSPORT_LOG_SRCLOC)
-#define _TRANSPORT_LOG_SRCLOC TRANSPORT_LOG_SRCLOC
-#elif defined(TRANSPORT_LOG_DEF_SRCLOC)
-#define _TRANSPORT_LOG_SRCLOC TRANSPORT_LOG_DEF_SRCLOC
-#else
-#ifdef NDEBUG
-#define _TRANSPORT_LOG_SRCLOC TRANSPORT_LOG_SRCLOC_NONE
-#else
-#define _TRANSPORT_LOG_SRCLOC TRANSPORT_LOG_SRCLOC_LONG
-#endif
-#endif
-#if TRANSPORT_LOG_SRCLOC_LONG == _TRANSPORT_LOG_SRCLOC
-#define _TRANSPORT_LOG_SRCLOC_FUNCTION _TRANSPORT_LOG_FUNCTION
-#else
-#define _TRANSPORT_LOG_SRCLOC_FUNCTION 0
-#endif
-
-/* Censoring provides conditional logging of secret information, also known as
- * Personally Identifiable Information (PII) or Sensitive Personal Information
- * (SPI). Censoring can be either enabled (TRANSPORT_LOG_CENSORED) or disabled
- * (TRANSPORT_LOG_UNCENSORED). When censoring is enabled, log statements marked
- * as "secrets" will be ignored and will have zero overhead (arguments also will
- * not be evaluated).
- */
-#define TRANSPORT_LOG_CENSORED 1
-#define TRANSPORT_LOG_UNCENSORED 0
-
-/* Censoring is configured per compilation module (.c/.cpp/.m file) by defining
- * TRANSPORT_LOG_DEF_CENSORING or TRANSPORT_LOG_CENSORING.
- * TRANSPORT_LOG_CENSORING has higer priority and when defined overrides value
- * provided by TRANSPORT_LOG_DEF_CENSORING.
- *
- * Common practice is to define default censoring with
- * TRANSPORT_LOG_DEF_CENSORING in build script (e.g. Makefile, CMakeLists.txt,
- * gyp, etc.) for the entire project or target:
- *
- * CC_ARGS := -DTRANSPORT_LOG_DEF_CENSORING=TRANSPORT_LOG_CENSORED
- *
- * And when necessary to override it with TRANSPORT_LOG_CENSORING in .c/.cpp/.m
- * files before including transport_log.h (consider doing it only for debug
- * purposes and be very careful not to push such temporary changes to source
- * control):
- *
- * #define TRANSPORT_LOG_CENSORING TRANSPORT_LOG_UNCENSORED
- * #include <hicn/transport_log.h>
- *
- * If both TRANSPORT_LOG_DEF_CENSORING and TRANSPORT_LOG_CENSORING are
- * undefined, then TRANSPORT_LOG_CENSORED will be used for release builds
- * (NDEBUG is defined) and TRANSPORT_LOG_UNCENSORED otherwise (NDEBUG is not
- * defined).
- */
-#if defined(TRANSPORT_LOG_CENSORING)
-#define _TRANSPORT_LOG_CENSORING TRANSPORT_LOG_CENSORING
-#elif defined(TRANSPORT_LOG_DEF_CENSORING)
-#define _TRANSPORT_LOG_CENSORING TRANSPORT_LOG_DEF_CENSORING
-#else
-#ifdef NDEBUG
-#define _TRANSPORT_LOG_CENSORING TRANSPORT_LOG_CENSORED
-#else
-#define _TRANSPORT_LOG_CENSORING TRANSPORT_LOG_UNCENSORED
-#endif
-#endif
-
-/* Check censoring at compile time. Evaluates to true when censoring is disabled
- * (i.e. when secrets will be logged). For example:
- *
- * #if TRANSPORT_LOG_SECRETS
- * char ssn[16];
- * getSocialSecurityNumber(ssn);
- * TRANSPORT_LOGI("Customer ssn: %s", ssn);
- * #endif
- *
- * See TRANSPORT_LOG_SECRET() macro for a more convenient way of guarding single
- * log statement.
- */
-#define TRANSPORT_LOG_SECRETS \
- (TRANSPORT_LOG_UNCENSORED == _TRANSPORT_LOG_CENSORING)
-
-/* Static (compile-time) initialization support allows to configure logging
- * before entering main() function. This mostly useful in C++ where functions
- * and methods could be called during initialization of global objects. Those
- * functions and methods could record log messages too and for that reason
- * static initialization of logging configuration is customizable.
- *
- * Macros below allow to specify values to use for initial configuration:
- * - TRANSPORT_LOG_EXTERN_TAG_PREFIX - tag prefix (default: none)
- * - TRANSPORT_LOG_EXTERN_GLOBAL_FORMAT - global format options (default: see
- * TRANSPORT_LOG_MEM_WIDTH in transport_log.c)
- * - TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT - global output facility (default:
- * stderr or platform specific, see TRANSPORT_LOG_USE_XXX macros in
- * transport_log.c)
- * - TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL - global output log level
- * (default: 0 - all levals are "turned on")
- *
- * For example, in log_config.c:
- *
- * #include <hicn/transport_log.h>
- * TRANSPORT_LOG_DEFINE_TAG_PREFIX = "MyApp";
- * TRANSPORT_LOG_DEFINE_GLOBAL_FORMAT = {CUSTOM_MEM_WIDTH};
- * TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT = {TRANSPORT_LOG_PUT_STD,
- * custom_output_callback, 0}; TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL =
- * TRANSPORT_LOG_INFO;
- *
- * However, to use any of those macros transport_log library must be compiled
- * with following macros defined:
- * - to use TRANSPORT_LOG_DEFINE_TAG_PREFIX define
- * TRANSPORT_LOG_EXTERN_TAG_PREFIX
- * - to use TRANSPORT_LOG_DEFINE_GLOBAL_FORMAT define
- * TRANSPORT_LOG_EXTERN_GLOBAL_FORMAT
- * - to use TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT define
- * TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT
- * - to use TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL define
- * TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL
- *
- * When transport_log library compiled with one of TRANSPORT_LOG_EXTERN_XXX
- * macros defined, corresponding TRANSPORT_LOG_DEFINE_XXX macro MUST be used
- * exactly once somewhere. Otherwise build will fail with link error (undefined
- * symbol).
- */
-#define TRANSPORT_LOG_DEFINE_TAG_PREFIX const char *_transport_log_tag_prefix
-#define TRANSPORT_LOG_DEFINE_GLOBAL_FORMAT \
- transport_log_format _transport_log_global_format
-#define TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT \
- transport_log_output _transport_log_global_output
-#define TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL \
- int _transport_log_global_output_lvl
-
-/* Pointer to global format options. Direct modification is not allowed. Use
- * transport_log_set_mem_width() instead. Could be used to initialize
- * transport_log_spec structure:
- *
- * const transport_log_output g_output = {TRANSPORT_LOG_PUT_STD,
- * output_callback, 0}; const transport_log_spec g_spec =
- * {TRANSPORT_LOG_GLOBAL_FORMAT, &g_output}; TRANSPORT_LOGI_AUX(&g_spec,
- * "Hello");
- */
-#define TRANSPORT_LOG_GLOBAL_FORMAT \
- ((const transport_log_format *)&_transport_log_global_format)
-
-/* Pointer to global output variable. Direct modification is not allowed. Use
- * transport_log_set_output_v() or transport_log_set_output_p() instead. Could
- * be used to initialize transport_log_spec structure:
- *
- * const transport_log_format g_format = {40};
- * const transport_log_spec g_spec = {g_format, TRANSPORT_LOG_GLOBAL_OUTPUT};
- * TRANSPORT_LOGI_AUX(&g_spec, "Hello");
- */
-#define TRANSPORT_LOG_GLOBAL_OUTPUT \
- ((const transport_log_output *)&_transport_log_global_output)
-
-/* When defined, all library symbols produced by linker will be prefixed with
- * provided value. That allows to use transport_log library privately in another
- * libraries without exposing transport_log symbols in their original form (to
- * avoid possible conflicts with other libraries / components that also could
- * use transport_log for logging). Value must be without quotes, for example:
- *
- * CC_ARGS := -DTRANSPORT_LOG_LIBRARY_PREFIX=my_lib_
- *
- * Note, that in this mode TRANSPORT_LOG_LIBRARY_PREFIX must be defined when
- * building transport_log library AND it also must be defined to the same value
- * when building a library that uses it. For example, consider fictional
- * KittyHttp library that wants to use transport_log for logging. First approach
- * that could be taken is to add transport_log.h and transport_log.c to the
- * KittyHttp's source code tree directly. In that case it will be enough just to
- * define TRANSPORT_LOG_LIBRARY_PREFIX in KittyHttp's build script:
- *
- * // KittyHttp/CMakeLists.txt
- * target_compile_definitions(KittyHttp PRIVATE
- * "TRANSPORT_LOG_LIBRARY_PREFIX=KittyHttp_")
- *
- * If KittyHttp doesn't want to include transport_log source code in its source
- * tree and wants to build transport_log as a separate library than
- * transport_log library must be built with TRANSPORT_LOG_LIBRARY_PREFIX defined
- * to KittyHttp_ AND KittyHttp library itself also needs to define
- * TRANSPORT_LOG_LIBRARY_PREFIX to KittyHttp_. It can do so either in its build
- * script, as in example above, or by providing a wrapper header that KittyHttp
- * library will need to use instead of transport_log.h:
- *
- * // KittyHttpLogging.h
- * #define TRANSPORT_LOG_LIBRARY_PREFIX KittyHttp_
- * #include <hicn/transport_log.h>
- *
- * Regardless of the method chosen, the end result is that transport_log symbols
- * will be prefixed with "KittyHttp_", so if a user of KittyHttp (say
- * DogeBrowser) also uses transport_log for logging, they will not interferer
- * with each other. Both will have their own log level, output facility, format
- * options etc.
- */
-#ifdef TRANSPORT_LOG_LIBRARY_PREFIX
-#define _TRANSPORT_LOG_DECOR__(prefix, name) prefix##name
-#define _TRANSPORT_LOG_DECOR_(prefix, name) _TRANSPORT_LOG_DECOR__(prefix, name)
-#define _TRANSPORT_LOG_DECOR(name) \
- _TRANSPORT_LOG_DECOR_(TRANSPORT_LOG_LIBRARY_PREFIX, name)
-
-#define transport_log_set_tag_prefix \
- _TRANSPORT_LOG_DECOR(transport_log_set_tag_prefix)
-#define transport_log_set_mem_width \
- _TRANSPORT_LOG_DECOR(transport_log_set_mem_width)
-#define transport_log_set_output_level \
- _TRANSPORT_LOG_DECOR(transport_log_set_output_level)
-#define transport_log_set_output_v \
- _TRANSPORT_LOG_DECOR(transport_log_set_output_v)
-#define transport_log_set_output_p \
- _TRANSPORT_LOG_DECOR(transport_log_set_output_p)
-#define transport_log_out_stderr_callback \
- _TRANSPORT_LOG_DECOR(transport_log_out_stderr_callback)
-#define _transport_log_tag_prefix \
- _TRANSPORT_LOG_DECOR(_transport_log_tag_prefix)
-#define _transport_log_global_format \
- _TRANSPORT_LOG_DECOR(_transport_log_global_format)
-#define _transport_log_global_output \
- _TRANSPORT_LOG_DECOR(_transport_log_global_output)
-#define _transport_log_global_output_lvl \
- _TRANSPORT_LOG_DECOR(_transport_log_global_output_lvl)
-#define _transport_log_write_d _TRANSPORT_LOG_DECOR(_transport_log_write_d)
-#define _transport_log_write_aux_d \
- _TRANSPORT_LOG_DECOR(_transport_log_write_aux_d)
-#define _transport_log_write _TRANSPORT_LOG_DECOR(_transport_log_write)
-#define _transport_log_write_aux _TRANSPORT_LOG_DECOR(_transport_log_write_aux)
-#define _transport_log_write_mem_d \
- _TRANSPORT_LOG_DECOR(_transport_log_write_mem_d)
-#define _transport_log_write_mem_aux_d \
- _TRANSPORT_LOG_DECOR(_transport_log_write_mem_aux_d)
-#define _transport_log_write_mem _TRANSPORT_LOG_DECOR(_transport_log_write_mem)
-#define _transport_log_write_mem_aux \
- _TRANSPORT_LOG_DECOR(_transport_log_write_mem_aux)
-#define _transport_log_stderr_spec \
- _TRANSPORT_LOG_DECOR(_transport_log_stderr_spec)
-#endif
-
-#if defined(__printflike)
-#define _TRANSPORT_LOG_PRINTFLIKE(str_index, first_to_check) \
- __printflike(str_index, first_to_check)
-#elif defined(__GNUC__)
-#define _TRANSPORT_LOG_PRINTFLIKE(str_index, first_to_check) \
- __attribute__((format(__printf__, str_index, first_to_check)))
-#else
-#define _TRANSPORT_LOG_PRINTFLIKE(str_index, first_to_check)
-#endif
-
-#if (defined(_WIN32) || defined(_WIN64)) && !defined(__GNUC__)
-#define _TRANSPORT_LOG_FUNCTION __FUNCTION__
-#else
-#define _TRANSPORT_LOG_FUNCTION __func__
-#endif
-
-#if defined(_MSC_VER) && !defined(__INTEL_COMPILER)
-#define _TRANSPORT_LOG_INLINE __inline
-#define _TRANSPORT_LOG_IF(cond) \
- __pragma(warning(push)) __pragma(warning(disable : 4127)) if (cond) \
- __pragma(warning(pop))
-#define _TRANSPORT_LOG_WHILE(cond) \
- __pragma(warning(push)) __pragma(warning(disable : 4127)) while (cond) \
- __pragma(warning(pop))
-#else
-#define _TRANSPORT_LOG_INLINE inline
-#define _TRANSPORT_LOG_IF(cond) if (cond)
-#define _TRANSPORT_LOG_WHILE(cond) while (cond)
-#endif
-#define _TRANSPORT_LOG_NEVER _TRANSPORT_LOG_IF(0)
-#define _TRANSPORT_LOG_ONCE _TRANSPORT_LOG_WHILE(0)
+#include <hicn/transport/utils/singleton.h>
-#ifdef __cplusplus
-extern "C" {
-#endif
+#include <ostream>
-/* Set tag prefix. Prefix will be separated from the tag with dot ('.').
- * Use 0 or empty string to disable (default). Common use is to set it to
- * the process (or build target) name (e.g. to separate client and server
- * processes). Function will NOT copy provided prefix string, but will store the
- * pointer. Hence specified prefix string must remain valid. See
- * TRANSPORT_LOG_DEFINE_TAG_PREFIX for a way to set it before entering main()
- * function. See TRANSPORT_LOG_TAG for more information about tag and tag
- * prefix.
- */
-void transport_log_set_tag_prefix(const char *const prefix);
-
-/* Set number of bytes per log line in memory (ASCII-HEX) output. Example:
- *
- * I hello.MAIN 4c6f72656d20697073756d20646f6c6f Lorem ipsum dolo
- * |<- w bytes ->| |<- w chars ->|
- *
- * See TRANSPORT_LOGF_MEM and TRANSPORT_LOGF_MEM_AUX for more details.
- */
-void transport_log_set_mem_width(const unsigned w);
+#define foreach_log_level \
+ _(Info, LOG(INFO)) \
+ _(Warning, LOG(WARNING)) \
+ _(Error, LOG(ERROR)) \
+ _(Fatal, LOG(FATAL))
-/* Set "output" log level. See TRANSPORT_LOG_LEVEL and
- * TRANSPORT_LOG_OUTPUT_LEVEL for more info about log levels.
- */
-void transport_log_set_output_level(const int lvl);
+#define CLASS_NAME(log_level) Log##log_level
-/* Put mask is a set of flags that define what fields will be added to each
- * log message. Default value is TRANSPORT_LOG_PUT_STD and other flags could be
- * used to alter its behavior. See transport_log_set_output_v() for more
- * details.
- *
- * Note about TRANSPORT_LOG_PUT_SRC: it will be added only in debug builds
- * (NDEBUG is not defined).
- */
-enum {
- TRANSPORT_LOG_PUT_CTX = 1 << 0, /* context (time, pid, tid, log level) */
- TRANSPORT_LOG_PUT_TAG = 1 << 1, /* tag (including tag prefix) */
- TRANSPORT_LOG_PUT_SRC = 1 << 2, /* source location (file, line, function) */
- TRANSPORT_LOG_PUT_MSG = 1 << 3, /* message text (formatted string) */
- TRANSPORT_LOG_PUT_STD = 0xffff, /* everything (default) */
-};
+namespace utils {
-typedef struct transport_log_message {
- int lvl; /* Log level of the message */
- const char *tag; /* Associated tag (without tag prefix) */
- char *buf; /* Buffer start */
- char *e; /* Buffer end (last position where EOL with 0 could be written) */
- char *p; /* Buffer content end (append position) */
- char *tag_b; /* Prefixed tag start */
- char *tag_e; /* Prefixed tag end (if != tag_b, points to msg separator) */
- char *msg_b; /* Message start (expanded format string) */
-} transport_log_message;
-
-/* Type of output callback function. It will be called for each log line allowed
- * by both "current" and "output" log levels ("enabled" and "turned on").
- * Callback function is allowed to modify content of the buffers pointed by the
- * msg, but it's not allowed to modify any of msg fields. Buffer pointed by msg
- * is UTF-8 encoded (no BOM mark).
- */
-typedef void (*transport_log_output_cb)(const transport_log_message *msg,
- void *arg);
-
-/* Format options. For more details see transport_log_set_mem_width().
- */
-typedef struct transport_log_format {
- unsigned mem_width; /* Bytes per line in memory (ASCII-HEX) dump */
-} transport_log_format;
-
-/* Output facility.
- */
-typedef struct transport_log_output {
- unsigned
- mask; /* What to put into log line buffer (see TRANSPORT_LOG_PUT_XXX) */
- void *arg; /* User provided output callback argument */
- transport_log_output_cb callback; /* Output callback function */
-} transport_log_output;
-
-/* Set output callback function.
- *
- * Mask allows to control what information will be added to the log line buffer
- * before callback function is invoked. Default mask value is
- * TRANSPORT_LOG_PUT_STD.
- */
-void transport_log_set_output_v(const unsigned mask, void *const arg,
- const transport_log_output_cb callback);
-static _TRANSPORT_LOG_INLINE void transport_log_set_output_p(
- const transport_log_output *const output) {
- transport_log_set_output_v(output->mask, output->arg, output->callback);
-}
-
-/* Used with _AUX macros and allows to override global format and output
- * facility. Use TRANSPORT_LOG_GLOBAL_FORMAT and TRANSPORT_LOG_GLOBAL_OUTPUT for
- * values from global configuration. Example:
- *
- * static const transport_log_output module_output = {
- * TRANSPORT_LOG_PUT_STD, 0, custom_output_callback
- * };
- * static const transport_log_spec module_spec = {
- * TRANSPORT_LOG_GLOBAL_FORMAT, &module_output
- * };
- * TRANSPORT_LOGI_AUX(&module_spec, "Position: %ix%i", x, y);
- *
- * See TRANSPORT_LOGF_AUX and TRANSPORT_LOGF_MEM_AUX for details.
- */
-typedef struct transport_log_spec {
- const transport_log_format *format;
- const transport_log_output *output;
-} transport_log_spec;
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Execute log statement if condition is true. Example:
- *
- * TRANSPORT_LOG_IF(1 < 2, TRANSPORT_LOGI("Log this"));
- * TRANSPORT_LOG_IF(1 > 2, TRANSPORT_LOGI("Don't log this"));
- *
- * Keep in mind though, that if condition can't be evaluated at compile time,
- * then it will be evaluated at run time. This will increase exectuable size
- * and can have noticeable performance overhead. Try to limit conditions to
- * expressions that can be evaluated at compile time.
- */
-#define TRANSPORT_LOG_IF(cond, f) \
- do { \
- _TRANSPORT_LOG_IF((cond)) { f; } \
- } \
- _TRANSPORT_LOG_ONCE
-
-/* Mark log statement as "secret". Log statements that are marked as secrets
- * will NOT be executed when censoring is enabled (see TRANSPORT_LOG_CENSORED).
- * Example:
- *
- * TRANSPORT_LOG_SECRET(TRANSPORT_LOGI("Credit card: %s", credit_card));
- * TRANSPORT_LOG_SECRET(TRANSPORT_LOGD_MEM(cipher, cipher_sz, "Cipher
- * bytes:"));
- */
-#define TRANSPORT_LOG_SECRET(f) TRANSPORT_LOG_IF(TRANSPORT_LOG_SECRETS, f)
+#define _(class_name, macro_name) \
+ class CLASS_NAME(class_name) : public Singleton<CLASS_NAME(class_name)> { \
+ friend class Singleton<CLASS_NAME(class_name)>; \
+ \
+ public: \
+ std::ostream& getStream(); \
+ };
+foreach_log_level
+#undef _
-/* Check "current" log level at compile time (ignoring "output" log level).
- * Evaluates to true when specified log level is enabled. For example:
- *
- * #if TRANSPORT_LOG_ENABLED_DEBUG
- * const char *const g_enum_strings[] = {
- * "enum_value_0", "enum_value_1", "enum_value_2"
- * };
- * #endif
- * // ...
- * #if TRANSPORT_LOG_ENABLED_DEBUG
- * TRANSPORT_LOGD("enum value: %s", g_enum_strings[v]);
- * #endif
- *
- * See TRANSPORT_LOG_LEVEL for details.
- */
-#define TRANSPORT_LOG_ENABLED(lvl) ((lvl) >= _TRANSPORT_LOG_LEVEL)
-#define TRANSPORT_LOG_ENABLED_VERBOSE \
- TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_VERBOSE)
-#define TRANSPORT_LOG_ENABLED_DEBUG TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_DEBUG)
-#define TRANSPORT_LOG_ENABLED_INFO TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_INFO)
-#define TRANSPORT_LOG_ENABLED_WARN TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_WARN)
-#define TRANSPORT_LOG_ENABLED_ERROR TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_ERROR)
-#define TRANSPORT_LOG_ENABLED_FATAL TRANSPORT_LOG_ENABLED(TRANSPORT_LOG_FATAL)
-
-/* Check "output" log level at run time (taking into account "current" log
- * level as well). Evaluates to true when specified log level is turned on AND
- * enabled. For example:
- *
- * if (TRANSPORT_LOG_ON_DEBUG)
- * {
- * char hash[65];
- * sha256(data_ptr, data_sz, hash);
- * TRANSPORT_LOGD("data: len=%u, sha256=%s", data_sz, hash);
- * }
- *
- * See TRANSPORT_LOG_OUTPUT_LEVEL for details.
- */
-#define TRANSPORT_LOG_ON(lvl) \
- (TRANSPORT_LOG_ENABLED((lvl)) && (lvl) >= _TRANSPORT_LOG_OUTPUT_LEVEL)
-#define TRANSPORT_LOG_ON_VERBOSE TRANSPORT_LOG_ON(TRANSPORT_LOG_VERBOSE)
-#define TRANSPORT_LOG_ON_DEBUG TRANSPORT_LOG_ON(TRANSPORT_LOG_DEBUG)
-#define TRANSPORT_LOG_ON_INFO TRANSPORT_LOG_ON(TRANSPORT_LOG_INFO)
-#define TRANSPORT_LOG_ON_WARN TRANSPORT_LOG_ON(TRANSPORT_LOG_WARN)
-#define TRANSPORT_LOG_ON_ERROR TRANSPORT_LOG_ON(TRANSPORT_LOG_ERROR)
-#define TRANSPORT_LOG_ON_FATAL TRANSPORT_LOG_ON(TRANSPORT_LOG_FATAL)
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern const char *_transport_log_tag_prefix;
-extern transport_log_format _transport_log_global_format;
-extern transport_log_output _transport_log_global_output;
-extern int _transport_log_global_output_lvl;
-extern const transport_log_spec _transport_log_stderr_spec;
-
-void _transport_log_write_d(const char *const func, const char *const file,
- const unsigned line, const int lvl,
- const char *const tag, const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(6, 7);
-void _transport_log_write_aux_d(const char *const func, const char *const file,
- const unsigned line,
- const transport_log_spec *const log,
- const int lvl, const char *const tag,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(7, 8);
-void _transport_log_write(const int lvl, const char *const tag,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(3, 4);
-void _transport_log_write_aux(const transport_log_spec *const log,
- const int lvl, const char *const tag,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(4, 5);
-void _transport_log_write_mem_d(const char *const func, const char *const file,
- const unsigned line, const int lvl,
- const char *const tag, const void *const d,
- const unsigned d_sz, const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(8, 9);
-void _transport_log_write_mem_aux_d(const char *const func,
- const char *const file, const unsigned line,
- const transport_log_spec *const log,
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(9, 10);
-void _transport_log_write_mem(const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(5, 6);
-void _transport_log_write_mem_aux(const transport_log_spec *const log,
- const int lvl, const char *const tag,
- const void *const d, const unsigned d_sz,
- const char *const fmt, ...)
- _TRANSPORT_LOG_PRINTFLIKE(6, 7);
-
-#ifdef __cplusplus
-}
-#endif
-
-/* Message logging macros:
- * - TRANSPORT_LOGV("format string", args, ...)
- * - TRANSPORT_LOGD("format string", args, ...)
- * - TRANSPORT_LOGI("format string", args, ...)
- * - TRANSPORT_LOGW("format string", args, ...)
- * - TRANSPORT_LOGE("format string", args, ...)
- * - TRANSPORT_LOGF("format string", args, ...)
- *
- * Memory logging macros:
- * - TRANSPORT_LOGV_MEM(data_ptr, data_sz, "format string", args, ...)
- * - TRANSPORT_LOGD_MEM(data_ptr, data_sz, "format string", args, ...)
- * - TRANSPORT_LOGI_MEM(data_ptr, data_sz, "format string", args, ...)
- * - TRANSPORT_LOGW_MEM(data_ptr, data_sz, "format string", args, ...)
- * - TRANSPORT_LOGE_MEM(data_ptr, data_sz, "format string", args, ...)
- * - TRANSPORT_LOGF_MEM(data_ptr, data_sz, "format string", args, ...)
- *
- * Auxiliary logging macros:
- * - TRANSPORT_LOGV_AUX(&log_instance, "format string", args, ...)
- * - TRANSPORT_LOGD_AUX(&log_instance, "format string", args, ...)
- * - TRANSPORT_LOGI_AUX(&log_instance, "format string", args, ...)
- * - TRANSPORT_LOGW_AUX(&log_instance, "format string", args, ...)
- * - TRANSPORT_LOGE_AUX(&log_instance, "format string", args, ...)
- * - TRANSPORT_LOGF_AUX(&log_instance, "format string", args, ...)
- *
- * Auxiliary memory logging macros:
- * - TRANSPORT_LOGV_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOGD_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOGI_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOGW_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOGE_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOGF_MEM_AUX(&log_instance, data_ptr, data_sz, "format string",
- * args, ...)
- *
- * Preformatted string logging macros:
- * - TRANSPORT_LOGV_STR("preformatted string");
- * - TRANSPORT_LOGD_STR("preformatted string");
- * - TRANSPORT_LOGI_STR("preformatted string");
- * - TRANSPORT_LOGW_STR("preformatted string");
- * - TRANSPORT_LOGE_STR("preformatted string");
- * - TRANSPORT_LOGF_STR("preformatted string");
- *
- * Explicit log level and tag macros:
- * - TRANSPORT_LOG_WRITE(level, tag, "format string", args, ...)
- * - TRANSPORT_LOG_WRITE_MEM(level, tag, data_ptr, data_sz, "format string",
- * args, ...)
- * - TRANSPORT_LOG_WRITE_AUX(&log_instance, level, tag, "format string", args,
- * ...)
- * - TRANSPORT_LOG_WRITE_MEM_AUX(&log_instance, level, tag, data_ptr, data_sz,
- * "format string", args, ...)
- *
- * Format string follows printf() conventions. Both data_ptr and data_sz could
- * be 0. Tag can be 0 as well. Most compilers will verify that type of arguments
- * match format specifiers in format string.
- *
- * Library assuming UTF-8 encoding for all strings (char *), including format
- * string itself.
- */
-#if TRANSPORT_LOG_SRCLOC_NONE == _TRANSPORT_LOG_SRCLOC
-#define TRANSPORT_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) _transport_log_write(lvl, tag, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_mem(lvl, tag, d, d_sz, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_aux(log, lvl, tag, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_mem_aux(log, lvl, tag, d, d_sz, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#else
-#define TRANSPORT_LOG_WRITE(lvl, tag, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_d(_TRANSPORT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, lvl, tag, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_MEM(lvl, tag, d, d_sz, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_mem_d(_TRANSPORT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, lvl, tag, d, d_sz, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_AUX(log, lvl, tag, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_aux_d(_TRANSPORT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, log, lvl, tag, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#define TRANSPORT_LOG_WRITE_MEM_AUX(log, lvl, tag, d, d_sz, ...) \
- do { \
- if (TRANSPORT_LOG_ON(lvl)) \
- _transport_log_write_mem_aux_d(_TRANSPORT_LOG_SRCLOC_FUNCTION, __FILE__, \
- __LINE__, log, lvl, tag, d, d_sz, \
- __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-#endif
-
-static _TRANSPORT_LOG_INLINE void _transport_log_unused(const int dummy, ...) {
- (void)dummy;
-}
-
-#define _TRANSPORT_LOG_UNUSED(...) \
- do { \
- _TRANSPORT_LOG_NEVER _transport_log_unused(0, __VA_ARGS__); \
- } \
- _TRANSPORT_LOG_ONCE
-
-#if TRANSPORT_LOG_ENABLED_VERBOSE
-#define TRANSPORT_LOGV(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_VERBOSE, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGV_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_VERBOSE, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGV_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_VERBOSE, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGV_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(log, TRANSPORT_LOG_VERBOSE, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGV(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGV_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGV_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGV_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if TRANSPORT_LOG_ENABLED_DEBUG
-#define TRANSPORT_LOGD(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_DEBUG, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGD_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_DEBUG, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGD_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_DEBUG, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGD_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM_AUX(log, TRANSPORT_LOG_DEBUG, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGD(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGD_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGD_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGD_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if TRANSPORT_LOG_ENABLED_INFO
-#define TRANSPORT_LOGI(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_INFO, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGI_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_INFO, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGI_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_INFO, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGI_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM_AUX(log, TRANSPORT_LOG_INFO, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGI(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGI_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGI_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGI_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if TRANSPORT_LOG_ENABLED_WARN
-#define TRANSPORT_LOGW(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_WARN, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGW_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_WARN, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGW_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_WARN, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGW_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM_AUX(log, TRANSPORT_LOG_WARN, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGW(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGW_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGW_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGW_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if TRANSPORT_LOG_ENABLED_ERROR
-#define TRANSPORT_LOGE(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_ERROR, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGE_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_ERROR, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGE_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_ERROR, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGE_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM_AUX(log, TRANSPORT_LOG_ERROR, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGE(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGE_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGE_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGE_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#if TRANSPORT_LOG_ENABLED_FATAL
-#define TRANSPORT_LOGF(...) \
- TRANSPORT_LOG_WRITE(TRANSPORT_LOG_FATAL, _TRANSPORT_LOG_TAG, __VA_ARGS__)
-#define TRANSPORT_LOGF_AUX(log, ...) \
- TRANSPORT_LOG_WRITE_AUX(log, TRANSPORT_LOG_FATAL, _TRANSPORT_LOG_TAG, \
- __VA_ARGS__)
-#define TRANSPORT_LOGF_MEM(d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM(TRANSPORT_LOG_FATAL, _TRANSPORT_LOG_TAG, d, d_sz, \
- __VA_ARGS__)
-#define TRANSPORT_LOGF_MEM_AUX(log, d, d_sz, ...) \
- TRANSPORT_LOG_WRITE_MEM_AUX(log, TRANSPORT_LOG_FATAL, _TRANSPORT_LOG_TAG, d, \
- d_sz, __VA_ARGS__)
-#else
-#define TRANSPORT_LOGF(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGF_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGF_MEM(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#define TRANSPORT_LOGF_MEM_AUX(...) _TRANSPORT_LOG_UNUSED(__VA_ARGS__)
-#endif
-
-#define TRANSPORT_LOGV_STR(s) TRANSPORT_LOGV("%s", (s))
-#define TRANSPORT_LOGD_STR(s) TRANSPORT_LOGD("%s", (s))
-#define TRANSPORT_LOGI_STR(s) TRANSPORT_LOGI("%s", (s))
-#define TRANSPORT_LOGW_STR(s) TRANSPORT_LOGW("%s", (s))
-#define TRANSPORT_LOGE_STR(s) TRANSPORT_LOGE("%s", (s))
-#define TRANSPORT_LOGF_STR(s) TRANSPORT_LOGF("%s", (s))
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Output to standard error stream. Library uses it by default, though in few
- * cases it could be necessary to specify it explicitly. For example, when
- * transport_log library is compiled with TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT,
- * application must define and initialize global output variable:
- *
- * TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT = {TRANSPORT_LOG_OUT_STDERR};
- *
- * Another example is when using custom output, stderr could be used as a
- * fallback when custom output facility failed to initialize:
- *
- * transport_log_set_output_v(TRANSPORT_LOG_OUT_STDERR);
- */
-enum { TRANSPORT_LOG_OUT_STDERR_MASK = TRANSPORT_LOG_PUT_STD };
-void transport_log_out_stderr_callback(const transport_log_message *const msg,
- void *arg);
-#define TRANSPORT_LOG_OUT_STDERR \
- TRANSPORT_LOG_OUT_STDERR_MASK, 0, transport_log_out_stderr_callback
-
-/* Predefined spec for stderr. Uses global format options
- * (TRANSPORT_LOG_GLOBAL_FORMAT) and TRANSPORT_LOG_OUT_STDERR. Could be used to
- * force output to stderr for a particular message. Example:
- *
- * f = fopen("foo.log", "w");
- * if (!f)
- * TRANSPORT_LOGE_AUX(TRANSPORT_LOG_STDERR, "Failed to open log file");
- */
-#define TRANSPORT_LOG_STDERR (&_transport_log_stderr_spec)
+} // namespace utils
-#ifdef __cplusplus
-}
-#endif \ No newline at end of file
+#define TRANSPORT_LOG_INFO ::utils::LogInfo::getInstance().getStream()
+#define TRANSPORT_LOG_WARNING ::utils::LogWarning::getInstance().getStream()
+#define TRANSPORT_LOG_ERROR ::utils::LogError::getInstance().getStream()
+#define TRANSPORT_LOG_FATAL ::utils::LogFatal::getInstance().getStream()
diff --git a/libtransport/includes/hicn/transport/utils/membuf.h b/libtransport/includes/hicn/transport/utils/membuf.h
index 0db87e9dd..6f92c2208 100644
--- a/libtransport/includes/hicn/transport/utils/membuf.h
+++ b/libtransport/includes/hicn/transport/utils/membuf.h
@@ -719,8 +719,8 @@ class MemBuf {
/**
* Override operator == and !=
*/
- bool operator ==(const MemBuf &other);
- bool operator !=(const MemBuf &other);
+ bool operator==(const MemBuf& other);
+ bool operator!=(const MemBuf& other);
// /**
// * Iteration support: a chain of MemBufs may be iterated through using
diff --git a/libtransport/includes/hicn/transport/utils/move_wrapper.h b/libtransport/includes/hicn/transport/utils/move_wrapper.h
index 3aba345d6..5dc3b461d 100644
--- a/libtransport/includes/hicn/transport/utils/move_wrapper.h
+++ b/libtransport/includes/hicn/transport/utils/move_wrapper.h
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
- * Copyright 2017 Facebook, Inc.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/libtransport/includes/hicn/transport/utils/object_pool.h b/libtransport/includes/hicn/transport/utils/object_pool.h
index a5e8b2eef..d9b28e663 100644
--- a/libtransport/includes/hicn/transport/utils/object_pool.h
+++ b/libtransport/includes/hicn/transport/utils/object_pool.h
@@ -15,9 +15,7 @@
#pragma once
-// TODO
#include <hicn/transport/utils/branch_prediction.h>
-#include <hicn/transport/utils/log.h>
#include <hicn/transport/utils/spinlock.h>
#include <deque>
@@ -34,7 +32,6 @@ class ObjectPool {
void operator()(T *t) {
if (pool_) {
- TRANSPORT_LOGV("Back in pool");
pool_->add(t);
} else {
delete t;
diff --git a/libtransport/includes/hicn/transport/utils/singleton.h b/libtransport/includes/hicn/transport/utils/singleton.h
index 7fd8b912f..4b7b19c0a 100644
--- a/libtransport/includes/hicn/transport/utils/singleton.h
+++ b/libtransport/includes/hicn/transport/utils/singleton.h
@@ -20,7 +20,7 @@
namespace utils {
template <typename T>
-class Singleton {
+class Singleton : NonCopyable {
public:
static T& getInstance() {
static T instance;
@@ -30,10 +30,6 @@ class Singleton {
protected:
Singleton() {}
~Singleton() {}
-
- public:
- Singleton(Singleton const&) = delete;
- Singleton& operator=(Singleton const&) = delete;
};
} // namespace utils \ No newline at end of file