aboutsummaryrefslogtreecommitdiffstats
path: root/apps/producers
diff options
context:
space:
mode:
Diffstat (limited to 'apps/producers')
-rwxr-xr-xapps/producers/CMakeLists.txt7
-rw-r--r--apps/producers/config/iping-server.service28
-rw-r--r--apps/producers/icnet_ping_server.cc14
3 files changed, 43 insertions, 6 deletions
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) {