/** * nm_ip6_config_get_routes: * @config: a #NMIP6Config * * Gets the routes. * * Returns: (element-type NetworkManager.IP6Route): the #GSList containing * #NMIP6Route<!-- -->s. This is the internal copy used by the configuration, * and must not be modified. **/ const GSList * nm_ip6_config_get_routes (NMIP6Config *config) { NMIP6ConfigPrivate *priv; GValue value = { 0, }; g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->routes) return priv->routes; if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Routes", &value, NULL)) { return NULL; } demarshal_ip6_routes_array (NM_OBJECT (config), NULL, &value, &priv->routes); g_value_unset (&value); return priv->routes; }
/** * nm_ip6_config_get_domains: * @config: a #NMIP6Config * * Gets the domain names. * * Returns: (element-type utf8): the #GPtrArray containing domains as strings. * This is the internal copy used by the configuration, and must not be modified. **/ const GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config) { NMIP6ConfigPrivate *priv; GValue value = {0,}; g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->domains) return handle_ptr_array_return (priv->domains); if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Domains", &value, NULL)) { return NULL; } demarshal_domains (NM_OBJECT (config), NULL, &value, &priv->domains); g_value_unset (&value); return handle_ptr_array_return (priv->domains); }
static GObject* constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params) { GObject *object; DBusGConnection *connection; NMIP6ConfigPrivate *priv; object = G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructor (type, n_construct_params, construct_params); if (!object) return NULL; priv = NM_IP6_CONFIG_GET_PRIVATE (object); connection = nm_object_get_connection (NM_OBJECT (object)); priv->proxy = dbus_g_proxy_new_for_name (connection, NM_DBUS_SERVICE, nm_object_get_path (NM_OBJECT (object)), NM_DBUS_INTERFACE_IP6_CONFIG); register_for_property_changed (NM_IP6_CONFIG (object)); return object; }
/** * nm_ip6_config_get_nameservers: (skip) * @config: a #NMIP6Config * * Gets the domain name servers (DNS). * * Returns: (element-type Posix.in6_addr): a #GSList containing elements of type * 'struct in6_addr' which contain the addresses of nameservers of the configuration. * This is the internal copy used by the configuration and must not be modified. **/ const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config) { NMIP6ConfigPrivate *priv; GParamSpec *pspec; GValue value = {0,}; g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->nameservers) return priv->nameservers; if (!_nm_object_get_property (NM_OBJECT (config), NM_DBUS_INTERFACE_IP6_CONFIG, "Nameservers", &value, NULL)) { return NULL; } pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (config)), NM_IP6_CONFIG_NAMESERVERS); demarshal_ip6_nameserver_array (NM_OBJECT (config), pspec, &value, &priv->nameservers); g_value_unset (&value); return priv->nameservers; }
NMIP6Route * nm_ip6_config_get_route (NMIP6Config *config, guint i) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); return (NMIP6Route *) g_slist_nth_data (NM_IP6_CONFIG_GET_PRIVATE (config)->routes, i); }
const char * nm_ip6_config_get_dbus_path (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); return NM_IP6_CONFIG_GET_PRIVATE (config)->path; }
gboolean nm_ip6_config_get_never_default (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), FALSE); return NM_IP6_CONFIG_GET_PRIVATE (config)->never_default; }
static void finalize (GObject *object) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); g_free (priv->gateway); g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref); g_slist_free_full (priv->nameservers, g_free); if (priv->domains) { g_ptr_array_set_free_func (priv->domains, g_free); g_ptr_array_free (priv->domains, TRUE); } if (priv->searches) { g_ptr_array_set_free_func (priv->searches, g_free); g_ptr_array_free (priv->searches, TRUE); } g_object_unref (priv->proxy); G_OBJECT_CLASS (nm_ip6_config_parent_class)->finalize (object); }
void nm_ip6_config_set_never_default (NMIP6Config *config, gboolean never_default) { g_return_if_fail (NM_IS_IP6_CONFIG (config)); NM_IP6_CONFIG_GET_PRIVATE (config)->never_default = never_default; }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMIP6Config *self = NM_IP6_CONFIG (object); NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (self); _nm_object_ensure_inited (NM_OBJECT (object)); switch (prop_id) { case PROP_GATEWAY: g_value_set_string (value, nm_ip6_config_get_gateway (self)); break; case PROP_ADDRESSES: nm_utils_ip6_addresses_to_gvalue (priv->addresses, value); break; case PROP_ROUTES: nm_utils_ip6_routes_to_gvalue (priv->routes, value); break; case PROP_NAMESERVERS: g_value_set_boxed (value, nm_ip6_config_get_nameservers (self)); break; case PROP_DOMAINS: g_value_set_boxed (value, nm_ip6_config_get_domains (self)); break; case PROP_SEARCHES: g_value_set_boxed (value, nm_ip6_config_get_searches (self)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/** * nm_ip6_config_get_searches: * @config: a #NMIP6Config * * Gets the dns searches. * * Returns: (element-type utf8): the #GPtrArray containing dns searches as strings. * This is the internal copy used by the configuration, and must not be modified. * * Since: 0.9.10 **/ const GPtrArray * nm_ip6_config_get_searches (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); _nm_object_ensure_inited (NM_OBJECT (config)); return handle_ptr_array_return (NM_IP6_CONFIG_GET_PRIVATE (config)->searches); }
NMIP6ConfigCompareFlags nm_ip6_config_diff (NMIP6Config *a, NMIP6Config *b) { NMIP6ConfigPrivate *a_priv; NMIP6ConfigPrivate *b_priv; NMIP6ConfigCompareFlags flags = NM_IP6_COMPARE_FLAG_NONE; if ((a && !b) || (b && !a)) return NM_IP6_COMPARE_FLAG_ALL; if (!a && !b) return NM_IP6_COMPARE_FLAG_NONE; a_priv = NM_IP6_CONFIG_GET_PRIVATE (a); b_priv = NM_IP6_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_IP6_COMPARE_FLAG_ADDRESSES; if (memcmp (&a_priv->ptp_address, &b_priv->ptp_address, sizeof (struct in6_addr)) != 0) flags |= NM_IP6_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_IP6_COMPARE_FLAG_NAMESERVERS; if ( !route_slist_compare (a_priv->routes, b_priv->routes) || !route_slist_compare (b_priv->routes, a_priv->routes)) flags |= NM_IP6_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_IP6_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_IP6_COMPARE_FLAG_SEARCHES; if (a_priv->mss != b_priv->mss) flags |= NM_IP6_COMPARE_FLAG_MSS; return flags; }
/** * nm_ip6_config_get_routes: * @config: a #NMIP6Config * * Gets the routes. * * Returns: (element-type NMIP6Route): the #GSList containing * #NMIP6Routes. This is the internal copy used by the configuration, * and must not be modified. **/ const GSList * nm_ip6_config_get_routes (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); _nm_object_ensure_inited (NM_OBJECT (config)); return NM_IP6_CONFIG_GET_PRIVATE (config)->routes; }
/** * nm_ip6_config_get_num_nameservers: * @config: a #NMIP6Config * * Gets the number of the domain name servers in the configuration. * * Returns: the number of domain name servers * * Since: 0.9.10 **/ guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); _nm_object_ensure_inited (NM_OBJECT (config)); return g_slist_length (NM_IP6_CONFIG_GET_PRIVATE (config)->nameservers); }
/** * nm_ip6_config_get_gateway: * @config: a #NMIP6Config * * Gets the IP6 gateway. * * Returns: the IPv6 gateway of the configuration. * * Since: 0.9.10 **/ const char * nm_ip6_config_get_gateway (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); _nm_object_ensure_inited (NM_OBJECT (config)); return NM_IP6_CONFIG_GET_PRIVATE (config)->gateway; }
static void constructed (GObject *object) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); G_OBJECT_CLASS (nm_ip6_config_parent_class)->constructed (object); priv->proxy = _nm_object_new_proxy (NM_OBJECT (object), NULL, NM_DBUS_INTERFACE_IP6_CONFIG); register_properties (NM_IP6_CONFIG (object)); }
void nm_ip6_config_reset_nameservers (NMIP6Config *config) { NMIP6ConfigPrivate *priv; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (priv->nameservers->len) g_array_remove_range (priv->nameservers, 0, priv->nameservers->len); }
static void nm_ip6_config_init (NMIP6Config *config) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); priv->nameservers = g_array_new (FALSE, TRUE, sizeof (struct in6_addr)); priv->domains = g_ptr_array_sized_new (3); priv->searches = g_ptr_array_sized_new (3); priv->gateway_set = FALSE; }
const struct in6_addr * nm_ip6_config_get_gateway (NMIP6Config *config) { NMIP6ConfigPrivate *priv; g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); return priv->gateway_set ? &priv->gateway : NULL; }
void nm_ip6_config_reset_routes (NMIP6Config *config) { NMIP6ConfigPrivate *priv; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); g_slist_foreach (priv->routes, (GFunc) g_free, NULL); priv->routes = NULL; }
void nm_ip6_config_take_address (NMIP6Config *config, NMIP6Address *address) { NMIP6ConfigPrivate *priv; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (address != NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); priv->addresses = g_slist_append (priv->addresses, address); }
void nm_ip6_config_take_route (NMIP6Config *config, NMIP6Route *route) { NMIP6ConfigPrivate *priv; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (route != NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); priv->routes = g_slist_append (priv->routes, route); }
void nm_ip6_config_set_gateway (NMIP6Config *config, const struct in6_addr *gateway) { NMIP6ConfigPrivate *priv; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); if (gateway) memcpy (&priv->gateway, gateway, sizeof (priv->gateway)); priv->gateway_set = !!gateway; }
static gboolean demarshal_ip6_address_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip6_address_unref); priv->addresses = NULL; priv->addresses = nm_utils_ip6_addresses_from_gvalue (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ADDRESSES); return TRUE; }
void nm_ip6_config_reset_searches (NMIP6Config *config) { NMIP6ConfigPrivate *priv; int i; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); for (i = 0; i < priv->searches->len; i++) g_free (g_ptr_array_index (priv->searches, i)); g_ptr_array_free (priv->searches, TRUE); priv->searches = g_ptr_array_sized_new (3); }
static gboolean demarshal_ip6_routes_array (NMObject *object, GParamSpec *pspec, GValue *value, gpointer field) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (object); g_slist_foreach (priv->routes, (GFunc) nm_ip6_route_unref, NULL); g_slist_free (priv->routes); priv->routes = NULL; priv->routes = nm_utils_ip6_routes_from_gvalue (value); _nm_object_queue_notify (object, NM_IP6_CONFIG_ROUTES); return TRUE; }
void nm_ip6_config_export (NMIP6Config *config) { NMIP6ConfigPrivate *priv; static guint32 counter = 0; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); g_return_if_fail (priv->path == NULL); priv->path = g_strdup_printf (NM_DBUS_PATH "/IP6Config/%d", counter++); nm_dbus_manager_register_object (nm_dbus_manager_get (), priv->path, config); }
static void register_for_property_changed (NMIP6Config *config) { NMIP6ConfigPrivate *priv = NM_IP6_CONFIG_GET_PRIVATE (config); const NMPropertiesChangedInfo property_changed_info[] = { { NM_IP6_CONFIG_ADDRESSES, demarshal_ip6_address_array, &priv->addresses }, { NM_IP6_CONFIG_NAMESERVERS, demarshal_ip6_nameserver_array, &priv->nameservers }, { NM_IP6_CONFIG_DOMAINS, demarshal_domains, &priv->domains }, { NM_IP6_CONFIG_ROUTES, demarshal_ip6_routes_array, &priv->routes }, { NULL }, }; _nm_object_handle_properties_changed (NM_OBJECT (config), priv->proxy, property_changed_info); }
void nm_ip6_config_replace_route (NMIP6Config *config, guint i, NMIP6Route *new_route) { NMIP6ConfigPrivate *priv; GSList *old; g_return_if_fail (NM_IS_IP6_CONFIG (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); old = g_slist_nth (priv->routes, i); g_return_if_fail (old != NULL); nm_ip6_route_unref ((NMIP6Route *) old->data); old->data = nm_ip6_route_dup (new_route); }
void nm_ip6_config_add_route (NMIP6Config *config, NMIP6Route *route) { NMIP6ConfigPrivate *priv; GSList *iter; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (route != NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); for (iter = priv->routes; iter; iter = g_slist_next (iter)) { if (nm_ip6_route_compare ((NMIP6Route *) iter->data, route)) return; } priv->routes = g_slist_append (priv->routes, nm_ip6_route_dup (route)); }