device: renew dhcp leases on awake for software devices
[NetworkManager.git] / src / nm-config.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* NetworkManager -- Network link manager
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  *
18  * Copyright (C) 2011 Red Hat, Inc.
19  * Copyright (C) 2013 Thomas Bechtold <thomasbechtold@jpberlin.de>
20  */
21
22 #ifndef __NETWORKMANAGER_CONFIG_H__
23 #define __NETWORKMANAGER_CONFIG_H__
24
25
26 #include "nm-default.h"
27 #include "nm-config-data.h"
28
29 G_BEGIN_DECLS
30
31 #define NM_TYPE_CONFIG            (nm_config_get_type ())
32 #define NM_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONFIG, NMConfig))
33 #define NM_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass),  NM_TYPE_CONFIG, NMConfigClass))
34 #define NM_IS_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONFIG))
35 #define NM_IS_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),  NM_TYPE_CONFIG))
36 #define NM_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj),  NM_TYPE_CONFIG, NMConfigClass))
37
38 /* Properties */
39 #define NM_CONFIG_CMD_LINE_OPTIONS                  "cmd-line-options"
40 #define NM_CONFIG_ATOMIC_SECTION_PREFIXES           "atomic-section-prefixes"
41
42 /* Signals */
43 #define NM_CONFIG_SIGNAL_CONFIG_CHANGED             "config-changed"
44
45 #define NM_CONFIG_DEFAULT_CONNECTIVITY_INTERVAL 300
46 #define NM_CONFIG_DEFAULT_CONNECTIVITY_RESPONSE "NetworkManager is online" /* NOT LOCALIZED */
47
48 #define NM_CONFIG_KEYFILE_LIST_SEPARATOR ','
49
50 #define NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN                ".intern."
51 #define NM_CONFIG_KEYFILE_GROUPPREFIX_CONNECTION            "connection"
52 #define NM_CONFIG_KEYFILE_GROUPPREFIX_GLOBAL_DNS_DOMAIN     "global-dns-domain-"
53 #define NM_CONFIG_KEYFILE_GROUPPREFIX_TEST_APPEND_STRINGLIST ".test-append-stringlist"
54
55 #define NM_CONFIG_KEYFILE_GROUP_MAIN                        "main"
56 #define NM_CONFIG_KEYFILE_GROUP_LOGGING                     "logging"
57 #define NM_CONFIG_KEYFILE_GROUP_CONNECTIVITY                "connectivity"
58 #define NM_CONFIG_KEYFILE_GROUP_GLOBAL_DNS                  "global-dns"
59 #define NM_CONFIG_KEYFILE_GROUP_CONFIG                      ".config"
60
61 #define NM_CONFIG_KEYFILE_GROUP_KEYFILE                     "keyfile"
62 #define NM_CONFIG_KEYFILE_GROUP_IFUPDOWN                    "ifupdown"
63 #define NM_CONFIG_KEYFILE_GROUP_IFNET                       "ifnet"
64
65 #define NM_CONFIG_KEYFILE_KEY_LOGGING_BACKEND               "backend"
66 #define NM_CONFIG_KEYFILE_KEY_CONFIG_ENABLE                 "enable"
67 #define NM_CONFIG_KEYFILE_KEY_ATOMIC_SECTION_WAS            ".was"
68 #define NM_CONFIG_KEYFILE_KEY_KEYFILE_PATH                  "path"
69 #define NM_CONFIG_KEYFILE_KEY_KEYFILE_UNMANAGED_DEVICES     "unmanaged-devices"
70 #define NM_CONFIG_KEYFILE_KEY_KEYFILE_HOSTNAME              "hostname"
71 #define NM_CONFIG_KEYFILE_KEY_IFNET_AUTO_REFRESH            "auto_refresh"
72 #define NM_CONFIG_KEYFILE_KEY_IFNET_MANAGED                 "managed"
73 #define NM_CONFIG_KEYFILE_KEY_IFUPDOWN_MANAGED              "managed"
74 #define NM_CONFIG_KEYFILE_KEY_AUDIT                         "audit"
75
76 #define NM_CONFIG_KEYFILE_KEYPREFIX_WAS                     ".was."
77 #define NM_CONFIG_KEYFILE_KEYPREFIX_SET                     ".set."
78
79 #define NM_CONFIG_KEYFILE_GROUP_INTERN_GLOBAL_DNS \
80         NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN NM_CONFIG_KEYFILE_GROUP_GLOBAL_DNS
81 #define NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN_GLOBAL_DNS_DOMAIN \
82         NM_CONFIG_KEYFILE_GROUPPREFIX_INTERN NM_CONFIG_KEYFILE_GROUPPREFIX_GLOBAL_DNS_DOMAIN
83
84 typedef struct NMConfigCmdLineOptions NMConfigCmdLineOptions;
85
86 struct _NMConfig {
87         GObject parent;
88 };
89
90 typedef struct {
91         GObjectClass parent;
92 } NMConfigClass;
93
94 GType nm_config_get_type (void);
95
96 NMConfig *nm_config_get (void);
97
98 const char *nm_config_change_flags_to_string (NMConfigChangeFlags flags, char *buf, gsize len);
99
100 NMConfigData *nm_config_get_data (NMConfig *config);
101 NMConfigData *nm_config_get_data_orig (NMConfig *config);
102
103 #define NM_CONFIG_GET_DATA      (nm_config_get_data (nm_config_get ()))
104 #define NM_CONFIG_GET_DATA_ORIG (nm_config_get_data_orig (nm_config_get ()))
105
106 const char **nm_config_get_plugins (NMConfig *config);
107 gboolean nm_config_get_monitor_connection_files (NMConfig *config);
108 gboolean nm_config_get_auth_polkit (NMConfig *config);
109 const char *nm_config_get_dhcp_client (NMConfig *config);
110 const char *nm_config_get_log_level (NMConfig *config);
111 const char *nm_config_get_log_domains (NMConfig *config);
112 const char *nm_config_get_debug (NMConfig *config);
113 gboolean nm_config_get_configure_and_quit (NMConfig *config);
114 gboolean nm_config_get_is_debug (NMConfig *config);
115
116 void nm_config_set_values (NMConfig *self,
117                            GKeyFile *keyfile_intern_new,
118                            gboolean allow_write,
119                            gboolean force_rewrite);
120
121 /* for main.c only */
122 NMConfigCmdLineOptions *nm_config_cmd_line_options_new (void);
123 void                    nm_config_cmd_line_options_free (NMConfigCmdLineOptions *cli);
124 void                    nm_config_cmd_line_options_add_to_entries (NMConfigCmdLineOptions *cli,
125                                                                    GOptionContext *opt_ctx);
126
127 gboolean nm_config_get_no_auto_default_for_device (NMConfig *config, NMDevice *device);
128 void nm_config_set_no_auto_default_for_device  (NMConfig *config, NMDevice *device);
129
130 NMConfig *nm_config_new (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes, GError **error);
131 NMConfig *nm_config_setup (const NMConfigCmdLineOptions *cli, char **atomic_section_prefixes, GError **error);
132 void nm_config_reload (NMConfig *config, int signal);
133
134 gint nm_config_parse_boolean (const char *str, gint default_value);
135
136 GKeyFile *nm_config_create_keyfile (void);
137 gint nm_config_keyfile_get_boolean (GKeyFile *keyfile,
138                                     const char *section,
139                                     const char *key,
140                                     gint default_value);
141 char *nm_config_keyfile_get_value (GKeyFile *keyfile,
142                                    const char *section,
143                                    const char *key,
144                                    NMConfigGetValueFlags flags);
145 void nm_config_keyfile_set_string_list (GKeyFile *keyfile,
146                                         const char *group,
147                                         const char *key,
148                                         const char *const* strv,
149                                         gssize len);
150 gboolean nm_config_keyfile_has_global_dns_config (GKeyFile *keyfile, gboolean internal);
151
152 GSList *nm_config_get_match_spec (const GKeyFile *keyfile, const char *group, const char *key, gboolean *out_has_key);
153
154 void _nm_config_sort_groups (char **groups, gsize ngroups);
155
156 gboolean nm_config_set_global_dns (NMConfig *self, NMGlobalDnsConfig *global_dns, GError **error);
157
158 /* internal defines ... */
159 extern guint _nm_config_match_nm_version;
160 extern char *_nm_config_match_env;
161
162 G_END_DECLS
163
164 #endif /* __NETWORKMANAGER_CONFIG_H__ */
165