Commit 62463647 authored by Thomas Haller's avatar Thomas Haller
Browse files

core: replace nm_dns_ip_config_data_get_dns_priority()

Add instead nm_ip_config_get_dns_priority(). If we want to treat NMIP4Config/NMIP6Config
generically, then the accessor should be right there.
parent 10d38a95
......@@ -568,12 +568,14 @@ update (NMDnsPlugin *plugin,
add_global_config (self, &servers, global_config);
else {
for (i = 0; i < configs->len; i++) {
prio = nm_dns_ip_config_data_get_dns_priority (configs->pdata[i]);
const NMDnsIPConfigData *data = configs->pdata[i];
prio = nm_ip_config_get_dns_priority (data->config);
if (i == 0)
first_prio = prio;
else if (first_prio < 0 && first_prio != prio)
break;
add_ip_config_data (self, &servers, configs->pdata[i]);
add_ip_config_data (self, &servers, data);
}
}
......
......@@ -197,19 +197,6 @@ NM_UTILS_LOOKUP_STR_DEFINE_STATIC (_config_type_to_string, NMDnsIPConfigType,
NM_UTILS_LOOKUP_STR_ITEM (NM_DNS_IP_CONFIG_TYPE_VPN, "vpn"),
);
int
nm_dns_ip_config_data_get_dns_priority (const NMDnsIPConfigData *config)
{
g_return_val_if_fail (config, 0);
if (NM_IS_IP4_CONFIG (config->config))
return nm_ip4_config_get_dns_priority (config->config);
else if (NM_IS_IP6_CONFIG (config->config))
return nm_ip6_config_get_dns_priority (config->config);
else
g_return_val_if_reached (0);
}
static NMDnsIPConfigData *
ip_config_data_new (gpointer config, NMDnsIPConfigType type, const char *iface)
{
......@@ -241,8 +228,8 @@ ip_config_data_compare (const NMDnsIPConfigData *a, const NMDnsIPConfigData *b)
{
int a_prio, b_prio;
a_prio = nm_dns_ip_config_data_get_dns_priority (a);
b_prio = nm_dns_ip_config_data_get_dns_priority (b);
a_prio = nm_ip_config_get_dns_priority (a->config);
b_prio = nm_ip_config_get_dns_priority (b->config);
/* Configurations with lower priority value first */
if (a_prio < b_prio)
......@@ -1018,7 +1005,7 @@ _collect_resolv_conf_data (NMDnsManager *self, /* only for logging context, no o
current = configs->pdata[i];
prio = nm_dns_ip_config_data_get_dns_priority (current);
prio = nm_ip_config_get_dns_priority (NM_IP_CONFIG_CAST (current->config));
if (i == 0)
first_prio = prio;
......
......@@ -44,8 +44,6 @@ typedef struct {
char *iface;
} NMDnsIPConfigData;
int nm_dns_ip_config_data_get_dns_priority (const NMDnsIPConfigData *config);
#define NM_TYPE_DNS_MANAGER (nm_dns_manager_get_type ())
#define NM_DNS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NM_TYPE_DNS_MANAGER, NMDnsManager))
#define NM_DNS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NM_TYPE_DNS_MANAGER, NMDnsManagerClass))
......
......@@ -289,14 +289,15 @@ update (NMDnsPlugin *plugin,
int prio, first_prio = 0;
for (i = 0; i < configs->len; i++) {
const NMDnsIPConfigData *data = configs->pdata[i];
gboolean skip = FALSE;
prio = nm_dns_ip_config_data_get_dns_priority (configs->pdata[i]);
prio = nm_ip_config_get_dns_priority (data->config);
if (i == 0)
first_prio = prio;
else if (first_prio < 0 && first_prio != prio)
skip = TRUE;
add_interface_configuration (self, interfaces, configs->pdata[i], skip);
add_interface_configuration (self, interfaces, data, skip);
}
free_pending_updates (self);
......
......@@ -300,4 +300,15 @@ gboolean nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b);
#define NM_IP_CONFIG_CAST(config) ((NMIPConfig *) (config))
#endif
static inline int
nm_ip_config_get_dns_priority (const NMIPConfig *config)
{
if (NM_IS_IP4_CONFIG (config))
return nm_ip4_config_get_dns_priority ((const NMIP4Config *) config);
else if (NM_IS_IP6_CONFIG (config))
return nm_ip6_config_get_dns_priority ((const NMIP6Config *) config);
else
g_return_val_if_reached (0);
}
#endif /* __NETWORKMANAGER_IP4_CONFIG_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment