1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
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.
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.
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.
18 * Copyright (C) 2008–2013 Red Hat, Inc.
21 #ifndef __NETWORKMANAGER_IP4_CONFIG_H__
22 #define __NETWORKMANAGER_IP4_CONFIG_H__
24 #include "nm-exported-object.h"
25 #include "nm-setting-ip4-config.h"
27 #define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
28 #define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
29 #define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
30 #define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
31 #define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP4_CONFIG))
32 #define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
34 struct _NMIP4ConfigPrivate;
37 NMExportedObject parent;
40 struct _NMIP4ConfigPrivate *priv;
44 NMExportedObjectClass parent;
48 #define NM_IP4_CONFIG_IFINDEX "ifindex"
51 #define NM_IP4_CONFIG_ADDRESS_DATA "address-data"
52 #define NM_IP4_CONFIG_ROUTE_DATA "route-data"
53 #define NM_IP4_CONFIG_GATEWAY "gateway"
54 #define NM_IP4_CONFIG_NAMESERVERS "nameservers"
55 #define NM_IP4_CONFIG_DOMAINS "domains"
56 #define NM_IP4_CONFIG_SEARCHES "searches"
57 #define NM_IP4_CONFIG_DNS_OPTIONS "dns-options"
58 #define NM_IP4_CONFIG_WINS_SERVERS "wins-servers"
61 #define NM_IP4_CONFIG_ADDRESSES "addresses"
62 #define NM_IP4_CONFIG_ROUTES "routes"
64 GType nm_ip4_config_get_type (void);
67 NMIP4Config * nm_ip4_config_new (int ifindex);
69 int nm_ip4_config_get_ifindex (const NMIP4Config *config);
71 /* Integration with nm-platform and nm-setting */
72 NMIP4Config *nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf);
73 gboolean nm_ip4_config_commit (const NMIP4Config *config, int ifindex, gboolean routes_full_sync, gint64 default_route_metric);
74 void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIPConfig *setting, guint32 default_route_metric);
75 NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config);
77 /* Utility functions */
78 void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src, NMIPConfigMergeFlags merge_flags);
79 void nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src);
80 void nm_ip4_config_intersect (NMIP4Config *dst, const NMIP4Config *src);
81 gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
82 gboolean nm_ip4_config_destination_is_direct (const NMIP4Config *config, guint32 dest, int plen);
83 void nm_ip4_config_dump (const NMIP4Config *config, const char *detail);
86 void nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default);
87 gboolean nm_ip4_config_get_never_default (const NMIP4Config *config);
88 void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway);
89 void nm_ip4_config_unset_gateway (NMIP4Config *config);
90 gboolean nm_ip4_config_has_gateway (const NMIP4Config *config);
91 guint32 nm_ip4_config_get_gateway (const NMIP4Config *config);
92 gint64 nm_ip4_config_get_route_metric (const NMIP4Config *config);
95 void nm_ip4_config_reset_addresses (NMIP4Config *config);
96 void nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *address);
97 void nm_ip4_config_del_address (NMIP4Config *config, guint i);
98 guint nm_ip4_config_get_num_addresses (const NMIP4Config *config);
99 const NMPlatformIP4Address *nm_ip4_config_get_address (const NMIP4Config *config, guint i);
100 gboolean nm_ip4_config_address_exists (const NMIP4Config *config, const NMPlatformIP4Address *address);
101 gboolean nm_ip4_config_addresses_sort (NMIP4Config *config);
104 void nm_ip4_config_reset_routes (NMIP4Config *config);
105 void nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *route);
106 void nm_ip4_config_del_route (NMIP4Config *config, guint i);
107 guint32 nm_ip4_config_get_num_routes (const NMIP4Config *config);
108 const NMPlatformIP4Route *nm_ip4_config_get_route (const NMIP4Config *config, guint32 i);
110 const NMPlatformIP4Route *nm_ip4_config_get_direct_route_for_host (const NMIP4Config *config, guint32 host);
113 void nm_ip4_config_reset_nameservers (NMIP4Config *config);
114 void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver);
115 void nm_ip4_config_del_nameserver (NMIP4Config *config, guint i);
116 guint32 nm_ip4_config_get_num_nameservers (const NMIP4Config *config);
117 guint32 nm_ip4_config_get_nameserver (const NMIP4Config *config, guint i);
120 void nm_ip4_config_reset_domains (NMIP4Config *config);
121 void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain);
122 void nm_ip4_config_del_domain (NMIP4Config *config, guint i);
123 guint32 nm_ip4_config_get_num_domains (const NMIP4Config *config);
124 const char * nm_ip4_config_get_domain (const NMIP4Config *config, guint i);
127 void nm_ip4_config_reset_searches (NMIP4Config *config);
128 void nm_ip4_config_add_search (NMIP4Config *config, const char *search);
129 void nm_ip4_config_del_search (NMIP4Config *config, guint i);
130 guint32 nm_ip4_config_get_num_searches (const NMIP4Config *config);
131 const char * nm_ip4_config_get_search (const NMIP4Config *config, guint i);
134 void nm_ip4_config_reset_dns_options (NMIP4Config *config);
135 void nm_ip4_config_add_dns_option (NMIP4Config *config, const char *option);
136 void nm_ip4_config_del_dns_option (NMIP4Config *config, guint i);
137 guint32 nm_ip4_config_get_num_dns_options (const NMIP4Config *config);
138 const char * nm_ip4_config_get_dns_option (const NMIP4Config *config, guint i);
141 void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss);
142 guint32 nm_ip4_config_get_mss (const NMIP4Config *config);
145 void nm_ip4_config_reset_nis_servers (NMIP4Config *config);
146 void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis);
147 void nm_ip4_config_del_nis_server (NMIP4Config *config, guint i);
148 guint32 nm_ip4_config_get_num_nis_servers (const NMIP4Config *config);
149 guint32 nm_ip4_config_get_nis_server (const NMIP4Config *config, guint i);
150 void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain);
151 const char * nm_ip4_config_get_nis_domain (const NMIP4Config *config);
154 void nm_ip4_config_reset_wins (NMIP4Config *config);
155 void nm_ip4_config_add_wins (NMIP4Config *config, guint32 wins);
156 void nm_ip4_config_del_wins (NMIP4Config *config, guint i);
157 guint32 nm_ip4_config_get_num_wins (const NMIP4Config *config);
158 guint32 nm_ip4_config_get_wins (const NMIP4Config *config, guint i);
161 void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu, NMIPConfigSource source);
162 guint32 nm_ip4_config_get_mtu (const NMIP4Config *config);
163 NMIPConfigSource nm_ip4_config_get_mtu_source (const NMIP4Config *config);
166 void nm_ip4_config_set_metered (NMIP4Config *config, gboolean metered);
167 gboolean nm_ip4_config_get_metered (const NMIP4Config *config);
169 void nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only);
170 gboolean nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b);
172 /******************************************************/
173 /* Testing-only functions */
175 gboolean nm_ip4_config_capture_resolv_conf (GArray *nameservers, GPtrArray *dns_options,
176 const char *rc_contents);
178 #endif /* __NETWORKMANAGER_IP4_CONFIG_H__ */