aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libtransport/src/hicn/transport/utils/CMakeLists.txt14
-rw-r--r--libtransport/src/hicn/transport/utils/daemonizator.cc3
-rw-r--r--libtransport/src/hicn/transport/utils/daemonizator.h7
-rw-r--r--utils/CMakeLists.txt2
-rw-r--r--utils/src/hiperf.cc34
-rw-r--r--utils/src/ping_client.cc15
-rw-r--r--utils/src/ping_server.cc23
7 files changed, 88 insertions, 10 deletions
diff --git a/libtransport/src/hicn/transport/utils/CMakeLists.txt b/libtransport/src/hicn/transport/utils/CMakeLists.txt
index 088fb5862..a5daf785e 100644
--- a/libtransport/src/hicn/transport/utils/CMakeLists.txt
+++ b/libtransport/src/hicn/transport/utils/CMakeLists.txt
@@ -16,8 +16,6 @@ cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
list(APPEND SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/string_tokenizer.cc
${CMAKE_CURRENT_SOURCE_DIR}/uri.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/daemonizator.cc
- ${CMAKE_CURRENT_SOURCE_DIR}/min_filter.h
${CMAKE_CURRENT_SOURCE_DIR}/signer.cc
${CMAKE_CURRENT_SOURCE_DIR}/verifier.cc
${CMAKE_CURRENT_SOURCE_DIR}/identity.cc
@@ -32,7 +30,6 @@ list(APPEND HEADER_FILES
${CMAKE_CURRENT_SOURCE_DIR}/string_tokenizer.h
${CMAKE_CURRENT_SOURCE_DIR}/hash.h
${CMAKE_CURRENT_SOURCE_DIR}/uri.h
- ${CMAKE_CURRENT_SOURCE_DIR}/daemonizator.h
${CMAKE_CURRENT_SOURCE_DIR}/sharable_vector.h
${CMAKE_CURRENT_SOURCE_DIR}/branch_prediction.h
${CMAKE_CURRENT_SOURCE_DIR}/event_reactor.h
@@ -72,5 +69,14 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
)
endif()
+if(NOT WIN32)
+ list(APPEND HEADER_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/daemonizator.h
+ )
+ list(APPEND SOURCE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/daemonizator.cc
+ )
+endif()
+
set(SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE)
-set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE)
+set(HEADER_FILES ${HEADER_FILES} PARENT_SCOPE) \ No newline at end of file
diff --git a/libtransport/src/hicn/transport/utils/daemonizator.cc b/libtransport/src/hicn/transport/utils/daemonizator.cc
index d9b3109af..c51a68d14 100644
--- a/libtransport/src/hicn/transport/utils/daemonizator.cc
+++ b/libtransport/src/hicn/transport/utils/daemonizator.cc
@@ -13,6 +13,7 @@
* limitations under the License.
*/
+#ifndef _WIN32
#include <hicn/transport/errors/runtime_exception.h>
#include <hicn/transport/utils/daemonizator.h>
#include <hicn/transport/utils/log.h>
@@ -71,3 +72,5 @@ void Daemonizator::daemonize(bool close_fds) {
}
} // namespace utils
+
+#endif
diff --git a/libtransport/src/hicn/transport/utils/daemonizator.h b/libtransport/src/hicn/transport/utils/daemonizator.h
index a21ce8a7b..028d74865 100644
--- a/libtransport/src/hicn/transport/utils/daemonizator.h
+++ b/libtransport/src/hicn/transport/utils/daemonizator.h
@@ -14,6 +14,9 @@
*/
#pragma once
+
+#ifndef _WIN32
+
#include <cstdlib>
namespace utils {
@@ -22,4 +25,6 @@ class Daemonizator {
static void daemonize(bool close_fds = true);
};
-} // namespace utils \ No newline at end of file
+} // namespace utils
+
+#endif \ No newline at end of file
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 9d05942ed..a377132e1 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -23,6 +23,7 @@ set(CMAKE_MODULE_PATH
)
include(BuildMacros)
+include(WindowsMacros)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
find_package(Libtransport REQUIRED)
@@ -51,5 +52,6 @@ foreach(util ${UTILS_SRC})
DEPENDS ${LIBTRANSPORT}
COMPONENT hicn-utils
DEFINITIONS ${COMPILER_DEFINITIONS}
+ LINK_LIBRARIES ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY}
)
endforeach() \ No newline at end of file
diff --git a/utils/src/hiperf.cc b/utils/src/hiperf.cc
index 221a8746b..65ee315f5 100644
--- a/utils/src/hiperf.cc
+++ b/utils/src/hiperf.cc
@@ -15,7 +15,9 @@
#include <hicn/transport/interfaces/socket_consumer.h>
#include <hicn/transport/interfaces/socket_producer.h>
+#ifndef _WIN32
#include <hicn/transport/utils/daemonizator.h>
+#endif
#include <hicn/transport/utils/literals.h>
#include <fstream>
@@ -25,6 +27,10 @@
#include <mcheck.h>
#endif
+#ifdef _WIN32
+#include <hicn/transport/portability/win_portability.h>
+#endif
+
namespace transport {
namespace interface {
@@ -492,8 +498,10 @@ void usage() {
<< std::endl;
std::cerr << "usage: hiperf [-S|-C] [options] [prefix|name]" << std::endl;
std::cerr << "Server or Client:" << std::endl;
+#ifndef _WIN32
std::cerr << "-D\t\t\t\t\t"
<< "Run as a daemon" << std::endl;
+#endif
std::cerr << std::endl;
std::cerr << "Server specific:" << std::endl;
std::cerr << "-s\t<content_size>\t\t\tSize of the content to publish"
@@ -538,8 +546,14 @@ void usage() {
}
int main(int argc, char *argv[]) {
+
+#ifndef _WIN32
// Common
bool daemon = false;
+#else
+ WSADATA wsaData = { 0 };
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+#endif
// -1 server, 0 undefined, 1 client
int role = 0;
@@ -554,12 +568,17 @@ int main(int argc, char *argv[]) {
ServerConfiguration server_configuration;
int opt;
+#ifndef _WIN32
while ((opt = getopt(argc, argv, "DSCf:b:d:W:c:vs:rmlk:y:p:hi:x")) != -1) {
switch (opt) {
// Common
case 'D':
daemon = true;
break;
+#else
+ while ((opt = getopt(argc, argv, "SCf:b:d:W:c:vs:rmlk:y:p:hi:x")) != -1) {
+ switch (opt) {
+#endif
case 'f':
log_file = optarg;
break;
@@ -685,15 +704,27 @@ int main(int argc, char *argv[]) {
}
if (log_file) {
+#ifndef _WIN32
int fd = open(log_file, O_WRONLY | O_APPEND | O_CREAT, S_IWUSR | S_IRUSR);
dup2(fd, STDOUT_FILENO);
dup2(STDOUT_FILENO, STDERR_FILENO);
close(fd);
+#else
+ int fd = _open(log_file, _O_WRONLY | _O_APPEND | _O_CREAT, _S_IWRITE | _S_IREAD);
+ _dup2(fd, STDOUT_FILENO);
+ _dup2(STDOUT_FILENO, STDERR_FILENO);
+ _close(fd);
+#endif
+ dup2(fd, STDOUT_FILENO);
+ dup2(STDOUT_FILENO, STDERR_FILENO);
+ close(fd);
}
+#ifndef _WIN32
if (daemon) {
utils::Daemonizator::daemonize(false);
}
+#endif
if (role > 0) {
HIperfClient c(client_configuration);
@@ -712,6 +743,9 @@ int main(int argc, char *argv[]) {
std::cout << "Bye bye" << std::endl;
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}
diff --git a/utils/src/ping_client.cc b/utils/src/ping_client.cc
index 24f7bd7c9..a99652b9c 100644
--- a/utils/src/ping_client.cc
+++ b/utils/src/ping_client.cc
@@ -76,10 +76,10 @@ class Configuration {
class Client : interface::BasePortal::ConsumerCallback {
public:
- Client(Configuration *c)
+ Client(Configuration *c)
: portal_(),
- signals_(portal_.getIoService(), SIGINT, SIGQUIT) {
- // Let the main thread to catch SIGINT and SIGQUIT
+ signals_(portal_.getIoService(), SIGINT) {
+ // Let the main thread to catch SIGINT
portal_.connect();
portal_.setConsumerCallback(this);
@@ -341,6 +341,12 @@ void help() {
}
int main(int argc, char *argv[]) {
+
+#ifdef _WIN32
+ WSADATA wsaData = { 0 };
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+#endif
+
Configuration *c = new Configuration();
int opt;
std::string producer_certificate = "";
@@ -419,6 +425,9 @@ int main(int argc, char *argv[]) {
<< std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()
<< std::endl;
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}
diff --git a/utils/src/ping_server.cc b/utils/src/ping_server.cc
index 19de34fec..9d68aec34 100644
--- a/utils/src/ping_server.cc
+++ b/utils/src/ping_server.cc
@@ -14,7 +14,9 @@
*/
#include <hicn/transport/interfaces/socket_producer.h>
+#ifndef _WIN32
#include <hicn/transport/utils/daemonizator.h>
+#endif
#include <hicn/transport/utils/signer.h>
#include <hicn/transport/utils/string_tokenizer.h>
@@ -183,14 +185,21 @@ void help() {
std::cout << "-D dump, dumps sent and received packets (default false)"
<< std::endl;
std::cout << "-q quite, not prints (default false)" << std::endl;
+#ifndef _WIN32
std::cout << "-d daemon mode" << std::endl;
+#endif
std::cout << "-H prints this message" << std::endl;
}
int main(int argc, char **argv) {
+#ifdef _WIN32
+ WSADATA wsaData = { 0 };
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+#else
+ bool daemon = false;
+#endif
std::string name_prefix = "b001::0/64";
std::string delimiter = "/";
- bool daemon = false;
bool verbose = false;
bool dump = false;
bool quite = false;
@@ -203,7 +212,11 @@ int main(int argc, char **argv) {
bool sign = false;
int opt;
+#ifndef _WIN32
while ((opt = getopt(argc, argv, "s:n:t:qfrVDdHk:p:")) != -1) {
+#else
+ while ((opt = getopt(argc, argv, "s:n:t:qfrVDHk:p:")) != -1) {
+#endif
switch (opt) {
case 's':
object_size = std::stoi(optarg);
@@ -225,9 +238,11 @@ int main(int argc, char **argv) {
dump = false;
quite = true;
break;
+#ifndef _WIN32
case 'd':
daemon = true;
break;
+#endif
case 'f':
flags = true;
break;
@@ -248,9 +263,11 @@ int main(int argc, char **argv) {
}
}
+#ifndef _WIN32
if (daemon) {
utils::Daemonizator::daemonize();
}
+#endif
core::Prefix producer_namespace(name_prefix);
@@ -287,7 +304,9 @@ int main(int argc, char **argv) {
p.connect();
p.serveForever();
-
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}