dns: merge IPv4 and IPv6 versions of add_ip_config() (part 1)
This commit is contained in:
@@ -201,9 +201,16 @@ add_global_config (NMDnsDnsmasq *self, GVariantBuilder *dnsmasq_servers, const N
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
add_ip4_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP4Config *ip4,
|
add_ip_config (NMDnsDnsmasq *self,
|
||||||
const char *iface, gboolean split)
|
GVariantBuilder *servers,
|
||||||
|
NMIPConfig *ip_config,
|
||||||
|
const char *iface,
|
||||||
|
gboolean split)
|
||||||
{
|
{
|
||||||
|
int addr_family = nm_ip_config_get_addr_family (ip_config);
|
||||||
|
|
||||||
|
if (addr_family == AF_INET) {
|
||||||
|
NMIP4Config *ip4 = (NMIP4Config *) ip_config;
|
||||||
char buf[INET_ADDRSTRLEN + 1 + IFNAMSIZ];
|
char buf[INET_ADDRSTRLEN + 1 + IFNAMSIZ];
|
||||||
char buf2[INET_ADDRSTRLEN];
|
char buf2[INET_ADDRSTRLEN];
|
||||||
in_addr_t addr;
|
in_addr_t addr;
|
||||||
@@ -267,14 +274,8 @@ add_ip4_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP4Config *ip4,
|
|||||||
add_dnsmasq_nameserver (self, servers, buf, NULL);
|
add_dnsmasq_nameserver (self, servers, buf, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
return TRUE;
|
NMIP6Config *ip6 = (NMIP6Config *) ip_config;
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6,
|
|
||||||
const char *iface, gboolean split)
|
|
||||||
{
|
|
||||||
const struct in6_addr *addr;
|
const struct in6_addr *addr;
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int nnameservers, i_nameserver, n, i;
|
int nnameservers, i_nameserver, n, i;
|
||||||
@@ -340,6 +341,7 @@ add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@@ -347,20 +349,11 @@ add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6,
|
|||||||
static gboolean
|
static gboolean
|
||||||
add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *data)
|
add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *data)
|
||||||
{
|
{
|
||||||
if (NM_IS_IP4_CONFIG (data->config)) {
|
return add_ip_config (self,
|
||||||
return add_ip4_config (self,
|
|
||||||
servers,
|
servers,
|
||||||
(NMIP4Config *) data->config,
|
data->config,
|
||||||
data->iface,
|
data->iface,
|
||||||
data->type == NM_DNS_IP_CONFIG_TYPE_VPN);
|
data->type == NM_DNS_IP_CONFIG_TYPE_VPN);
|
||||||
} else if (NM_IS_IP6_CONFIG (data->config)) {
|
|
||||||
return add_ip6_config (self,
|
|
||||||
servers,
|
|
||||||
(NMIP6Config *) data->config,
|
|
||||||
data->iface,
|
|
||||||
data->type == NM_DNS_IP_CONFIG_TYPE_VPN);
|
|
||||||
} else
|
|
||||||
g_return_val_if_reached (FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Reference in New Issue
Block a user