From 50a58f0fabd8a34c1b6108a107e08abe3c1ccd24 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Tue, 14 Jul 2015 19:38:58 +0200 Subject: Imported Upstream version 1.0.4 --- src/rdisc/nm-rdisc.c | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'src/rdisc/nm-rdisc.c') diff --git a/src/rdisc/nm-rdisc.c b/src/rdisc/nm-rdisc.c index 07271a89..a73ab7d0 100644 --- a/src/rdisc/nm-rdisc.c +++ b/src/rdisc/nm-rdisc.c @@ -83,7 +83,7 @@ nm_rdisc_add_gateway (NMRDisc *rdisc, const NMRDiscGateway *new) } if (new->lifetime) - g_array_insert_val (rdisc->gateways, CLAMP (insert_idx, 0, G_MAXINT), *new); + g_array_insert_val (rdisc->gateways, MAX (insert_idx, 0), *new); return !!new->lifetime; } @@ -241,12 +241,38 @@ clear_rs_timeout (NMRDisc *rdisc) } } -void +/** + * nm_rdisc_set_iid: + * @rdisc: the #NMRDisc + * @iid: the new interface ID + * + * Sets the "Modified EUI-64" interface ID to be used when generating + * IPv6 addresses using received prefixes. Identifiers are either generated + * from the hardware addresses or manually set by the operator with + * "ip token" command. + * + * Upon token change (or initial setting) all addresses generated using + * the old identifier are removed. The caller should ensure the addresses + * will be reset by soliciting router advertisements. + * + * Returns: %TRUE if the token was changed, %FALSE otherwise. + **/ +gboolean nm_rdisc_set_iid (NMRDisc *rdisc, const NMUtilsIPv6IfaceId iid) { - g_return_if_fail (NM_IS_RDISC (rdisc)); + g_return_val_if_fail (NM_IS_RDISC (rdisc), FALSE); + + if (rdisc->iid.id != iid.id) { + rdisc->iid = iid; + if (rdisc->addresses->len) { + debug ("(%s) IPv6 interface identifier changed, flushing addresses", rdisc->ifname); + g_array_remove_range (rdisc->addresses, 0, rdisc->addresses->len); + g_signal_emit_by_name (rdisc, NM_RDISC_CONFIG_CHANGED, NM_RDISC_CONFIG_ADDRESSES); + } + return TRUE; + } - rdisc->iid = iid; + return FALSE; } static gboolean -- cgit 1.3.0-6-gf8a5