Skip to content

Commit

Permalink
odhcp6c: reuse md5 from libubox
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Hrvoje Varga committed Oct 26, 2016
1 parent 7533a62 commit 33a2ba1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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/)
Expand Down
4 changes: 4 additions & 0 deletions src/dhcpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
#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,\
Expand Down

0 comments on commit 33a2ba1

Please sign in to comment.