Ejemplo n.º 1
0
const char *
nm_dhcp4_config_get_dbus_path (NMDHCP4Config *self)
{
	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);

	return NM_DHCP4_CONFIG_GET_PRIVATE (self)->dbus_path;
}
Ejemplo n.º 2
0
GVariant *
nm_dhcp4_config_get_options (NMDhcp4Config *self)
{
	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);

	return g_variant_ref (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options);
}
Ejemplo n.º 3
0
/**
 * nm_dhcp4_config_get_one_option:
 * @config: a #NMDHCP4Config
 * @option: the option to retrieve
 *
 * Gets one option by option name.
 *
 * Returns: the configuration option's value. This is the internal string used by the
 * configuration, and must not be modified.
 **/
const char *
nm_dhcp4_config_get_one_option (NMDHCP4Config *config, const char *option)
{
	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL);

	return g_hash_table_lookup (nm_dhcp4_config_get_options (config), option);
}
Ejemplo n.º 4
0
/**
 * nm_dhcp_config_get_family:
 * @config: a #NMDhcpConfig
 *
 * Gets the IP address family of the configuration
 *
 * Returns: the IP address family; either <literal>AF_INET</literal> or
 *   <literal>AF_INET6</literal>
 **/
int
nm_dhcp_config_get_family (NMDhcpConfig *config)
{
	g_return_val_if_fail (NM_IS_DHCP_CONFIG (config), AF_UNSPEC);

	return NM_IS_DHCP4_CONFIG (config) ? AF_INET : AF_INET6;
}
Ejemplo n.º 5
0
void
nm_dhcp4_config_reset (NMDHCP4Config *self)
{
	g_return_if_fail (NM_IS_DHCP4_CONFIG (self));

	g_hash_table_remove_all (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options);
	g_object_notify (G_OBJECT (self), NM_DHCP4_CONFIG_OPTIONS);
}
Ejemplo n.º 6
0
/**
 * nm_dhcp4_config_get_options:
 * @config: a #NMDHCP4Config
 *
 * Gets all the options contained in the configuration.
 *
 * Returns: (transfer none) (element-type utf8 GObject.Value): the #GHashTable containing strings for keys and values.
 * This is the internal copy used by the configuration, and must not be modified.
 **/
GHashTable *
nm_dhcp4_config_get_options (NMDHCP4Config *config)
{
	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (config), NULL);

	_nm_object_ensure_inited (NM_OBJECT (config));
	return NM_DHCP4_CONFIG_GET_PRIVATE (config)->options;
}
Ejemplo n.º 7
0
const char *
nm_dhcp4_config_get_option (NMDHCP4Config *self, const char *key)
{
	GValue *value;

	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);
	g_return_val_if_fail (key != NULL, NULL);

	value = g_hash_table_lookup (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options, key);
	return value ? g_value_get_string (value) : NULL;
}
Ejemplo n.º 8
0
const char *
nm_dhcp4_config_get_option (NMDhcp4Config *self, const char *key)
{
	NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
	const char *value;

	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);
	g_return_val_if_fail (key != NULL, NULL);

	if (g_variant_lookup (priv->options, key, "&s", &value))
		return value;
	else
		return NULL;
}
Ejemplo n.º 9
0
/* Caller owns the list, but not the values in the list */
GSList *
nm_dhcp4_config_list_options (NMDHCP4Config *self)
{
	GHashTableIter iter;
	const char *option = NULL;
	GSList *list = NULL;

	g_return_val_if_fail (NM_IS_DHCP4_CONFIG (self), NULL);

	g_hash_table_iter_init (&iter, NM_DHCP4_CONFIG_GET_PRIVATE (self)->options);
	while (g_hash_table_iter_next (&iter, (gpointer) &option, NULL))
		list = g_slist_prepend (list, (gpointer) option);

	return list;
}
Ejemplo n.º 10
0
void
nm_dhcp4_config_add_option (NMDHCP4Config *self,
                            const char *key,
                            const char *option)
{
	GValue *svalue;

	g_return_if_fail (NM_IS_DHCP4_CONFIG (self));
	g_return_if_fail (key != NULL);
	g_return_if_fail (option != NULL);

	svalue = g_slice_new0 (GValue);
	g_value_init (svalue, G_TYPE_STRING);
	g_value_set_string (svalue, option);
	g_hash_table_insert (NM_DHCP4_CONFIG_GET_PRIVATE (self)->options, g_strdup (key), svalue);
	g_object_notify (G_OBJECT (self), NM_DHCP4_CONFIG_OPTIONS);
}
Ejemplo n.º 11
0
static void
init_dbus (NMObject *object)
{
	NMDhcpConfigPrivate *priv = NM_DHCP_CONFIG_GET_PRIVATE (object);
	const NMPropertiesInfo property_info[] = {
		{ NM_DHCP_CONFIG_OPTIONS, &priv->options, demarshal_dhcp_options },
		{ NULL },
	};

	NM_OBJECT_CLASS (nm_dhcp_config_parent_class)->init_dbus (object);

	_nm_object_register_properties (object,
	                                (NM_IS_DHCP4_CONFIG (object) ?
	                                 NM_DBUS_INTERFACE_DHCP4_CONFIG :
	                                 NM_DBUS_INTERFACE_DHCP6_CONFIG),
	                                property_info);
}
Ejemplo n.º 12
0
void
nm_dhcp4_config_set_options (NMDhcp4Config *self,
                             GHashTable *options)
{
	NMDhcp4ConfigPrivate *priv = NM_DHCP4_CONFIG_GET_PRIVATE (self);
	GHashTableIter iter;
	const char *key, *value;
	GVariantBuilder builder;

	g_return_if_fail (NM_IS_DHCP4_CONFIG (self));
	g_return_if_fail (options != NULL);

	g_variant_unref (priv->options);

	g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
	g_hash_table_iter_init (&iter, options);
	while (g_hash_table_iter_next (&iter, (gpointer) &key, (gpointer) &value))
		g_variant_builder_add (&builder, "{sv}", key, g_variant_new_string (value));

	priv->options = g_variant_builder_end (&builder);
	g_variant_ref_sink (priv->options);
	g_object_notify (G_OBJECT (self), NM_DHCP4_CONFIG_OPTIONS);
}