mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-22 10:46:59 +00:00
build: buld nm-dhcp-manager.c as part of libNetworkMangerBase
NetworkManager and nm-iface-helper compiled nm-dhcp-manager.c twice, the latter with setting -DNM_DHCP_INTERNAL_ONLY to only enable the internal plugin. Change that to compile nm-dhcp-manager.c once for both users by putting it into libNetworkManagerBase.
This commit is contained in:
parent
f9bd72c337
commit
7b73951b1b
12
Makefile.am
12
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 = \
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
Loading…
Reference in a new issue