summaryrefslogtreecommitdiff
path: root/src/nm-ip4-config.h
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-11-20 14:59:32 +0100
committerBeniamino Galvani <bgalvani@redhat.com>2017-12-06 09:53:18 +0100
commite5a8aba225ff77a8b02a2772c09ae537bea64a8a (patch)
treec2922c257e0e83bb608e4c6b72e412137d5de0eb /src/nm-ip4-config.h
parenteae63475d9e3ec11bec93ac7d6c5cf2d48de133f (diff)
downloadNetworkManager-e5a8aba225ff77a8b02a2772c09ae537bea64a8a.tar.gz
core: add non-destructive ip config intersect function
Add a new function to compute the intersection between 2 IP configurations without modifying them.
Diffstat (limited to 'src/nm-ip4-config.h')
-rw-r--r--src/nm-ip4-config.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nm-ip4-config.h b/src/nm-ip4-config.h
index f53ba02007..c614863d03 100644
--- a/src/nm-ip4-config.h
+++ b/src/nm-ip4-config.h
@@ -187,6 +187,9 @@ void nm_ip4_config_subtract (NMIP4Config *dst,
void nm_ip4_config_intersect (NMIP4Config *dst,
const NMIP4Config *src,
guint32 default_route_metric_penalty);
+NMIP4Config *nm_ip4_config_intersect_alloc (const NMIP4Config *a,
+ const NMIP4Config *b,
+ guint32 default_route_metric_penalty);
gboolean nm_ip4_config_replace (NMIP4Config *dst, const NMIP4Config *src, gboolean *relevant_changes);
void nm_ip4_config_dump (const NMIP4Config *self, const char *detail);
@@ -455,4 +458,23 @@ nm_ip_config_merge (NMIPConfig *dst,
default_route_metric_penalty);
}
+static inline NMIPConfig *
+nm_ip_config_intersect_alloc (const NMIPConfig *a,
+ const NMIPConfig *b,
+ guint32 default_route_metric_penalty)
+{
+ int family;
+
+ family = nm_ip_config_get_addr_family (a);
+ nm_assert (family == nm_ip_config_get_addr_family (b));
+
+ if (family == AF_INET)
+ return (NMIPConfig *) nm_ip4_config_intersect_alloc ((const NMIP4Config *) a,
+ (const NMIP4Config *) b,
+ default_route_metric_penalty);
+ else
+ return (NMIPConfig *) nm_ip6_config_intersect_alloc ((const NMIP6Config *) a,
+ (const NMIP6Config *) b,
+ default_route_metric_penalty);
+}
#endif /* __NETWORKMANAGER_IP4_CONFIG_H__ */