odhcp6c: reuse md5 from libubox
authorHrvoje Varga <hrvoje.varga@sartura.hr>
Tue, 25 Oct 2016 14:08:25 +0000 (14:08 +0000)
committerHrvoje Varga <hrvoje.varga@sartura.hr>
Wed, 26 Oct 2016 08:54:59 +0000 (08:54 +0000)
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 <hrvoje.varga@sartura.hr>
CMakeLists.txt
src/dhcpv6.c

index f85334c0e733f17959f13f5b8ee7a44142dbf3e3..745fba2de29671c586a58967f72a45f0b52e322f 100644 (file)
@@ -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/)
index 5998b75ccf5281fa06edfa94201515b8c9ed501e..2a9f8a2f56b7d5bd3fdb059a517732a271feeaec 100644 (file)
 #include <net/ethernet.h>
 
 #include "odhcp6c.h"
+#ifdef LIBUBOX
+#include <libubox/md5.h>
+#else
 #include "md5.h"
+#endif
 
 
 #define ALL_DHCPV6_RELAYS {{{0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\