aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/ping_server.cc
diff options
context:
space:
mode:
authorAngelo Mantellini <manangel@cisco.com>2019-01-31 10:36:54 +0100
committerAngelo Mantellini <manangel@cisco.com>2019-01-31 11:17:49 +0100
commit7b61129b2ed89d2cc3ca5560f55c26c6c347a215 (patch)
tree5c2433fdcc0447f05f79a981a6e8287e61182038 /utils/src/ping_server.cc
parent67371907c2433f5233d4a669a1c9176539e9928f (diff)
[HICN-20] This source upgrade allows to compile ping_client, ping_server and hiperf (utils folder) in Windows.
Change-Id: I8253aa9aa640644b0daffd95dff202956371d814 Signed-off-by: Angelo Mantellini <manangel@cisco.com>
Diffstat (limited to 'utils/src/ping_server.cc')
-rw-r--r--utils/src/ping_server.cc23
1 files changed, 21 insertions, 2 deletions
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;
}