about summary refs log tree commit diff
path: root/src/dns/nm-dns-plugin.c
blob: c8876f1e6e1667d4e392cbb105e534310b3e3322 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2010 - 2012 Red Hat, Inc.
 */

#include "nm-default.h"

#include "nm-dns-plugin.h"

#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

#include "nm-core-internal.h"
#include "NetworkManagerUtils.h"

/*****************************************************************************/

typedef struct _NMDnsPluginPrivate {
	GPid pid;
	guint watch_id;
	char *progname;
	char *pidfile;
} NMDnsPluginPrivate;

G_DEFINE_ABSTRACT_TYPE (NMDnsPlugin, nm_dns_plugin, G_TYPE_OBJECT)

#define NM_DNS_PLUGIN_GET_PRIVATE(self) _NM_GET_PRIVATE_PTR (self, NMDnsPlugin, NM_IS_DNS_PLUGIN)

/*****************************************************************************/

#define _NMLOG_PREFIX_NAME                "dns-plugin"
#define _NMLOG_DOMAIN                     LOGD_DNS
#define _NMLOG(level, ...) \
    G_STMT_START { \
        const NMLogLevel __level = (level); \
        \
        if (nm_logging_enabled (__level, _NMLOG_DOMAIN)) { \
            char __prefix[20]; \
            const NMDnsPlugin *const __self = (self); \
            \
            _nm_log (__level, _NMLOG_DOMAIN, 0, NULL, NULL, \
                     "%s%s: " _NM_UTILS_MACRO_FIRST (__VA_ARGS__), \
                     _NMLOG_PREFIX_NAME, \
                     (!__self \
                        ? "" \
                        : nm_sprintf_buf (__prefix, "[%p]", __self)) \
                     _NM_UTILS_MACRO_REST (__VA_ARGS__)); \
        } \
    } G_STMT_END

/*****************************************************************************/

gboolean
nm_dns_plugin_update (NMDnsPlugin *self,
                      const NMGlobalDnsConfig *global_config,
                      const CList *ip_config_lst_head,
                      const char *hostname,
                      GError **error)
{
	g_return_val_if_fail (NM_DNS_PLUGIN_GET_CLASS (self)->update != NULL, FALSE);

	return NM_DNS_PLUGIN_GET_CLASS (self)->update (self,
	                                               global_config,
	                                               ip_config_lst_head,
	                                               hostname,
	                                               error);
}

gboolean
nm_dns_plugin_is_caching (NMDnsPlugin *self)
{
	return NM_DNS_PLUGIN_GET_CLASS (self)->is_caching;
}

const char *
nm_dns_plugin_get_name (NMDnsPlugin *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;
}

void
nm_dns_plugin_stop (NMDnsPlugin *self)
{
	NMDnsPluginClass *klass;

	g_return_if_fail (NM_IS_DNS_PLUGIN (self));

	klass = NM_DNS_PLUGIN_GET_CLASS (self);
	if (klass->stop)
		klass->stop (self);
}

/*****************************************************************************/

static void
nm_dns_plugin_init (NMDnsPlugin *self)
{
}

static void
nm_dns_plugin_class_init (NMDnsPluginClass *plugin_class)
{
}