device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-core / nm-setting-ip-config.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library 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 GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2007 - 2014 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #ifndef NM_SETTING_IP_CONFIG_H
24 #define NM_SETTING_IP_CONFIG_H
25
26 #if !defined (__NETWORKMANAGER_H_INSIDE__) && !defined (NETWORKMANAGER_COMPILATION)
27 #error "Only <NetworkManager.h> can be included directly."
28 #endif
29
30 #include "nm-setting.h"
31
32 G_BEGIN_DECLS
33
34 typedef struct NMIPAddress NMIPAddress;
35
36 GType        nm_ip_address_get_type            (void);
37
38 NMIPAddress *nm_ip_address_new                 (int family,
39                                                 const char  *addr,
40                                                 guint prefix,
41                                                 GError **error);
42 NMIPAddress *nm_ip_address_new_binary          (int family,
43                                                 gconstpointer addr,
44                                                 guint prefix,
45                                                 GError **error);
46
47 void         nm_ip_address_ref                 (NMIPAddress *address);
48 void         nm_ip_address_unref               (NMIPAddress *address);
49 gboolean     nm_ip_address_equal               (NMIPAddress *address,
50                                                 NMIPAddress *other);
51 NMIPAddress *nm_ip_address_dup                 (NMIPAddress *address);
52
53 int          nm_ip_address_get_family          (NMIPAddress *address);
54 const char  *nm_ip_address_get_address         (NMIPAddress *address);
55 void         nm_ip_address_set_address         (NMIPAddress *address,
56                                                 const char *addr);
57 void         nm_ip_address_get_address_binary  (NMIPAddress *address,
58                                                 gpointer addr);
59 void         nm_ip_address_set_address_binary  (NMIPAddress *address,
60                                                 gconstpointer addr);
61 guint        nm_ip_address_get_prefix          (NMIPAddress *address);
62 void         nm_ip_address_set_prefix          (NMIPAddress *address,
63                                                 guint prefix);
64
65 char       **nm_ip_address_get_attribute_names (NMIPAddress *address);
66 GVariant    *nm_ip_address_get_attribute       (NMIPAddress *address,
67                                                 const char  *name);
68 void         nm_ip_address_set_attribute       (NMIPAddress *address,
69                                                 const char  *name,
70                                                 GVariant    *value);
71
72
73 typedef struct NMIPRoute NMIPRoute;
74
75 GType        nm_ip_route_get_type            (void);
76
77 NMIPRoute   *nm_ip_route_new                 (int family,
78                                               const char *dest,
79                                               guint prefix,
80                                               const char *next_hop,
81                                               gint64 metric,
82                                               GError **error);
83 NMIPRoute   *nm_ip_route_new_binary          (int family,
84                                               gconstpointer dest,
85                                               guint prefix,
86                                               gconstpointer next_hop,
87                                               gint64 metric,
88                                               GError **error);
89
90 void         nm_ip_route_ref                 (NMIPRoute  *route);
91 void         nm_ip_route_unref               (NMIPRoute  *route);
92 gboolean     nm_ip_route_equal               (NMIPRoute  *route,
93                                               NMIPRoute  *other);
94 NMIPRoute   *nm_ip_route_dup                 (NMIPRoute  *route);
95
96 int          nm_ip_route_get_family          (NMIPRoute  *route);
97 const char  *nm_ip_route_get_dest            (NMIPRoute  *route);
98 void         nm_ip_route_set_dest            (NMIPRoute  *route,
99                                               const char *dest);
100 void         nm_ip_route_get_dest_binary     (NMIPRoute  *route,
101                                               gpointer dest);
102 void         nm_ip_route_set_dest_binary     (NMIPRoute  *route,
103                                               gconstpointer dest);
104 guint        nm_ip_route_get_prefix          (NMIPRoute  *route);
105 void         nm_ip_route_set_prefix          (NMIPRoute  *route,
106                                               guint prefix);
107 const char  *nm_ip_route_get_next_hop        (NMIPRoute  *route);
108 void         nm_ip_route_set_next_hop        (NMIPRoute  *route,
109                                               const char *next_hop);
110 gboolean     nm_ip_route_get_next_hop_binary (NMIPRoute  *route,
111                                               gpointer next_hop);
112 void         nm_ip_route_set_next_hop_binary (NMIPRoute  *route,
113                                               gconstpointer next_hop);
114 gint64       nm_ip_route_get_metric          (NMIPRoute  *route);
115 void         nm_ip_route_set_metric          (NMIPRoute  *route,
116                                               gint64 metric);
117
118 char       **nm_ip_route_get_attribute_names (NMIPRoute   *route);
119 GVariant    *nm_ip_route_get_attribute       (NMIPRoute   *route,
120                                               const char  *name);
121 void         nm_ip_route_set_attribute       (NMIPRoute   *route,
122                                               const char  *name,
123                                               GVariant    *value);
124
125
126 #define NM_TYPE_SETTING_IP_CONFIG            (nm_setting_ip_config_get_type ())
127 #define NM_SETTING_IP_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP_CONFIG, NMSettingIPConfig))
128 #define NM_SETTING_IP_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IPCONFIG, NMSettingIPConfigClass))
129 #define NM_IS_SETTING_IP_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_IP_CONFIG))
130 #define NM_IS_SETTING_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_IP_CONFIG))
131 #define NM_SETTING_IP_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_IP_CONFIG, NMSettingIPConfigClass))
132
133 #define NM_SETTING_IP_CONFIG_DAD_TIMEOUT_MAX     30000
134
135 #define NM_SETTING_IP_CONFIG_METHOD             "method"
136 #define NM_SETTING_IP_CONFIG_DNS                "dns"
137 #define NM_SETTING_IP_CONFIG_DNS_SEARCH         "dns-search"
138 #define NM_SETTING_IP_CONFIG_DNS_OPTIONS        "dns-options"
139 #define NM_SETTING_IP_CONFIG_ADDRESSES          "addresses"
140 #define NM_SETTING_IP_CONFIG_GATEWAY            "gateway"
141 #define NM_SETTING_IP_CONFIG_ROUTES             "routes"
142 #define NM_SETTING_IP_CONFIG_ROUTE_METRIC       "route-metric"
143 #define NM_SETTING_IP_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
144 #define NM_SETTING_IP_CONFIG_IGNORE_AUTO_DNS    "ignore-auto-dns"
145 #define NM_SETTING_IP_CONFIG_DHCP_HOSTNAME      "dhcp-hostname"
146 #define NM_SETTING_IP_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
147 #define NM_SETTING_IP_CONFIG_NEVER_DEFAULT      "never-default"
148 #define NM_SETTING_IP_CONFIG_MAY_FAIL           "may-fail"
149 #define NM_SETTING_IP_CONFIG_DAD_TIMEOUT        "dad-timeout"
150 #define NM_SETTING_IP_CONFIG_DHCP_TIMEOUT       "dhcp-timeout"
151
152 #define NM_SETTING_DNS_OPTION_DEBUG                     "debug"
153 #define NM_SETTING_DNS_OPTION_NDOTS                     "ndots"
154 #define NM_SETTING_DNS_OPTION_TIMEOUT                   "timeout"
155 #define NM_SETTING_DNS_OPTION_ATTEMPTS                  "attempts"
156 #define NM_SETTING_DNS_OPTION_ROTATE                    "rotate"
157 #define NM_SETTING_DNS_OPTION_NO_CHECK_NAMES            "no-check-names"
158 #define NM_SETTING_DNS_OPTION_INET6                     "inet6"
159 #define NM_SETTING_DNS_OPTION_IP6_BYTESTRING            "ip6-bytestring"
160 #define NM_SETTING_DNS_OPTION_IP6_DOTINT                "ip6-dotint"
161 #define NM_SETTING_DNS_OPTION_NO_IP6_DOTINT             "no-ip6-dotint"
162 #define NM_SETTING_DNS_OPTION_EDNS0                     "edns0"
163 #define NM_SETTING_DNS_OPTION_SINGLE_REQUEST            "single-request"
164 #define NM_SETTING_DNS_OPTION_SINGLE_REQUEST_REOPEN     "single-request-reopen"
165 #define NM_SETTING_DNS_OPTION_NO_TLD_QUERY              "no-tld-query"
166
167 struct _NMSettingIPConfig {
168         NMSetting parent;
169 };
170
171 typedef struct {
172         NMSettingClass parent;
173
174         /* Padding for future expansion */
175         gpointer padding[8];
176 } NMSettingIPConfigClass;
177
178 GType nm_setting_ip_config_get_type (void);
179
180 const char   *nm_setting_ip_config_get_method                 (NMSettingIPConfig *setting);
181
182 guint         nm_setting_ip_config_get_num_dns                (NMSettingIPConfig *setting);
183 const char   *nm_setting_ip_config_get_dns                    (NMSettingIPConfig *setting,
184                                                                int                idx);
185 gboolean      nm_setting_ip_config_add_dns                    (NMSettingIPConfig *setting,
186                                                                const char        *dns);
187 void          nm_setting_ip_config_remove_dns                 (NMSettingIPConfig *setting,
188                                                                int                idx);
189 gboolean      nm_setting_ip_config_remove_dns_by_value        (NMSettingIPConfig *setting,
190                                                                const char        *dns);
191 void          nm_setting_ip_config_clear_dns                  (NMSettingIPConfig *setting);
192
193 guint         nm_setting_ip_config_get_num_dns_searches       (NMSettingIPConfig *setting);
194 const char   *nm_setting_ip_config_get_dns_search             (NMSettingIPConfig *setting,
195                                                                int                idx);
196 gboolean      nm_setting_ip_config_add_dns_search             (NMSettingIPConfig *setting,
197                                                                const char        *dns_search);
198 void          nm_setting_ip_config_remove_dns_search          (NMSettingIPConfig *setting,
199                                                                int                idx);
200 gboolean      nm_setting_ip_config_remove_dns_search_by_value (NMSettingIPConfig *setting,
201                                                                const char        *dns_search);
202 void          nm_setting_ip_config_clear_dns_searches         (NMSettingIPConfig *setting);
203
204 guint         nm_setting_ip_config_get_num_dns_options        (NMSettingIPConfig *setting);
205 gboolean      nm_setting_ip_config_has_dns_options            (NMSettingIPConfig *setting);
206 const char   *nm_setting_ip_config_get_dns_option             (NMSettingIPConfig *setting,
207                                                                guint              idx);
208 gint          nm_setting_ip_config_next_valid_dns_option      (NMSettingIPConfig *setting,
209                                                                guint              idx);
210 gboolean      nm_setting_ip_config_add_dns_option             (NMSettingIPConfig *setting,
211                                                                const char        *dns_option);
212 void          nm_setting_ip_config_remove_dns_option          (NMSettingIPConfig *setting,
213                                                                int                idx);
214 gboolean      nm_setting_ip_config_remove_dns_option_by_value (NMSettingIPConfig *setting,
215                                                                const char        *dns_option);
216 void          nm_setting_ip_config_clear_dns_options          (NMSettingIPConfig *setting, gboolean is_set);
217
218 guint         nm_setting_ip_config_get_num_addresses          (NMSettingIPConfig *setting);
219 NMIPAddress  *nm_setting_ip_config_get_address                (NMSettingIPConfig *setting,
220                                                                int                idx);
221 gboolean      nm_setting_ip_config_add_address                (NMSettingIPConfig *setting,
222                                                                NMIPAddress       *address);
223 void          nm_setting_ip_config_remove_address             (NMSettingIPConfig *setting,
224                                                                int                idx);
225 gboolean      nm_setting_ip_config_remove_address_by_value    (NMSettingIPConfig *setting,
226                                                                NMIPAddress       *address);
227 void          nm_setting_ip_config_clear_addresses            (NMSettingIPConfig *setting);
228
229 const char   *nm_setting_ip_config_get_gateway                (NMSettingIPConfig *setting);
230
231 guint         nm_setting_ip_config_get_num_routes             (NMSettingIPConfig *setting);
232 NMIPRoute    *nm_setting_ip_config_get_route                  (NMSettingIPConfig *setting,
233                                                                int                idx);
234 gboolean      nm_setting_ip_config_add_route                  (NMSettingIPConfig *setting,
235                                                                NMIPRoute         *route);
236 void          nm_setting_ip_config_remove_route               (NMSettingIPConfig *setting,
237                                                                int                idx);
238 gboolean      nm_setting_ip_config_remove_route_by_value      (NMSettingIPConfig *setting,
239                                                                NMIPRoute         *route);
240 void          nm_setting_ip_config_clear_routes               (NMSettingIPConfig *setting);
241
242 gint64        nm_setting_ip_config_get_route_metric           (NMSettingIPConfig *setting);
243
244 gboolean      nm_setting_ip_config_get_ignore_auto_routes     (NMSettingIPConfig *setting);
245 gboolean      nm_setting_ip_config_get_ignore_auto_dns        (NMSettingIPConfig *setting);
246
247 const char   *nm_setting_ip_config_get_dhcp_hostname          (NMSettingIPConfig *setting);
248 gboolean      nm_setting_ip_config_get_dhcp_send_hostname     (NMSettingIPConfig *setting);
249
250 gboolean      nm_setting_ip_config_get_never_default          (NMSettingIPConfig *setting);
251 gboolean      nm_setting_ip_config_get_may_fail               (NMSettingIPConfig *setting);
252 NM_AVAILABLE_IN_1_2
253 gint          nm_setting_ip_config_get_dad_timeout            (NMSettingIPConfig *setting);
254 NM_AVAILABLE_IN_1_2
255 gint          nm_setting_ip_config_get_dhcp_timeout           (NMSettingIPConfig *setting);
256
257 G_END_DECLS
258
259 #endif /* NM_SETTING_IP_CONFIG_H */