diff options
Diffstat (limited to 'libtransport/src/core')
-rw-r--r-- | libtransport/src/core/manifest_format.h | 5 | ||||
-rw-r--r-- | libtransport/src/core/manifest_format_fixed.cc | 8 | ||||
-rw-r--r-- | libtransport/src/core/manifest_format_fixed.h | 6 | ||||
-rw-r--r-- | libtransport/src/core/packet.cc | 13 |
4 files changed, 17 insertions, 15 deletions
diff --git a/libtransport/src/core/manifest_format.h b/libtransport/src/core/manifest_format.h index 38f26067e..caee210cd 100644 --- a/libtransport/src/core/manifest_format.h +++ b/libtransport/src/core/manifest_format.h @@ -18,6 +18,7 @@ #include <hicn/transport/auth/crypto_hash.h> #include <hicn/transport/core/name.h> #include <hicn/transport/interfaces/socket_options_keys.h> +#include <protocols/fec_utils.h> #include <cinttypes> #include <type_traits> @@ -41,11 +42,11 @@ struct ParamsRTC { std::uint64_t timestamp; std::uint32_t prod_rate; std::uint32_t prod_seg; - std::uint32_t support_fec; + protocol::fec::FECType fec_type; bool operator==(const ParamsRTC &other) const { return (timestamp == other.timestamp && prod_rate == other.prod_rate && - prod_seg == other.prod_seg && support_fec == other.support_fec); + prod_seg == other.prod_seg && fec_type == other.fec_type); } }; diff --git a/libtransport/src/core/manifest_format_fixed.cc b/libtransport/src/core/manifest_format_fixed.cc index 4c8a5e031..428d6ad12 100644 --- a/libtransport/src/core/manifest_format_fixed.cc +++ b/libtransport/src/core/manifest_format_fixed.cc @@ -154,22 +154,20 @@ FixedManifestEncoder &FixedManifestEncoder::setParamsRTCImpl( .timestamp = params.timestamp, .prod_rate = params.prod_rate, .prod_seg = params.prod_seg, - .support_fec = params.support_fec, + .fec_type = static_cast<uint32_t>(params.fec_type), }; return *this; } FixedManifestEncoder &FixedManifestEncoder::addSuffixAndHashImpl( uint32_t suffix, const auth::CryptoHash &hash) { - std::vector<uint8_t> _hash = hash.getDigest(); - manifest_entries_.push_back(ManifestEntry{ .suffix = htonl(suffix), .hash = {0}, }); std::memcpy(reinterpret_cast<uint8_t *>(manifest_entries_.back().hash), - _hash.data(), _hash.size()); + hash.getDigest()->data(), hash.getSize()); if (TRANSPORT_EXPECT_FALSE(estimateSerializedLengthImpl() > max_size_)) { throw errors::RuntimeException("Manifest size exceeded the packet MTU!"); @@ -301,7 +299,7 @@ ParamsRTC FixedManifestDecoder::getParamsRTCImpl() const { .timestamp = params_rtc_->timestamp, .prod_rate = params_rtc_->prod_rate, .prod_seg = params_rtc_->prod_seg, - .support_fec = params_rtc_->support_fec, + .fec_type = static_cast<protocol::fec::FECType>(params_rtc_->fec_type), }; } diff --git a/libtransport/src/core/manifest_format_fixed.h b/libtransport/src/core/manifest_format_fixed.h index ade4bf02c..5fd2a673d 100644 --- a/libtransport/src/core/manifest_format_fixed.h +++ b/libtransport/src/core/manifest_format_fixed.h @@ -65,9 +65,7 @@ namespace core { // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // | Current Segment | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ -// |F| | -// + Reserved for future parameters + -// | | +// | FEC Type | // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ // Manifest Entry: @@ -137,7 +135,7 @@ struct __attribute__((__packed__)) TransportParamsRTC { std::uint64_t timestamp; std::uint32_t prod_rate; std::uint32_t prod_seg; - std::uint32_t support_fec; + std::uint32_t fec_type; }; static_assert(sizeof(TransportParamsRTC) == MANIFEST_PARAMS_RTC_SIZE); diff --git a/libtransport/src/core/packet.cc b/libtransport/src/core/packet.cc index df27444af..0c08246af 100644 --- a/libtransport/src/core/packet.cc +++ b/libtransport/src/core/packet.cc @@ -15,6 +15,7 @@ #include <glog/logging.h> #include <hicn/transport/auth/crypto_hash.h> +#include <hicn/transport/core/global_object_pool.h> #include <hicn/transport/core/packet.h> #include <hicn/transport/errors/malformed_packet_exception.h> #include <hicn/transport/utils/hash.h> @@ -481,7 +482,7 @@ uint8_t Packet::getTTL() const { bool Packet::hasAH() const { return _is_ah(format_); } -std::vector<uint8_t> Packet::getSignature() const { +utils::MemBuf::Ptr Packet::getSignature() const { if (!hasAH()) { throw errors::RuntimeException("Packet without Authentication Header."); } @@ -493,7 +494,11 @@ std::vector<uint8_t> Packet::getSignature() const { throw errors::RuntimeException("Error getting signature."); } - return std::vector<uint8_t>(signature, signature + getSignatureFieldSize()); + utils::MemBuf::Ptr membuf = PacketManager<>::getInstance().getMemBuf(); + membuf->append(getSignatureFieldSize()); + memcpy(membuf->writableData(), signature, getSignatureFieldSize()); + + return membuf; } std::size_t Packet::getSignatureFieldSize() const { @@ -570,7 +575,7 @@ auth::CryptoSuite Packet::getValidationAlgorithm() const { return auth::CryptoSuite(return_value); } -void Packet::setSignature(const std::vector<uint8_t> &signature) { +void Packet::setSignature(const utils::MemBuf::Ptr &signature) { if (!hasAH()) { throw errors::RuntimeException("Packet without Authentication Header."); } @@ -580,7 +585,7 @@ void Packet::setSignature(const std::vector<uint8_t> &signature) { if (ret < 0) { throw errors::RuntimeException("Error getting signature."); } - memcpy(signature_field, signature.data(), signature.size()); + memcpy(signature_field, signature->data(), signature->length()); } void Packet::setSignatureFieldSize(std::size_t size) { |