diff --git a/Makefile.am b/Makefile.am index 9201259ed7..c3b3f71d60 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1163,6 +1163,8 @@ src_libNetworkManagerBase_la_SOURCES = \ src/dhcp-manager/nm-dhcp-utils.c \ src/dhcp-manager/nm-dhcp-utils.h \ src/dhcp-manager/nm-dhcp-systemd.c \ + src/dhcp-manager/nm-dhcp-manager.c \ + src/dhcp-manager/nm-dhcp-manager.h \ \ src/main-utils.c \ src/main-utils.h \ @@ -1229,8 +1231,6 @@ src_libNetworkManager_la_SOURCES = \ src/devices/nm-device-vxlan.c \ src/devices/nm-device-vxlan.h \ \ - src/dhcp-manager/nm-dhcp-manager.c \ - src/dhcp-manager/nm-dhcp-manager.h \ src/dhcp-manager/nm-dhcp-dhclient.c \ src/dhcp-manager/nm-dhcp-dhcpcd.c \ src/dhcp-manager/nm-dhcp-helper-api.h \ @@ -1405,15 +1405,9 @@ src_NetworkManager_LDFLAGS = \ ############################################################################### -src_nm_iface_helper_CPPFLAGS = \ - $(src_cppflags) \ - -DNM_DHCP_INTERNAL_ONLY +src_nm_iface_helper_CPPFLAGS = $(src_cppflags) src_nm_iface_helper_SOURCES = \ - \ - src/dhcp-manager/nm-dhcp-manager.c \ - src/dhcp-manager/nm-dhcp-manager.h \ - \ src/nm-iface-helper.c src_nm_iface_helper_LDADD = \ diff --git a/src/dhcp-manager/nm-dhcp-listener.c b/src/dhcp-manager/nm-dhcp-listener.c index 5b2e618b2d..56bd9d1768 100644 --- a/src/dhcp-manager/nm-dhcp-listener.c +++ b/src/dhcp-manager/nm-dhcp-listener.c @@ -30,6 +30,7 @@ #include #include "nm-dhcp-helper-api.h" +#include "nm-dhcp-client.h" #include "nm-core-internal.h" #include "nm-bus-manager.h" #include "NetworkManagerUtils.h" @@ -39,6 +40,21 @@ /*****************************************************************************/ +const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3] = { + /* the order here matters, as we will try the plugins in this order to find + * the first available plugin. */ + +#if WITH_DHCLIENT + &_nm_dhcp_client_factory_dhclient, +#endif +#if WITH_DHCPCD + &_nm_dhcp_client_factory_dhcpcd, +#endif + &_nm_dhcp_client_factory_internal, +}; + +/*****************************************************************************/ + typedef struct { NMBusManager * dbus_mgr; gulong new_conn_id; diff --git a/src/dhcp-manager/nm-dhcp-manager.c b/src/dhcp-manager/nm-dhcp-manager.c index 570626dbc7..cc0289c9ab 100644 --- a/src/dhcp-manager/nm-dhcp-manager.c +++ b/src/dhcp-manager/nm-dhcp-manager.c @@ -67,22 +67,6 @@ const char *nm_dhcp_helper_path = LIBEXECDIR "/nm-dhcp-helper"; /*****************************************************************************/ -const NMDhcpClientFactory *const _factories[] = { - - /* the order here matters, as we will try the plugins in this order to find - * the first available plugin. */ - -#ifndef NM_DHCP_INTERNAL_ONLY -#if WITH_DHCLIENT - &_nm_dhcp_client_factory_dhclient, -#endif -#if WITH_DHCPCD - &_nm_dhcp_client_factory_dhcpcd, -#endif -#endif - &_nm_dhcp_client_factory_internal, -}; - static const NMDhcpClientFactory * _client_factory_find_by_name (const char *name) { @@ -90,10 +74,10 @@ _client_factory_find_by_name (const char *name) g_return_val_if_fail (name, NULL); - for (i = 0; i < G_N_ELEMENTS (_factories); i++) { - const NMDhcpClientFactory *f = _factories[i]; + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; - if (nm_streq (f->name, name)) + if (f && nm_streq (f->name, name)) return f; } return NULL; @@ -349,8 +333,11 @@ nm_dhcp_manager_init (NMDhcpManager *self) int i; const NMDhcpClientFactory *client_factory = NULL; - for (i = 0; i < G_N_ELEMENTS (_factories); i++) { - const NMDhcpClientFactory *f = _factories[i]; + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + const NMDhcpClientFactory *f = _nm_dhcp_manager_factories[i]; + + if (!f) + continue; nm_log_dbg (LOGD_DHCP, "dhcp-init: enabled DHCP client '%s' (%s)%s", f->name, g_type_name (f->get_type ()), @@ -370,8 +357,8 @@ nm_dhcp_manager_init (NMDhcpManager *self) nm_log_warn (LOGD_DHCP, "dhcp-init: DHCP client '%s' not available", client); } if (!client_factory) { - for (i = 0; i < G_N_ELEMENTS (_factories); i++) { - client_factory = _client_factory_available (_factories[i]); + for (i = 0; i < G_N_ELEMENTS (_nm_dhcp_manager_factories); i++) { + client_factory = _client_factory_available (_nm_dhcp_manager_factories[i]); if (client_factory) break; } diff --git a/src/dhcp-manager/nm-dhcp-manager.h b/src/dhcp-manager/nm-dhcp-manager.h index 32477a658e..e525180d43 100644 --- a/src/dhcp-manager/nm-dhcp-manager.h +++ b/src/dhcp-manager/nm-dhcp-manager.h @@ -81,4 +81,6 @@ GSList * nm_dhcp_manager_get_lease_ip_configs (NMDhcpManager *self, /* For testing only */ extern const char* nm_dhcp_helper_path; +extern const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3]; + #endif /* __NETWORKMANAGER_DHCP_MANAGER_H__ */ diff --git a/src/nm-iface-helper.c b/src/nm-iface-helper.c index d24c3cd3cd..a64f876126 100644 --- a/src/nm-iface-helper.c +++ b/src/nm-iface-helper.c @@ -546,6 +546,12 @@ main (int argc, char *argv[]) return 0; } +/*****************************************************************************/ + +const NMDhcpClientFactory *const _nm_dhcp_manager_factories[3] = { + &_nm_dhcp_client_factory_internal, +}; + /*****************************************************************************/ /* Stub functions */