diff options
author | Pavel Šimerda <psimerda@redhat.com> | 2013-07-04 13:34:44 +0200 |
---|---|---|
committer | Pavel Šimerda <psimerda@redhat.com> | 2013-07-04 13:37:26 +0200 |
commit | 8de1b1732ea6ab697b8cd2c812c470680cd9cb4f (patch) | |
tree | 3eb64a45c03523d0c4c06c72c5764ad80a387994 | |
parent | 6cdc16d147b15b883e0903ffe59dac46bbcda88d (diff) | |
download | NetworkManager-8de1b1732ea6ab697b8cd2c812c470680cd9cb4f.tar.gz |
trivial: move merge_ip6_configs() to nm-ip6-config
-rw-r--r-- | src/devices/nm-device.c | 46 | ||||
-rw-r--r-- | src/nm-ip6-config.c | 40 | ||||
-rw-r--r-- | src/nm-ip6-config.h | 1 |
3 files changed, 44 insertions, 43 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index ef57b8129d..f6cfadf9cc 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -2535,46 +2535,6 @@ dhcp6_add_option_cb (gpointer key, gpointer value, gpointer user_data) (const char *) value); } -static void -merge_ip6_configs (NMIP6Config *dst, NMIP6Config *src) -{ - guint32 i; - - g_return_if_fail (src != NULL); - g_return_if_fail (dst != NULL); - - /* addresses */ - for (i = 0; i < nm_ip6_config_get_num_addresses (src); i++) - nm_ip6_config_add_address (dst, nm_ip6_config_get_address (src, i)); - - /* ptp address; only replace if src doesn't have one */ - if (!nm_ip6_config_get_ptp_address (dst)) - nm_ip6_config_set_ptp_address (dst, nm_ip6_config_get_ptp_address (src)); - - /* nameservers */ - for (i = 0; i < nm_ip6_config_get_num_nameservers (src); i++) - nm_ip6_config_add_nameserver (dst, nm_ip6_config_get_nameserver (src, i)); - - /* default gateway */ - if (!nm_ip6_config_get_gateway (dst)) - nm_ip6_config_set_gateway (dst, nm_ip6_config_get_gateway (src)); - - /* routes */ - for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) - nm_ip6_config_add_route (dst, nm_ip6_config_get_route (src, i)); - - /* domains */ - for (i = 0; i < nm_ip6_config_get_num_domains (src); i++) - nm_ip6_config_add_domain (dst, nm_ip6_config_get_domain (src, i)); - - /* dns searches */ - for (i = 0; i < nm_ip6_config_get_num_searches (src); i++) - nm_ip6_config_add_search (dst, nm_ip6_config_get_search (src, i)); - - if (!nm_ip6_config_get_mss (dst)) - nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src)); -} - static gboolean ip6_config_merge_and_apply (NMDevice *self, NMIP6Config *src_config, @@ -2594,13 +2554,13 @@ ip6_config_merge_and_apply (NMDevice *self, /* Merge in the given config first, if any */ if (src_config) - merge_ip6_configs (composite, src_config); + nm_ip6_config_merge (composite, src_config); /* Merge RA and DHCPv6 configs into the composite config */ if (priv->ac_ip6_config && (src_config != priv->ac_ip6_config)) - merge_ip6_configs (composite, priv->ac_ip6_config); + nm_ip6_config_merge (composite, priv->ac_ip6_config); if (priv->dhcp6_ip6_config && (src_config != priv->dhcp6_ip6_config)) - merge_ip6_configs (composite, priv->dhcp6_ip6_config); + nm_ip6_config_merge (composite, priv->dhcp6_ip6_config); /* Merge user overrides into the composite config */ nm_ip6_config_merge_setting (composite, nm_connection_get_setting_ip6_config (connection)); diff --git a/src/nm-ip6-config.c b/src/nm-ip6-config.c index d9a3387e19..453f7f134d 100644 --- a/src/nm-ip6-config.c +++ b/src/nm-ip6-config.c @@ -342,6 +342,46 @@ nm_match_spec_string (const GSList *specs, const char *match) /******************************************************************/ +void +nm_ip6_config_merge (NMIP6Config *dst, NMIP6Config *src) +{ + guint32 i; + + g_return_if_fail (src != NULL); + g_return_if_fail (dst != NULL); + + /* addresses */ + for (i = 0; i < nm_ip6_config_get_num_addresses (src); i++) + nm_ip6_config_add_address (dst, nm_ip6_config_get_address (src, i)); + + /* ptp address; only replace if src doesn't have one */ + if (!nm_ip6_config_get_ptp_address (dst)) + nm_ip6_config_set_ptp_address (dst, nm_ip6_config_get_ptp_address (src)); + + /* nameservers */ + for (i = 0; i < nm_ip6_config_get_num_nameservers (src); i++) + nm_ip6_config_add_nameserver (dst, nm_ip6_config_get_nameserver (src, i)); + + /* default gateway */ + if (!nm_ip6_config_get_gateway (dst)) + nm_ip6_config_set_gateway (dst, nm_ip6_config_get_gateway (src)); + + /* routes */ + for (i = 0; i < nm_ip6_config_get_num_routes (src); i++) + nm_ip6_config_add_route (dst, nm_ip6_config_get_route (src, i)); + + /* domains */ + for (i = 0; i < nm_ip6_config_get_num_domains (src); i++) + nm_ip6_config_add_domain (dst, nm_ip6_config_get_domain (src, i)); + + /* dns searches */ + for (i = 0; i < nm_ip6_config_get_num_searches (src); i++) + nm_ip6_config_add_search (dst, nm_ip6_config_get_search (src, i)); + + if (!nm_ip6_config_get_mss (dst)) + nm_ip6_config_set_mss (dst, nm_ip6_config_get_mss (src)); +} + gboolean nm_ip6_config_destination_is_direct (NMIP6Config *config, const struct in6_addr *dest, guint32 dest_prefix) { diff --git a/src/nm-ip6-config.h b/src/nm-ip6-config.h index b051f30678..2b126f86dc 100644 --- a/src/nm-ip6-config.h +++ b/src/nm-ip6-config.h @@ -60,6 +60,7 @@ gboolean nm_ip6_config_commit (NMIP6Config *config, int ifindex, int priority); void nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting); /* Utility functions */ +void nm_ip6_config_merge (NMIP6Config *dst, NMIP6Config *src); gboolean nm_ip6_config_destination_is_direct (NMIP6Config *config, const struct in6_addr *dest, guint32 plen); void nm_ip6_config_take_address (NMIP6Config *config, NMIP6Address *address); |