device: renew dhcp leases on awake for software devices
[NetworkManager.git] / src / nm-ip6-config.h
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2 /* NetworkManager
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) 2008–2013 Red Hat, Inc.
19  */
20
21 #ifndef __NETWORKMANAGER_IP6_CONFIG_H__
22 #define __NETWORKMANAGER_IP6_CONFIG_H__
23
24 #include <netinet/in.h>
25
26 #include "nm-exported-object.h"
27 #include "nm-setting-ip6-config.h"
28
29 #define NM_TYPE_IP6_CONFIG (nm_ip6_config_get_type ())
30 #define NM_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP6_CONFIG, NMIP6Config))
31 #define NM_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass))
32 #define NM_IS_IP6_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP6_CONFIG))
33 #define NM_IS_IP6_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP6_CONFIG))
34 #define NM_IP6_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP6_CONFIG, NMIP6ConfigClass))
35
36 struct _NMIP6ConfigPrivate;
37
38 struct _NMIP6Config {
39         NMExportedObject parent;
40
41         /* private */
42         struct _NMIP6ConfigPrivate *priv;
43 };
44
45 typedef struct {
46         NMExportedObjectClass parent;
47 } NMIP6ConfigClass;
48
49 /* internal */
50 #define NM_IP6_CONFIG_IFINDEX "ifindex"
51
52 /* public */
53 #define NM_IP6_CONFIG_ADDRESS_DATA "address-data"
54 #define NM_IP6_CONFIG_ROUTE_DATA "route-data"
55 #define NM_IP6_CONFIG_GATEWAY "gateway"
56 #define NM_IP6_CONFIG_NAMESERVERS "nameservers"
57 #define NM_IP6_CONFIG_DOMAINS "domains"
58 #define NM_IP6_CONFIG_SEARCHES "searches"
59 #define NM_IP6_CONFIG_DNS_OPTIONS "dns-options"
60
61 /* deprecated */
62 #define NM_IP6_CONFIG_ADDRESSES "addresses"
63 #define NM_IP6_CONFIG_ROUTES "routes"
64
65 GType nm_ip6_config_get_type (void);
66
67
68 NMIP6Config * nm_ip6_config_new (int ifindex);
69 NMIP6Config * nm_ip6_config_new_cloned (const NMIP6Config *src);
70
71 int nm_ip6_config_get_ifindex (const NMIP6Config *config);
72
73 /* Integration with nm-platform and nm-setting */
74 NMIP6Config *nm_ip6_config_capture (int ifindex, gboolean capture_resolv_conf, NMSettingIP6ConfigPrivacy use_temporary);
75 gboolean nm_ip6_config_commit (const NMIP6Config *config, int ifindex, gboolean routes_full_sync);
76 void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIPConfig *setting, guint32 default_route_metric);
77 NMSetting *nm_ip6_config_create_setting (const NMIP6Config *config);
78
79 /* Utility functions */
80 void nm_ip6_config_merge (NMIP6Config *dst, const NMIP6Config *src, NMIPConfigMergeFlags merge_flags);
81 void nm_ip6_config_subtract (NMIP6Config *dst, const NMIP6Config *src);
82 void nm_ip6_config_intersect (NMIP6Config *dst, const NMIP6Config *src);
83 gboolean nm_ip6_config_replace (NMIP6Config *dst, const NMIP6Config *src, gboolean *relevant_changes);
84 int nm_ip6_config_destination_is_direct (const NMIP6Config *config, const struct in6_addr *dest, int plen);
85 void nm_ip6_config_dump (const NMIP6Config *config, const char *detail);
86
87 /* Gateways */
88 void nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default);
89 gboolean nm_ip6_config_get_never_default (const NMIP6Config *config);
90 void nm_ip6_config_set_gateway (NMIP6Config *config, const struct in6_addr *);
91 const struct in6_addr *nm_ip6_config_get_gateway (const NMIP6Config *config);
92 gint64 nm_ip6_config_get_route_metric (const NMIP6Config *config);
93
94 /* Addresses */
95 void nm_ip6_config_reset_addresses (NMIP6Config *config);
96 void nm_ip6_config_add_address (NMIP6Config *config, const NMPlatformIP6Address *address);
97 void nm_ip6_config_del_address (NMIP6Config *config, guint i);
98 guint nm_ip6_config_get_num_addresses (const NMIP6Config *config);
99 const NMPlatformIP6Address *nm_ip6_config_get_address (const NMIP6Config *config, guint i);
100 const NMPlatformIP6Address *nm_ip6_config_get_address_first_nontentative (const NMIP6Config *config, gboolean linklocal);
101 gboolean nm_ip6_config_address_exists (const NMIP6Config *config, const NMPlatformIP6Address *address);
102 gboolean nm_ip6_config_addresses_sort (NMIP6Config *config, NMSettingIP6ConfigPrivacy use_temporary);
103
104 /* Routes */
105 void nm_ip6_config_reset_routes (NMIP6Config *config);
106 void nm_ip6_config_add_route (NMIP6Config *config, const NMPlatformIP6Route *route);
107 void nm_ip6_config_del_route (NMIP6Config *config, guint i);
108 guint32 nm_ip6_config_get_num_routes (const NMIP6Config *config);
109 const NMPlatformIP6Route *nm_ip6_config_get_route (const NMIP6Config *config, guint32 i);
110
111 const NMPlatformIP6Route *nm_ip6_config_get_direct_route_for_host (const NMIP6Config *config, const struct in6_addr *host);
112 const NMPlatformIP6Address *nm_ip6_config_get_subnet_for_host (const NMIP6Config *config, const struct in6_addr *host);
113
114 /* Nameservers */
115 void nm_ip6_config_reset_nameservers (NMIP6Config *config);
116 void nm_ip6_config_add_nameserver (NMIP6Config *config, const struct in6_addr *nameserver);
117 void nm_ip6_config_del_nameserver (NMIP6Config *config, guint i);
118 guint32 nm_ip6_config_get_num_nameservers (const NMIP6Config *config);
119 const struct in6_addr *nm_ip6_config_get_nameserver (const NMIP6Config *config, guint i);
120
121 /* Domains */
122 void nm_ip6_config_reset_domains (NMIP6Config *config);
123 void nm_ip6_config_add_domain (NMIP6Config *config, const char *domain);
124 void nm_ip6_config_del_domain (NMIP6Config *config, guint i);
125 guint32 nm_ip6_config_get_num_domains (const NMIP6Config *config);
126 const char * nm_ip6_config_get_domain (const NMIP6Config *config, guint i);
127
128 /* Search lists */
129 void nm_ip6_config_reset_searches (NMIP6Config *config);
130 void nm_ip6_config_add_search (NMIP6Config *config, const char *search);
131 void nm_ip6_config_del_search (NMIP6Config *config, guint i);
132 guint32 nm_ip6_config_get_num_searches (const NMIP6Config *config);
133 const char * nm_ip6_config_get_search (const NMIP6Config *config, guint i);
134
135 /* DNS options */
136 void nm_ip6_config_reset_dns_options (NMIP6Config *config);
137 void nm_ip6_config_add_dns_option (NMIP6Config *config, const char *option);
138 void nm_ip6_config_del_dns_option (NMIP6Config *config, guint i);
139 guint32 nm_ip6_config_get_num_dns_options (const NMIP6Config *config);
140 const char * nm_ip6_config_get_dns_option (const NMIP6Config *config, guint i);
141
142 /* MSS */
143 void nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss);
144 guint32 nm_ip6_config_get_mss (const NMIP6Config *config);
145
146 void nm_ip6_config_hash (const NMIP6Config *config, GChecksum *sum, gboolean dns_only);
147 gboolean nm_ip6_config_equal (const NMIP6Config *a, const NMIP6Config *b);
148
149 /******************************************************/
150 /* Testing-only functions */
151
152 gboolean nm_ip6_config_capture_resolv_conf (GArray *nameservers,
153                                             GPtrArray *dns_options,
154                                             const char *rc_contents);
155
156 #endif /* __NETWORKMANAGER_IP6_CONFIG_H__ */