/** * nm_setting_wired_get_port: * @setting: the #NMSettingWired * * Returns: the #NMSettingWired:port property of the setting **/ const char * nm_setting_wired_get_port (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); return NM_SETTING_WIRED_GET_PRIVATE (setting)->port; }
/** * nm_setting_wired_get_cloned_mac_address: * @setting: the #NMSettingWired * * Returns: the #NMSettingWired:cloned-mac-address property of the setting **/ const GByteArray * nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); return NM_SETTING_WIRED_GET_PRIVATE (setting)->cloned_mac_address; }
/** * nm_setting_wired_get_speed: * @setting: the #NMSettingWired * * Returns: the #NMSettingWired:speed property of the setting **/ guint32 nm_setting_wired_get_speed (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); return NM_SETTING_WIRED_GET_PRIVATE (setting)->speed; }
/** * nm_setting_wired_get_s390_option: * @setting: the #NMSettingWired * @idx: index of the desired option, from 0 to * nm_setting_wired_get_num_s390_options() - 1 * @out_key: (out): on return, the key name of the s390 specific option; this * value is owned by the setting and should not be modified * @out_value: (out): on return, the value of the key of the s390 specific * option; this value is owned by the setting and should not be modified * * Given an index, return the value of the s390 option at that index. indexes * are *not* guaranteed to be static across modifications to options done by * nm_setting_wired_add_s390_option() and nm_setting_wired_remove_s390_option(), * and should not be used to refer to options except for short periods of time * such as during option iteration. * * Returns: %TRUE on success if the index was valid and an option was found, * %FALSE if the index was invalid (ie, greater than the number of options * currently held by the setting) **/ gboolean nm_setting_wired_get_s390_option (NMSettingWired *setting, guint32 idx, const char **out_key, const char **out_value) { NMSettingWiredPrivate *priv; guint32 num_keys; GList *keys; const char *_key = NULL, *_value = NULL; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); priv = NM_SETTING_WIRED_GET_PRIVATE (setting); num_keys = nm_setting_wired_get_num_s390_options (setting); g_return_val_if_fail (idx < num_keys, FALSE); keys = g_hash_table_get_keys (priv->s390_options); _key = g_list_nth_data (keys, idx); _value = g_hash_table_lookup (priv->s390_options, _key); if (out_key) *out_key = _key; if (out_value) *out_value = _value; return TRUE; }
/** * nm_setting_wired_get_num_s390_options: * @setting: the #NMSettingWired * * Returns the number of s390-specific options that should be set for this * device when it is activated. This can be used to retrieve each s390 * option individually using nm_setting_wired_get_s390_option(). * * Returns: the number of s390-specific device options **/ guint32 nm_setting_wired_get_num_s390_options (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); return g_hash_table_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options); }
/** * nm_setting_wired_get_s390_subchannels: * @setting: the #NMSettingWired * * Return the list of s390 subchannels that identify the device that this * connection is applicable to. The connection should only be used in * conjunction with that device. * * Returns: (element-type utf8): #GPtrArray of strings, each specifying one * subchannel the s390 device uses to communicate to the host. **/ const GPtrArray * nm_setting_wired_get_s390_subchannels (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels; }
/** * nm_setting_wired_get_mac_address_blacklist: * @setting: the #NMSettingWired * * Returns: (element-type GLib.ByteArray): the #NMSettingWired:mac-address-blacklist * property of the setting **/ const GSList * nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist; }
/** * nm_setting_wired_get_auto_negotiate: * @setting: the #NMSettingWired * * Returns: the #NMSettingWired:auto-negotiate property of the setting **/ gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); return NM_SETTING_WIRED_GET_PRIVATE (setting)->auto_negotiate; }
/** * nm_setting_wired_clear_mac_blacklist_items: * @setting: the #NMSettingWired * * Removes all blacklisted MAC addresses. * * Since: 0.9.10 **/ void nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting) { g_return_if_fail (NM_IS_SETTING_WIRED (setting)); g_slist_free_full (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist, g_free); NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist = NULL; g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST); }
/** * nm_setting_wired_remove_s390_options: * @setting: the #NMSettingWired * @key: key name for the option to remove * * Remove the s390-specific option referenced by @key from the internal option * list. * * Returns: %TRUE if the option was found and removed from the internal option * list, %FALSE if it was not. **/ gboolean nm_setting_wired_remove_s390_option (NMSettingWired *setting, const char *key) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (key != NULL, FALSE); g_return_val_if_fail (strlen (key), FALSE); return g_hash_table_remove (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key); }
/** * nm_setting_wired_get_s390_option_by_key: * @setting: the #NMSettingWired * @key: the key for which to retrieve the value * * Returns the value associated with the s390-specific option specified by * @key, if it exists. * * Returns: the value, or %NULL if the key/value pair was never added to the * setting; the value is owned by the setting and must not be modified **/ const char * nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting, const char *key) { g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); g_return_val_if_fail (key != NULL, NULL); g_return_val_if_fail (strlen (key), NULL); return g_hash_table_lookup (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key); }
/** * nm_setting_wired_get_mac_blacklist_item: * @setting: the #NMSettingWired * @idx: the zero-based index of the MAC address entry * * Returns: the blacklisted MAC address string (hex-digits-and-colons notation) * at index @idx * * Since: 0.9.10 **/ const char * nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx) { NMSettingWiredPrivate *priv; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); priv = NM_SETTING_WIRED_GET_PRIVATE (setting); g_return_val_if_fail (idx <= g_slist_length (priv->mac_address_blacklist), NULL); return (const char *) g_slist_nth_data (priv->mac_address_blacklist, idx); }
/** * nm_setting_wired_remove_mac_blacklist_item: * @setting: the #NMSettingWired * @idx: index number of the MAC address * * Removes the MAC address at index @idx from the blacklist. * * Since: 0.9.10 **/ void nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx) { NMSettingWiredPrivate *priv; GSList *elt; g_return_if_fail (NM_IS_SETTING_WIRED (setting)); priv = NM_SETTING_WIRED_GET_PRIVATE (setting); elt = g_slist_nth (priv->mac_address_blacklist, idx); g_return_if_fail (elt != NULL); g_free (elt->data); priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, elt); }
/** * nm_setting_wired_remove_s390_option: * @setting: the #NMSettingWired * @key: key name for the option to remove * * Remove the s390-specific option referenced by @key from the internal option * list. * * Returns: %TRUE if the option was found and removed from the internal option * list, %FALSE if it was not. **/ gboolean nm_setting_wired_remove_s390_option (NMSettingWired *setting, const char *key) { gboolean found; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (key != NULL, FALSE); g_return_val_if_fail (strlen (key), FALSE); found = g_hash_table_remove (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, key); if (found) g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS); return found; }
/** * nm_setting_wired_add_s390_options: * @setting: the #NMSettingWired * @key: key name for the option * @value: value for the option * * Add an option to the table. The option is compared to an internal list * of allowed options. Key names may contain only alphanumeric characters * (ie [a-zA-Z0-9]). Adding a new key replaces any existing key/value pair that * may already exist. * * Returns: %TRUE if the option was valid and was added to the internal option * list, %FALSE if it was not. **/ gboolean nm_setting_wired_add_s390_option (NMSettingWired *setting, const char *key, const char *value) { size_t value_len; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (key != NULL, FALSE); g_return_val_if_fail (strlen (key), FALSE); g_return_val_if_fail (_nm_utils_string_in_list (key, valid_s390_opts), FALSE); g_return_val_if_fail (value != NULL, FALSE); value_len = strlen (value); g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE); g_hash_table_insert (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, g_strdup (key), g_strdup (value)); return TRUE; }
static gboolean is_connection_always_ask (NMConnection *connection) { NMSettingConnection *s_con; const char *ctype; NMSetting *setting; /* For the given connection type, check if the secrets for that connection * are always-ask or not. */ s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); ctype = nm_setting_connection_get_connection_type (s_con); setting = nm_connection_get_setting_by_name (connection, ctype); g_return_val_if_fail (setting != NULL, FALSE); if (has_always_ask (setting)) return TRUE; /* Try type-specific settings too; be a bit paranoid and only consider * secrets from settings relevant to the connection type. */ if (NM_IS_SETTING_WIRELESS (setting)) { setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); if (setting && has_always_ask (setting)) return TRUE; setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X); if (setting && has_always_ask (setting)) return TRUE; } else if (NM_IS_SETTING_WIRED (setting)) { setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_PPPOE); if (setting && has_always_ask (setting)) return TRUE; setting = nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X); if (setting && has_always_ask (setting)) return TRUE; } return FALSE; }
/** * nm_setting_wired_add_s390_option: * @setting: the #NMSettingWired * @key: key name for the option * @value: value for the option * * Add an option to the table. The option is compared to an internal list * of allowed options. Key names may contain only alphanumeric characters * (ie [a-zA-Z0-9]). Adding a new key replaces any existing key/value pair that * may already exist. * * Returns: %TRUE if the option was valid and was added to the internal option * list, %FALSE if it was not. **/ gboolean nm_setting_wired_add_s390_option (NMSettingWired *setting, const char *key, const char *value) { size_t value_len; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (key != NULL, FALSE); g_return_val_if_fail (strlen (key), FALSE); g_return_val_if_fail (g_strv_contains (valid_s390_opts, key), FALSE); g_return_val_if_fail (value != NULL, FALSE); value_len = strlen (value); g_return_val_if_fail (value_len > 0 && value_len < 200, FALSE); g_hash_table_insert (NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options, g_strdup (key), g_strdup (value)); g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_S390_OPTIONS); return TRUE; }
/** * nm_setting_wired_add_mac_blacklist_item: * @setting: the #NMSettingWired * @mac: the MAC address string (hex-digits-and-colons notation) to blacklist * * Adds a new MAC address to the #NMSettingWired:mac-address-blacklist property. * * Returns: %TRUE if the MAC address was added; %FALSE if the MAC address * is invalid or was already present * * Since: 0.9.10 **/ gboolean nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; GSList *iter; guint8 buf[32]; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (mac != NULL, FALSE); if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf)) return FALSE; priv = NM_SETTING_WIRED_GET_PRIVATE (setting); for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) { if (!strcasecmp (mac, (char *) iter->data)) return FALSE; } priv->mac_address_blacklist = g_slist_append (priv->mac_address_blacklist, g_ascii_strup (mac, -1)); return TRUE; }
/** * nm_setting_wired_remove_mac_blacklist_item_by_value: * @setting: the #NMSettingWired * @mac: the MAC address string (hex-digits-and-colons notation) to remove from * the blacklist * * Removes the MAC address @mac from the blacklist. * * Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not. * * Since: 0.9.10 **/ gboolean nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, const char *mac) { NMSettingWiredPrivate *priv; GSList *iter; guint8 buf[32]; g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); g_return_val_if_fail (mac != NULL, FALSE); if (!nm_utils_hwaddr_aton (mac, ARPHRD_ETHER, buf)) return FALSE; priv = NM_SETTING_WIRED_GET_PRIVATE (setting); for (iter = priv->mac_address_blacklist; iter; iter = g_slist_next (iter)) { if (!strcasecmp (mac, (char *) iter->data)) { priv->mac_address_blacklist = g_slist_delete_link (priv->mac_address_blacklist, iter); g_object_notify (G_OBJECT (setting), NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST); return TRUE; } } return FALSE; }
static gboolean verify (NMSetting *setting, GSList *all_settings, GError **error) { NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE (setting); NMSettingConnection *s_con = NULL; NMSettingWired *s_wired = NULL; GSList *iter; for (iter = all_settings; iter; iter = iter->next) { if (NM_IS_SETTING_CONNECTION (iter->data)) s_con = iter->data; else if (NM_IS_SETTING_WIRED (iter->data)) s_wired = iter->data; } /* If iface_name is specified, it must be a valid interface name. We * don't check that it matches parent and/or id, because we allowing * renaming vlans to arbitrary names. */ if (priv->iface_name && !nm_utils_iface_valid_name (priv->iface_name)) { g_set_error (error, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, NM_SETTING_VLAN_INTERFACE_NAME); return FALSE; } if (priv->parent) { if (nm_utils_is_uuid (priv->parent)) { /* If we have an NMSettingConnection:master with slave-type="vlan", * then it must be the same UUID. */ if (s_con) { const char *master = NULL, *slave_type = NULL; slave_type = nm_setting_connection_get_slave_type (s_con); if (!g_strcmp0 (slave_type, NM_SETTING_VLAN_SETTING_NAME)) master = nm_setting_connection_get_master (s_con); if (master && g_strcmp0 (priv->parent, master) != 0) { g_set_error (error, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_INVALID_PARENT, NM_SETTING_CONNECTION_MASTER); return FALSE; } } } else if (!nm_utils_iface_valid_name (priv->parent)) { /* parent must be either a UUID or an interface name */ g_set_error (error, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, NM_SETTING_VLAN_PARENT); return FALSE; } } else { /* If parent is NULL, the parent must be specified via * NMSettingWired:mac-address. */ if (!s_wired || !nm_setting_wired_get_mac_address (s_wired)) { g_set_error (error, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_MISSING_PROPERTY, NM_SETTING_VLAN_PARENT); return FALSE; } } if (priv->flags & ~(NM_VLAN_FLAG_REORDER_HEADERS | NM_VLAN_FLAG_GVRP | NM_VLAN_FLAG_LOOSE_BINDING)) { g_set_error (error, NM_SETTING_VLAN_ERROR, NM_SETTING_VLAN_ERROR_INVALID_PROPERTY, NM_SETTING_VLAN_FLAGS); return FALSE; } return TRUE; }
static void populate_ui (CEPageVlan *self) { CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self); GSList *devices, *d_iter; NMConnection *parent_connection = NULL; NMDevice *device, *parent_device = NULL; const char *parent, *iface, *current_parent; int i, mtu_def, mtu_val; devices = get_vlan_devices (self); /* Parent */ build_vlan_parent_list (self, devices); parent = nm_setting_vlan_get_parent (priv->setting); if (parent) { /* UUID? */ parent_connection = (NMConnection *)nm_remote_settings_get_connection_by_uuid (CE_PAGE (self)->settings, parent); if (!parent_connection) { /* Interface name? */ for (d_iter = devices; d_iter; d_iter = d_iter->next) { device = d_iter->data; if (!g_strcmp0 (parent, nm_device_get_iface (device))) { parent_device = device; break; } } } } /* If NMSettingVlan:parent didn't indicate a device, but we have a * wired setting, figure out the device from that. */ if (priv->s_hw && !parent_device) { const GByteArray *mac; const char *device_mac_str; char *mac_str; if (NM_IS_SETTING_WIRED (priv->s_hw)) mac = nm_setting_wired_get_mac_address (NM_SETTING_WIRED (priv->s_hw)); else mac = NULL; if (mac) { mac_str = nm_utils_hwaddr_ntoa (mac->data, ARPHRD_ETHER); for (d_iter = devices; d_iter; d_iter = d_iter->next) { device = d_iter->data; if (NM_IS_DEVICE_ETHERNET (device)) device_mac_str = nm_device_ethernet_get_permanent_hw_address (NM_DEVICE_ETHERNET (device)); else device_mac_str = NULL; if (!g_strcmp0 (mac_str, device_mac_str)) { parent_device = device; break; } } } } current_parent = parent; if (parent_device || parent_connection) { for (i = 0; priv->parents[i]; i++) { if (parent_device && parent_device != priv->parents[i]->device) continue; if (parent_connection != priv->parents[i]->connection) continue; current_parent = priv->parents[i]->label; break; } } ce_page_setup_mac_combo (CE_PAGE (self), priv->parent, current_parent, priv->parent_labels); g_signal_connect (priv->parent, "changed", G_CALLBACK (parent_changed), self); if (current_parent) priv->last_parent = g_strndup (current_parent, strcspn (current_parent, " ")); /* Name */ iface = nm_setting_vlan_get_interface_name (priv->setting); if (iface) gtk_entry_set_text (priv->name_entry, iface); g_signal_connect (priv->name_entry, "changed", G_CALLBACK (name_changed), self); /* ID */ priv->last_id = nm_setting_vlan_get_id (priv->setting); gtk_spin_button_set_value (priv->id_entry, priv->last_id); g_signal_connect (priv->id_entry, "value-changed", G_CALLBACK (id_changed), self); /* Cloned MAC address */ if (NM_IS_SETTING_WIRED (priv->s_hw)) { ce_page_mac_to_entry (nm_setting_wired_get_cloned_mac_address (NM_SETTING_WIRED (priv->s_hw)), ARPHRD_ETHER, priv->cloned_mac); } g_signal_connect (priv->cloned_mac, "changed", G_CALLBACK (stuff_changed), self); /* MTU */ if (NM_IS_SETTING_WIRED (priv->s_hw)) { mtu_def = ce_get_property_default (priv->s_hw, NM_SETTING_WIRED_MTU); mtu_val = nm_setting_wired_get_mtu (NM_SETTING_WIRED (priv->s_hw)); } else { mtu_def = mtu_val = 1500; } g_signal_connect (priv->mtu, "output", G_CALLBACK (ce_spin_output_with_default), GINT_TO_POINTER (mtu_def)); gtk_spin_button_set_value (priv->mtu, (gdouble) mtu_val); g_signal_connect (priv->mtu, "value-changed", G_CALLBACK (stuff_changed), self); g_slist_free (devices); }