aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMauro Sardara <msardara+fdio@cisco.com>2017-04-18 11:25:13 +0200
committerMauro Sardara <msardara+fdio@cisco.com>2017-04-18 09:31:56 +0000
commit7e312299ab4a84334af19e4988e9c5365626b80b (patch)
treed223f035dbcfb734dd6384c18c83fa6421a3aa1b /apps
parent526f25cf2a8777e4cf88732b87076bf9457ae8df (diff)
- Fixing code style issues
- Adding new feature to producer test: now it is possible to specify the size of the file to download - Fixing initialization of max number of retransmissions in icnet_socket_consumer.cc Change-Id: Ia7e48a4beda6adebf5179700c80f6d7316922187 Signed-off-by: Mauro Sardara <msardara+fdio@cisco.com>
Diffstat (limited to 'apps')
-rwxr-xr-xapps/producers/icnet_producer_test.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/apps/producers/icnet_producer_test.cc b/apps/producers/icnet_producer_test.cc
index 571e9615..6add25d3 100755
--- a/apps/producers/icnet_producer_test.cc
+++ b/apps/producers/icnet_producer_test.cc
@@ -15,14 +15,18 @@
#include "icnet_socket_producer.h"
-#define IDENTITY_NAME "ciao"
+#define IDENTITY_NAME "cisco"
namespace icnet {
class CallbackContainer {
public:
- CallbackContainer() : buffer_(1400, 'X') {
+ CallbackContainer(unsigned long download_size = 0)
+ : buffer_(1400, 'X'), final_chunk_number_(0) {
content_object_.setContent((uint8_t *) buffer_.c_str(), 1400);
+ if (download_size > 0) {
+ final_chunk_number_ = static_cast<uint64_t>(std::ceil(download_size / 1400));
+ }
}
void processInterest(ProducerSocket &p, const Interest &interest) {
@@ -31,17 +35,21 @@ class CallbackContainer {
void processIncomingInterest(ProducerSocket &p, const Interest &interest) {
content_object_.setName(Name(interest.getName().getWrappedStructure()));
+ if (final_chunk_number_ > 0) {
+ content_object_.setFinalChunkNumber(final_chunk_number_);
+ }
p.produce(content_object_);
}
private:
-
ContentObject content_object_;
std::string buffer_;
+ uint64_t final_chunk_number_;
};
class Signer {
public:
- Signer() : counter_(0), identity_name_(IDENTITY_NAME) {
+ Signer()
+ : counter_(0), identity_name_(IDENTITY_NAME) {
};
~Signer() {
@@ -102,15 +110,19 @@ void becomeDaemon() {
int main(int argc, char **argv) {
std::string name = "ccnx:/ccnxtest";
+ unsigned long download_size = 0;
bool daemon = false;
int opt;
- while ((opt = getopt(argc, argv, "D")) != -1) {
+ while ((opt = getopt(argc, argv, "Ds:")) != -1) {
switch (opt) {
case 'D':
daemon = true;
break;
+ case 's':
+ download_size = std::stoul(optarg);
+ break;
default:
exit(EXIT_FAILURE);
}
@@ -126,7 +138,8 @@ int main(int argc, char **argv) {
becomeDaemon();
}
- CallbackContainer stubs;
+ CallbackContainer stubs(download_size);
+
// Signer signer;
std::cout << "Setting name.. " << name << std::endl;