Skip to content

Commit

Permalink
Ensure that BYTE_ORDER is set (#538)
Browse files Browse the repository at this point in the history
get byte order from cmake if not defined
  • Loading branch information
scareything authored Oct 24, 2022
1 parent 04239ac commit cb52eb0
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.20)
if(NOT ZITI_SDK_C_BRANCH)
#allow using a different branch of the CSDK easily
set(ZITI_SDK_C_BRANCH "0.30.2")
set(ZITI_SDK_C_BRANCH "0.30.4")
endif()

# if TUNNEL_SDK_ONLY then don't descend into programs/ziti-edge-tunnel
Expand Down
1 change: 1 addition & 0 deletions lib/ziti-tunnel/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ set (LWIP_INCLUDE_DIRS
include(${LWIP_DIR}/src/Filelists.cmake)

target_sources(lwipcore PRIVATE ${lwip_sys_srcs} lwip/lwiphooks_ip6.c lwip/lwiphooks_ip4.c lwip/lwip_cloned_fns.c)
target_compile_definitions(lwipcore PUBLIC CMAKE_C_BYTE_ORDER=${CMAKE_C_BYTE_ORDER})

target_include_directories(ziti-tunnel-sdk-c
PUBLIC ${LWIP_INCLUDE_DIRS}
Expand Down
1 change: 0 additions & 1 deletion lib/ziti-tunnel/intercept.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const ziti_address *address_match(const ziti_address *addr, const address_list_t

STAILQ_FOREACH(a, addresses, entries) {
score = ziti_address_match(addr, &a->za);
TNL_LOG(VERBOSE, "ziti_address_match score %d", score);
if (score < 0) continue;
if (best_score == -1 || score < best_score) {
best_score = score;
Expand Down
10 changes: 10 additions & 0 deletions lib/ziti-tunnel/lwip/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@
#define LWIP_NO_UNISTD_H 1
#endif

#ifndef BYTE_ORDER
// make sure BYTE_ORDER is defined early, otherwise lwip sources will be compiled with inconsistent values.
#define BYTE_ORDER CMAKE_C_BYTE_ORDER // define BYTE_ORDER before including arch.h. the default is dumb.
#include "lwip/arch.h" // defines BIG_ENDIAN, etc

#if (BYTE_ORDER != LITTLE_ENDIAN && BYTE_ORDER != BIG_ENDIAN)
#error "BYTE_ORDER is not defined"
#endif
#endif

// hooks
#define LWIP_HOOK_FILENAME "lwiphooks.h"
#define LWIP_HOOK_IP4_INPUT(pbuf, input_netif) ip4_input_hook((pbuf),(input_netif))
Expand Down

0 comments on commit cb52eb0

Please sign in to comment.