aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/includes/hicn/transport/core/content_object.h
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/includes/hicn/transport/core/content_object.h')
-rw-r--r--libtransport/includes/hicn/transport/core/content_object.h64
1 files changed, 47 insertions, 17 deletions
diff --git a/libtransport/includes/hicn/transport/core/content_object.h b/libtransport/includes/hicn/transport/core/content_object.h
index 822790e56..3d6d98c48 100644
--- a/libtransport/includes/hicn/transport/core/content_object.h
+++ b/libtransport/includes/hicn/transport/core/content_object.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021-2022 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:
@@ -17,6 +17,7 @@
#include <hicn/transport/core/name.h>
#include <hicn/transport/core/packet.h>
+#include <hicn/transport/utils/shared_ptr_utils.h>
namespace transport {
@@ -27,24 +28,49 @@ namespace core {
class ContentObject : public Packet {
public:
- using Ptr = utils::ObjectPool<ContentObject>::Ptr;
- using HICNContentObject = hicn_header_t;
+ using Ptr = std::shared_ptr<ContentObject>;
+ using HICNContentObject = u8;
- ContentObject(Packet::Format format = HF_INET6_TCP);
+ ContentObject(Packet::Format format, std::size_t additional_header_size = 0);
- ContentObject(const Name &name, Packet::Format format = HF_INET6_TCP);
+ ContentObject(const Name &name, Packet::Format format,
+ std::size_t additional_header_size = 0);
- ContentObject(const Name &name, hicn_format_t format, const uint8_t *payload,
+ ContentObject(const Name &name, hicn_packet_format_t format,
+ std::size_t additional_header_size, const uint8_t *payload,
std::size_t payload_size);
- ContentObject(const uint8_t *buffer, std::size_t size);
- ContentObject(MemBufPtr &&buffer);
-
- ContentObject(const ContentObject &content_object) = delete;
+ template <typename... Args>
+ ContentObject(CopyBufferOp op, Args &&...args)
+ : Packet(op, std::forward<Args>(args)...) {
+ if (hicn_data_get_name(&pkbuf_, &name_.getStructReference()) < 0) {
+ throw errors::MalformedPacketException();
+ }
+ }
+
+ template <typename... Args>
+ ContentObject(WrapBufferOp op, Args &&...args)
+ : Packet(op, std::forward<Args>(args)...) {
+ if (hicn_data_get_name(&pkbuf_, &name_.getStructReference()) < 0) {
+ throw errors::MalformedPacketException();
+ }
+ }
+
+ template <typename... Args>
+ ContentObject(CreateOp op, Args &&...args)
+ : Packet(op, HICN_PACKET_TYPE_DATA, std::forward<Args>(args)...) {
+ if (hicn_data_get_name(&pkbuf_, &name_.getStructReference()) < 0) {
+ throw errors::MalformedPacketException();
+ }
+ }
+
+ ContentObject(const ContentObject &content_object);
+
+ ContentObject &operator=(const ContentObject &other);
ContentObject(ContentObject &&content_object);
- ~ContentObject() override;
+ ~ContentObject();
const Name &getName() const override;
@@ -52,20 +78,24 @@ class ContentObject : public Packet {
void setName(const Name &name) override;
- void setName(Name &&name) override;
-
- uint32_t getPathLabel() const;
+ hicn_path_label_t getPathLabel() const;
- ContentObject &setPathLabel(uint32_t path_label);
+ ContentObject &setPathLabel(hicn_path_label_t path_label);
- void setLocator(const ip_address_t &ip_address) override;
+ void setLocator(const hicn_ip_address_t &ip_address) override;
- ip_address_t getLocator() const override;
+ hicn_ip_address_t getLocator() const override;
void setLifetime(uint32_t lifetime) override;
uint32_t getLifetime() const override;
+ auto shared_from_this() { return utils::shared_from(this); }
+
+ bool isLast() const;
+
+ void setLast();
+
private:
void resetForHash() override;
};