pex-msg: fix memory leak on fread fail in pex_msg_update_request_init
[project/unetd.git] / CMakeLists.txt
index b51fc4481a56d1dbd482c2a5bc783164c91525f2..ec31711dc7ee108c85eb69f677310e969ddf353d 100644 (file)
@@ -4,8 +4,8 @@ PROJECT(unetd C)
 
 
 SET(SOURCES
-       main.c network.c host.c service.c pex.c utils.c
-       wg.c wg-dummy.c wg-user.c
+       main.c network.c host.c service.c pex.c pex-stun.c
+       wg.c wg-user.c
 )
 
 SET(RUNSTATEDIR /var/run)
@@ -14,29 +14,48 @@ ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DRUNST
 FIND_LIBRARY(libjson NAMES json-c json)
 
 OPTION(UBUS_SUPPORT "enable ubus support" ON)
+OPTION(VXLAN_SUPPORT "enable VXLAN support" ON)
 IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
        FIND_LIBRARY(nl nl-tiny)
-       find_library(bpf NAMES bpf)
-       SET(SOURCES ${SOURCES} wg-linux.c vxlan.c bpf.c rtnl.c)
+       SET(SOURCES ${SOURCES} wg-linux.c)
 ELSE()
        SET(nl "")
+       SET(VXLAN_SUPPORT OFF)
+ENDIF()
+IF(VXLAN_SUPPORT)
+       find_library(bpf NAMES bpf)
+       find_library(elf NAMES elf)
+       find_library(zlib NAMES z)
+       SET(SOURCES ${SOURCES} bpf.c vxlan.c rtnl.c)
+       ADD_DEFINITIONS(-DVXLAN_SUPPORT)
+ELSE()
        SET(bpf "")
+       SET(elf "")
+       SET(zlib "")
 ENDIF()
+
 IF(UBUS_SUPPORT)
   SET(SOURCES ${SOURCES} ubus.c)
+  SET(DHT_SOURCES ${DHT_SOURCES} udht-ubus.c)
   ADD_DEFINITIONS(-DUBUS_SUPPORT=1)
   FIND_LIBRARY(ubus ubus)
 ELSE()
   SET(ubus "")
 ENDIF()
 
-ADD_LIBRARY(unet SHARED curve25519.c siphash.c)
+ADD_LIBRARY(unet SHARED curve25519.c siphash.c sha512.c fprime.c f25519.c ed25519.c edsign.c auth-data.c chacha20.c pex-msg.c utils.c stun.c)
 TARGET_LINK_LIBRARIES(unet ubox)
 
 ADD_EXECUTABLE(unetd ${SOURCES})
-TARGET_LINK_LIBRARIES(unetd unet ubox ${ubus} blobmsg_json ${libjson} ${nl} ${bpf})
+TARGET_LINK_LIBRARIES(unetd unet ubox ${ubus} blobmsg_json ${libjson} ${nl} ${bpf} ${elf} ${zlib})
+
+ADD_EXECUTABLE(unet-tool cli.c)
+TARGET_LINK_LIBRARIES(unet-tool unet blobmsg_json ${libjson} ubox)
+
+ADD_EXECUTABLE(unet-dht dht.c udht.c ${DHT_SOURCES})
+TARGET_LINK_LIBRARIES(unet-dht unet ${ubus} ubox)
 
-INSTALL(TARGETS unetd unet
+INSTALL(TARGETS unetd unet unet-tool unet-dht
        RUNTIME DESTINATION sbin
        LIBRARY DESTINATION lib
 )