mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 08:00:18 +01:00
dhcp: add client_flags argument to nm_dhcp_manager_start_ip[46]()
This commit is contained in:
parent
b6b38af8aa
commit
4acbb0fdc9
5 changed files with 92 additions and 59 deletions
|
|
@ -9482,6 +9482,7 @@ dhcp4_start(NMDevice *self)
|
|||
nm_connection_get_uuid(connection),
|
||||
nm_device_get_route_table(self, AF_INET),
|
||||
nm_device_get_route_metric(self, AF_INET),
|
||||
NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
nm_setting_ip_config_get_dhcp_send_hostname(s_ip4),
|
||||
nm_setting_ip_config_get_dhcp_hostname(s_ip4),
|
||||
nm_setting_ip4_config_get_dhcp_fqdn(NM_SETTING_IP4_CONFIG(s_ip4)),
|
||||
|
|
@ -9931,6 +9932,8 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
|
|||
nm_connection_get_uuid(connection),
|
||||
nm_device_get_route_table(self, AF_INET6),
|
||||
nm_device_get_route_metric(self, AF_INET6),
|
||||
(priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY
|
||||
: NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
nm_setting_ip_config_get_dhcp_send_hostname(s_ip6),
|
||||
nm_setting_ip_config_get_dhcp_hostname(s_ip6),
|
||||
_prop_get_ipvx_dhcp_hostname_flags(self, AF_INET6),
|
||||
|
|
@ -9941,7 +9944,6 @@ dhcp6_start_with_link_ready(NMDevice *self, NMConnection *connection)
|
|||
iaid_explicit,
|
||||
_prop_get_ipvx_dhcp_timeout(self, AF_INET6),
|
||||
priv->dhcp_anycast_address,
|
||||
(priv->dhcp6.mode == NM_NDISC_DHCP_LEVEL_OTHERCONF) ? TRUE : FALSE,
|
||||
nm_setting_ip6_config_get_ip6_privacy(NM_SETTING_IP6_CONFIG(s_ip6)),
|
||||
priv->dhcp6.needed_prefixes,
|
||||
&error);
|
||||
|
|
|
|||
|
|
@ -1141,6 +1141,24 @@ nm_dhcp_client_init(NMDhcpClient *self)
|
|||
priv->pid = -1;
|
||||
}
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
static void
|
||||
constructed(GObject *object)
|
||||
{
|
||||
NMDhcpClient * self = NM_DHCP_CLIENT(object);
|
||||
NMDhcpClientPrivate *priv = NM_DHCP_CLIENT_GET_PRIVATE(self);
|
||||
|
||||
/* certain flags only make sense with certain address family. Assert
|
||||
* for that. */
|
||||
if (NM_IS_IPv4(priv->addr_family))
|
||||
nm_assert(!NM_FLAGS_ANY(priv->client_flags, NM_DHCP_CLIENT_FLAGS_INFO_ONLY));
|
||||
else
|
||||
nm_assert(NM_FLAGS_HAS(priv->client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN));
|
||||
|
||||
G_OBJECT_CLASS(nm_dhcp_client_parent_class)->constructed(object);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
dispose(GObject *object)
|
||||
{
|
||||
|
|
@ -1179,6 +1197,9 @@ nm_dhcp_client_class_init(NMDhcpClientClass *client_class)
|
|||
|
||||
g_type_class_add_private(client_class, sizeof(NMDhcpClientPrivate));
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
object_class->constructed = constructed;
|
||||
#endif
|
||||
object_class->dispose = dispose;
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
|
|
|
|||
|
|
@ -240,6 +240,7 @@ client_start(NMDhcpManager * self,
|
|||
|| g_bytes_get_size(vendor_class_identifier) <= 255,
|
||||
NULL);
|
||||
g_return_val_if_fail(!error || !*error, NULL);
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags, ~NM_DHCP_CLIENT_FLAGS_ALL));
|
||||
|
||||
if (addr_family == AF_INET) {
|
||||
if (!hwaddr || !bcast_hwaddr) {
|
||||
|
|
@ -406,6 +407,7 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
const char * dhcp_fqdn,
|
||||
|
|
@ -425,6 +427,10 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
gboolean use_fqdn = FALSE;
|
||||
char * dot;
|
||||
|
||||
/* these flags are set automatically/prohibited, and not free to set to the caller. */
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags,
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN | NM_DHCP_CLIENT_FLAGS_INFO_ONLY));
|
||||
|
||||
g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL);
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
|
|
@ -451,33 +457,34 @@ nm_dhcp_manager_start_ip4(NMDhcpManager * self,
|
|||
}
|
||||
}
|
||||
|
||||
return client_start(self,
|
||||
AF_INET,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
NULL,
|
||||
dhcp_client_id,
|
||||
FALSE,
|
||||
0,
|
||||
FALSE,
|
||||
timeout,
|
||||
(use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : NM_DHCP_CLIENT_FLAGS_NONE),
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
0,
|
||||
last_ip_address,
|
||||
0,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
error);
|
||||
return client_start(
|
||||
self,
|
||||
AF_INET,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
hwaddr,
|
||||
bcast_hwaddr,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
NULL,
|
||||
dhcp_client_id,
|
||||
FALSE,
|
||||
0,
|
||||
FALSE,
|
||||
timeout,
|
||||
client_flags | (use_fqdn ? NM_DHCP_CLIENT_FLAGS_USE_FQDN : NM_DHCP_CLIENT_FLAGS_NONE),
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
0,
|
||||
last_ip_address,
|
||||
0,
|
||||
vendor_class_identifier,
|
||||
reject_servers,
|
||||
error);
|
||||
}
|
||||
|
||||
/* Caller owns a reference to the NMDhcpClient on return */
|
||||
|
|
@ -490,6 +497,7 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
|
|
@ -500,7 +508,6 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char * dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
guint needed_prefixes,
|
||||
GError ** error)
|
||||
|
|
@ -508,6 +515,9 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
NMDhcpManagerPrivate *priv;
|
||||
const char * hostname = NULL;
|
||||
|
||||
/* this flag is set automatically, and not free to set to the caller. */
|
||||
nm_assert(!NM_FLAGS_ANY(client_flags, NM_DHCP_CLIENT_FLAGS_USE_FQDN));
|
||||
|
||||
g_return_val_if_fail(NM_IS_DHCP_MANAGER(self), NULL);
|
||||
priv = NM_DHCP_MANAGER_GET_PRIVATE(self);
|
||||
|
||||
|
|
@ -515,35 +525,33 @@ nm_dhcp_manager_start_ip6(NMDhcpManager * self,
|
|||
/* Always prefer the explicit dhcp-hostname if given */
|
||||
hostname = dhcp_hostname ?: priv->default_hostname;
|
||||
}
|
||||
return client_start(
|
||||
self,
|
||||
AF_INET6,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
NULL,
|
||||
NULL,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
ll_addr,
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
iaid_explicit,
|
||||
timeout,
|
||||
NM_DHCP_CLIENT_FLAGS_USE_FQDN
|
||||
| (info_only ? NM_DHCP_CLIENT_FLAGS_INFO_ONLY : NM_DHCP_CLIENT_FLAGS_NONE),
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
privacy,
|
||||
NULL,
|
||||
needed_prefixes,
|
||||
NULL,
|
||||
NULL,
|
||||
error);
|
||||
return client_start(self,
|
||||
AF_INET6,
|
||||
multi_idx,
|
||||
iface,
|
||||
ifindex,
|
||||
NULL,
|
||||
NULL,
|
||||
uuid,
|
||||
route_table,
|
||||
route_metric,
|
||||
ll_addr,
|
||||
duid,
|
||||
enforce_duid,
|
||||
iaid,
|
||||
iaid_explicit,
|
||||
timeout,
|
||||
client_flags | NM_DHCP_CLIENT_FLAGS_USE_FQDN,
|
||||
dhcp_anycast_addr,
|
||||
hostname,
|
||||
hostname_flags,
|
||||
mud_url,
|
||||
privacy,
|
||||
NULL,
|
||||
needed_prefixes,
|
||||
NULL,
|
||||
NULL,
|
||||
error);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ NMDhcpClient *nm_dhcp_manager_start_ip4(NMDhcpManager * manager,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
const char * dhcp_fqdn,
|
||||
|
|
@ -62,6 +63,7 @@ NMDhcpClient *nm_dhcp_manager_start_ip6(NMDhcpManager * manager,
|
|||
const char * uuid,
|
||||
guint32 route_table,
|
||||
guint32 route_metric,
|
||||
NMDhcpClientFlags client_flags,
|
||||
gboolean send_hostname,
|
||||
const char * dhcp_hostname,
|
||||
NMDhcpHostnameFlags hostname_flags,
|
||||
|
|
@ -72,7 +74,6 @@ NMDhcpClient *nm_dhcp_manager_start_ip6(NMDhcpManager * manager,
|
|||
gboolean iaid_explicit,
|
||||
guint32 timeout,
|
||||
const char * dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
guint needed_prefixes,
|
||||
GError ** error);
|
||||
|
|
|
|||
|
|
@ -668,6 +668,7 @@ main(int argc, char *argv[])
|
|||
global_opt.uuid,
|
||||
RT_TABLE_MAIN,
|
||||
global_opt.priority_v4,
|
||||
NM_DHCP_CLIENT_FLAGS_NONE,
|
||||
!!global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_hostname,
|
||||
global_opt.dhcp4_fqdn,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue