.enable_tz = true,
.main_dhcpv4 = false,
.dhcp_cb = NULL,
+#ifdef WITH_UBUS
+ .use_ubus = true,
+#else
+ .use_ubus = false,
+#endif /* WITH_UBUS */
.dhcp_statefile = NULL,
.dhcp_statedir_fd = -1,
.dhcp_hostsdir = NULL,
ifname = blobmsg_get_string(c);
}
-#ifdef WITH_UBUS
if (overwrite || !iface->ifname)
- ifname = ubus_get_ifname(name);
-#endif
+ if (config.use_ubus)
+ ifname = ubus_get_ifname(name);
if (!iface->ifname && !ifname)
goto err;
continue;
enum odhcpd_mode hybrid_mode = MODE_DISABLED;
-#ifdef WITH_UBUS
- if (!ubus_has_prefix(i->name, i->ifname))
+
+ if (config.use_ubus && !ubus_has_prefix(i->name, i->ifname))
hybrid_mode = MODE_RELAY;
-#endif
if (i->dhcpv6 == MODE_HYBRID)
i->dhcpv6 = hybrid_mode;
{
static struct uloop_signal sighup = { .signo = SIGHUP, .cb = signal_reload };
- while (ubus_init()) {
- if (uloop_cancelled)
- return EXIT_FAILURE;
- sleep(1);
+ if (config.use_ubus) {
+ while (ubus_init()) {
+ if (uloop_cancelled)
+ return EXIT_FAILURE;
+ sleep(1);
+ }
}
odhcpd_reload();
va_end(ap);
}
-static void print_usage(const char *app)
+_o_noreturn static void print_usage(const char *app, int exit_status)
{
printf("== %s Usage ==\n"
"Features: ra ndp dhcpv6"
" -c <dir> Read UCI configuration files from <dir>\n"
" -l <int> Specify log level 0..7 (default %d)\n"
" -f Log to stderr instead of syslog\n"
+#ifdef WITH_UBUS
+ " -u Disable ubus support\n"
+#endif /* WITH_UBUS */
" -h Print this help text and exit\n",
app, config.log_level);
+
+ exit(exit_status);
}
static bool ipv6_enabled(void)
{
int opt;
- while ((opt = getopt(argc, argv, "c:l:fh")) != -1) {
+ while ((opt = getopt(argc, argv, "c:l:fuh")) != -1) {
switch (opt) {
case 'c':
struct stat sb;
config.log_syslog = false;
fprintf(stderr, "Logging to stderr\n");
break;
+ case 'u':
+ config.use_ubus = false;
+ fprintf(stderr, "Ubus support disabled\n");
+ break;
case 'h':
- print_usage(argv[0]);
- return 0;
+ print_usage(argv[0], EXIT_SUCCESS);
+ case '?':
+ default:
+ print_usage(argv[0], EXIT_FAILURE);
}
}
#define _o_unused __attribute__((unused))
#endif /* _o_unused */
+#ifndef _o_noreturn
+#define _o_noreturn __attribute__((__noreturn__))
+#endif /* _o_noreturn */
+
#define ALL_IPV6_NODES "ff02::1"
#define ALL_IPV6_ROUTERS "ff02::2"
};
struct config {
- bool legacy;
bool enable_tz;
bool main_dhcpv4;
char *dhcp_cb;
+ bool use_ubus;
char *dhcp_statefile;
int dhcp_statedir_fd;
return 0;
}
+static inline const char *ubus_get_ifname(const char *name)
+{
+ return NULL;
+}
+
static inline void ubus_apply_network(void)
{
return;
}
+static inline bool ubus_has_prefix(const char *name, const char *ifname)
+{
+ return false;
+}
+
static inline
void ubus_bcast_dhcpv4_event(const char *type, const char *iface,
const struct dhcpv4_lease *lease)
unsigned rem;
if (!dump)
- return NULL;
+ return false;
blobmsg_for_each_attr(c, dump, rem) {
struct blob_attr *tb[IFACE_ATTR_MAX];