From: Hrvoje Varga Date: Tue, 25 Oct 2016 14:08:25 +0000 (+0000) Subject: odhcp6c: reuse md5 from libubox X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=33a2ba1c14eb5447326945c120e0b64a587ed151;p=oweals%2Fodhcp6c.git odhcp6c: reuse md5 from libubox Added config support to use the MD5 implementation from libubox instead of the in-house implementation. By default if not specified, libubox will be linked and its MD5 will be used instead of the in-house implementation. Signed-off-by: Hrvoje Varga --- diff --git a/CMakeLists.txt b/CMakeLists.txt index f85334c..745fba2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ cmake_policy(SET CMP0015 NEW) project(odhcp6c C) set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -std=c99") +set(LIBUBOX 1 CACHE BOOL "Link with libubox") add_definitions(-D_GNU_SOURCE -Wall -Werror -Wextra -pedantic) if(${EXT_PREFIX_CLASS}) @@ -15,8 +16,17 @@ if(${EXT_CER_ID}) add_definitions(-DEXT_CER_ID=${EXT_CER_ID}) endif(${EXT_CER_ID}) -add_executable(odhcp6c src/odhcp6c.c src/dhcpv6.c src/ra.c src/script.c src/md5.c) -target_link_libraries(odhcp6c resolv) +set(SOURCES src/odhcp6c.c src/dhcpv6.c src/ra.c src/script.c) +if(LIBUBOX EQUAL 0) + set(SOURCES ${SOURCES} src/md5.c) +endif() +add_executable(odhcp6c ${SOURCES}) + +set(LIBRARIES resolv) +if(LIBUBOX EQUAL 1) + set(LIBRARIES ${LIBRARIES} ubox) +endif() +target_link_libraries(odhcp6c ${LIBRARIES}) # Installation install(TARGETS odhcp6c DESTINATION sbin/) diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 5998b75..2a9f8a2 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -33,7 +33,11 @@ #include #include "odhcp6c.h" +#ifdef LIBUBOX +#include +#else #include "md5.h" +#endif #define ALL_DHCPV6_RELAYS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\