dns: remove nm-dns-utils.c and nm-dns-utils.h

The functions in the two files seem to belong to nm-dns-dnsmasq.c as
nobody else is using them.

(cherry picked from commit 6c5a5c9f2a)
This commit is contained in:
Beniamino Galvani 2016-06-03 22:07:45 +02:00 committed by Thomas Haller
parent c3c2ed489c
commit 98741c802c
4 changed files with 68 additions and 127 deletions

View file

@ -305,8 +305,6 @@ libNetworkManager_la_SOURCES = \
dns-manager/nm-dns-manager.h \
dns-manager/nm-dns-plugin.c \
dns-manager/nm-dns-plugin.h \
dns-manager/nm-dns-utils.c \
dns-manager/nm-dns-utils.h \
\
dnsmasq-manager/nm-dnsmasq-manager.c \
dnsmasq-manager/nm-dnsmasq-manager.h \

View file

@ -29,10 +29,11 @@
#include <linux/if.h>
#include "nm-dns-dnsmasq.h"
#include "nm-core-internal.h"
#include "nm-platform.h"
#include "nm-utils.h"
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
#include "nm-dns-utils.h"
#include "nm-bus-manager.h"
#include "NetworkManagerUtils.h"
@ -70,6 +71,70 @@ typedef struct {
/*****************************************************************************/
static char **
get_ip4_rdns_domains (NMIP4Config *ip4)
{
char **strv;
GPtrArray *domains = NULL;
int i;
g_return_val_if_fail (ip4 != NULL, NULL);
domains = g_ptr_array_sized_new (5);
for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i);
nm_utils_get_reverse_dns_domains_ip4 (address->address, address->plen, domains);
}
for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) {
const NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i);
nm_utils_get_reverse_dns_domains_ip4 (route->network, route->plen, domains);
}
/* Terminating NULL so we can use g_strfreev() to free it */
g_ptr_array_add (domains, NULL);
/* Free the array and return NULL if the only element was the ending NULL */
strv = (char **) g_ptr_array_free (domains, (domains->len == 1));
return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE);
}
static char **
get_ip6_rdns_domains (NMIP6Config *ip6)
{
char **strv;
GPtrArray *domains = NULL;
int i;
g_return_val_if_fail (ip6 != NULL, NULL);
domains = g_ptr_array_sized_new (5);
for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) {
const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i);
nm_utils_get_reverse_dns_domains_ip6 (&address->address, address->plen, domains);
}
for (i = 0; i < nm_ip6_config_get_num_routes (ip6); i++) {
const NMPlatformIP6Route *route = nm_ip6_config_get_route (ip6, i);
nm_utils_get_reverse_dns_domains_ip6 (&route->network, route->plen, domains);
}
/* Terminating NULL so we can use g_strfreev() to free it */
g_ptr_array_add (domains, NULL);
/* Free the array and return NULL if the only element was the ending NULL */
strv = (char **) g_ptr_array_free (domains, (domains->len == 1));
return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE);
}
static void
add_dnsmasq_nameserver (NMDnsDnsmasq *self,
GVariantBuilder *servers,
@ -139,7 +204,7 @@ add_ip4_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP4Config *ip4,
/* Ensure reverse-DNS works by directing queries for in-addr.arpa
* domains to the split domain's nameserver.
*/
domains = nm_dns_utils_get_ip4_rdns_domains (ip4);
domains = get_ip4_rdns_domains (ip4);
if (domains) {
for (iter = domains; iter && *iter; iter++)
add_dnsmasq_nameserver (self, servers, buf, *iter);
@ -253,7 +318,7 @@ add_ip6_config (NMDnsDnsmasq *self, GVariantBuilder *servers, NMIP6Config *ip6,
/* Ensure reverse-DNS works by directing queries for ip6.arpa
* domains to the split domain's nameserver.
*/
domains = nm_dns_utils_get_ip6_rdns_domains (ip6);
domains = get_ip6_rdns_domains (ip6);
if (domains) {
for (iter = domains; iter && *iter; iter++)
add_dnsmasq_nameserver (self, servers, buf, *iter);

View file

@ -1,92 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
*
*/
#include "nm-default.h"
#include <arpa/inet.h>
#include <string.h>
#include "nm-dns-utils.h"
#include "nm-core-internal.h"
#include "nm-platform.h"
#include "nm-utils.h"
char **
nm_dns_utils_get_ip4_rdns_domains (NMIP4Config *ip4)
{
char **strv;
GPtrArray *domains = NULL;
int i;
g_return_val_if_fail (ip4 != NULL, NULL);
domains = g_ptr_array_sized_new (5);
for (i = 0; i < nm_ip4_config_get_num_addresses (ip4); i++) {
const NMPlatformIP4Address *address = nm_ip4_config_get_address (ip4, i);
nm_utils_get_reverse_dns_domains_ip4 (address->address, address->plen, domains);
}
for (i = 0; i < nm_ip4_config_get_num_routes (ip4); i++) {
const NMPlatformIP4Route *route = nm_ip4_config_get_route (ip4, i);
nm_utils_get_reverse_dns_domains_ip4 (route->network, route->plen, domains);
}
/* Terminating NULL so we can use g_strfreev() to free it */
g_ptr_array_add (domains, NULL);
/* Free the array and return NULL if the only element was the ending NULL */
strv = (char **) g_ptr_array_free (domains, (domains->len == 1));
return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE);
}
char **
nm_dns_utils_get_ip6_rdns_domains (NMIP6Config *ip6)
{
char **strv;
GPtrArray *domains = NULL;
int i;
g_return_val_if_fail (ip6 != NULL, NULL);
domains = g_ptr_array_sized_new (5);
for (i = 0; i < nm_ip6_config_get_num_addresses (ip6); i++) {
const NMPlatformIP6Address *address = nm_ip6_config_get_address (ip6, i);
nm_utils_get_reverse_dns_domains_ip6 (&address->address, address->plen, domains);
}
for (i = 0; i < nm_ip6_config_get_num_routes (ip6); i++) {
const NMPlatformIP6Route *route = nm_ip6_config_get_route (ip6, i);
nm_utils_get_reverse_dns_domains_ip6 (&route->network, route->plen, domains);
}
/* Terminating NULL so we can use g_strfreev() to free it */
g_ptr_array_add (domains, NULL);
/* Free the array and return NULL if the only element was the ending NULL */
strv = (char **) g_ptr_array_free (domains, (domains->len == 1));
return _nm_utils_strv_cleanup (strv, FALSE, FALSE, TRUE);
}

View file

@ -1,30 +0,0 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright (C) 2010 Red Hat, Inc.
*
*/
#ifndef __NETWORKMANAGER_DNS_UTILS_H__
#define __NETWORKMANAGER_DNS_UTILS_H__
#include "nm-ip4-config.h"
#include "nm-ip6-config.h"
char **nm_dns_utils_get_ip4_rdns_domains (NMIP4Config *ip4);
char **nm_dns_utils_get_ip6_rdns_domains (NMIP6Config *ip6);
#endif /* NM_DNS_UTILS_H */