device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-util / nm-setting-ip4-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_IP4_CONFIG_H
24 #define NM_SETTING_IP4_CONFIG_H
25
26 #include "nm-setting.h"
27
28 G_BEGIN_DECLS
29
30 #define NM_TYPE_SETTING_IP4_CONFIG            (nm_setting_ip4_config_get_type ())
31 #define NM_SETTING_IP4_CONFIG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4Config))
32 #define NM_SETTING_IP4_CONFIG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IP4CONFIG, NMSettingIP4ConfigClass))
33 #define NM_IS_SETTING_IP4_CONFIG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_SETTING_IP4_CONFIG))
34 #define NM_IS_SETTING_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_SETTING_IP4_CONFIG))
35 #define NM_SETTING_IP4_CONFIG_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_SETTING_IP4_CONFIG, NMSettingIP4ConfigClass))
36
37 #define NM_SETTING_IP4_CONFIG_SETTING_NAME "ipv4"
38
39 /**
40  * NMSettingIP4ConfigError:
41  * @NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN: unknown or unclassified error
42  * @NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY: the property was invalid
43  * @NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY: the property was missing and is
44  * required
45  * @NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD: the property's value is
46  * not valid with the given IP4 method
47  */
48 typedef enum {
49         NM_SETTING_IP4_CONFIG_ERROR_UNKNOWN = 0,           /*< nick=UnknownError >*/
50         NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,      /*< nick=InvalidProperty >*/
51         NM_SETTING_IP4_CONFIG_ERROR_MISSING_PROPERTY,      /*< nick=MissingProperty >*/
52         NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD /*< nick=NotAllowedForMethod >*/
53 } NMSettingIP4ConfigError;
54
55 #define NM_SETTING_IP4_CONFIG_ERROR nm_setting_ip4_config_error_quark ()
56 GQuark nm_setting_ip4_config_error_quark (void);
57
58 #define NM_SETTING_IP4_CONFIG_METHOD             "method"
59 #define NM_SETTING_IP4_CONFIG_DNS                "dns"
60 #define NM_SETTING_IP4_CONFIG_DNS_SEARCH         "dns-search"
61 #define NM_SETTING_IP4_CONFIG_ADDRESSES          "addresses"
62 #define NM_SETTING_IP4_CONFIG_ROUTES             "routes"
63 #define NM_SETTING_IP4_CONFIG_ROUTE_METRIC       "route-metric"
64 #define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES "ignore-auto-routes"
65 #define NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS    "ignore-auto-dns"
66 #define NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID     "dhcp-client-id"
67 #define NM_SETTING_IP4_CONFIG_DHCP_SEND_HOSTNAME "dhcp-send-hostname"
68 #define NM_SETTING_IP4_CONFIG_DHCP_HOSTNAME      "dhcp-hostname"
69 #define NM_SETTING_IP4_CONFIG_DHCP_TIMEOUT       "dhcp-timeout"
70 #define NM_SETTING_IP4_CONFIG_NEVER_DEFAULT      "never-default"
71 #define NM_SETTING_IP4_CONFIG_MAY_FAIL           "may-fail"
72
73 /**
74  * NM_SETTING_IP4_CONFIG_METHOD_AUTO:
75  *
76  * IPv4 configuration should be automatically determined via a method appropriate
77  * for the hardware interface, ie DHCP or PPP or some other device-specific
78  * manner.
79  */
80 #define NM_SETTING_IP4_CONFIG_METHOD_AUTO       "auto"
81
82 /**
83  * NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL:
84  *
85  * IPv4 configuration should be automatically configured for link-local-only
86  * operation.
87  */
88 #define NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL "link-local"
89
90 /**
91  * NM_SETTING_IP4_CONFIG_METHOD_MANUAL:
92  *
93  * All necessary IPv4 configuration (addresses, prefix, DNS, etc) is specified
94  * in the setting's properties.
95  */
96 #define NM_SETTING_IP4_CONFIG_METHOD_MANUAL     "manual"
97
98 /**
99  * NM_SETTING_IP4_CONFIG_METHOD_SHARED:
100  *
101  * This connection specifies configuration that allows other computers to
102  * connect through it to the default network (usually the Internet).  The
103  * connection's interface will be assigned a private address, and a DHCP server,
104  * caching DNS server, and Network Address Translation (NAT) functionality will
105  * be started on this connection's interface to allow other devices to connect
106  * through that interface to the default network.
107  */
108 #define NM_SETTING_IP4_CONFIG_METHOD_SHARED     "shared"
109
110 /**
111  * NM_SETTING_IP4_CONFIG_METHOD_DISABLED:
112  *
113  * This connection does not use or require IPv4 address and it should be disabled.
114  */
115 #define NM_SETTING_IP4_CONFIG_METHOD_DISABLED   "disabled"
116
117 typedef struct NMIP4Address NMIP4Address;
118
119 GType nm_ip4_address_get_type (void);
120
121 NMIP4Address * nm_ip4_address_new         (void);
122 NMIP4Address * nm_ip4_address_dup         (NMIP4Address *source);
123 void           nm_ip4_address_ref         (NMIP4Address *address);
124 void           nm_ip4_address_unref       (NMIP4Address *address);
125 /* Return TRUE if addresses are identical */
126 gboolean       nm_ip4_address_compare     (NMIP4Address *address, NMIP4Address *other);
127
128 guint32        nm_ip4_address_get_address (NMIP4Address *address);
129 void           nm_ip4_address_set_address (NMIP4Address *address,
130                                            guint32 addr);  /* network byte order */
131
132 guint32        nm_ip4_address_get_prefix  (NMIP4Address *address);
133 void           nm_ip4_address_set_prefix  (NMIP4Address *address,
134                                            guint32 prefix);
135
136 guint32        nm_ip4_address_get_gateway (NMIP4Address *address);
137 void           nm_ip4_address_set_gateway (NMIP4Address *address,
138                                            guint32 gateway);  /* network byte order */
139
140 typedef struct NMIP4Route NMIP4Route;
141
142 GType nm_ip4_route_get_type (void);
143
144 NMIP4Route * nm_ip4_route_new          (void);
145 NMIP4Route * nm_ip4_route_dup          (NMIP4Route *source);
146 void         nm_ip4_route_ref          (NMIP4Route *route);
147 void         nm_ip4_route_unref        (NMIP4Route *route);
148 /* Return TRUE if routes are identical */
149 gboolean     nm_ip4_route_compare      (NMIP4Route *route, NMIP4Route *other);
150
151 guint32      nm_ip4_route_get_dest     (NMIP4Route *route);
152 void         nm_ip4_route_set_dest     (NMIP4Route *route,
153                                         guint32 dest);  /* network byte order */
154
155 guint32      nm_ip4_route_get_prefix   (NMIP4Route *route);
156 void         nm_ip4_route_set_prefix   (NMIP4Route *route,
157                                         guint32 prefix);
158
159 guint32      nm_ip4_route_get_next_hop (NMIP4Route *route);
160 void         nm_ip4_route_set_next_hop (NMIP4Route *route,
161                                         guint32 next_hop);  /* network byte order */
162
163 guint32      nm_ip4_route_get_metric   (NMIP4Route *route);
164 void         nm_ip4_route_set_metric   (NMIP4Route *route,
165                                         guint32 metric);
166
167
168 typedef struct {
169         NMSetting parent;
170 } NMSettingIP4Config;
171
172 typedef struct {
173         NMSettingClass parent;
174
175         /* Padding for future expansion */
176         void (*_reserved1) (void);
177         void (*_reserved2) (void);
178         void (*_reserved3) (void);
179         void (*_reserved4) (void);
180 } NMSettingIP4ConfigClass;
181
182 GType nm_setting_ip4_config_get_type (void);
183
184 NMSetting *   nm_setting_ip4_config_new                    (void);
185 const char *  nm_setting_ip4_config_get_method             (NMSettingIP4Config *setting);
186
187 guint32       nm_setting_ip4_config_get_num_dns            (NMSettingIP4Config *setting);
188 guint32       nm_setting_ip4_config_get_dns                (NMSettingIP4Config *setting, guint32 i);
189 gboolean      nm_setting_ip4_config_add_dns                (NMSettingIP4Config *setting, guint32 dns);
190 void          nm_setting_ip4_config_remove_dns             (NMSettingIP4Config *setting, guint32 i);
191 NM_AVAILABLE_IN_0_9_10
192 gboolean      nm_setting_ip4_config_remove_dns_by_value    (NMSettingIP4Config *setting, guint32 dns);
193 void          nm_setting_ip4_config_clear_dns              (NMSettingIP4Config *setting);
194
195 guint32       nm_setting_ip4_config_get_num_dns_searches       (NMSettingIP4Config *setting);
196 const char *  nm_setting_ip4_config_get_dns_search             (NMSettingIP4Config *setting, guint32 i);
197 gboolean      nm_setting_ip4_config_add_dns_search             (NMSettingIP4Config *setting, const char *dns_search);
198 void          nm_setting_ip4_config_remove_dns_search          (NMSettingIP4Config *setting, guint32 i);
199 NM_AVAILABLE_IN_0_9_10
200 gboolean      nm_setting_ip4_config_remove_dns_search_by_value (NMSettingIP4Config *setting, const char *dns_search);
201 void          nm_setting_ip4_config_clear_dns_searches         (NMSettingIP4Config *setting);
202
203 guint32       nm_setting_ip4_config_get_num_addresses       (NMSettingIP4Config *setting);
204 NMIP4Address *nm_setting_ip4_config_get_address             (NMSettingIP4Config *setting, guint32 i);
205 gboolean      nm_setting_ip4_config_add_address             (NMSettingIP4Config *setting, NMIP4Address *address);
206 void          nm_setting_ip4_config_remove_address          (NMSettingIP4Config *setting, guint32 i);
207 NM_AVAILABLE_IN_0_9_10
208 gboolean      nm_setting_ip4_config_remove_address_by_value (NMSettingIP4Config *setting, NMIP4Address *address);
209 void          nm_setting_ip4_config_clear_addresses         (NMSettingIP4Config *setting);
210
211 guint32       nm_setting_ip4_config_get_num_routes         (NMSettingIP4Config *setting);
212 NMIP4Route *  nm_setting_ip4_config_get_route              (NMSettingIP4Config *setting, guint32 i);
213 gboolean      nm_setting_ip4_config_add_route              (NMSettingIP4Config *setting, NMIP4Route *route);
214 void          nm_setting_ip4_config_remove_route           (NMSettingIP4Config *setting, guint32 i);
215 NM_AVAILABLE_IN_0_9_10
216 gboolean      nm_setting_ip4_config_remove_route_by_value  (NMSettingIP4Config *setting, NMIP4Route *route);
217 void          nm_setting_ip4_config_clear_routes           (NMSettingIP4Config *setting);
218
219 NM_AVAILABLE_IN_1_0
220 gint64        nm_setting_ip4_config_get_route_metric       (NMSettingIP4Config *setting);
221
222 gboolean      nm_setting_ip4_config_get_ignore_auto_routes (NMSettingIP4Config *setting);
223 gboolean      nm_setting_ip4_config_get_ignore_auto_dns    (NMSettingIP4Config *setting);
224 const char *  nm_setting_ip4_config_get_dhcp_client_id     (NMSettingIP4Config *setting);
225 gboolean      nm_setting_ip4_config_get_dhcp_send_hostname (NMSettingIP4Config *setting);
226 const char *  nm_setting_ip4_config_get_dhcp_hostname      (NMSettingIP4Config *setting);
227 NM_AVAILABLE_IN_1_2
228 int           nm_setting_ip4_config_get_dhcp_timeout       (NMSettingIP4Config *setting);
229
230 gboolean      nm_setting_ip4_config_get_never_default      (NMSettingIP4Config *setting);
231
232 gboolean      nm_setting_ip4_config_get_may_fail           (NMSettingIP4Config *setting);
233
234 G_END_DECLS
235
236 #endif /* NM_SETTING_IP4_CONFIG_H */