nm-dns-plugin.h 4.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* -*- 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.
 */

19
20
#ifndef __NETWORKMANAGER_DNS_PLUGIN_H__
#define __NETWORKMANAGER_DNS_PLUGIN_H__
21

22
#include "nm-dns-manager.h"
23
24
#include "nm-config-data.h"

25
26
27
28
#define NM_TYPE_DNS_PLUGIN            (nm_dns_plugin_get_type ())
#define NM_DNS_PLUGIN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPlugin))
#define NM_DNS_PLUGIN_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass))
#define NM_IS_DNS_PLUGIN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_DNS_PLUGIN))
29
#define NM_IS_DNS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DNS_PLUGIN))
30
31
32
33
34
#define NM_DNS_PLUGIN_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DNS_PLUGIN, NMDnsPluginClass))

#define NM_DNS_PLUGIN_FAILED "failed"
#define NM_DNS_PLUGIN_CHILD_QUIT "child-quit"

35
36
struct _NMDnsPluginPrivate;

37
38
typedef struct {
	GObject parent;
39
	struct _NMDnsPluginPrivate *_priv;
40
41
42
43
44
45
46
} NMDnsPlugin;

typedef struct {
	GObjectClass parent;

	/* Methods */

47
48
49
50
	/* Called when DNS information is changed.  'configs' is an array
	 * of pointers to NMDnsIPConfigData sorted by priority.
	 * 'global_config' is the optional global DNS
	 * configuration.
51
52
	 */
	gboolean (*update) (NMDnsPlugin *self,
53
	                    const GPtrArray *configs,
54
	                    const NMGlobalDnsConfig *global_config,
55
	                    const char *hostname);
56
57
58
59
60

	/* 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.
	 */
61
62
	gboolean (*is_caching) (NMDnsPlugin *self);

63
64
65
66
67
	/* Subclasses wishing to control interface mDNS status should override. */
	gboolean (*update_mdns) (NMDnsPlugin *self,
	                         int ifindex,
	                         NMSettingConnectionMdns mdns);

68
69
	/* Subclasses should override this and return their plugin name */
	const char *(*get_name) (NMDnsPlugin *self);
70
71
72
73
74
75
76
77
78
79
80
81
82

	/* Signals */

	/* Emitted by the plugin base class when the nameserver subprocess
	 * quits.  This signal is consumed by the plugin subclasses and not
	 * by NMDnsManager.  If the subclass decides the exit status (as returned
	 * by waitpid(2)) is fatal it should then emit the 'failed' signal.
	 */
	void (*child_quit) (NMDnsPlugin *self, gint status);
} NMDnsPluginClass;

GType nm_dns_plugin_get_type (void);

83
84
85
gboolean nm_dns_plugin_is_caching (NMDnsPlugin *self);

const char *nm_dns_plugin_get_name (NMDnsPlugin *self);
86
87

gboolean nm_dns_plugin_update (NMDnsPlugin *self,
88
                               const GPtrArray *configs,
89
                               const NMGlobalDnsConfig *global_config,
90
                               const char *hostname);
91

92
93
94
95
gboolean nm_dns_plugin_update_mdns (NMDnsPlugin *self,
                                    int ifindex,
                                    NMSettingConnectionMdns mdns);

96
97
void nm_dns_plugin_stop (NMDnsPlugin *self);

98
99
100
101
102
103
104
105
106
107
108
109
110
/* For subclasses/plugins */

/* Spawn a child process and watch for it to quit.  'argv' is the NULL-terminated
 * argument vector to spawn the child with, where argv[0] is the full path to
 * the child's executable.  If 'pidfile' is given the process owning the PID
 * contained in 'pidfile' will be killed if its command line matches 'kill_match'
 * and the pidfile will be deleted.
 */
GPid nm_dns_plugin_child_spawn (NMDnsPlugin *self,
                                const char **argv,
                                const char *pidfile,
                                const char *kill_match);

111
112
GPid nm_dns_plugin_child_pid (NMDnsPlugin *self);

113
114
gboolean nm_dns_plugin_child_kill (NMDnsPlugin *self);

115
#endif /* __NETWORKMANAGER_DNS_PLUGIN_H__ */