diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-03-19 14:26:52 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-03-23 15:05:53 +0100 |
commit | 1ad06afe9f952642a26f4d28239cf05eb3283eb7 (patch) | |
tree | 1ea58529d64a38597cd09f78653cc784c4b61d79 /libtransport | |
parent | e6d4612011483b267dc9f47c5d2b2444dd88f402 (diff) |
[HICN-6] ATS Working, little refactoring of apps
Change-Id: I174815b70bf3a9fbe99ffab7dd2914be04d364b9
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport')
9 files changed, 34 insertions, 30 deletions
diff --git a/libtransport/src/hicn/transport/core/forwarder_interface.h b/libtransport/src/hicn/transport/core/forwarder_interface.h index 974b1c39a..b4bc26da7 100644 --- a/libtransport/src/hicn/transport/core/forwarder_interface.h +++ b/libtransport/src/hicn/transport/core/forwarder_interface.h @@ -98,7 +98,7 @@ class ForwarderInterface { } packet.setChecksum(); - connector_.send(packet.data()); + connector_.send(packet.acquireMemBufReference()); } template <typename Handler> diff --git a/libtransport/src/hicn/transport/core/packet.cc b/libtransport/src/hicn/transport/core/packet.cc index c5c2b9796..de8ede421 100644 --- a/libtransport/src/hicn/transport/core/packet.cc +++ b/libtransport/src/hicn/transport/core/packet.cc @@ -230,7 +230,9 @@ Packet::Format Packet::getFormat() const { return format_; } -const std::shared_ptr<utils::MemBuf> Packet::data() { return packet_; } +const std::shared_ptr<utils::MemBuf> Packet::acquireMemBufReference() { + return packet_; +} void Packet::dump() const { const_cast<Packet *>(this)->separateHeaderPayload(); diff --git a/libtransport/src/hicn/transport/core/packet.h b/libtransport/src/hicn/transport/core/packet.h index 88d9f9318..6d8bc7e0f 100644 --- a/libtransport/src/hicn/transport/core/packet.h +++ b/libtransport/src/hicn/transport/core/packet.h @@ -99,7 +99,7 @@ class Packet : public std::enable_shared_from_this<Packet> { std::size_t headerSize() const; - const std::shared_ptr<utils::MemBuf> data(); + const std::shared_ptr<utils::MemBuf> acquireMemBufReference(); virtual const Name &getName() const = 0; diff --git a/libtransport/src/hicn/transport/http/client_connection.cc b/libtransport/src/hicn/transport/http/client_connection.cc index e2ee6478d..b31d89b6b 100644 --- a/libtransport/src/hicn/transport/http/client_connection.cc +++ b/libtransport/src/hicn/transport/http/client_connection.cc @@ -154,10 +154,10 @@ bool HTTPClientConnection::verifyData( void HTTPClientConnection::processLeavingInterest( ConsumerSocket &c, const core::Interest &interest, std::string &payload) { - // if (interest.getName().getSuffix() == 0) { - Interest &int2 = const_cast<Interest &>(interest); - int2.appendPayload((uint8_t *)payload.data(), payload.size()); - // } + if (interest.payloadSize() == 0) { + Interest &int2 = const_cast<Interest &>(interest); + int2.appendPayload((uint8_t *)payload.data(), payload.size()); + } } ConsumerSocket &HTTPClientConnection::getConsumer() { return consumer_; } diff --git a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc index 2e180cf34..fdd422dee 100644 --- a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc +++ b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.cc @@ -187,14 +187,14 @@ void AsyncFullDuplexSocket::write(WriteCallback *callback, const void *buf, if (bytes > core::Packet::default_mtu - sizeof(PayloadMessage)) { TRANSPORT_LOGI("Producing content with name %s", - options.name.toString().c_str()); - producer_->asyncProduce(options.name, + options.getName().toString().c_str()); + producer_->asyncProduce(options.getName(), reinterpret_cast<const uint8_t *>(buf), bytes); - signalProductionToSubscribers(options.name); + signalProductionToSubscribers(options.getName()); } else { TRANSPORT_LOGI("Sending payload through interest"); piggybackPayloadToSubscribers( - options.name, reinterpret_cast<const uint8_t *>(buf), bytes); + options.getName(), reinterpret_cast<const uint8_t *>(buf), bytes); } } @@ -212,12 +212,12 @@ void AsyncFullDuplexSocket::write(WriteCallback *callback, if (output_buffer->size() > core::Packet::default_mtu - sizeof(PayloadMessage)) { TRANSPORT_LOGI("Producing content with name %s", - options.name.toString().c_str()); - producer_->asyncProduce(options.name, std::move(output_buffer)); - signalProductionToSubscribers(options.name); + options.getName().toString().c_str()); + producer_->asyncProduce(options.getName(), std::move(output_buffer)); + signalProductionToSubscribers(options.getName()); } else { TRANSPORT_LOGI("Sending payload through interest"); - piggybackPayloadToSubscribers(options.name, &(*output_buffer)[0], + piggybackPayloadToSubscribers(options.getName(), &(*output_buffer)[0], output_buffer->size()); } } diff --git a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h index 1d7ad3cb1..438325fdb 100644 --- a/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h +++ b/libtransport/src/hicn/transport/interfaces/full_duplex_socket.h @@ -139,13 +139,6 @@ class AsyncFullDuplexSocket : public AsyncSocket, void waitForSubscribers(AcceptCallback *cb) override; - // void writev( - // WriteCallback* callback, - // const iovec* vec, - // size_t count, - // Name &&content_to_publish_name, - // WriteFlags flags = WriteFlags::NONE) override; - void close() override; void closeNow() override; diff --git a/libtransport/src/hicn/transport/interfaces/publication_options.h b/libtransport/src/hicn/transport/interfaces/publication_options.h index ae5366ce7..6910e5371 100644 --- a/libtransport/src/hicn/transport/interfaces/publication_options.h +++ b/libtransport/src/hicn/transport/interfaces/publication_options.h @@ -15,9 +15,7 @@ #pragma once -#include <map> -#include <sstream> -#include <vector> +#include <hicn/transport/core/name.h> namespace transport { @@ -25,8 +23,19 @@ namespace interface { class PublicationOptions { public: - core::Name name; - uint32_t content_lifetime_milliseconds; + template <typename T> + PublicationOptions(T&& name, uint32_t lifetime) + : name_(std::forward<T&&>(name)), + content_lifetime_milliseconds_(lifetime) {} + + TRANSPORT_ALWAYS_INLINE const core::Name& getName() const { return name_; } + TRANSPORT_ALWAYS_INLINE uint32_t getLifetime() const { + return content_lifetime_milliseconds_; + } + + private: + core::Name name_; + uint32_t content_lifetime_milliseconds_; // TODO Signature }; } // namespace interface diff --git a/libtransport/src/hicn/transport/utils/content_store.cc b/libtransport/src/hicn/transport/utils/content_store.cc index d48e16daf..c3864310e 100644 --- a/libtransport/src/hicn/transport/utils/content_store.cc +++ b/libtransport/src/hicn/transport/utils/content_store.cc @@ -62,7 +62,7 @@ void ContentStore::insert( } } -const std::shared_ptr<ContentObject> &ContentStore::find( +const std::shared_ptr<ContentObject> ContentStore::find( const Interest &interest) { std::unique_lock<std::mutex> lock(cs_mutex_); auto it = content_store_hash_table_.find(interest.getName()); diff --git a/libtransport/src/hicn/transport/utils/content_store.h b/libtransport/src/hicn/transport/utils/content_store.h index 39e87fb7d..ba8ee5bd2 100644 --- a/libtransport/src/hicn/transport/utils/content_store.h +++ b/libtransport/src/hicn/transport/utils/content_store.h @@ -46,13 +46,13 @@ typedef std::unordered_map<Name, ContentStoreEntry> ContentStoreHashTable; class ContentStore { public: - explicit ContentStore(std::size_t max_packets = 65536); + explicit ContentStore(std::size_t max_packets = (1 << 16)); ~ContentStore(); void insert(const std::shared_ptr<ContentObject> &content_object); - const std::shared_ptr<ContentObject> &find(const Interest &interest); + const std::shared_ptr<ContentObject> find(const Interest &interest); void erase(const Name &exact_name); |