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; }
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); }
/** * 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); }
/** * 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; }
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); }
/** * 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; }
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; }
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; }
/* 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; }
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); }
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); }
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); }