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
${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
)
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
* 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>
}
} // namespace utils
+
+#endif
*/
#pragma once
+
+#ifndef _WIN32
+
#include <cstdlib>
namespace utils {
static void daemonize(bool close_fds = true);
};
-} // namespace utils
\ No newline at end of file
+} // namespace utils
+
+#endif
\ No newline at end of file
)
include(BuildMacros)
+include(WindowsMacros)
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
find_package(Libtransport REQUIRED)
DEPENDS ${LIBTRANSPORT}
COMPONENT hicn-utils
DEFINITIONS ${COMPILER_DEFINITIONS}
+ LINK_LIBRARIES ${WSOCK32_LIBRARY} ${WS2_32_LIBRARY}
)
endforeach()
\ No newline at end of file
#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>
#include <mcheck.h>
#endif
+#ifdef _WIN32
+#include <hicn/transport/portability/win_portability.h>
+#endif
+
namespace transport {
namespace interface {
<< 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"
}
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;
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;
}
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);
std::cout << "Bye bye" << std::endl;
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}
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);
}
int main(int argc, char *argv[]) {
+
+#ifdef _WIN32
+ WSADATA wsaData = { 0 };\r
+ WSAStartup(MAKEWORD(2, 2), &wsaData);
+#endif
+
Configuration *c = new Configuration();
int opt;
std::string producer_certificate = "";
<< std::chrono::duration_cast<std::chrono::microseconds>(t1 - t0).count()
<< std::endl;
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}
*/
#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>
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;
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);
dump = false;
quite = true;
break;
+#ifndef _WIN32
case 'd':
daemon = true;
break;
+#endif
case 'f':
flags = true;
break;
}
}
+#ifndef _WIN32
if (daemon) {
utils::Daemonizator::daemonize();
}
+#endif
core::Prefix producer_namespace(name_prefix);
p.connect();
p.serveForever();
-
+#ifdef _WIN32
+ WSACleanup();
+#endif
return 0;
}