aboutsummaryrefslogtreecommitdiffstats
path: root/libtransport/src/hicn/transport/interfaces/socket_producer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libtransport/src/hicn/transport/interfaces/socket_producer.cc')
-rw-r--r--libtransport/src/hicn/transport/interfaces/socket_producer.cc554
1 files changed, 3 insertions, 551 deletions
diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.cc b/libtransport/src/hicn/transport/interfaces/socket_producer.cc
index 66c656924..497c40c99 100644
--- a/libtransport/src/hicn/transport/interfaces/socket_producer.cc
+++ b/libtransport/src/hicn/transport/interfaces/socket_producer.cc
@@ -122,23 +122,7 @@ void ProducerSocket::passContentObjectToCallbacks(
on_content_object_output_(*this, *content_object);
}
-#ifndef PUSH_API
- std::unordered_map<Name, std::shared_ptr<const Interest>>::iterator it;
-
- {
- std::lock_guard<std::mutex> lock(pending_interests_mtx_);
- it = pending_interests_.find(content_object->getName());
- }
-
- if (it != pending_interests_.end()) {
- content_object->setLocator(it->second->getLocator());
- portal_->sendContentObject(*content_object);
- std::lock_guard<std::mutex> lock(pending_interests_mtx_);
- pending_interests_.erase(it);
- }
-#else
portal_->sendContentObject(*content_object);
-#endif
}
}
@@ -154,23 +138,7 @@ void ProducerSocket::produce(ContentObject &content_object) {
on_content_object_output_(*this, content_object);
}
-#ifndef PUSH_API
- std::unordered_map<Name, std::shared_ptr<const Interest>>::iterator it;
-
- {
- std::lock_guard<std::mutex> lock(pending_interests_mtx_);
- it = pending_interests_.find(content_object.getName());
- }
-
- if (it != pending_interests_.end()) {
- content_object.setLocator(it->second->getLocator());
- portal_->sendContentObject(content_object);
- std::lock_guard<std::mutex> lock(pending_interests_mtx_);
- pending_interests_.erase(it);
- }
-#else
portal_->sendContentObject(content_object);
-#endif
}
uint32_t ProducerSocket::produce(Name content_name, const uint8_t *buf,
@@ -307,10 +275,6 @@ uint32_t ProducerSocket::produce(Name content_name, const uint8_t *buf,
content_name.setSuffix(current_segment), format);
content_object->setLifetime(content_object_expiry_time_);
- if (!making_manifest_ && identity_) {
- content_object->setSignatureSize(signature_length);
- }
-
if (packaged_segments == number_of_segments - 1) {
content_object->appendPayload(&buf[bytes_segmented],
buffer_size - bytes_segmented);
@@ -389,14 +353,12 @@ void ProducerSocket::asyncProduce(const Name &suffix, const uint8_t *buf,
}
}
-void ProducerSocket::asyncProduce(
- const Name &suffix, utils::SharableVector<uint8_t> &&output_buffer) {
+void ProducerSocket::asyncProduce(const Name &suffix,
+ ContentBuffer &&output_buffer) {
if (!async_thread_.stopped()) {
async_thread_.add(
[this, suff = suffix, buffer = std::move(output_buffer)]() {
- TRANSPORT_LOGI("FOR REAL!!!!!! --> Producing content with name %s",
- suff.toString().c_str());
- produce(suff, &buffer[0], buffer.size(), true);
+ produce(suff, &(*buffer)[0], buffer->size(), true);
});
}
}
@@ -420,524 +382,14 @@ void ProducerSocket::onInterest(Interest &interest) {
portal_->sendContentObject(*content_object);
} else {
-#ifndef PUSH_API
- {
- std::lock_guard<std::mutex> lock(pending_interests_mtx_);
- pending_interests_[interest.getName()] =
- std::static_pointer_cast<const Interest>(interest.shared_from_this());
- }
-#endif
-
if (on_interest_process_ != VOID_HANDLER) {
- // external_io_service_.post([this, &interest] () {
on_interest_process_(*this, interest);
- // });
}
}
}
asio::io_service &ProducerSocket::getIoService() { return io_service_; }
-int ProducerSocket::setSocketOption(int socket_option_key,
- uint32_t socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::DATA_PACKET_SIZE:
- if (socket_option_value < default_values::max_content_object_size &&
- socket_option_value > 0) {
- data_packet_size_ = socket_option_value;
- return SOCKET_OPTION_SET;
- } else {
- return SOCKET_OPTION_NOT_SET;
- }
-
- case GeneralTransportOptions::INPUT_BUFFER_SIZE:
- if (socket_option_value >= 1) {
- input_buffer_capacity_ = socket_option_value;
- return SOCKET_OPTION_SET;
- } else {
- return SOCKET_OPTION_NOT_SET;
- }
-
- case GeneralTransportOptions::OUTPUT_BUFFER_SIZE:
- output_buffer_.setLimit(socket_option_value);
- return SOCKET_OPTION_SET;
-
- case GeneralTransportOptions::CONTENT_OBJECT_EXPIRY_TIME:
- content_object_expiry_time_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case GeneralTransportOptions::SIGNATURE_TYPE:
- if (socket_option_value == SOCKET_OPTION_DEFAULT) {
- signature_type_ = SHA_256;
- } else {
- signature_type_ = socket_option_value;
- }
-
- if (signature_type_ == SHA_256 || signature_type_ == RSA_256) {
- signature_size_ = 32;
- }
-
- case ProducerCallbacksOptions::INTEREST_INPUT:
- if (socket_option_value == VOID_HANDLER) {
- on_interest_input_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::INTEREST_DROP:
- if (socket_option_value == VOID_HANDLER) {
- on_interest_dropped_input_buffer_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::INTEREST_PASS:
- if (socket_option_value == VOID_HANDLER) {
- on_interest_inserted_input_buffer_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::CACHE_HIT:
- if (socket_option_value == VOID_HANDLER) {
- on_interest_satisfied_output_buffer_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::CACHE_MISS:
- if (socket_option_value == VOID_HANDLER) {
- on_interest_process_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::NEW_CONTENT_OBJECT:
- if (socket_option_value == VOID_HANDLER) {
- on_new_segment_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_SIGN:
- if (socket_option_value == VOID_HANDLER) {
- on_content_object_to_sign_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_READY:
- if (socket_option_value == VOID_HANDLER) {
- on_content_object_in_output_buffer_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_OUTPUT:
- if (socket_option_value == VOID_HANDLER) {
- on_content_object_output_ = VOID_HANDLER;
- return SOCKET_OPTION_SET;
- }
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- double socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- bool socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::MAKE_MANIFEST:
- making_manifest_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- Name socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- std::list<Prefix> socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::NETWORK_NAME:
- served_namespaces_ = socket_option_value;
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-
- return SOCKET_OPTION_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ProducerContentObjectCallback socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::NEW_CONTENT_OBJECT:
- on_new_segment_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_SIGN:
- on_content_object_to_sign_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_READY:
- on_content_object_in_output_buffer_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_OUTPUT:
- on_content_object_output_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ProducerInterestCallback socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::INTEREST_INPUT:
- on_interest_input_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::INTEREST_DROP:
- on_interest_dropped_input_buffer_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::INTEREST_PASS:
- on_interest_inserted_input_buffer_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::CACHE_HIT:
- on_interest_satisfied_output_buffer_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- case ProducerCallbacksOptions::CACHE_MISS:
- on_interest_process_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ProducerContentCallback socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::CONTENT_PRODUCED:
- on_content_produced_ = socket_option_value;
- return SOCKET_OPTION_SET;
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ConsumerContentObjectCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ConsumerInterestCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ConsumerContentCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, ConsumerManifestCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- HashAlgorithm socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::HASH_ALGORITHM:
- hash_algorithm_ = socket_option_value;
- return SOCKET_OPTION_SET;
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- utils::CryptoSuite socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::CRYPTO_SUITE:
- crypto_suite_ = socket_option_value;
- return SOCKET_OPTION_SET;
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key, const utils::Identity &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::IDENTITY:
- identity_.reset();
- identity_ = std::make_unique<utils::Identity>(socket_option_value);
- return SOCKET_OPTION_SET;
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- const std::string &socket_option_value) {
- switch (socket_option_key) {
- case DataLinkOptions::OUTPUT_INTERFACE:
- output_interface_ = socket_option_value;
- portal_->setOutputInterface(output_interface_);
- return SOCKET_OPTION_SET;
- }
-
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::setSocketOption(
- int socket_option_key,
- interface::ConsumerTimerCallback socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- uint32_t &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::INPUT_BUFFER_SIZE:
- socket_option_value = (int)input_buffer_capacity_;
- return SOCKET_OPTION_GET;
-
- case GeneralTransportOptions::OUTPUT_BUFFER_SIZE:
- socket_option_value = (uint32_t)output_buffer_.getLimit();
- return SOCKET_OPTION_GET;
-
- case GeneralTransportOptions::DATA_PACKET_SIZE:
- socket_option_value = (uint32_t)data_packet_size_;
- return SOCKET_OPTION_GET;
-
- case GeneralTransportOptions::CONTENT_OBJECT_EXPIRY_TIME:
- socket_option_value = content_object_expiry_time_;
- return SOCKET_OPTION_GET;
-
- case GeneralTransportOptions::SIGNATURE_TYPE:
- socket_option_value = signature_type_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- double &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- bool &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::MAKE_MANIFEST:
- socket_option_value = making_manifest_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- Name &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- std::list<Prefix> &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::NETWORK_NAME:
-
- socket_option_value = served_namespaces_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ProducerContentObjectCallback &socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::NEW_CONTENT_OBJECT:
- socket_option_value = on_new_segment_;
- return SOCKET_OPTION_GET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_SIGN:
- socket_option_value = on_content_object_to_sign_;
- return SOCKET_OPTION_GET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_READY:
- socket_option_value = on_content_object_in_output_buffer_;
- return SOCKET_OPTION_GET;
-
- case ProducerCallbacksOptions::CONTENT_OBJECT_OUTPUT:
- socket_option_value = on_content_object_output_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ProducerContentCallback &socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::CONTENT_PRODUCED:
- socket_option_value = on_content_produced_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ProducerInterestCallback &socket_option_value) {
- switch (socket_option_key) {
- case ProducerCallbacksOptions::INTEREST_INPUT:
- socket_option_value = on_interest_input_;
- return SOCKET_OPTION_GET;
-
- case ProducerCallbacksOptions::INTEREST_DROP:
- socket_option_value = on_interest_dropped_input_buffer_;
- return SOCKET_OPTION_GET;
-
- case ProducerCallbacksOptions::INTEREST_PASS:
- socket_option_value = on_interest_inserted_input_buffer_;
- return SOCKET_OPTION_GET;
-
- case CACHE_HIT:
- socket_option_value = on_interest_satisfied_output_buffer_;
- return SOCKET_OPTION_GET;
-
- case CACHE_MISS:
- socket_option_value = on_interest_process_;
- return SOCKET_OPTION_GET;
-
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ConsumerContentObjectCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key,
- ConsumerContentObjectVerificationCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ConsumerInterestCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ConsumerContentCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, ConsumerManifestCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key, std::shared_ptr<Portal> &socket_option_value) {
- switch (socket_option_key) {
- case PORTAL:
- socket_option_value = portal_;
- return SOCKET_OPTION_GET;
- }
-
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- IcnObserver **socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::setSocketOption(int socket_option_key,
- IcnObserver *socket_option_value) {
- return SOCKET_OPTION_NOT_SET;
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- HashAlgorithm &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::HASH_ALGORITHM:
- socket_option_value = hash_algorithm_;
- return SOCKET_OPTION_GET;
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- utils::CryptoSuite &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::HASH_ALGORITHM:
- socket_option_value = crypto_suite_;
- return SOCKET_OPTION_GET;
- default:
- return SOCKET_OPTION_NOT_GET;
- }
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- utils::Identity &socket_option_value) {
- switch (socket_option_key) {
- case GeneralTransportOptions::IDENTITY:
- if (identity_) {
- socket_option_value = *identity_;
- return SOCKET_OPTION_SET;
- }
- default:
- return SOCKET_OPTION_NOT_SET;
- }
-}
-
-int ProducerSocket::getSocketOption(int socket_option_key,
- std::string &socket_option_value) {
- switch (socket_option_key) {
- case DataLinkOptions::OUTPUT_INTERFACE:
- socket_option_value = output_interface_;
- return SOCKET_OPTION_GET;
- }
-
- return SOCKET_OPTION_NOT_GET;
-}
-
-int ProducerSocket::getSocketOption(
- int socket_option_key,
- interface::ConsumerTimerCallback &socket_option_value) {
- return SOCKET_OPTION_NOT_GET;
-}
-
} // namespace interface
} // end namespace transport