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; }
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; }
/** * 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); }
/** * 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); }
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; }
/** * 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; }
/** * 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); }
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); }
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_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_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_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; }
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 void print_ip6_info (NMIP6Config * ip6) { GSList * addresses; GSList * dns; const GPtrArray * domains; int i; if (!ip6) return; g_return_if_fail (NM_IS_IP6_CONFIG (ip6)); addresses = (GSList *) nm_ip6_config_get_addresses (ip6); dns = (GSList *) nm_ip6_config_get_nameservers (ip6); domains = nm_ip6_config_get_domains (ip6); g_slist_foreach (addresses, (GFunc) print_ip6_addr, NULL); if ((domains && domains->len) || (dns && dns->data)) g_print("%-9s ", ""); if (dns && dns->data) { g_print("DNS:"); while(dns) { char buf[INET6_ADDRSTRLEN + 1]; struct in6_addr * tmp_addr = dns->data; dns = g_slist_next (dns); inet_ntop (AF_INET6, &tmp_addr, buf, sizeof (buf)); g_print("%s ", buf); } g_print (" "); } if (domains && domains->len) { g_print("Domains:"); for (i = 0; i < domains->len; i++) { char * domain = (char *) g_ptr_array_index(domains, i); g_print("%s ", domain); } } if ((domains && domains->len) || (dns && dns->data)) g_print("\n"); }
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); }
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)); }
void nm_ip6_config_replace_address (NMIP6Config *config, guint i, NMIP6Address *new_address) { 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->addresses, i); g_return_if_fail (old != NULL); nm_ip6_address_unref ((NMIP6Address *) old->data); old->data = nm_ip6_address_dup (new_address); }
void nm_ip6_config_add_address (NMIP6Config *config, NMIP6Address *address) { NMIP6ConfigPrivate *priv; GSList *iter; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (address != NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); for (iter = priv->addresses; iter; iter = g_slist_next (iter)) { if (nm_ip6_address_compare ((NMIP6Address *) iter->data, address)) return; } priv->addresses = g_slist_append (priv->addresses, nm_ip6_address_dup (address)); }
void nm_ip6_config_add_domain (NMIP6Config *config, const char *domain) { NMIP6ConfigPrivate *priv; int i; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (domain != NULL); g_return_if_fail (strlen (domain) > 0); priv = NM_IP6_CONFIG_GET_PRIVATE (config); for (i = 0; i < priv->domains->len; i++) { if (!strcmp (g_ptr_array_index (priv->domains, i), domain)) return; } g_ptr_array_add (priv->domains, g_strdup (domain)); }
/** * nm_ip6_config_get_nameserver: * @config: a #NMIP6Config * @idx: index of the nameserver to return * * Gets the domain name server at index @idx in the configuration. * * Returns: (array fixed-size=16) (element-type guint8) (transfer none): * the IPv6 address of domain name server at index @iidx * * Since: 0.9.10 **/ const struct in6_addr * nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx) { NMIP6ConfigPrivate *priv; GSList *item; guint32 i = 0; g_return_val_if_fail (NM_IS_IP6_CONFIG (config), NULL); _nm_object_ensure_inited (NM_OBJECT (config)); priv = NM_IP6_CONFIG_GET_PRIVATE (config); for (item = priv->nameservers; item && i < idx; i++) item = item->next; g_return_val_if_fail (item, NULL); return item ? (const struct in6_addr *) item->data : NULL; }
static gboolean add_ip_config_data (NMDnsDnsmasq *self, GVariantBuilder *servers, const NMDnsIPConfigData *data) { if (NM_IS_IP4_CONFIG (data->config)) { return add_ip4_config (self, servers, (NMIP4Config *) data->config, data->iface, data->type == NM_DNS_IP_CONFIG_TYPE_VPN); } else if (NM_IS_IP6_CONFIG (data->config)) { return add_ip6_config (self, servers, (NMIP6Config *) data->config, data->iface, data->type == NM_DNS_IP_CONFIG_TYPE_VPN); } else g_return_val_if_reached (FALSE); }
void nm_ip6_config_add_nameserver (NMIP6Config *config, const struct in6_addr *nameserver) { NMIP6ConfigPrivate *priv; struct in6_addr *nameservers; int i; g_return_if_fail (NM_IS_IP6_CONFIG (config)); g_return_if_fail (nameserver != NULL); priv = NM_IP6_CONFIG_GET_PRIVATE (config); /* No dupes */ nameservers = (struct in6_addr *)priv->nameservers->data; for (i = 0; i < priv->nameservers->len; i++) { if (IN6_ARE_ADDR_EQUAL (nameserver, &nameservers[i])) return; } g_array_append_val (priv->nameservers, *nameserver); }
guint32 nm_ip6_config_get_mss (NMIP6Config *config) { g_return_val_if_fail (NM_IS_IP6_CONFIG (config), 0); return NM_IP6_CONFIG_GET_PRIVATE (config)->mss; }
void nm_ip6_config_set_mss (NMIP6Config *config, guint32 mss) { g_return_if_fail (NM_IS_IP6_CONFIG (config)); NM_IP6_CONFIG_GET_PRIVATE (config)->mss = mss; }