static gboolean demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); priv->routes = NULL; priv->routes = nm_utils_ip6_routes_from_gvalue (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES); return TRUE; }
static void set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (object); switch (prop_id) { case PROP_METHOD: g_free (priv->method); priv->method = g_value_dup_string (value); break; case PROP_DNS: nm_utils_slist_free (priv->dns, g_free); priv->dns = nm_utils_ip6_dns_from_gvalue (value); break; case PROP_DNS_SEARCH: nm_utils_slist_free (priv->dns_search, g_free); priv->dns_search = g_value_dup_boxed (value); break; case PROP_ADDRESSES: nm_utils_slist_free (priv->addresses, g_free); priv->addresses = nm_utils_ip6_addresses_from_gvalue (value); break; case PROP_ROUTES: nm_utils_slist_free (priv->routes, g_free); priv->routes = nm_utils_ip6_routes_from_gvalue (value); break; case PROP_IGNORE_AUTO_ROUTES: priv->ignore_auto_routes = g_value_get_boolean (value); break; case PROP_IGNORE_AUTO_DNS: priv->ignore_auto_dns = g_value_get_boolean (value); break; case PROP_DHCP_HOSTNAME: g_free (priv->dhcp_hostname); priv->dhcp_hostname = g_value_dup_string (value); break; case PROP_NEVER_DEFAULT: priv->never_default = g_value_get_boolean (value); break; case PROP_MAY_FAIL: priv->may_fail = g_value_get_boolean (value); break; case PROP_IP6_PRIVACY: priv->ip6_privacy = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static GSList * construct_ip6_items (GSList *items, GHashTable *ip6_config, const char *prefix) { GSList *addresses = NULL, *routes = NULL, *dns = NULL, *iter; guint32 num; GString *tmp; GValue *val; if (ip6_config == NULL) return items; if (prefix == NULL) prefix = ""; /* IP addresses */ val = g_hash_table_lookup (ip6_config, "addresses"); if (val) addresses = nm_utils_ip6_addresses_from_gvalue (val); for (iter = addresses, num = 0; iter; iter = g_slist_next (iter)) { NMIP6Address *addr = (NMIP6Address *) iter->data; char str_addr[INET6_ADDRSTRLEN + 1]; char str_gw[INET6_ADDRSTRLEN + 1]; const struct in6_addr *tmp_addr; guint32 ip_prefix = nm_ip6_address_get_prefix (addr); char *addrtmp; memset (str_addr, 0, sizeof (str_addr)); tmp_addr = nm_ip6_address_get_address (addr); if (!inet_ntop (AF_INET6, &tmp_addr, str_addr, sizeof (str_addr))) continue; memset (str_gw, 0, sizeof (str_gw)); tmp_addr = nm_ip6_address_get_gateway (addr); inet_ntop (AF_INET6, &tmp_addr, str_gw, sizeof (str_gw)); addrtmp = g_strdup_printf ("%sIP6_ADDRESS_%d=%s/%d %s", prefix, num++, str_addr, ip_prefix, str_gw); items = g_slist_prepend (items, addrtmp); } if (num) items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ADDRESSES=%d", prefix, num)); if (addresses) { g_slist_foreach (addresses, (GFunc) nm_ip6_address_unref, NULL); g_slist_free (addresses); } /* DNS servers */ val = g_hash_table_lookup (ip6_config, "nameservers"); if (val) dns = nm_utils_ip6_dns_from_gvalue (val); if (g_slist_length (dns)) { tmp = g_string_new (NULL); g_string_append_printf (tmp, "%sIP6_NAMESERVERS=", prefix); for (iter = dns; iter; iter = g_slist_next (iter)) { const struct in6_addr *addr = iter->data; gboolean first = TRUE; char buf[INET6_ADDRSTRLEN + 1]; memset (buf, 0, sizeof (buf)); if (inet_ntop (AF_INET6, addr, buf, sizeof (buf))) { if (!first) g_string_append_c (tmp, ' '); g_string_append (tmp, buf); first = FALSE; } } items = g_slist_prepend (items, tmp->str); g_string_free (tmp, FALSE); } /* Search domains */ items = add_domains (items, ip6_config, prefix, '6'); /* Static routes */ val = g_hash_table_lookup (ip6_config, "routes"); if (val) routes = nm_utils_ip6_routes_from_gvalue (val); for (iter = routes, num = 0; iter; iter = g_slist_next (iter)) { NMIP6Route *route = (NMIP6Route *) iter->data; char str_addr[INET6_ADDRSTRLEN + 1]; char str_nh[INET6_ADDRSTRLEN + 1]; const struct in6_addr *tmp_addr; guint32 ip_prefix = nm_ip6_route_get_prefix (route); guint32 metric = nm_ip6_route_get_metric (route); char *routetmp; memset (str_addr, 0, sizeof (str_addr)); tmp_addr = nm_ip6_route_get_dest (route); if (!inet_ntop (AF_INET6, &tmp_addr, str_addr, sizeof (str_addr))) continue; memset (str_nh, 0, sizeof (str_nh)); tmp_addr = nm_ip6_route_get_next_hop (route); inet_ntop (AF_INET6, &tmp_addr, str_nh, sizeof (str_nh)); routetmp = g_strdup_printf ("%sIP6_ROUTE_%d=%s/%d %s %d", prefix, num++, str_addr, ip_prefix, str_nh, metric); items = g_slist_prepend (items, routetmp); } if (num) items = g_slist_prepend (items, g_strdup_printf ("%sIP6_NUM_ROUTES=%d", prefix, num)); if (routes) { g_slist_foreach (routes, (GFunc) nm_ip6_route_unref, NULL); g_slist_free (routes); } return items; }