diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-03-14 21:16:56 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@fd.io> | 2019-03-14 21:16:56 +0000 |
commit | 68dff43b0477d0ed3c96f0f56b56e6a1266a7405 (patch) | |
tree | 1b5e5ed7a71883e3d4d7672fa2dc7e2c603f6d0d /libtransport | |
parent | 9c4aded148355148aa90343c51432ddf3598481b (diff) | |
parent | 7254a7d407c62d705ef410052825be74a6bd1b4e (diff) |
Merge "[HICN-116] Added RTC producer option to hiperf."
Diffstat (limited to 'libtransport')
3 files changed, 21 insertions, 15 deletions
diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc index c07ca7989..5a432a99f 100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.cc @@ -74,22 +74,22 @@ RTCProducerSocket::RTCProducerSocket() RTCProducerSocket::~RTCProducerSocket() {} -void RTCProducerSocket::registerName(Prefix &producer_namespace) { +void RTCProducerSocket::registerPrefix(const Prefix &producer_namespace) { ProducerSocket::registerPrefix(producer_namespace); flowName_ = producer_namespace.getName(); - - if (flowName_.getType() == HNT_CONTIGUOUS_V4 || - flowName_.getType() == HNT_IOV_V4) { - headerSize_ = sizeof(hicn_v6_hdr_t::ip); - } else if (flowName_.getType() == HNT_CONTIGUOUS_V6 || - flowName_.getType() == HNT_IOV_V6) { - headerSize_ = sizeof(hicn_v4_hdr_t::ip); - } else { - throw errors::RuntimeException("Unknown name format."); + auto family = flowName_.getAddressFamily(); + + switch (family) { + case AF_INET6: + headerSize_ = Packet::getHeaderSizeFromFormat(HF_INET6_TCP); + break; + case AF_INET: + headerSize_ = Packet::getHeaderSizeFromFormat(HF_INET_TCP); + break; + default: + throw errors::RuntimeException("Unknown name format."); } - - headerSize_ += TCP_HEADER_SIZE; } void RTCProducerSocket::updateStats(uint32_t packet_size) { diff --git a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h index f1bcaa9e8..bc54be4bb 100644 --- a/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/rtc_socket_producer.h @@ -33,9 +33,9 @@ class RTCProducerSocket : public ProducerSocket { ~RTCProducerSocket(); - void registerName(Prefix &producer_namespace); + void registerPrefix(const Prefix &producer_namespace) override; - void produce(const uint8_t *buffer, size_t buffer_size); + void produce(const uint8_t *buffer, size_t buffer_size) override; void onInterest(Interest::Ptr &&interest) override; diff --git a/libtransport/src/hicn/transport/interfaces/socket_producer.h b/libtransport/src/hicn/transport/interfaces/socket_producer.h index d3738dc59..6ba5671cc 100644 --- a/libtransport/src/hicn/transport/interfaces/socket_producer.h +++ b/libtransport/src/hicn/transport/interfaces/socket_producer.h @@ -51,13 +51,19 @@ class ProducerSocket : public Socket<BasePortal>, void produce(ContentObject &content_object); + virtual void produce(const uint8_t *buffer, size_t buffer_size) { + // This API is meant to be used just with the RTC producer. + // Here it cannot be used since no name for the content is specified. + throw errors::NotImplementedException(); + } + void asyncProduce(const Name &suffix, const uint8_t *buf, size_t buffer_size); void asyncProduce(const Name &suffix, ContentBuffer &&output_buffer); void asyncProduce(ContentObject &content_object); - void registerPrefix(const Prefix &producer_namespace); + virtual void registerPrefix(const Prefix &producer_namespace); void serveForever(); |