diff options
-rw-r--r-- | cmake/Modules/BuildMacros.cmake | 53 | ||||
-rw-r--r-- | hicn-light/src/io/udpConnection.c | 19 | ||||
-rw-r--r-- | lib/src/common.h | 28 | ||||
-rw-r--r-- | lib/src/protocol/tcp.c | 4 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/forwarder_interface.h | 2 | ||||
-rw-r--r-- | libtransport/src/hicn/transport/core/manifest_inline.h | 2 | ||||
-rw-r--r-- | utils/src/ping_client.cc | 5 |
7 files changed, 81 insertions, 32 deletions
diff --git a/cmake/Modules/BuildMacros.cmake b/cmake/Modules/BuildMacros.cmake index 474026d1d..0908189b5 100644 --- a/cmake/Modules/BuildMacros.cmake +++ b/cmake/Modules/BuildMacros.cmake @@ -23,10 +23,19 @@ macro(build_executable exec) ${ARGN} ) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - add_executable(${exec} ${ARG_SOURCES}) + + set(BUILD_ROOT ${CMAKE_BINARY_DIR}/build-root) + + set_target_properties(${exec} + PROPERTIES + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" + INSTALL_RPATH_USE_LINK_PATH TRUE + ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" + LIBRARY_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" + RUNTIME_OUTPUT_DIRECTORY "${BUILD_ROOT}/bin" + ) + if(ARG_LINK_LIBRARIES) target_link_libraries(${exec} ${ARG_LINK_LIBRARIES}) endif() @@ -47,7 +56,7 @@ macro(build_executable exec) endif() if(NOT ARG_NO_INSTALL) - install(TARGETS ${exec} DESTINATION bin COMPONENT ${ARG_COMPONENT}) + install(TARGETS ${exec} RUNTIME DESTINATION bin COMPONENT ${ARG_COMPONENT}) endif() endmacro() @@ -59,9 +68,6 @@ macro(build_library lib) ${ARGN} ) - set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") - set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - if (ARG_SHARED) list(APPEND TARGET_LIBS ${lib}.shared @@ -76,18 +82,13 @@ macro(build_library lib) add_library(${lib} STATIC ${ARG_SOURCES}) endif() - # install .so if(NOT ARG_COMPONENT) set(ARG_COMPONENT hicn) endif() - foreach(library ${TARGET_LIBS}) + set(BUILD_ROOT ${CMAKE_BINARY_DIR}/build-root) - if (WIN32) - target_compile_options(${library} PRIVATE) - else () - target_compile_options(${library} PRIVATE -Wall) - endif () + foreach(library ${TARGET_LIBS}) if(HICN_VERSION) set_target_properties(${library} @@ -98,9 +99,27 @@ macro(build_library lib) set_target_properties(${library} PROPERTIES - OUTPUT_NAME ${lib} + INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" + INSTALL_RPATH_USE_LINK_PATH TRUE + ARCHIVE_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" + LIBRARY_OUTPUT_DIRECTORY "${BUILD_ROOT}/lib" + RUNTIME_OUTPUT_DIRECTORY "${BUILD_ROOT}/bin" ) + if (WIN32) + target_compile_options(${library} PRIVATE) + set_target_properties(${library} + PROPERTIES + WINDOWS_EXPORT_ALL_SYMBOLS TRUE + ) + else () + target_compile_options(${library} PRIVATE -Wall) + set_target_properties(${library} + PROPERTIES + OUTPUT_NAME ${lib} + ) + endif () + # library deps if(ARG_LINK_LIBRARIES) target_link_libraries(${library} ${ARG_LINK_LIBRARIES}) @@ -119,7 +138,9 @@ macro(build_library lib) install( TARGETS ${library} - DESTINATION lib + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib COMPONENT ${ARG_COMPONENT} ) diff --git a/hicn-light/src/io/udpConnection.c b/hicn-light/src/io/udpConnection.c index c3e6d32ac..5fbdf4998 100644 --- a/hicn-light/src/io/udpConnection.c +++ b/hicn-light/src/io/udpConnection.c @@ -287,13 +287,20 @@ static bool _sendCommandResponse(IoOperations *ops, struct iovec *message){ return false; } #else - ssize_t writeLength = write(udpConnState->udpListenerSocket, message[0].iov_base, (unsigned int)message[0].iov_len); - if (writeLength < 0) { - return false; + WSABUF dataBuf[2]; + DWORD BytesSent = 0; + + for (int i = 0; i < 2; i++) { + dataBuf[i].buf = message[i].iov_base; + dataBuf[i].len = (ULONG)message[i].iov_len; } - writeLength = write(udpConnState->udpListenerSocket, message[0].iov_base, (unsigned int)message[0].iov_len); - if (writeLength < 0) { - return false; + + int rc = WSASendTo(udpConnState->udpListenerSocket, dataBuf, 2, + &BytesSent, 0, (SOCKADDR *)udpConnState->peerAddress, + udpConnState->peerAddressLength, NULL, NULL); + + if (rc == SOCKET_ERROR) { + return false; } #endif return true; diff --git a/lib/src/common.h b/lib/src/common.h index 1d4b1e6bf..33323da1b 100644 --- a/lib/src/common.h +++ b/lib/src/common.h @@ -60,6 +60,28 @@ typedef uint8_t u8; #define STATIC_ASSERT(x) +/* Architecture-dependent uword size */ +#if INTPTR_MAX == INT64_MAX +#define log2_uword_bits 6 +#elif INTPTR_MAX == INT32_MAX +#define log2_uword_bits 5 +#else +#error "Impossible to detect architecture" +#endif + +#define uword_bits (1 << log2_uword_bits) + +/* Word types. */ +#if uword_bits == 64 +/* 64 bit word machines. */ +typedef u64 uword; +#else +/* 32 bit word machines. */ +typedef u32 uword; +#endif + +typedef uword ip_csum_t; + #endif /* ! HICN_VPP_PLUGIN */ /* @@ -173,8 +195,6 @@ int get_addr_family (const char *ip_address); #ifndef HICN_VPP_PLUGIN -typedef u16 ip_csum_t; - /* * Checksum update (incremental and non-incremental) * @@ -186,7 +206,7 @@ static_always_inline u16 ip_csum_fold (ip_csum_t c) { /* Reduce to 16 bits. */ -#if 0 // uword_bits == 64 +#if uword_bits == 64 c = (c & (ip_csum_t) 0xffffffff) + (c >> (ip_csum_t) 32); c = (c & 0xffff) + (c >> 16); #endif @@ -194,7 +214,7 @@ ip_csum_fold (ip_csum_t c) c = (c & 0xffff) + (c >> 16); c = (c & 0xffff) + (c >> 16); - return c; + return (u16)c; } static_always_inline ip_csum_t diff --git a/lib/src/protocol/tcp.c b/lib/src/protocol/tcp.c index 08b7bde8a..b9f1d2775 100644 --- a/lib/src/protocol/tcp.c +++ b/lib/src/protocol/tcp.c @@ -247,7 +247,7 @@ tcp_rewrite_interest (hicn_type_t type, hicn_protocol_t * h, * csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32); * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32); */ - u16 csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (h->ipv6.saddr.as_u64[0])); + ip_csum_t csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (h->ipv6.saddr.as_u64[0])); csum = ip_csum_sub_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1])); csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[0])); csum = ip_csum_add_even (csum, (ip_csum_t) (h->ipv6.saddr.as_u64[1])); @@ -272,7 +272,7 @@ tcp_rewrite_data (hicn_type_t type, hicn_protocol_t * h, * csum = ip_csum_sub_even (*tcp_checksum, h->ipv4.saddr.as_u32); * csum = ip_csum_add_even (csum, h->ipv4.saddr.as_u32); */ - u16 csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[0])); + ip_csum_t csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[0])); csum = ip_csum_sub_even (*tcp_checksum, (ip_csum_t) (addr_old->ip6.as_u64[1])); csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[0])); csum = ip_csum_add_even (csum, (ip_csum_t) (addr_new->ip6.as_u64[1])); diff --git a/libtransport/src/hicn/transport/core/forwarder_interface.h b/libtransport/src/hicn/transport/core/forwarder_interface.h index d470b6276..974b1c39a 100644 --- a/libtransport/src/hicn/transport/core/forwarder_interface.h +++ b/libtransport/src/hicn/transport/core/forwarder_interface.h @@ -19,8 +19,6 @@ #include <hicn/transport/core/udp_socket_connector.h> #include <hicn/transport/portability/portability.h> #include <hicn/transport/utils/chrono_typedefs.h> -#include <hicn/transport/utils/log.h> - #include <deque> namespace transport { diff --git a/libtransport/src/hicn/transport/core/manifest_inline.h b/libtransport/src/hicn/transport/core/manifest_inline.h index 60eb08433..385e43af3 100644 --- a/libtransport/src/hicn/transport/core/manifest_inline.h +++ b/libtransport/src/hicn/transport/core/manifest_inline.h @@ -18,8 +18,6 @@ #include <hicn/transport/core/manifest.h> #include <hicn/transport/core/manifest_format.h> #include <hicn/transport/portability/portability.h> -#include <hicn/transport/utils/log.h> - #include <set> namespace transport { diff --git a/utils/src/ping_client.cc b/utils/src/ping_client.cc index 3811c6db8..72a310c2d 100644 --- a/utils/src/ping_client.cc +++ b/utils/src/ping_client.cc @@ -16,6 +16,11 @@ #include <hicn/transport/interfaces/socket.h> #include <hicn/transport/utils/verifier.h> +// Let's make the linker happy +#if !TRANSPORT_LOG_EXTERN_GLOBAL_OUTPUT_LEVEL +TRANSPORT_LOG_DEFINE_GLOBAL_OUTPUT_LEVEL = 0; +#endif + #include <asio/steady_timer.hpp> #include <chrono> #include <map> |