SET(SOURCES
- main.c ubus.c network.c host.c service.c pex.c utils.c
+ main.c network.c host.c service.c pex.c utils.c
curve25519.c siphash.c
wg.c wg-dummy.c wg-user.c
)
ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DRUNSTATEDIR="${RUNSTATEDIR}")
FIND_LIBRARY(libjson NAMES json-c json)
+OPTION(UBUS_SUPPORT "enable ubus support" ON)
IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
FIND_LIBRARY(nl nl-tiny)
SET(SOURCES ${SOURCES} wg-linux.c)
ELSE()
SET(nl "")
ENDIF()
+IF(UBUS_SUPPORT)
+ SET(SOURCES ${SOURCES} ubus.c)
+ ADD_DEFINITIONS(-DUBUS_SUPPORT=1)
+ FIND_LIBRARY(ubus ubus)
+ELSE()
+ SET(ubus "")
+ENDIF()
ADD_EXECUTABLE(unetd ${SOURCES})
-TARGET_LINK_LIBRARIES(unetd ubox ubus blobmsg_json ${libjson} ${nl})
+TARGET_LINK_LIBRARIES(unetd ubox ${ubus} blobmsg_json ${libjson} ${nl})
INSTALL(TARGETS unetd
RUNTIME DESTINATION sbin
--- /dev/null
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2022 Felix Fietkau <nbd@nbd.name>
+ */
+#ifndef __UNETD_UBUS_H
+#define __UNETD_UBUS_H
+
+#ifdef UBUS_SUPPORT
+void unetd_ubus_init(void);
+void unetd_ubus_netifd_update(struct blob_attr *data);
+void unetd_ubus_netifd_add_route(struct network *net, union network_endpoint *ep);
+#else
+static inline void unetd_ubus_init(void)
+{
+}
+static inline void unetd_ubus_netifd_update(struct blob_attr *data)
+{
+}
+static inline void unetd_ubus_netifd_add_route(struct network *net, union network_endpoint *ep)
+{
+}
+#endif
+
+#endif
#include "network.h"
#include "host.h"
#include "service.h"
+#include "ubus.h"
extern bool dummy_mode;
extern bool debug;
void unetd_write_hosts(void);
-void unetd_ubus_init(void);
-void unetd_ubus_netifd_update(struct blob_attr *data);
-void unetd_ubus_netifd_add_route(struct network *net, union network_endpoint *ep);
#endif