eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit c0d033b80c7d321ba17cf062497f90ea96e790bc
parent 0c0d9e5696d9b72ea3b6228ff964bdc614b3c7b2
Author: illiliti <illiliti@protonmail.com>
Date:   Mon, 15 Mar 2021 04:45:36 +0300

make dbus optional

This is up-to-date version of original eiwd with small changes:

- iwd_passphrase is not provided.
- Restored ability to use iwd without resolvconf.

Diffstat:
A.gitmodules | 3+++
MMakefile.am | 17++++++++++++-----
Mconfigure.ac | 31++++++++++++++++++-------------
Aell | 2++
Aell-src | 1+
Msrc/adhoc.c | 6++++++
Msrc/agent.c | 48++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/ap.c | 6++++++
Msrc/device.c | 15++++++++++++++-
Msrc/knownnetworks.c | 20++++++++++++++++++++
Msrc/main.c | 11+++++++++++
Msrc/network.c | 22++++++++++++++++++++++
Msrc/p2p.c | 16++++++++++++++++
Msrc/resolve.c | 9++++++++-
Msrc/station.c | 40++++++++++++++++++++++++++++++++++++++++
Msrc/wiphy.c | 16++++++++++++++++
Msrc/wsc.c | 10++++++++++
17 files changed, 253 insertions(+), 20 deletions(-)

