summaryrefslogtreecommitdiff
path: root/src/nm-ip4-config.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nm-ip4-config.h')
-rw-r--r--src/nm-ip4-config.h203
1 files changed, 104 insertions, 99 deletions
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index 5433768cd..c9096bb38 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
-/* NetworkManager -- Network link manager
+/* NetworkManager
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -15,23 +15,23 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2008 Red Hat, Inc.
+ * Copyright (C) 2008–2013 Red Hat, Inc.
*/
#ifndef NM_IP4_CONFIG_H
#define NM_IP4_CONFIG_H
-#include <glib.h>
#include <glib-object.h>
+#include "nm-platform.h"
#include "nm-setting-ip4-config.h"
-#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
-#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
-#define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
-#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
+#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
+#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
+#define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
+#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
#define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_IP4_CONFIG))
-#define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
+#define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
typedef struct {
GObject parent;
@@ -41,104 +41,109 @@ typedef struct {
GObjectClass parent;
} NMIP4ConfigClass;
+#define NM_IP4_CONFIG_GATEWAY "gateway"
#define NM_IP4_CONFIG_ADDRESSES "addresses"
+#define NM_IP4_CONFIG_ROUTES "routes"
#define NM_IP4_CONFIG_NAMESERVERS "nameservers"
#define NM_IP4_CONFIG_DOMAINS "domains"
-#define NM_IP4_CONFIG_ROUTES "routes"
+#define NM_IP4_CONFIG_SEARCHES "searches"
#define NM_IP4_CONFIG_WINS_SERVERS "wins-servers"
GType nm_ip4_config_get_type (void);
-NMIP4Config * nm_ip4_config_new (void);
-void nm_ip4_config_export (NMIP4Config *config);
-const char * nm_ip4_config_get_dbus_path (NMIP4Config *config);
-
-void nm_ip4_config_take_address (NMIP4Config *config, NMIP4Address *address);
-void nm_ip4_config_add_address (NMIP4Config *config, NMIP4Address *address);
-void nm_ip4_config_replace_address (NMIP4Config *config, guint32 i, NMIP4Address *new_address);
-NMIP4Address *nm_ip4_config_get_address (NMIP4Config *config, guint32 i);
-guint32 nm_ip4_config_get_num_addresses (NMIP4Config *config);
-
-guint32 nm_ip4_config_get_ptp_address (NMIP4Config *config);
-void nm_ip4_config_set_ptp_address (NMIP4Config *config, guint32 ptp_addr);
-
-void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver);
-guint32 nm_ip4_config_get_nameserver (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config);
-void nm_ip4_config_reset_nameservers (NMIP4Config *config);
-
-void nm_ip4_config_add_wins (NMIP4Config *config, guint32 wins);
-guint32 nm_ip4_config_get_wins (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_wins (NMIP4Config *config);
-void nm_ip4_config_reset_wins (NMIP4Config *config);
-
-void nm_ip4_config_take_route (NMIP4Config *config, NMIP4Route *route);
-void nm_ip4_config_add_route (NMIP4Config *config, NMIP4Route *route);
-void nm_ip4_config_replace_route (NMIP4Config *config, guint32 i, NMIP4Route *new_route);
-NMIP4Route * nm_ip4_config_get_route (NMIP4Config *config, guint32 i);
-guint32 nm_ip4_config_get_num_routes (NMIP4Config *config);
-void nm_ip4_config_reset_routes (NMIP4Config *config);
-
-void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain);
-const char * nm_ip4_config_get_domain (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_domains (NMIP4Config *config);
-void nm_ip4_config_reset_domains (NMIP4Config *config);
-
-void nm_ip4_config_add_search (NMIP4Config *config, const char *search);
-const char * nm_ip4_config_get_search (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_searches (NMIP4Config *config);
-void nm_ip4_config_reset_searches (NMIP4Config *config);
-
-guint32 nm_ip4_config_get_mtu (NMIP4Config *config);
-void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu);
-
-guint32 nm_ip4_config_get_mss (NMIP4Config *config);
-void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss);
-
-gboolean nm_ip4_config_get_never_default (NMIP4Config *config);
-void nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default);
-
-void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis);
-guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i);
-guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config);
-void nm_ip4_config_reset_nis_servers (NMIP4Config *config);
-
-void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain);
-const char * nm_ip4_config_get_nis_domain (NMIP4Config *config);
-
-
-/* Flags for nm_ip4_config_to_rtnl_addr() */
-#define NM_RTNL_ADDR_NONE 0x0000
-#define NM_RTNL_ADDR_ADDR 0x0001
-#define NM_RTNL_ADDR_PTP_ADDR 0x0002
-#define NM_RTNL_ADDR_PREFIX 0x0004
-#define NM_RTNL_ADDR_BROADCAST 0x0008
-
-#define NM_RTNL_ADDR_DEFAULT (NM_RTNL_ADDR_ADDR | NM_RTNL_ADDR_PREFIX | NM_RTNL_ADDR_BROADCAST)
-#define NM_RTNL_ADDR_PTP_DEFAULT (NM_RTNL_ADDR_ADDR | NM_RTNL_ADDR_PREFIX | NM_RTNL_ADDR_PTP_ADDR)
-
-struct rtnl_addr *nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 i, guint32 flags);
-
-typedef enum {
- NM_IP4_COMPARE_FLAG_NONE = 0x00000000, /* match nothing, kinda pointless */
- NM_IP4_COMPARE_FLAG_ADDRESSES = 0x00000001,
- NM_IP4_COMPARE_FLAG_PTP_ADDRESS = 0x00000002,
- NM_IP4_COMPARE_FLAG_NAMESERVERS = 0x00000004,
- NM_IP4_COMPARE_FLAG_ROUTES = 0x00000008,
- NM_IP4_COMPARE_FLAG_DOMAINS = 0x00000010,
- NM_IP4_COMPARE_FLAG_SEARCHES = 0x00000020,
- NM_IP4_COMPARE_FLAG_MTU = 0x00000040,
- NM_IP4_COMPARE_FLAG_MSS = 0x00000080,
- NM_IP4_COMPARE_FLAG_WINS_SERVERS= 0x00000100,
- NM_IP4_COMPARE_FLAG_NIS_SERVERS = 0x00000200,
- NM_IP4_COMPARE_FLAG_NIS_DOMAIN = 0x00000400,
- NM_IP4_COMPARE_FLAG_ALL = 0xFFFFFFFF /* match everything */
-} NMIP4ConfigCompareFlags;
-
-/* Returns a bitfield representing how the two IP4 configs differ */
-NMIP4ConfigCompareFlags nm_ip4_config_diff (NMIP4Config *a, NMIP4Config *b);
-
-void nm_ip4_config_hash (NMIP4Config *config, GChecksum *sum, gboolean dns_only);
+NMIP4Config * nm_ip4_config_new (void);
+
+/* D-Bus integration */
+void nm_ip4_config_export (NMIP4Config *config);
+const char * nm_ip4_config_get_dbus_path (const NMIP4Config *config);
+
+/* Integration with nm-platform and nm-setting */
+NMIP4Config *nm_ip4_config_capture (int ifindex, gboolean capture_resolv_conf);
+gboolean nm_ip4_config_commit (const NMIP4Config *config, int ifindex);
+void nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, int default_route_metric);
+NMSetting *nm_ip4_config_create_setting (const NMIP4Config *config);
+
+/* Utility functions */
+void nm_ip4_config_merge (NMIP4Config *dst, const NMIP4Config *src);
+void nm_ip4_config_subtract (NMIP4Config *dst, const NMIP4Config *src);
+gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
+gboolean nm_ip4_config_destination_is_direct (const NMIP4Config *config, guint32 dest, int plen);
+void nm_ip4_config_dump (const NMIP4Config *config, const char *detail);
+
+/* Gateways */
+void nm_ip4_config_set_never_default (NMIP4Config *config, gboolean never_default);
+gboolean nm_ip4_config_get_never_default (const NMIP4Config *config);
+void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway);
+guint32 nm_ip4_config_get_gateway (const NMIP4Config *config);
+
+/* Addresses */
+void nm_ip4_config_reset_addresses (NMIP4Config *config);
+void nm_ip4_config_add_address (NMIP4Config *config, const NMPlatformIP4Address *address);
+void nm_ip4_config_del_address (NMIP4Config *config, guint i);
+guint nm_ip4_config_get_num_addresses (const NMIP4Config *config);
+const NMPlatformIP4Address *nm_ip4_config_get_address (const NMIP4Config *config, guint i);
+gboolean nm_ip4_config_address_exists (const NMIP4Config *config, const NMPlatformIP4Address *address);
+
+/* Routes */
+void nm_ip4_config_reset_routes (NMIP4Config *config);
+void nm_ip4_config_add_route (NMIP4Config *config, const NMPlatformIP4Route *route);
+void nm_ip4_config_del_route (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_routes (const NMIP4Config *config);
+const NMPlatformIP4Route *nm_ip4_config_get_route (const NMIP4Config *config, guint32 i);
+
+/* Nameservers */
+void nm_ip4_config_reset_nameservers (NMIP4Config *config);
+void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver);
+void nm_ip4_config_del_nameserver (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_nameservers (const NMIP4Config *config);
+guint32 nm_ip4_config_get_nameserver (const NMIP4Config *config, guint i);
+
+/* Domains */
+void nm_ip4_config_reset_domains (NMIP4Config *config);
+void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain);
+void nm_ip4_config_del_domain (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_domains (const NMIP4Config *config);
+const char * nm_ip4_config_get_domain (const NMIP4Config *config, guint i);
+
+/* Search lists */
+void nm_ip4_config_reset_searches (NMIP4Config *config);
+void nm_ip4_config_add_search (NMIP4Config *config, const char *search);
+void nm_ip4_config_del_search (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_searches (const NMIP4Config *config);
+const char * nm_ip4_config_get_search (const NMIP4Config *config, guint i);
+
+/* MSS */
+void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss);
+guint32 nm_ip4_config_get_mss (const NMIP4Config *config);
+
+/* NIS */
+void nm_ip4_config_reset_nis_servers (NMIP4Config *config);
+void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis);
+void nm_ip4_config_del_nis_server (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_nis_servers (const NMIP4Config *config);
+guint32 nm_ip4_config_get_nis_server (const NMIP4Config *config, guint i);
+void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain);
+const char * nm_ip4_config_get_nis_domain (const NMIP4Config *config);
+
+/* WINS */
+void nm_ip4_config_reset_wins (NMIP4Config *config);
+void nm_ip4_config_add_wins (NMIP4Config *config, guint32 wins);
+void nm_ip4_config_del_wins (NMIP4Config *config, guint i);
+guint32 nm_ip4_config_get_num_wins (const NMIP4Config *config);
+guint32 nm_ip4_config_get_wins (const NMIP4Config *config, guint i);
+
+/* MTU */
+void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu);
+guint32 nm_ip4_config_get_mtu (const NMIP4Config *config);
+
+void nm_ip4_config_hash (const NMIP4Config *config, GChecksum *sum, gboolean dns_only);
+gboolean nm_ip4_config_equal (const NMIP4Config *a, const NMIP4Config *b);
+
+/******************************************************/
+/* Testing-only functions */
+
+gboolean nm_ip4_config_capture_resolv_conf (GArray *nameservers,
+ const char *rc_contents);
#endif /* NM_IP4_CONFIG_H */