diff options
author | Mauro Sardara <msardara@cisco.com> | 2021-02-10 14:26:52 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2021-02-10 14:26:52 +0000 |
commit | 71a5c399d8064e2aa97a047e23174bb784eea399 (patch) | |
tree | 740bae933895ab6c40db1eb14fcd84a67536df06 /libtransport/includes | |
parent | db76bbc76c8d2cb2d817df8c9233937d230a1ff2 (diff) | |
parent | 8d08f8dd79ac12874ba0da6b26973f5a33163131 (diff) |
Merge "[HICN-679] Do not throw exception when receiving corrupted/not-hicn packet from network layer"v21.01-rc0
Diffstat (limited to 'libtransport/includes')
-rw-r--r-- | libtransport/includes/hicn/transport/core/packet.h | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/libtransport/includes/hicn/transport/core/packet.h b/libtransport/includes/hicn/transport/core/packet.h index 2efd7439d..91f957964 100644 --- a/libtransport/includes/hicn/transport/core/packet.h +++ b/libtransport/includes/hicn/transport/core/packet.h @@ -23,6 +23,7 @@ #include <hicn/transport/security/crypto_suite.h> #include <hicn/transport/security/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> @@ -97,13 +98,16 @@ class Packet : public std::enable_shared_from_this<Packet> { static bool isInterest(const uint8_t *buffer); - static Format getFormatFromBuffer(const uint8_t *buffer) { + static Format getFormatFromBuffer(const uint8_t *buffer, std::size_t length) { Format format = HF_UNSPEC; if (TRANSPORT_EXPECT_FALSE( hicn_packet_get_format((const hicn_header_t *)buffer, &format) < 0)) { - throw errors::MalformedPacketException(); + TRANSPORT_LOGE( + "Error while getting format from packet buffer. Packet will be " + "discarded."); + hicn_packet_dump(buffer, length); } return format; @@ -114,7 +118,8 @@ class Packet : public std::enable_shared_from_this<Packet> { packet_start_ = reinterpret_cast<hicn_header_t *>(packet_->writableData()); header_head_ = packet_.get(); payload_head_ = nullptr; - format_ = getFormatFromBuffer(reinterpret_cast<uint8_t *>(packet_start_)); + format_ = getFormatFromBuffer(reinterpret_cast<uint8_t *>(packet_start_), + packet_->length()); name_.clear(); } |