diff options
author | Mauro Sardara <msardara@cisco.com> | 2019-03-14 19:46:43 +0100 |
---|---|---|
committer | Mauro Sardara <msardara@cisco.com> | 2019-03-14 19:52:25 +0100 |
commit | 7254a7d407c62d705ef410052825be74a6bd1b4e (patch) | |
tree | ea12cd3800d99d5b4f6fae1ce6e6e719243abb91 /libtransport/src | |
parent | 998977b643a700b2be5a1b476c03f90f517e9ffa (diff) |
[HICN-116] Added RTC producer option to hiperf.
Change-Id: I665b7dd3c8eae222d62057bc3387daf6c73df1f8
Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'libtransport/src')
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(); |