diff options
author | 2021-02-04 12:20:30 +0100 | |
---|---|---|
committer | 2021-02-05 09:54:15 +0100 | |
commit | 8d08f8dd79ac12874ba0da6b26973f5a33163131 (patch) | |
tree | 554993ddd190183a0722112ace984f6077e0aa8e /libtransport/includes | |
parent | f77f2a01fb49b52f02d6493e926d0ccc41abf4d0 (diff) |
[HICN-679] Do not throw exception when receiving corrupted/not-hicn packet from network layer
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Change-Id: I082e3c1b5fc9f535089114cfe14940f094947b66
Signed-off-by: Mauro Sardara <msardara@cisco.com>
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(); } |