diff --git a/.gitmodules b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ell-src"] + path = ell-src + url = https://git.kernel.org/pub/scm/libs/ell/ell.git diff --git a/Makefile.am b/Makefile.am @@ -153,15 +153,16 @@ noinst_PROGRAMS = if DBUS_POLICY dbus_datadir = @DBUS_DATADIR@/dbus-1/system.d dist_dbus_data_DATA = + + +dbus_busdir = @DBUS_BUSDIR@ +dbus_bus_DATA = endif if SYSTEMD_SERVICE systemd_unitdir = @SYSTEMD_UNITDIR@ systemd_unit_DATA = -dbus_busdir = @DBUS_BUSDIR@ -dbus_bus_DATA = - systemd_networkdir = @SYSTEMD_NETWORKDIR@ systemd_network_DATA = @@ -256,13 +257,13 @@ endif if DBUS_POLICY dist_dbus_data_DATA += src/iwd-dbus.conf +dbus_bus_DATA += src/net.connman.iwd.service endif if SYSTEMD_SERVICE src_iwd_DEPENDENCIES += src/iwd.service systemd_unit_DATA += src/iwd.service -dbus_bus_DATA += src/net.connman.iwd.service systemd_network_DATA += src/80-iwd.link endif @@ -336,13 +337,13 @@ wired_ead_DEPENDENCIES = $(ell_dependencies) if DBUS_POLICY dist_dbus_data_DATA += wired/ead-dbus.conf +dbus_bus_DATA += wired/net.connman.ead.service endif if SYSTEMD_SERVICE wired_ead_DEPENDENCIES += wired/ead.service systemd_unit_DATA += wired/ead.service -dbus_bus_DATA += wired/net.connman.ead.service endif if MANUAL_PAGES @@ -350,6 +351,7 @@ man_MANS += wired/ead.8 endif endif +if TOOLS noinst_PROGRAMS += tools/probe-req tools_probe_req_SOURCES = tools/probe-req.c src/mpdu.h src/mpdu.c \ @@ -358,6 +360,7 @@ tools_probe_req_SOURCES = tools/probe-req.c src/mpdu.h src/mpdu.c \ src/util.h src/util.c \ src/common.h src/common.c tools_probe_req_LDADD = $(ell_ldadd) +endif if HWSIM bin_PROGRAMS += tools/hwsim @@ -539,6 +542,10 @@ AM_CFLAGS = $(ell_cflags) -fvisibility=hidden \ -DUNITDIR=\""$(top_srcdir)/unit/"\" \ -DCERTDIR=\""$(top_builddir)/unit/"\" +if DBUS +AM_CFLAGS += -DHAVE_DBUS +endif + if MAINTAINER_MODE AM_CFLAGS += -DHAVE_PKCS8_SUPPORT endif diff --git a/configure.ac b/configure.ac @@ -143,6 +143,11 @@ if (test "${USE_MAINTAINER_MODE}" = yes); then ]) fi +AC_ARG_ENABLE([dbus], AC_HELP_STRING([--disable-dbus], + [don't provide dbus support]), + [disable_dbus=${enableval}]) +AM_CONDITIONAL(DBUS, test "${disable_dbus}" != "no") + AC_ARG_ENABLE([daemon], AC_HELP_STRING([--disable-daemon], [don't install iwd system daemon]), [enable_daemon=${enableval}]) @@ -151,14 +156,14 @@ AM_CONDITIONAL(DAEMON, test "${enable_daemon}" != "no") AC_ARG_ENABLE([client], AC_HELP_STRING([--disable-client], [don't install iwctl client utility]), [enable_client=${enableval}]) -if (test "${enable_client}" != "no"); then +if (test "${disable_dbus}" != "no" && test "${enable_client}" != "no"); then AC_CHECK_HEADERS(readline/readline.h, enable_readline=yes, AC_MSG_ERROR(readline header files are required)) PKG_CHECK_MODULES(READLINE, readline, dummy=yes, READLINE_LIBS=-lreadline) AC_SUBST(READLINE_CFLAGS) AC_SUBST(READLINE_LIBS) fi -AM_CONDITIONAL(CLIENT, test "${enable_client}" != "no") +AM_CONDITIONAL(CLIENT, test "${enable_client}" != "no" && test "${disable_dbus}" != "no") AC_ARG_ENABLE([monitor], AC_HELP_STRING([--disable-monitor], [don't install iwmon monitor utility]), @@ -168,12 +173,12 @@ AM_CONDITIONAL(MONITOR, test "${enable_monitor}" != "no") AC_ARG_ENABLE([dbus-policy], AC_HELP_STRING([--disable-dbus-policy], [don't install D-Bus system policy files]), [enable_dbus_policy=${enableval}]) -AM_CONDITIONAL(DBUS_POLICY, test "${enable_dbus_policy}" != "no") +AM_CONDITIONAL(DBUS_POLICY, test "${enable_dbus_policy}" != "no" && test "${disable_dbus}" != "no") AC_ARG_WITH([dbus-datadir], AC_HELP_STRING([--with-dbus-datadir=DIR], [path to D-Bus data directory]), [path_dbus_datadir=${withval}]) -if (test "${enable_dbus_policy}" != "no" && test -z "${path_dbus_datadir}"); then +if (test "${disable_dbus}" != "no" && test "${enable_dbus_policy}" != "no" && test -z "${path_dbus_datadir}"); then AC_MSG_CHECKING([D-Bus data directory]) path_dbus_datadir="`$PKG_CONFIG --variable=datadir dbus-1`" if (test -z "${path_dbus_datadir}"); then @@ -189,7 +194,7 @@ AC_SUBST(DBUS_DATADIR, [${path_dbus_datadir}]) AC_ARG_ENABLE([systemd-service], AC_HELP_STRING([--disable-systemd-service], [don't install systemd service files]), [enable_systemd_service=${enableval}]) -AM_CONDITIONAL(SYSTEMD_SERVICE, test "${enable_systemd_service}" != "no") +AM_CONDITIONAL(SYSTEMD_SERVICE, test "${enable_systemd_service}" != "no" && test "${disable_dbus}" != "no") AC_ARG_ENABLE([manual-pages], AC_HELP_STRING([--disable-manual-pages], [don't install manual pages]), @@ -203,7 +208,7 @@ AM_CONDITIONAL(RUN_RST2MAN, test "${enable_manual_pages}" != "no" && test "${RST AC_ARG_WITH([dbus-busdir], AC_HELP_STRING([--with-dbus-busdir=DIR], [path to D-Bus bus services directory]), [path_dbus_busdir=${withval}]) -if (test "${enable_systemd_service}" != "no" && test -z "${path_dbus_busdir}"); then +if (test "${disable_dbus}" != "no" && test "${enable_dbus_policy}" != "no" && test -z "${path_dbus_busdir}"); then AC_MSG_CHECKING([D-Bus bus services directory]) path_dbus_busdir="`$PKG_CONFIG --variable=system_bus_services_dir dbus-1`" if (test -z "${path_dbus_busdir}"); then @@ -216,7 +221,7 @@ AC_SUBST(DBUS_BUSDIR, [${path_dbus_busdir}]) AC_ARG_WITH([systemd-unitdir], AC_HELP_STRING([--with-systemd-unitdir=DIR], [path to systemd unit directory]), [path_systemd_unitdir=${withval}]) -if (test "${enable_systemd_service}" != "no" && test -z "${path_systemd_unitdir}"); then +if (test "${disable_dbus}" != "no" && test "${enable_systemd_service}" != "no" && test -z "${path_systemd_unitdir}"); then AC_MSG_CHECKING([systemd unit directory]) path_systemd_unitdir="`$PKG_CONFIG --variable=systemdsystemunitdir systemd`" if (test -z "${path_systemd_unitdir}"); then @@ -229,7 +234,7 @@ AC_SUBST(SYSTEMD_UNITDIR, [${path_systemd_unitdir}]) AC_ARG_WITH([systemd-networkdir], AC_HELP_STRING([--with-systemd-networkdir=DIR], [path to systemd network directory]), [path_systemd_networkdir=${withval}]) -if (test "${enable_systemd_service}" != "no" && test -z "${path_systemd_networkdir}"); then +if (test "${disable_dbus}" != "no" && test "${enable_systemd_service}" != "no" && test -z "${path_systemd_networkdir}"); then AC_MSG_CHECKING([systemd network directory]) path_systemd_networkdir="`$PKG_CONFIG --variable=systemdutildir systemd`" if (test -z "${path_systemd_networkdir}"); then @@ -243,7 +248,7 @@ AC_SUBST(SYSTEMD_NETWORKDIR, [${path_systemd_networkdir}]) AC_ARG_WITH([systemd-modloaddir], AC_HELP_STRING([--with-systemd-modloaddir=DIR], [path to systemd modules load directory]), [path_systemd_modloaddir=${withval}]) -if (test "${enable_systemd_service}" != "no" && test -z "${path_systemd_modloaddir}"); then +if (test "${disable_dbus}" != "no" && test "${enable_systemd_service}" != "no" && test -z "${path_systemd_modloaddir}"); then AC_MSG_CHECKING([systemd modules load directory]) path_systemd_modloaddir="`$PKG_CONFIG --variable=modulesloaddir systemd`" if (test -z "${path_systemd_modloaddir}"); then @@ -277,22 +282,22 @@ AM_CONDITIONAL(EXTERNAL_ELL, test "${enable_external_ell}" = "yes") AC_ARG_ENABLE([wired], AC_HELP_STRING([--enable-wired], [enable Ethernet authentication support]), [enable_wired=${enableval}]) -AM_CONDITIONAL(WIRED, test "${enable_wired}" = "yes") +AM_CONDITIONAL(WIRED, test "${enable_wired}" = "yes" && test "${disable_dbus}" != "no") AC_ARG_ENABLE([hwsim], AC_HELP_STRING([--enable-hwsim], [enable Wireless simulation utility]), [enable_hwsim=${enableval}]) -AM_CONDITIONAL(HWSIM, test "${enable_hwsim}" = "yes") +AM_CONDITIONAL(HWSIM, test "${enable_hwsim}" = "yes" && test "${disable_dbus}" != "no") AC_ARG_ENABLE([tools], AC_HELP_STRING([--enable-tools], [enable internal testing utilities]), [enable_tools=${enableval}]) -AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes") +AM_CONDITIONAL(TOOLS, test "${enable_tools}" = "yes" && test "${disable_dbus}" != "no") AC_ARG_ENABLE([ofono], AC_HELP_STRING([--enable-ofono], [enable oFono SIM authentication support]), [enable_ofono=${enableval}]) -AM_CONDITIONAL(OFONO, test "${enable_ofono}" = "yes") +AM_CONDITIONAL(OFONO, test "${enable_ofono}" = "yes" && test "${disable_dbus}" != "no") AC_CONFIG_FILES(Makefile) diff --git a/ell b/ell @@ -0,0 +1 @@ +ell-src/ell +\ No newline at end of file diff --git a/ell-src b/ell-src @@ -0,0 +1 @@ +Subproject commit 6d3db49e07af7a4d1aad04e003c9aac5ed6e1bd1 diff --git a/src/adhoc.c b/src/adhoc.c @@ -742,6 +742,7 @@ static void adhoc_netdev_watch(struct netdev *netdev, { switch (event) { case NETDEV_WATCH_EVENT_UP: +#ifdef HAVE_DBUS case NETDEV_WATCH_EVENT_NEW: if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_ADHOC && netdev_get_is_up(netdev)) @@ -751,6 +752,7 @@ static void adhoc_netdev_watch(struct netdev *netdev, case NETDEV_WATCH_EVENT_DEL: adhoc_remove_interface(netdev); break; +#endif default: break; } @@ -759,8 +761,10 @@ static void adhoc_netdev_watch(struct netdev *netdev, static int adhoc_init(void) { netdev_watch = netdev_watch_add(adhoc_netdev_watch, NULL, NULL); +#ifdef HAVE_DBUS l_dbus_register_interface(dbus_get_bus(), IWD_ADHOC_INTERFACE, adhoc_setup_interface, adhoc_destroy_interface, false); +#endif return 0; } @@ -768,7 +772,9 @@ static int adhoc_init(void) static void adhoc_exit(void) { netdev_watch_remove(netdev_watch); +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_ADHOC_INTERFACE); +#endif } IWD_MODULE(adhoc, adhoc_init, adhoc_exit) diff --git a/src/agent.c b/src/agent.c @@ -69,6 +69,7 @@ static struct l_queue *agents; * This should probably be configurable by user via * config file/command line option/env variable. */ +#ifdef HAVE_DBUS static unsigned int agent_timeout_input_request(void) { return 120; @@ -128,11 +129,13 @@ static void send_cancel_request(void *user_data, int reason) l_dbus_send(dbus_get_bus(), message); } +#endif static void agent_request_free(void *user_data) { struct agent_request *request = user_data; +#ifdef HAVE_DBUS l_dbus_message_unref(request->message); if (request->trigger) @@ -141,10 +144,12 @@ static void agent_request_free(void *user_data) if (request->destroy) request->destroy(request->user_data); +#endif l_free(request); } +#ifdef HAVE_DBUS static void passphrase_reply(struct l_dbus_message *reply, struct agent_request *request) { @@ -187,6 +192,7 @@ done: user_callback(result, username, passwd, request->trigger, request->user_data); } +#endif static void agent_finalize_pending(struct agent *agent, struct l_dbus_message *reply) @@ -198,6 +204,7 @@ static void agent_finalize_pending(struct agent *agent, agent->timeout = NULL; } +#ifdef HAVE_DBUS pending = l_queue_pop_head(agent->requests); switch (pending->type) { @@ -215,6 +222,7 @@ static void agent_finalize_pending(struct agent *agent, } agent_request_free(pending); +#endif } static void agent_free(void *data) @@ -226,13 +234,17 @@ static void agent_free(void *data) if (agent->timeout) l_timeout_remove(agent->timeout); +#ifdef HAVE_DBUS if (agent->pending_id) l_dbus_cancel(dbus_get_bus(), agent->pending_id); l_queue_destroy(agent->requests, agent_request_free); +#endif +#ifdef HAVE_DBUS if (agent->disconnect_watch) l_dbus_remove_watch(dbus_get_bus(), agent->disconnect_watch); +#endif l_free(agent->owner); l_free(agent->path); @@ -245,15 +257,18 @@ static void request_timeout(struct l_timeout *timeout, void *user_data) { struct agent *agent = user_data; +#ifdef HAVE_DBUS l_dbus_cancel(dbus_get_bus(), agent->pending_id); send_cancel_request(agent, -ETIMEDOUT); +#endif agent_finalize_pending(agent, NULL); agent_send_next_request(agent); } +#ifdef HAVE_DBUS static void agent_receive_reply(struct l_dbus_message *message, void *user_data) { @@ -268,6 +283,7 @@ static void agent_receive_reply(struct l_dbus_message *message, if (!agent->pending_id) agent_send_next_request(agent); } +#endif static void agent_send_next_request(struct agent *agent) { @@ -283,16 +299,19 @@ static void agent_send_next_request(struct agent *agent) l_debug("send request to %s %s", agent->owner, agent->path); +#ifdef HAVE_DBUS agent->pending_id = l_dbus_send_with_reply(dbus_get_bus(), pending->message, agent_receive_reply, agent, NULL); +#endif pending->message = NULL; return; } +#ifdef HAVE_DBUS static unsigned int agent_queue_request(struct agent *agent, enum agent_request_type type, struct l_dbus_message *message, @@ -351,6 +370,7 @@ static struct agent *get_agent(const char *owner) return l_queue_peek_head(agents); } +#endif /** * agent_request_passphrase: @@ -375,6 +395,7 @@ unsigned int agent_request_passphrase(const char *path, void *user_data, agent_request_destroy_func_t destroy) { +#ifdef HAVE_DBUS struct agent *agent = get_agent(l_dbus_message_get_sender(trigger)); struct l_dbus_message *message; @@ -394,6 +415,9 @@ unsigned int agent_request_passphrase(const char *path, return agent_queue_request(agent, AGENT_REQUEST_TYPE_PASSPHRASE, message, agent_timeout_input_request(), callback, trigger, user_data, destroy); +#else + return 0; +#endif } unsigned int agent_request_pkey_passphrase(const char *path, @@ -402,6 +426,7 @@ unsigned int agent_request_pkey_passphrase(const char *path, void *user_data, agent_request_destroy_func_t destroy) { +#ifdef HAVE_DBUS struct agent *agent = get_agent(l_dbus_message_get_sender(trigger)); struct l_dbus_message *message; @@ -420,6 +445,9 @@ unsigned int agent_request_pkey_passphrase(const char *path, return agent_queue_request(agent, AGENT_REQUEST_TYPE_PASSPHRASE, message, agent_timeout_input_request(), callback, trigger, user_data, destroy); +#else + return 0; +#endif } unsigned int agent_request_user_name_password(const char *path, @@ -428,6 +456,7 @@ unsigned int agent_request_user_name_password(const char *path, void *user_data, agent_request_destroy_func_t destroy) { +#ifdef HAVE_DBUS struct agent *agent = get_agent(l_dbus_message_get_sender(trigger)); struct l_dbus_message *message; @@ -446,6 +475,9 @@ unsigned int agent_request_user_name_password(const char *path, return agent_queue_request(agent, AGENT_REQUEST_TYPE_USER_NAME_PASSWD, message, agent_timeout_input_request(), callback, trigger, user_data, destroy); +#else + return 0; +#endif } unsigned int agent_request_user_password(const char *path, const char *user, @@ -453,6 +485,7 @@ unsigned int agent_request_user_password(const char *path, const char *user, struct l_dbus_message *trigger, void *user_data, agent_request_destroy_func_t destroy) { +#ifdef HAVE_DBUS struct agent *agent = get_agent(l_dbus_message_get_sender(trigger)); struct l_dbus_message *message; @@ -471,6 +504,9 @@ unsigned int agent_request_user_password(const char *path, const char *user, return agent_queue_request(agent, AGENT_REQUEST_TYPE_PASSPHRASE, message, agent_timeout_input_request(), callback, trigger, user_data, destroy); +#else + return 0; +#endif } static bool find_request(const void *a, const void *b) @@ -500,9 +536,11 @@ bool agent_request_cancel(unsigned int req_id, int reason) return false; if (!request->message) { +#ifdef HAVE_DBUS send_cancel_request(agent, reason); l_dbus_cancel(dbus_get_bus(), agent->pending_id); +#endif agent->pending_id = 0; @@ -519,6 +557,7 @@ bool agent_request_cancel(unsigned int req_id, int reason) return true; } +#ifdef HAVE_DBUS static void agent_disconnect(struct l_dbus *dbus, void *user_data) { struct agent *agent = user_data; @@ -609,12 +648,15 @@ static void setup_agent_interface(struct l_dbus_interface *interface) agent_unregister, "", "o", "path"); } +#endif static bool release_agent(void *data, void *user_data) { struct agent *agent = data; +#ifdef HAVE_DBUS send_request(agent, "Release"); +#endif agent_free(agent); @@ -623,10 +665,13 @@ static bool release_agent(void *data, void *user_data) static int agent_init(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif agents = l_queue_new(); +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus, IWD_AGENT_MANAGER_INTERFACE, setup_agent_interface, NULL, false)) { @@ -643,15 +688,18 @@ static int agent_init(void) l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE); return -EIO; } +#endif return 0; } static void agent_exit(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); l_dbus_unregister_interface(dbus, IWD_AGENT_MANAGER_INTERFACE); +#endif l_queue_destroy(agents, agent_free); agents = NULL; diff --git a/src/ap.c b/src/ap.c @@ -3399,6 +3399,7 @@ static void ap_netdev_watch(struct netdev *netdev, { switch (event) { case NETDEV_WATCH_EVENT_UP: +#ifdef HAVE_DBUS case NETDEV_WATCH_EVENT_NEW: if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_AP && netdev_get_is_up(netdev)) @@ -3408,6 +3409,7 @@ static void ap_netdev_watch(struct netdev *netdev, case NETDEV_WATCH_EVENT_DEL: ap_remove_interface(netdev); break; +#endif default: break; } @@ -3420,11 +3422,13 @@ static int ap_init(void) netdev_watch = netdev_watch_add(ap_netdev_watch, NULL, NULL); +#ifdef HAVE_DBUS l_dbus_register_interface(dbus_get_bus(), IWD_AP_INTERFACE, ap_setup_interface, ap_destroy_interface, false); l_dbus_register_interface(dbus_get_bus(), IWD_AP_DIAGNOSTIC_INTERFACE, ap_setup_diagnostic_interface, ap_diagnostic_interface_destroy, false); +#endif /* * Reusing [General].EnableNetworkConfiguration as a switch to enable @@ -3462,7 +3466,9 @@ static int ap_init(void) static void ap_exit(void) { netdev_watch_remove(netdev_watch); +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_AP_INTERFACE); +#endif ip_pool_destroy(); } diff --git a/src/device.c b/src/device.c @@ -302,7 +302,9 @@ static void device_wiphy_state_changed_event(struct wiphy *wiphy, static struct device *device_create(struct wiphy *wiphy, struct netdev *netdev) { struct device *device; +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif uint32_t ifindex = netdev_get_ifindex(netdev); const uint8_t action_ap_roam_prefix[2] = { 0x0a, 0x07 }; @@ -311,6 +313,7 @@ static struct device *device_create(struct wiphy *wiphy, struct netdev *netdev) device->wiphy = wiphy; device->netdev = netdev; +#ifdef HAVE_DBUS if (!l_dbus_object_add_interface(dbus, netdev_get_path(device->netdev), IWD_DEVICE_INTERFACE, device)) l_info("Unable to register %s interface", IWD_DEVICE_INTERFACE); @@ -319,6 +322,7 @@ static struct device *device_create(struct wiphy *wiphy, struct netdev *netdev) L_DBUS_INTERFACE_PROPERTIES, device)) l_info("Unable to register %s interface", L_DBUS_INTERFACE_PROPERTIES); +#endif /* * register for AP roam transition watch @@ -358,6 +362,7 @@ static void device_netdev_notify(struct netdev *netdev, enum netdev_watch_event event, void *user_data) { +#ifdef HAVE_DBUS struct device *device; struct l_dbus *dbus = dbus_get_bus(); const char *path = netdev_get_path(netdev); @@ -366,11 +371,14 @@ static void device_netdev_notify(struct netdev *netdev, if (!device && event != NETDEV_WATCH_EVENT_NEW) return; +#endif switch (event) { case NETDEV_WATCH_EVENT_NEW: +#ifdef HAVE_DBUS if (L_WARN_ON(device)) break; +#endif if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_P2P_CLIENT || netdev_get_iftype(netdev) == @@ -379,6 +387,7 @@ static void device_netdev_notify(struct netdev *netdev, device_create(netdev_get_wiphy(netdev), netdev); break; +#ifdef HAVE_DBUS case NETDEV_WATCH_EVENT_DEL: l_dbus_unregister_object(dbus, path); break; @@ -402,6 +411,7 @@ static void device_netdev_notify(struct netdev *netdev, l_dbus_property_changed(dbus, path, IWD_DEVICE_INTERFACE, "Address"); break; +#endif default: break; } @@ -416,11 +426,13 @@ static void destroy_device_interface(void *user_data) static int device_init(void) { +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus_get_bus(), IWD_DEVICE_INTERFACE, setup_device_interface, destroy_device_interface, false)) return -EPERM; +#endif netdev_watch = netdev_watch_add(device_netdev_notify, NULL, NULL); @@ -430,8 +442,9 @@ static int device_init(void) static void device_exit(void) { netdev_watch_remove(netdev_watch); - +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_DEVICE_INTERFACE); +#endif } IWD_MODULE(device, device_init, device_exit) diff --git a/src/knownnetworks.c b/src/knownnetworks.c @@ -143,8 +143,10 @@ static void known_network_set_autoconnect(struct network_info *network, network->is_autoconnectable = autoconnect; +#ifdef HAVE_DBUS l_dbus_property_changed(dbus_get_bus(), known_network_get_path(network), IWD_KNOWN_NETWORK_INTERFACE, "AutoConnect"); +#endif } static int known_network_touch(struct network_info *info) @@ -344,10 +346,12 @@ void known_network_set_connected_time(struct network_info *network, network->connected_time = connected_time; +#ifdef HAVE_DBUS l_dbus_property_changed(dbus_get_bus(), known_network_get_path(network), IWD_KNOWN_NETWORK_INTERFACE, "LastConnectedTime"); +#endif l_queue_remove(known_networks, network); l_queue_insert(known_networks, network, connected_time_compare, NULL); @@ -368,10 +372,12 @@ void known_network_update(struct network_info *network, else if (!network->is_hidden && is_hidden) num_known_hidden_networks++; +#ifdef HAVE_DBUS l_dbus_property_changed(dbus_get_bus(), known_network_get_path(network), IWD_KNOWN_NETWORK_INTERFACE, "Hidden"); +#endif } network->is_hidden = is_hidden; @@ -648,8 +654,10 @@ void known_networks_remove(struct network_info *network) num_known_hidden_networks--; l_queue_remove(known_networks, network); +#ifdef HAVE_DBUS l_dbus_unregister_object(dbus_get_bus(), known_network_get_path(network)); +#endif WATCHLIST_NOTIFY(&known_network_watches, known_networks_watch_func_t, @@ -669,7 +677,9 @@ void known_networks_remove(struct network_info *network) void known_networks_add(struct network_info *network) { l_queue_insert(known_networks, network, connected_time_compare, NULL); +#ifdef HAVE_DBUS known_network_register_dbus(network); +#endif WATCHLIST_NOTIFY(&known_network_watches, known_networks_watch_func_t, @@ -993,12 +1003,15 @@ void known_networks_watch_remove(uint32_t id) static int known_networks_init(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif DIR *dir; struct dirent *dirent; L_AUTO_FREE_VAR(char *, storage_dir) = storage_get_path(NULL); +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus, IWD_KNOWN_NETWORK_INTERFACE, setup_known_network_interface, NULL, false)) { @@ -1006,11 +1019,14 @@ static int known_networks_init(void) IWD_KNOWN_NETWORK_INTERFACE); return -EPERM; } +#endif dir = opendir(storage_dir); if (!dir) { l_info("Unable to open %s: %s", storage_dir, strerror(errno)); +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus, IWD_KNOWN_NETWORK_INTERFACE); +#endif return -ENOENT; } @@ -1057,14 +1073,18 @@ static int known_networks_init(void) static void known_networks_exit(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif l_dir_watch_destroy(storage_dir_watch); l_queue_destroy(known_networks, network_info_free); known_networks = NULL; +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus, IWD_KNOWN_NETWORK_INTERFACE); +#endif watchlist_destroy(&known_network_watches); } diff --git a/src/main.c b/src/main.c @@ -74,7 +74,9 @@ static void iwd_shutdown(void) return; } +#ifdef HAVE_DBUS dbus_shutdown(); +#endif netdev_shutdown(); timeout = l_timeout_create(1, main_loop_quit, NULL, NULL); @@ -174,6 +176,7 @@ static void nl80211_appeared(const struct l_genl_family_info *info, } } +#ifdef HAVE_DBUS static void request_name_callback(struct l_dbus *dbus, bool success, bool queued, void *user_data) { @@ -207,6 +210,7 @@ static void dbus_disconnected(void *user_data) l_info("D-Bus disconnected, quitting..."); iwd_shutdown(); } +#endif static void print_koption(const void *key, void *value, void *user_data) { @@ -474,6 +478,7 @@ int main(int argc, char *argv[]) if (getenv("IWD_RTNL_DEBUG")) l_netlink_set_debug(rtnl, do_debug, "[RTNL] ", NULL); +#ifdef HAVE_DBUS dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS); if (!dbus) { l_error("Failed to initialize D-Bus"); @@ -486,12 +491,18 @@ int main(int argc, char *argv[]) l_dbus_set_ready_handler(dbus, dbus_ready, dbus, NULL); l_dbus_set_disconnect_handler(dbus, dbus_disconnected, NULL, NULL); dbus_init(dbus); +#else + l_genl_request_family(genl, NL80211_GENL_NAME, nl80211_appeared, + NULL, NULL); +#endif exit_status = l_main_run_with_signal(signal_handler, NULL); iwd_modules_exit(); +#ifdef HAVE_DBUS dbus_exit(); l_dbus_destroy(dbus); +#endif failed_dbus: l_netlink_destroy(rtnl); diff --git a/src/network.c b/src/network.c @@ -495,8 +495,10 @@ void network_set_info(struct network *network, struct network_info *info) network->info = NULL; } +#ifdef HAVE_DBUS l_dbus_property_changed(dbus_get_bus(), network_get_path(network), IWD_NETWORK_INTERFACE, "KnownNetwork"); +#endif } static inline bool __bss_is_sae(const struct scan_bss *bss, @@ -1094,6 +1096,7 @@ static struct l_dbus_message *network_connect_8021x(struct network *network, r = eap_check_settings(network->settings, network->secrets, "EAP-", true, &missing_secrets); if (r) { +#ifdef HAVE_DBUS if (r == -EUNATCH) reply = dbus_error_not_available(message); else if (r == -ENOTSUP) @@ -1102,6 +1105,7 @@ static struct l_dbus_message *network_connect_8021x(struct network *network, reply = dbus_error_failed(message); else reply = dbus_error_not_configured(message); +#endif goto error; } @@ -1112,7 +1116,9 @@ static struct l_dbus_message *network_connect_8021x(struct network *network, if (l_queue_isempty(missing_secrets)) { if (!network_set_8021x_secrets(network)) { +#ifdef HAVE_DBUS reply = dbus_error_failed(message); +#endif goto error; } @@ -1126,7 +1132,9 @@ static struct l_dbus_message *network_connect_8021x(struct network *network, eap_secret_done)) return NULL; +#ifdef HAVE_DBUS reply = dbus_error_no_agent(message); +#endif error: network_settings_close(network); @@ -1330,6 +1338,7 @@ static bool network_property_get_known_network(struct l_dbus *dbus, bool network_register(struct network *network, const char *path) { +#ifdef HAVE_DBUS if (!l_dbus_object_add_interface(dbus_get_bus(), path, IWD_NETWORK_INTERFACE, network)) { l_info("Unable to register %s interface", @@ -1341,6 +1350,7 @@ bool network_register(struct network *network, const char *path) L_DBUS_INTERFACE_PROPERTIES, network)) l_info("Unable to register %s interface", L_DBUS_INTERFACE_PROPERTIES); +#endif network->object_path = l_strdup(path); @@ -1349,12 +1359,16 @@ bool network_register(struct network *network, const char *path) static void network_unregister(struct network *network, int reason) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif agent_request_cancel(network->agent_request, reason); network_settings_close(network); +#ifdef HAVE_DBUS l_dbus_unregister_object(dbus, network->object_path); +#endif l_free(network->object_path); network->object_path = NULL; @@ -1523,9 +1537,11 @@ static void anqp_watch_changed(enum station_anqp_state state, l_debug("ANQP complete, resuming connect to %s", network->ssid); if (!network_settings_load(network)) { +#ifdef HAVE_DBUS reply = dbus_error_not_configured( network->connect_after_anqp); dbus_pending_reply(&network->connect_after_anqp, reply); +#endif return; } @@ -1533,10 +1549,12 @@ static void anqp_watch_changed(enum station_anqp_state state, network_bss_select(network, true), network->connect_after_anqp); +#ifdef HAVE_DBUS if (reply) l_dbus_send(dbus_get_bus(), reply); l_dbus_message_unref(network->connect_after_anqp); +#endif network->connect_after_anqp = NULL; } } @@ -1566,10 +1584,12 @@ static void setup_network_interface(struct l_dbus_interface *interface) static int network_init(void) { +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE, setup_network_interface, NULL, false)) l_error("Unable to register %s interface", IWD_NETWORK_INTERFACE); +#endif known_networks_watch = known_networks_watch_add(known_networks_changed, NULL, NULL); @@ -1587,7 +1607,9 @@ static void network_exit(void) station_remove_anqp_watch(anqp_watch); anqp_watch = 0; +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_NETWORK_INTERFACE); +#endif } IWD_MODULE(network, network_init, network_exit) diff --git a/src/p2p.c b/src/p2p.c @@ -222,8 +222,10 @@ static void p2p_discovery_user_free(void *data) { struct p2p_discovery_user *user = data; +#ifdef HAVE_DBUS if (user->disconnect_watch) l_dbus_remove_watch(dbus_get_bus(), user->disconnect_watch); +#endif l_free(user->client); l_free(user); @@ -275,7 +277,9 @@ static void p2p_peer_put(void *user_data) * Removes all interfaces with one call, no need to call * wsc_dbus_remove_interface. */ +#ifdef HAVE_DBUS l_dbus_unregister_object(dbus_get_bus(), p2p_peer_get_path(peer)); +#endif p2p_peer_free(peer); } @@ -4405,11 +4409,13 @@ struct p2p_device *p2p_device_update_from_genl(struct l_genl_msg *msg, p2p_mlme_notify, dev, NULL)) l_error("Registering for MLME notifications failed"); +#ifdef HAVE_DBUS if (!l_dbus_object_add_interface(dbus_get_bus(), p2p_device_get_path(dev), IWD_P2P_INTERFACE, dev)) l_info("Unable to add the %s interface to %s", IWD_P2P_INTERFACE, p2p_device_get_path(dev)); +#endif return dev; } @@ -4418,6 +4424,7 @@ static void p2p_device_free(void *user_data) { struct p2p_device *dev = user_data; +#ifdef HAVE_DBUS if (dev->pending_message) { struct l_dbus_message *reply = dbus_error_aborted(dev->pending_message); @@ -4427,10 +4434,13 @@ static void p2p_device_free(void *user_data) dev->pending_message = NULL; dev->pending_complete = NULL; } +#endif p2p_device_discovery_stop(dev); p2p_connection_reset(dev); +#ifdef HAVE_DBUS l_dbus_unregister_object(dbus_get_bus(), p2p_device_get_path(dev)); +#endif l_queue_destroy(dev->peer_list, p2p_peer_put); l_queue_destroy(dev->discovery_users, p2p_discovery_user_free); l_genl_family_free(dev->nl80211); /* Cancels dev->start_stop_cmd_id */ @@ -5102,6 +5112,7 @@ static void p2p_service_manager_destroy_cb(void *user_data) static int p2p_init(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); if (!l_dbus_register_interface(dbus, IWD_P2P_INTERFACE, @@ -5115,10 +5126,12 @@ static int p2p_init(void) NULL, false)) l_error("Unable to register the %s interface", IWD_P2P_PEER_INTERFACE); +#endif p2p_dhcp_settings = l_settings_new(); p2p_device_list = l_queue_new(); +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus, IWD_P2P_WFD_INTERFACE, p2p_wfd_interface_setup, NULL, false)) @@ -5135,18 +5148,21 @@ static int p2p_init(void) IWD_P2P_SERVICE_MANAGER_INTERFACE, NULL)) l_error("Unable to register the P2P Service Manager object"); +#endif return 0; } static void p2p_exit(void) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); l_dbus_unregister_interface(dbus, IWD_P2P_INTERFACE); l_dbus_unregister_interface(dbus, IWD_P2P_PEER_INTERFACE); l_dbus_unregister_interface(dbus, IWD_P2P_WFD_INTERFACE); l_dbus_unregister_interface(dbus, IWD_P2P_SERVICE_MANAGER_INTERFACE); +#endif l_queue_destroy(p2p_device_list, p2p_device_free); p2p_device_list = NULL; l_settings_free(p2p_dhcp_settings); diff --git a/src/resolve.c b/src/resolve.c @@ -527,7 +527,8 @@ static int resolve_resolvconf_init(void) if (!resolvconf_path) { l_error("No usable resolvconf found on system"); - return -ENOENT; + /* return -ENOENT; */ + return 0; } l_debug("resolvconf found as: %s", resolvconf_path); @@ -573,7 +574,9 @@ static const struct { const char *name; const struct resolve_method_ops *method_ops; } resolve_method_ops_list[] = { +#ifdef HAVE_DBUS { "systemd", &resolve_method_systemd_ops }, +#endif { "resolvconf", &resolve_method_resolvconf_ops }, { } }; @@ -604,7 +607,11 @@ static int resolve_init(void) l_warn("[General].dns_resolve_method is deprecated, " "use [Network].NameResolvingService"); else /* Default to systemd-resolved service. */ +#ifdef HAVE_DBUS method_name = "systemd"; +#else + method_name = "resolvconf"; +#endif } for (i = 0; resolve_method_ops_list[i].name; i++) { diff --git a/src/station.c b/src/station.c @@ -165,9 +165,11 @@ static void station_property_set_scanning(struct station *station, station->scanning = scanning; +#ifdef HAVE_DBUS l_dbus_property_changed(dbus_get_bus(), netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "Scanning"); +#endif } static void station_enter_state(struct station *station, @@ -1223,19 +1225,23 @@ static void station_enter_state(struct station *station, enum station_state state) { uint64_t id = netdev_get_wdev_id(station->netdev); +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif bool disconnected; l_debug("Old State: %s, new state: %s", station_state_to_string(station->state), station_state_to_string(state)); +#ifdef HAVE_DBUS disconnected = !station_is_busy(station); if ((disconnected && state > STATION_STATE_AUTOCONNECT_FULL) || (!disconnected && state != station->state)) l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "State"); +#endif station->state = state; @@ -1257,25 +1263,31 @@ static void station_enter_state(struct station *station, l_queue_insert(station->networks_sorted, station->connected_network, network_rank_compare, NULL); +#ifdef HAVE_DBUS l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); l_dbus_property_changed(dbus, network_get_path(station->connected_network), IWD_NETWORK_INTERFACE, "Connected"); +#endif periodic_scan_stop(station); break; case STATION_STATE_DISCONNECTED: +#ifdef HAVE_DBUS l_dbus_object_remove_interface(dbus_get_bus(), netdev_get_path(station->netdev), IWD_STATION_DIAGNOSTIC_INTERFACE); +#endif periodic_scan_stop(station); break; case STATION_STATE_CONNECTED: +#ifdef HAVE_DBUS l_dbus_object_add_interface(dbus, netdev_get_path(station->netdev), IWD_STATION_DIAGNOSTIC_INTERFACE, station); +#endif periodic_scan_stop(station); break; case STATION_STATE_DISCONNECTING: @@ -1355,7 +1367,9 @@ static void station_roam_state_clear(struct station *station) static void station_reset_connection_state(struct station *station) { struct network *network = station->connected_network; +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif if (!network) return; @@ -1376,10 +1390,12 @@ static void station_reset_connection_state(struct station *station) station->connected_bss = NULL; station->connected_network = NULL; +#ifdef HAVE_DBUS l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); l_dbus_property_changed(dbus, network_get_path(network), IWD_NETWORK_INTERFACE, "Connected"); +#endif } static void station_disassociated(struct station *station) @@ -2542,9 +2558,11 @@ static void station_disconnect_onconnect_cb(struct netdev *netdev, bool success, station->connect_pending_bss = NULL; if (err < 0) { +#ifdef HAVE_DBUS dbus_pending_reply(&station->connect_pending, dbus_error_from_errno(err, station->connect_pending)); +#endif return; } @@ -2558,8 +2576,10 @@ static void station_disconnect_onconnect(struct station *station, { if (netdev_disconnect(station->netdev, station_disconnect_onconnect_cb, station) < 0) { +#ifdef HAVE_DBUS l_dbus_send(dbus_get_bus(), dbus_error_from_errno(-EIO, message)); +#endif return; } @@ -2580,7 +2600,9 @@ void station_connect_network(struct station *station, struct network *network, struct scan_bss *bss, struct l_dbus_message *message) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif int err; /* @@ -2592,8 +2614,10 @@ void station_connect_network(struct station *station, struct network *network, scan_cancel(netdev_get_wdev_id(station->netdev), station->hidden_network_scan_id); +#ifdef HAVE_DBUS dbus_pending_reply(&station->hidden_pending, dbus_error_failed(station->hidden_pending)); +#endif } if (station->quick_scan_id) { @@ -2620,7 +2644,11 @@ void station_connect_network(struct station *station, struct network *network, return; error: +#ifdef HAVE_DBUS l_dbus_send(dbus, dbus_error_from_errno(err, message)); +#else + return; +#endif } static void station_hidden_network_scan_triggered(int err, void *user_data) @@ -2829,6 +2857,7 @@ static void station_disconnect_cb(struct netdev *netdev, bool success, l_debug("%u, success: %d", netdev_get_ifindex(station->netdev), success); +#ifdef HAVE_DBUS if (station->disconnect_pending) { struct l_dbus_message *reply; @@ -2841,6 +2870,7 @@ static void station_disconnect_cb(struct netdev *netdev, bool success, dbus_pending_reply(&station->disconnect_pending, reply); } +#endif station_enter_state(station, STATION_STATE_DISCONNECTED); @@ -3434,7 +3464,9 @@ static void station_fill_scan_freq_subsets(struct station *station) static struct station *station_create(struct netdev *netdev) { struct station *station; +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif station = l_new(struct station, 1); watchlist_init(&station->state_watches, NULL); @@ -3454,8 +3486,10 @@ static struct station *station_create(struct netdev *netdev) station_set_autoconnect(station, true); +#ifdef HAVE_DBUS l_dbus_object_add_interface(dbus, netdev_get_path(netdev), IWD_STATION_INTERFACE, station); +#endif if (netconfig_enabled) station->netconfig = netconfig_new(netdev_get_ifindex(netdev)); @@ -3663,12 +3697,14 @@ static void station_netdev_watch(struct netdev *netdev, netdev_get_is_up(netdev)) station_create(netdev); break; +#ifdef HAVE_DBUS case NETDEV_WATCH_EVENT_DOWN: case NETDEV_WATCH_EVENT_DEL: l_dbus_object_remove_interface(dbus_get_bus(), netdev_get_path(netdev), IWD_STATION_INTERFACE); break; +#endif default: break; } @@ -3678,6 +3714,7 @@ static int station_init(void) { station_list = l_queue_new(); netdev_watch = netdev_watch_add(station_netdev_watch, NULL, NULL); +#ifdef HAVE_DBUS l_dbus_register_interface(dbus_get_bus(), IWD_STATION_INTERFACE, station_setup_interface, station_destroy_interface, false); @@ -3686,6 +3723,7 @@ static int station_init(void) station_setup_diagnostic_interface, station_destroy_diagnostic_interface, false); +#endif if (!l_settings_get_uint(iwd_get_config(), "General", "ManagementFrameProtection", @@ -3732,9 +3770,11 @@ static int station_init(void) static void station_exit(void) { +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_STATION_DIAGNOSTIC_INTERFACE); l_dbus_unregister_interface(dbus_get_bus(), IWD_STATION_INTERFACE); +#endif netdev_watch_remove(netdev_watch); l_queue_destroy(station_list, NULL); station_list = NULL; diff --git a/src/wiphy.c b/src/wiphy.c @@ -1039,7 +1039,9 @@ static int wiphy_get_permanent_addr_from_sysfs(struct wiphy *wiphy) static void wiphy_register(struct wiphy *wiphy) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif wiphy->soft_rfkill = rfkill_get_soft_state(wiphy->id); wiphy->hard_rfkill = rfkill_get_hard_state(wiphy->id); @@ -1079,6 +1081,7 @@ static void wiphy_register(struct wiphy *wiphy) wiphy_get_driver_name(wiphy); +#ifdef HAVE_DBUS if (!l_dbus_object_add_interface(dbus, wiphy_get_path(wiphy), IWD_WIPHY_INTERFACE, wiphy)) l_info("Unable to add the %s interface to %s", @@ -1089,6 +1092,7 @@ static void wiphy_register(struct wiphy *wiphy) l_info("Unable to add the %s interface to %s", L_DBUS_INTERFACE_PROPERTIES, wiphy_get_path(wiphy)); +#endif wiphy->registered = true; } @@ -1128,12 +1132,14 @@ void wiphy_update_name(struct wiphy *wiphy, const char *name) updated = true; } +#ifdef HAVE_DBUS if (updated && wiphy->registered) { struct l_dbus *dbus = dbus_get_bus(); l_dbus_property_changed(dbus, wiphy_get_path(wiphy), IWD_WIPHY_INTERFACE, "Name"); } +#endif } static void wiphy_set_station_capability_bits(struct wiphy *wiphy) @@ -1280,8 +1286,10 @@ bool wiphy_destroy(struct wiphy *wiphy) if (!l_queue_remove(wiphy_list, wiphy)) return false; +#ifdef HAVE_DBUS if (wiphy->registered) l_dbus_unregister_object(dbus_get_bus(), wiphy_get_path(wiphy)); +#endif wiphy_free(wiphy); return true; @@ -1291,7 +1299,9 @@ static void wiphy_rfkill_cb(unsigned int wiphy_id, bool soft, bool hard, void *user_data) { struct wiphy *wiphy = wiphy_find(wiphy_id); +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); +#endif bool old_powered, new_powered; enum wiphy_state_watch_event event; @@ -1313,8 +1323,10 @@ static void wiphy_rfkill_cb(unsigned int wiphy_id, bool soft, bool hard, WATCHLIST_NOTIFY(&wiphy->state_watches, wiphy_state_watch_func_t, wiphy, event); +#ifdef HAVE_DBUS l_dbus_property_changed(dbus, wiphy_get_path(wiphy), IWD_WIPHY_INTERFACE, "Powered"); +#endif } static bool wiphy_property_get_powered(struct l_dbus *dbus, @@ -1605,12 +1617,14 @@ static int wiphy_init(void) rfkill_watch_add(wiphy_rfkill_cb, NULL); +#ifdef HAVE_DBUS if (!l_dbus_register_interface(dbus_get_bus(), IWD_WIPHY_INTERFACE, setup_wiphy_interface, NULL, false)) l_error("Unable to register the %s interface", IWD_WIPHY_INTERFACE); +#endif hwdb = l_hwdb_new_default(); @@ -1651,7 +1665,9 @@ static void wiphy_exit(void) nl80211 = NULL; mac_randomize_bytes = 6; +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_WIPHY_INTERFACE); +#endif l_hwdb_unref(hwdb); } diff --git a/src/wsc.c b/src/wsc.c @@ -1196,6 +1196,7 @@ static void setup_wsc_interface(struct l_dbus_interface *interface) bool wsc_dbus_add_interface(struct wsc_dbus *wsc) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); if (!l_dbus_object_add_interface(dbus, wsc->get_path(wsc), @@ -1203,16 +1204,19 @@ bool wsc_dbus_add_interface(struct wsc_dbus *wsc) l_info("Unable to register %s interface", IWD_WSC_INTERFACE); return false; } +#endif return true; } void wsc_dbus_remove_interface(struct wsc_dbus *wsc) { +#ifdef HAVE_DBUS struct l_dbus *dbus = dbus_get_bus(); l_dbus_object_remove_interface(dbus, wsc->get_path(wsc), IWD_WSC_INTERFACE); +#endif } static void wsc_dbus_free(void *user_data) @@ -1265,6 +1269,7 @@ static void wsc_netdev_watch(struct netdev *netdev, { switch (event) { case NETDEV_WATCH_EVENT_UP: +#ifdef HAVE_DBUS case NETDEV_WATCH_EVENT_NEW: if (netdev_get_iftype(netdev) == NETDEV_IFTYPE_STATION && netdev_get_is_up(netdev)) @@ -1274,6 +1279,7 @@ static void wsc_netdev_watch(struct netdev *netdev, case NETDEV_WATCH_EVENT_DEL: wsc_remove_station(netdev); break; +#endif default: break; } @@ -1283,16 +1289,20 @@ static int wsc_init(void) { l_debug(""); netdev_watch = netdev_watch_add(wsc_netdev_watch, NULL, NULL); +#ifdef HAVE_DBUS l_dbus_register_interface(dbus_get_bus(), IWD_WSC_INTERFACE, setup_wsc_interface, wsc_dbus_free, false); +#endif return 0; } static void wsc_exit(void) { l_debug(""); +#ifdef HAVE_DBUS l_dbus_unregister_interface(dbus_get_bus(), IWD_WSC_INTERFACE); +#endif netdev_watch_remove(netdev_watch); }