NetworkManager r4275 - in trunk: . src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r4275 - in trunk: . src
- Date: Fri, 7 Nov 2008 13:43:15 +0000 (UTC)
Author: dcbw
Date: Fri Nov 7 13:43:15 2008
New Revision: 4275
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4275&view=rev
Log:
2008-11-07 Dan Williams <dcbw redhat com>
* src/nm-ip4-config.c
src/nm-ip4-config.h
- (nm_ip4_config_diff): new function; return the difference between two
IP4 configs
- (nm_ip4_config_compare): change into nm_ip4_config_diff
Modified:
trunk/ChangeLog
trunk/src/nm-ip4-config.c
trunk/src/nm-ip4-config.h
Modified: trunk/src/nm-ip4-config.c
==============================================================================
--- trunk/src/nm-ip4-config.c (original)
+++ trunk/src/nm-ip4-config.c Fri Nov 7 13:43:15 2008
@@ -544,95 +544,54 @@
return TRUE;
}
-gboolean
-nm_ip4_config_compare (NMIP4Config *a,
- NMIP4Config *b,
- NMIP4ConfigCompareFlags flags)
+NMIP4ConfigCompareFlags
+nm_ip4_config_diff (NMIP4Config *a, NMIP4Config *b)
{
- NMIP4ConfigPrivate *a_priv = NM_IP4_CONFIG_GET_PRIVATE (a);
- NMIP4ConfigPrivate *b_priv = NM_IP4_CONFIG_GET_PRIVATE (b);
+ NMIP4ConfigPrivate *a_priv;
+ NMIP4ConfigPrivate *b_priv;
+ NMIP4ConfigCompareFlags flags = NM_IP4_COMPARE_FLAG_NONE;
+
+ if ((a && !b) || (b && !a))
+ return 0xFFFFFFFF;
+ if (!a && !b)
+ return NM_IP4_COMPARE_FLAG_NONE;
+
+ a_priv = NM_IP4_CONFIG_GET_PRIVATE (a);
+ b_priv = NM_IP4_CONFIG_GET_PRIVATE (b);
+
+ if ( !addr_slist_compare (a_priv->addresses, b_priv->addresses)
+ || !addr_slist_compare (b_priv->addresses, a_priv->addresses))
+ flags |= NM_IP4_COMPARE_FLAG_ADDRESSES;
+
+ if (a_priv->ptp_address != b_priv->ptp_address)
+ flags |= NM_IP4_COMPARE_FLAG_PTP_ADDRESS;
+
+ if ( (a_priv->nameservers->len != b_priv->nameservers->len)
+ || !addr_array_compare (a_priv->nameservers, b_priv->nameservers)
+ || !addr_array_compare (b_priv->nameservers, a_priv->nameservers))
+ flags |= NM_IP4_COMPARE_FLAG_NAMESERVERS;
+
+ if ( !route_slist_compare (a_priv->routes, b_priv->routes)
+ || !route_slist_compare (b_priv->routes, a_priv->routes))
+ flags |= NM_IP4_COMPARE_FLAG_ROUTES;
+
+ if ( (a_priv->domains->len != b_priv->domains->len)
+ || !string_array_compare (a_priv->domains, b_priv->domains)
+ || !string_array_compare (b_priv->domains, a_priv->domains))
+ flags |= NM_IP4_COMPARE_FLAG_DOMAINS;
+
+ if ( (a_priv->searches->len != b_priv->searches->len)
+ || !string_array_compare (a_priv->searches, b_priv->searches)
+ || !string_array_compare (b_priv->searches, a_priv->searches))
+ flags |= NM_IP4_COMPARE_FLAG_SEARCHES;
- g_return_val_if_fail (NM_IS_IP4_CONFIG (a), FALSE);
- g_return_val_if_fail (NM_IS_IP4_CONFIG (b), FALSE);
+ if (a_priv->mtu != b_priv->mtu)
+ flags |= NM_IP4_COMPARE_FLAG_MTU;
- if (flags == NM_IP4_COMPARE_FLAG_EXACT)
- flags = 0xFFFFFFFF;
+ if (a_priv->mss != b_priv->mss)
+ flags |= NM_IP4_COMPARE_FLAG_MSS;
- if (flags & NM_IP4_COMPARE_FLAG_ADDRESSES) {
- /* Ensure all A exist in B */
- if (!addr_slist_compare (a_priv->addresses, b_priv->addresses))
- return FALSE;
-
- /* Ensure all B exist in A */
- if (!addr_slist_compare (b_priv->addresses, a_priv->addresses))
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_PTP_ADDRESS) {
- if (a_priv->ptp_address != b_priv->ptp_address)
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_NAMESERVERS) {
- if (a_priv->nameservers->len != b_priv->nameservers->len) /* Shortcut */
- return FALSE;
-
- /* Ensure all A exist in B */
- if (!addr_array_compare (a_priv->nameservers, b_priv->nameservers))
- return FALSE;
-
- /* Ensure all B exist in A */
- if (!addr_array_compare (b_priv->nameservers, a_priv->nameservers))
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_ROUTES) {
- /* Ensure all A exist in B */
- if (!route_slist_compare (a_priv->routes, b_priv->routes))
- return FALSE;
-
- /* Ensure all B exist in A */
- if (!route_slist_compare (b_priv->routes, a_priv->routes))
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_DOMAINS) {
- if (a_priv->domains->len != b_priv->domains->len) /* Shortcut */
- return FALSE;
-
- /* Ensure all A exist in B */
- if (!string_array_compare (a_priv->domains, b_priv->domains))
- return FALSE;
-
- /* Ensure all B exist in A */
- if (!string_array_compare (b_priv->domains, a_priv->domains))
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_SEARCHES) {
- if (a_priv->searches->len != b_priv->searches->len) /* Shortcut */
- return FALSE;
-
- /* Ensure all A exist in B */
- if (!string_array_compare (a_priv->searches, b_priv->searches))
- return FALSE;
-
- /* Ensure all B exist in A */
- if (!string_array_compare (b_priv->searches, a_priv->searches))
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_MTU) {
- if (a_priv->mtu != b_priv->mtu)
- return FALSE;
- }
-
- if (flags & NM_IP4_COMPARE_FLAG_MSS) {
- if (a_priv->mss != b_priv->mss)
- return FALSE;
- }
-
- return TRUE;
+ return flags;
}
static void
Modified: trunk/src/nm-ip4-config.h
==============================================================================
--- trunk/src/nm-ip4-config.h (original)
+++ trunk/src/nm-ip4-config.h Fri Nov 7 13:43:15 2008
@@ -102,7 +102,7 @@
struct rtnl_addr *nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 i, guint32 flags);
typedef enum {
- NM_IP4_COMPARE_FLAG_EXACT = 0x00000000, /* match exactly */
+ 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,
@@ -110,9 +110,11 @@
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_MSS = 0x00000080,
+ NM_IP4_COMPARE_FLAG_ALL = 0xFFFFFFFF /* match everything */
} NMIP4ConfigCompareFlags;
-gboolean nm_ip4_config_compare (NMIP4Config *a, NMIP4Config *b, NMIP4ConfigCompareFlags flags);
+/* Returns a bitfield representing how the two IP4 configs differ */
+NMIP4ConfigCompareFlags nm_ip4_config_diff (NMIP4Config *a, NMIP4Config *b);
#endif /* NM_IP4_CONFIG_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]