Commit 8ee4f58e authored by Jiří Klimeš's avatar Jiří Klimeš

libnm-glib: additional functions to get nameservers (rh #1056146)

This commit adds two new functions for introspection users to get nameservers:
guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config)
const struct in6_addr *nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx)
The existing function can't be used due to GObject introspection limitations:
const GSList *nm_ip6_config_get_nameservers (NMIP6Config *config);

https://bugzilla.redhat.com/show_bug.cgi?id=1056146
parent 041f449a
......@@ -227,7 +227,9 @@ global:
nm_ip6_config_get_addresses;
nm_ip6_config_get_domains;
nm_ip6_config_get_gateway;
nm_ip6_config_get_nameserver;
nm_ip6_config_get_nameservers;
nm_ip6_config_get_num_nameservers;
nm_ip6_config_get_routes;
nm_ip6_config_get_searches;
nm_ip6_config_get_type;
......
......@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2008 - 2011 Red Hat, Inc.
* Copyright (C) 2008 - 2014 Red Hat, Inc.
*/
#include <string.h>
......@@ -192,6 +192,56 @@ nm_ip6_config_get_addresses (NMIP6Config *config)
return NM_IP6_CONFIG_GET_PRIVATE (config)->addresses;
}
/**
* 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_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;
}
/* FIXME: like in libnm_util, in6_addr is not introspectable, so skipping here */
/**
* nm_ip6_config_get_nameservers: (skip)
......
......@@ -18,7 +18,7 @@
* Boston, MA 02110-1301 USA.
*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2008 Red Hat, Inc.
* Copyright (C) 2008 - 2014 Red Hat, Inc.
*/
#ifndef NM_IP6_CONFIG_H
......@@ -65,12 +65,14 @@ GType nm_ip6_config_get_type (void);
GObject *nm_ip6_config_new (DBusGConnection *connection, const char *object_path);
const char * nm_ip6_config_get_gateway (NMIP6Config *config);
const GSList * nm_ip6_config_get_addresses (NMIP6Config *config);
const GSList * nm_ip6_config_get_routes (NMIP6Config *config);
const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config);
const GPtrArray *nm_ip6_config_get_domains (NMIP6Config *config);
const GPtrArray *nm_ip6_config_get_searches (NMIP6Config *config);
const char * nm_ip6_config_get_gateway (NMIP6Config *config);
const GSList * nm_ip6_config_get_addresses (NMIP6Config *config);
const GSList * nm_ip6_config_get_routes (NMIP6Config *config);
guint32 nm_ip6_config_get_num_nameservers (NMIP6Config *config);
const struct in6_addr *nm_ip6_config_get_nameserver (NMIP6Config *config, guint32 idx);
const GSList * nm_ip6_config_get_nameservers (NMIP6Config *config);
const GPtrArray * nm_ip6_config_get_domains (NMIP6Config *config);
const GPtrArray * nm_ip6_config_get_searches (NMIP6Config *config);
G_END_DECLS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment