aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/consumers/icnet_ping_client.cc26
-rwxr-xr-xapps/producers/CMakeLists.txt7
-rw-r--r--apps/producers/config/iping-server.service28
-rw-r--r--apps/producers/icnet_ping_server.cc14
4 files changed, 56 insertions, 19 deletions
diff --git a/apps/consumers/icnet_ping_client.cc b/apps/consumers/icnet_ping_client.cc
index 42a0ab19..fdc0b405 100644
--- a/apps/consumers/icnet_ping_client.cc
+++ b/apps/consumers/icnet_ping_client.cc
@@ -202,15 +202,14 @@ class Client {
};
void help(char * program_name) {
- std::cout << "usage: " << program_name << " [options]" << std::endl;
+ std::cout << "usage: " << program_name << " [options]" << " icn-name" << std::endl;
std::cout << "PING options" << std::endl;
- std::cout << "-i <val> ping interval in microseconds (default 1000ms)" << std::endl;
+ std::cout << "-i <val> ping interval in microseconds (default 1000 ms)" << std::endl;
std::cout << "-m <val> maximum number of pings to send (default unlimited)" << std::endl;
std::cout << "-t <val> set packet ttl (default 64)" << std::endl;
//std::cout << "-j <val1> <val2> jump <val2> sequence numbers every <val1> interests (default disabled)" << std::endl;
std::cout << "ICN options" << std::endl;
- std::cout << "-n <val> icn name (default ccnx:/pingserver)" << std::endl;
- std::cout << "-l <val> interest lifetime in milliseconds (default 500ms)" << std::endl;
+ std::cout << "-l <val> interest lifetime in milliseconds (default 500 ms)" << std::endl;
std::cout << "OUTPUT options" << std::endl;
std::cout << "-H prints this message" << std::endl;
}
@@ -220,19 +219,19 @@ int main(int argc, char *argv[]) {
Configuration c;
int opt;
- while ((opt = getopt(argc, argv, "j::t:i:m:s:d:n:l:SAOqVDH")) != -1) {
+ while ((opt = getopt(argc, argv, "t:i:m:l:H")) != -1) {
switch (opt) {
case 't':
c.ttl_ = (uint8_t) std::stoi(optarg);
break;
case 'i':
- c.pingInterval_ = std::stoi(optarg);
+ c.pingInterval_ = std::stoul(optarg);
break;
case 'm':
- c.maxPing_ = std::stoi(optarg);
+ c.maxPing_ = std::stoul(optarg);
break;
case 'l':
- c.interestLifetime_ = std::stoi(optarg);
+ c.interestLifetime_ = std::stoul(optarg);
break;
case 'H':
default:
@@ -241,16 +240,17 @@ int main(int argc, char *argv[]) {
}
}
- if (argv[optind] == 0) {
- std::cerr << "Using default name " << c.name_ << std::endl;
+ if (argv[optind] == nullptr) {
+ help(argv[0]);
+ exit(EXIT_FAILURE);
} else {
c.name_ = argv[optind];
}
- Client *ping = new Client(c);
- ping->ping();
+ Client ping(c);
+ ping.ping();
- exit(1);
+ return 0;
}
//close name spaces
diff --git a/apps/producers/CMakeLists.txt b/apps/producers/CMakeLists.txt
index 10353057..29d71010 100755
--- a/apps/producers/CMakeLists.txt
+++ b/apps/producers/CMakeLists.txt
@@ -23,6 +23,9 @@ set(PRODUCER_HELLO_WORLD_SOURCE_FILES
set(PRODUCER_PING_SOURCE_FILES
icnet_ping_server.cc)
+set(PRODUCER_PING_SERVER_SERVICE_FILE
+ config/iping-server.service)
+
add_executable(producer-test ${PRODUCER_SOURCE_FILES})
add_executable(producer-hello-world ${PRODUCER_HELLO_WORLD_SOURCE_FILES})
add_executable(iping-server ${PRODUCER_PING_SOURCE_FILES})
@@ -35,3 +38,7 @@ target_link_libraries(iping-server icnet ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRA
install(TARGETS producer-test DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT library)
install(TARGETS producer-hello-world DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT library)
install(TARGETS iping-server DESTINATION ${CMAKE_INSTALL_PREFIX}/bin COMPONENT library)
+
+if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ install(FILES ${PRODUCER_PING_SERVER_SERVICE_FILE} DESTINATION /lib/systemd/system)
+endif()
diff --git a/apps/producers/config/iping-server.service b/apps/producers/config/iping-server.service
new file mode 100644
index 00000000..1c5d12f9
--- /dev/null
+++ b/apps/producers/config/iping-server.service
@@ -0,0 +1,28 @@
+# Copyright (c) 2017 Cisco and/or its affiliates.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+[Unit]
+Description=Ping server application.
+After=metis-forwarder.service
+#Documentation=man:iping-server
+
+[Service]
+Environment=SIZE=64
+Environment-NAME=ccnx:/$(hostname)-pingserver
+# This will overrride the default environment
+EnvironmentFile=-/etc/default/ccnx/iping.conf
+ExecStart=/bin/bash -c "/usr/bin/iping-server -s ${SIZE} ${NAME}"
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target \ No newline at end of file
diff --git a/apps/producers/icnet_ping_server.cc b/apps/producers/icnet_ping_server.cc
index 57f0d88f..5ea084fc 100644
--- a/apps/producers/icnet_ping_server.cc
+++ b/apps/producers/icnet_ping_server.cc
@@ -45,25 +45,24 @@ class CallbackContainer {
};
void help(char * program_name) {
- std::cout << "usage: " << program_name <<" [options]" << std::endl;
+ std::cout << "usage: " << program_name <<" [options]" << " icn-name" << std::endl;
std::cout << "PING options" << std::endl;
std::cout << "-s <val> object content size (default 64B)" << std::endl;
- std::cout << "-n <val> icn name (default ccnx:/webserver)" << std::endl;
std::cout << "OUTPUT options" << std::endl;
std::cout << "-H prints this message" << std::endl;
}
int main(int argc, char **argv) {
- std::string name_prefix = "ccnx:/pingserver";
+ std::string name_prefix = "ccnx:/ipingserver";
bool daemon = false;
uint32_t object_size = 64;
uint8_t ttl = 64;
int opt;
- while ((opt = getopt(argc, argv, "s:n:t:dH")) != -1) {
+ while ((opt = getopt(argc, argv, "s:t:dH")) != -1) {
switch (opt) {
case 's':
- object_size = std::stoi(optarg);
+ object_size = uint32_t(std::stoul(optarg));
break;
case 't':
ttl = (uint8_t) std::stoi(optarg);
@@ -78,8 +77,11 @@ int main(int argc, char **argv) {
}
}
- if (argv[optind] != 0) {
+ if (argv[optind] != nullptr) {
name_prefix = argv[optind];
+ } else {
+ help(argv[0]);
+ exit(EXIT_FAILURE);
}
if (daemon) {