diff --git a/src/dns/nm-dns-dnsmasq.c b/src/dns/nm-dns-dnsmasq.c index b2f5875dcc..c57522bf87 100644 --- a/src/dns/nm-dns-dnsmasq.c +++ b/src/dns/nm-dns-dnsmasq.c @@ -425,20 +425,6 @@ child_quit (NMDnsPlugin *plugin, int status) /*****************************************************************************/ -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "dnsmasq"; -} - -/*****************************************************************************/ - static void nm_dns_dnsmasq_init (NMDnsDnsmasq *self) { @@ -473,8 +459,8 @@ nm_dns_dnsmasq_class_init (NMDnsDnsmasqClass *dns_class) object_class->dispose = dispose; - plugin_class->child_quit = child_quit; - plugin_class->is_caching = is_caching; - plugin_class->update = update; - plugin_class->get_name = get_name; + plugin_class->plugin_name = "dnsmasq"; + plugin_class->is_caching = TRUE; + plugin_class->child_quit = child_quit; + plugin_class->update = update; } diff --git a/src/dns/nm-dns-plugin.c b/src/dns/nm-dns-plugin.c index 8082c15f65..62488a454e 100644 --- a/src/dns/nm-dns-plugin.c +++ b/src/dns/nm-dns-plugin.c @@ -74,23 +74,22 @@ nm_dns_plugin_update (NMDnsPlugin *self, hostname); } -static gboolean -is_caching (NMDnsPlugin *self) -{ - return FALSE; -} - gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self) { - return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching (self); + return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching; } const char * nm_dns_plugin_get_name (NMDnsPlugin *self) { - g_assert (NM_DNS_PLUGIN_GET_CLASS (self)->get_name); - return NM_DNS_PLUGIN_GET_CLASS (self)->get_name (self); + NMDnsPluginClass *klass; + + g_return_val_if_fail (NM_IS_DNS_PLUGIN (self), NULL); + + klass = NM_DNS_PLUGIN_GET_CLASS (self); + nm_assert (klass->plugin_name); + return klass->plugin_name; } /*****************************************************************************/ @@ -275,8 +274,6 @@ nm_dns_plugin_class_init (NMDnsPluginClass *plugin_class) object_class->dispose = dispose; - plugin_class->is_caching = is_caching; - /* Emitted by the plugin and consumed by NMDnsManager when * some error happens with the nameserver subprocess. Causes NM to fall * back to writing out a non-local-caching resolv.conf until the next diff --git a/src/dns/nm-dns-plugin.h b/src/dns/nm-dns-plugin.h index f8c3f9144f..286a4fb196 100644 --- a/src/dns/nm-dns-plugin.h +++ b/src/dns/nm-dns-plugin.h @@ -2,8 +2,8 @@ /* Copyright (C) 2010 Red Hat, Inc. */ -#ifndef __NETWORKMANAGER_DNS_PLUGIN_H__ -#define __NETWORKMANAGER_DNS_PLUGIN_H__ +#ifndef __NM_DNS_PLUGIN_H__ +#define __NM_DNS_PLUGIN_H__ #include "nm-dns-manager.h" #include "nm-config-data.h" @@ -28,8 +28,6 @@ typedef struct { typedef struct { GObjectClass parent; - /* Methods */ - /* Called when DNS information is changed. 'configs' is an array * of pointers to NMDnsIPConfigData sorted by priority. * 'global_config' is the optional global DNS @@ -40,16 +38,7 @@ typedef struct { const CList *ip_config_lst_head, const char *hostname); - /* Subclasses should override and return TRUE if they start a local - * caching nameserver that listens on localhost and would block any - * other local caching nameserver from operating. - */ - gboolean (*is_caching) (NMDnsPlugin *self); - - /* Subclasses should override this and return their plugin name */ - const char *(*get_name) (NMDnsPlugin *self); - - /* Signals */ + const char *plugin_name; /* Emitted by the plugin base class when the nameserver subprocess * quits. This signal is consumed by the plugin subclasses and not @@ -57,6 +46,13 @@ typedef struct { * by waitpid(2)) is fatal it should then emit the 'failed' signal. */ void (*child_quit) (NMDnsPlugin *self, int status); + + /* Types should set to TRUE if they start a local caching nameserver + * that listens on localhost and would block any other local caching + * nameserver from operating. + */ + bool is_caching:1; + } NMDnsPluginClass; GType nm_dns_plugin_get_type (void); @@ -89,4 +85,4 @@ GPid nm_dns_plugin_child_pid (NMDnsPlugin *self); gboolean nm_dns_plugin_child_kill (NMDnsPlugin *self); -#endif /* __NETWORKMANAGER_DNS_PLUGIN_H__ */ +#endif /* __NM_DNS_PLUGIN_H__ */ diff --git a/src/dns/nm-dns-systemd-resolved.c b/src/dns/nm-dns-systemd-resolved.c index 67a6f43301..c9fb773f52 100644 --- a/src/dns/nm-dns-systemd-resolved.c +++ b/src/dns/nm-dns-systemd-resolved.c @@ -388,20 +388,6 @@ update (NMDnsPlugin *plugin, /*****************************************************************************/ -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "systemd-resolved"; -} - -/*****************************************************************************/ - static void name_owner_changed (NMDnsSystemdResolved *self, const char *owner) @@ -553,7 +539,7 @@ nm_dns_systemd_resolved_class_init (NMDnsSystemdResolvedClass *dns_class) object_class->dispose = dispose; - plugin_class->is_caching = is_caching; - plugin_class->update = update; - plugin_class->get_name = get_name; + plugin_class->plugin_name = "systemd-resolved"; + plugin_class->is_caching = TRUE; + plugin_class->update = update; } diff --git a/src/dns/nm-dns-unbound.c b/src/dns/nm-dns-unbound.c index 11f719aa5d..e9515ba351 100644 --- a/src/dns/nm-dns-unbound.c +++ b/src/dns/nm-dns-unbound.c @@ -46,18 +46,6 @@ update (NMDnsPlugin *plugin, return (status == 0); } -static gboolean -is_caching (NMDnsPlugin *plugin) -{ - return TRUE; -} - -static const char * -get_name (NMDnsPlugin *plugin) -{ - return "unbound"; -} - /*****************************************************************************/ static void @@ -76,7 +64,7 @@ nm_dns_unbound_class_init (NMDnsUnboundClass *klass) { NMDnsPluginClass *plugin_class = NM_DNS_PLUGIN_CLASS (klass); - plugin_class->update = update; - plugin_class->is_caching = is_caching; - plugin_class->get_name = get_name; + plugin_class->plugin_name = "unbound"; + plugin_class->is_caching = TRUE; + plugin_class->update = update; }