diff options
Diffstat (limited to 'libnm-core/nm-setting-wired.c')
-rw-r--r-- | libnm-core/nm-setting-wired.c | 1729 |
1 files changed, 877 insertions, 852 deletions
diff --git a/libnm-core/nm-setting-wired.c b/libnm-core/nm-setting-wired.c index 8b0f255860..d74bc2a187 100644 --- a/libnm-core/nm-setting-wired.c +++ b/libnm-core/nm-setting-wired.c @@ -25,116 +25,117 @@ /*****************************************************************************/ -G_STATIC_ASSERT (NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS == ( NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT - | NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)); +G_STATIC_ASSERT(NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS + == (NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT | NM_SETTING_WIRED_WAKE_ON_LAN_IGNORE)); /*****************************************************************************/ -NM_GOBJECT_PROPERTIES_DEFINE (NMSettingWired, - PROP_PORT, - PROP_SPEED, - PROP_DUPLEX, - PROP_AUTO_NEGOTIATE, - PROP_MAC_ADDRESS, - PROP_CLONED_MAC_ADDRESS, - PROP_GENERATE_MAC_ADDRESS_MASK, - PROP_MAC_ADDRESS_BLACKLIST, - PROP_MTU, - PROP_S390_SUBCHANNELS, - PROP_S390_NETTYPE, - PROP_S390_OPTIONS, - PROP_WAKE_ON_LAN, - PROP_WAKE_ON_LAN_PASSWORD, -); +NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWired, + PROP_PORT, + PROP_SPEED, + PROP_DUPLEX, + PROP_AUTO_NEGOTIATE, + PROP_MAC_ADDRESS, + PROP_CLONED_MAC_ADDRESS, + PROP_GENERATE_MAC_ADDRESS_MASK, + PROP_MAC_ADDRESS_BLACKLIST, + PROP_MTU, + PROP_S390_SUBCHANNELS, + PROP_S390_NETTYPE, + PROP_S390_OPTIONS, + PROP_WAKE_ON_LAN, + PROP_WAKE_ON_LAN_PASSWORD, ); typedef struct { - struct { - NMUtilsNamedValue *arr; - guint len; - guint n_alloc; - } s390_options; - GArray *mac_address_blacklist; - char **s390_subchannels; - char *port; - char *duplex; - char *device_mac_address; - char *cloned_mac_address; - char *generate_mac_address_mask; - char *s390_nettype; - char *wol_password; - NMSettingWiredWakeOnLan wol; - guint32 speed; - guint32 mtu; - bool auto_negotiate:1; + struct { + NMUtilsNamedValue *arr; + guint len; + guint n_alloc; + } s390_options; + GArray * mac_address_blacklist; + char ** s390_subchannels; + char * port; + char * duplex; + char * device_mac_address; + char * cloned_mac_address; + char * generate_mac_address_mask; + char * s390_nettype; + char * wol_password; + NMSettingWiredWakeOnLan wol; + guint32 speed; + guint32 mtu; + bool auto_negotiate : 1; } NMSettingWiredPrivate; -G_DEFINE_TYPE (NMSettingWired, nm_setting_wired, NM_TYPE_SETTING) +G_DEFINE_TYPE(NMSettingWired, nm_setting_wired, NM_TYPE_SETTING) -#define NM_SETTING_WIRED_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate)) +#define NM_SETTING_WIRED_GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE((o), NM_TYPE_SETTING_WIRED, NMSettingWiredPrivate)) /*****************************************************************************/ static const char *valid_s390_opts[] = { - "broadcast_mode", - "buffer_count", - "canonical_macaddr", - "checksumming", - "ctcprot", - "fake_broadcast", - "inter", - "inter_jumbo", - "ipato_add4", - "ipato_add6", - "ipato_enable", - "ipato_invert4", - "ipato_invert6", - "isolation", - "lancmd_timeout", - "large_send", - "layer2", - "portname", - "portno", - "priority_queueing", - "protocol", - "route4", - "route6", - "rxip_add4", - "rxip_add6", - "sniffer", - "total", - "vipa_add4", - "vipa_add6", - NULL, + "broadcast_mode", + "buffer_count", + "canonical_macaddr", + "checksumming", + "ctcprot", + "fake_broadcast", + "inter", + "inter_jumbo", + "ipato_add4", + "ipato_add6", + "ipato_enable", + "ipato_invert4", + "ipato_invert6", + "isolation", + "lancmd_timeout", + "large_send", + "layer2", + "portname", + "portno", + "priority_queueing", + "protocol", + "route4", + "route6", + "rxip_add4", + "rxip_add6", + "sniffer", + "total", + "vipa_add4", + "vipa_add6", + NULL, }; static gboolean -valid_s390_opts_check (const char *option) +valid_s390_opts_check(const char *option) { #if NM_MORE_ASSERTS > 5 - nm_assert (NM_PTRARRAY_LEN (valid_s390_opts) + 1 == G_N_ELEMENTS (valid_s390_opts)); - { - gsize i; - - for (i = 0; i < G_N_ELEMENTS (valid_s390_opts); i++) { - if (i == G_N_ELEMENTS (valid_s390_opts) - 1) - nm_assert (!valid_s390_opts[i]); - else { - nm_assert (valid_s390_opts[i]); - nm_assert (valid_s390_opts[i][0] != '\0'); - if (i > 0) - g_assert (strcmp (valid_s390_opts[i - 1], valid_s390_opts[i]) < 0); - } - } - } + nm_assert(NM_PTRARRAY_LEN(valid_s390_opts) + 1 == G_N_ELEMENTS(valid_s390_opts)); + { + gsize i; + + for (i = 0; i < G_N_ELEMENTS(valid_s390_opts); i++) { + if (i == G_N_ELEMENTS(valid_s390_opts) - 1) + nm_assert(!valid_s390_opts[i]); + else { + nm_assert(valid_s390_opts[i]); + nm_assert(valid_s390_opts[i][0] != '\0'); + if (i > 0) + g_assert(strcmp(valid_s390_opts[i - 1], valid_s390_opts[i]) < 0); + } + } + } #endif - return option - && (nm_utils_array_find_binary_search (valid_s390_opts, - sizeof (const char *), - G_N_ELEMENTS (valid_s390_opts) - 1, - &option, - nm_strcmp_p_with_data, - NULL) >= 0); + return option + && (nm_utils_array_find_binary_search(valid_s390_opts, + sizeof(const char *), + G_N_ELEMENTS(valid_s390_opts) - 1, + &option, + nm_strcmp_p_with_data, + NULL) + >= 0); } /** @@ -144,11 +145,11 @@ valid_s390_opts_check (const char *option) * Returns: the #NMSettingWired:port property of the setting **/ const char * -nm_setting_wired_get_port (NMSettingWired *setting) +nm_setting_wired_get_port(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->port; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->port; } /** @@ -158,11 +159,11 @@ nm_setting_wired_get_port (NMSettingWired *setting) * Returns: the #NMSettingWired:speed property of the setting **/ guint32 -nm_setting_wired_get_speed (NMSettingWired *setting) +nm_setting_wired_get_speed(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), 0); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->speed; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->speed; } /** @@ -172,11 +173,11 @@ nm_setting_wired_get_speed (NMSettingWired *setting) * Returns: the #NMSettingWired:duplex property of the setting **/ const char * -nm_setting_wired_get_duplex (NMSettingWired *setting) +nm_setting_wired_get_duplex(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->duplex; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->duplex; } /** @@ -186,11 +187,11 @@ nm_setting_wired_get_duplex (NMSettingWired *setting) * Returns: the #NMSettingWired:auto-negotiate property of the setting **/ gboolean -nm_setting_wired_get_auto_negotiate (NMSettingWired *setting) +nm_setting_wired_get_auto_negotiate(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->auto_negotiate; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->auto_negotiate; } /** @@ -200,11 +201,11 @@ nm_setting_wired_get_auto_negotiate (NMSettingWired *setting) * Returns: the #NMSettingWired:mac-address property of the setting **/ const char * -nm_setting_wired_get_mac_address (NMSettingWired *setting) +nm_setting_wired_get_mac_address(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->device_mac_address; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->device_mac_address; } /** @@ -214,11 +215,11 @@ nm_setting_wired_get_mac_address (NMSettingWired *setting) * Returns: the #NMSettingWired:cloned-mac-address property of the setting **/ const char * -nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting) +nm_setting_wired_get_cloned_mac_address(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->cloned_mac_address; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->cloned_mac_address; } /** @@ -230,11 +231,11 @@ nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting) * Since: 1.4 **/ const char * -nm_setting_wired_get_generate_mac_address_mask (NMSettingWired *setting) +nm_setting_wired_get_generate_mac_address_mask(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->generate_mac_address_mask; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->generate_mac_address_mask; } /** @@ -243,15 +244,15 @@ nm_setting_wired_get_generate_mac_address_mask (NMSettingWired *setting) * * Returns: the #NMSettingWired:mac-address-blacklist property of the setting **/ -const char * const * -nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting) +const char *const * +nm_setting_wired_get_mac_address_blacklist(NMSettingWired *setting) { - NMSettingWiredPrivate *priv; + NMSettingWiredPrivate *priv; - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - return (const char * const *) priv->mac_address_blacklist->data; + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + return (const char *const *) priv->mac_address_blacklist->data; } /** @@ -261,11 +262,11 @@ nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting) * Returns: the number of blacklisted MAC addresses **/ guint32 -nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting) +nm_setting_wired_get_num_mac_blacklist_items(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), 0); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist->len; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->mac_address_blacklist->len; } /** @@ -277,16 +278,16 @@ nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting) * at index @idx **/ const char * -nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx) +nm_setting_wired_get_mac_blacklist_item(NMSettingWired *setting, guint32 idx) { - NMSettingWiredPrivate *priv; + NMSettingWiredPrivate *priv; - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - g_return_val_if_fail (idx <= priv->mac_address_blacklist->len, NULL); + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + g_return_val_if_fail(idx <= priv->mac_address_blacklist->len, NULL); - return g_array_index (priv->mac_address_blacklist, const char *, idx); + return g_array_index(priv->mac_address_blacklist, const char *, idx); } /** @@ -300,29 +301,29 @@ nm_setting_wired_get_mac_blacklist_item (NMSettingWired *setting, guint32 idx) * is invalid or was already present **/ gboolean -nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *mac) +nm_setting_wired_add_mac_blacklist_item(NMSettingWired *setting, const char *mac) { - NMSettingWiredPrivate *priv; - const char *candidate; - int i; - - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); - g_return_val_if_fail (mac != NULL, FALSE); - - if (!nm_utils_hwaddr_valid (mac, ETH_ALEN)) - return FALSE; - - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - for (i = 0; i < priv->mac_address_blacklist->len; i++) { - candidate = g_array_index (priv->mac_address_blacklist, char *, i); - if (nm_utils_hwaddr_matches (mac, -1, candidate, -1)) - return FALSE; - } - - mac = nm_utils_hwaddr_canonical (mac, ETH_ALEN); - g_array_append_val (priv->mac_address_blacklist, mac); - _notify (setting, PROP_MAC_ADDRESS_BLACKLIST); - return TRUE; + NMSettingWiredPrivate *priv; + const char * candidate; + int i; + + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); + g_return_val_if_fail(mac != NULL, FALSE); + + if (!nm_utils_hwaddr_valid(mac, ETH_ALEN)) + return FALSE; + + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + for (i = 0; i < priv->mac_address_blacklist->len; i++) { + candidate = g_array_index(priv->mac_address_blacklist, char *, i); + if (nm_utils_hwaddr_matches(mac, -1, candidate, -1)) + return FALSE; + } + + mac = nm_utils_hwaddr_canonical(mac, ETH_ALEN); + g_array_append_val(priv->mac_address_blacklist, mac); + _notify(setting, PROP_MAC_ADDRESS_BLACKLIST); + return TRUE; } /** @@ -333,17 +334,17 @@ nm_setting_wired_add_mac_blacklist_item (NMSettingWired *setting, const char *ma * Removes the MAC address at index @idx from the blacklist. **/ void -nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx) +nm_setting_wired_remove_mac_blacklist_item(NMSettingWired *setting, guint32 idx) { - NMSettingWiredPrivate *priv; + NMSettingWiredPrivate *priv; - g_return_if_fail (NM_IS_SETTING_WIRED (setting)); + g_return_if_fail(NM_IS_SETTING_WIRED(setting)); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - g_return_if_fail (idx < priv->mac_address_blacklist->len); + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + g_return_if_fail(idx < priv->mac_address_blacklist->len); - g_array_remove_index (priv->mac_address_blacklist, idx); - _notify (setting, PROP_MAC_ADDRESS_BLACKLIST); + g_array_remove_index(priv->mac_address_blacklist, idx); + _notify(setting, PROP_MAC_ADDRESS_BLACKLIST); } /** @@ -357,25 +358,25 @@ nm_setting_wired_remove_mac_blacklist_item (NMSettingWired *setting, guint32 idx * Returns: %TRUE if the MAC address was found and removed; %FALSE if it was not. **/ gboolean -nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, const char *mac) +nm_setting_wired_remove_mac_blacklist_item_by_value(NMSettingWired *setting, const char *mac) { - NMSettingWiredPrivate *priv; - const char *candidate; - int i; - - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); - g_return_val_if_fail (mac != NULL, FALSE); - - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - for (i = 0; i < priv->mac_address_blacklist->len; i++) { - candidate = g_array_index (priv->mac_address_blacklist, char *, i); - if (!nm_utils_hwaddr_matches (mac, -1, candidate, -1)) { - g_array_remove_index (priv->mac_address_blacklist, i); - _notify (setting, PROP_MAC_ADDRESS_BLACKLIST); - return TRUE; - } - } - return FALSE; + NMSettingWiredPrivate *priv; + const char * candidate; + int i; + + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); + g_return_val_if_fail(mac != NULL, FALSE); + + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + for (i = 0; i < priv->mac_address_blacklist->len; i++) { + candidate = g_array_index(priv->mac_address_blacklist, char *, i); + if (!nm_utils_hwaddr_matches(mac, -1, candidate, -1)) { + g_array_remove_index(priv->mac_address_blacklist, i); + _notify(setting, PROP_MAC_ADDRESS_BLACKLIST); + return TRUE; + } + } + return FALSE; } /** @@ -385,12 +386,12 @@ nm_setting_wired_remove_mac_blacklist_item_by_value (NMSettingWired *setting, co * Removes all blacklisted MAC addresses. **/ void -nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting) +nm_setting_wired_clear_mac_blacklist_items(NMSettingWired *setting) { - g_return_if_fail (NM_IS_SETTING_WIRED (setting)); + g_return_if_fail(NM_IS_SETTING_WIRED(setting)); - g_array_set_size (NM_SETTING_WIRED_GET_PRIVATE (setting)->mac_address_blacklist, 0); - _notify (setting, PROP_MAC_ADDRESS_BLACKLIST); + g_array_set_size(NM_SETTING_WIRED_GET_PRIVATE(setting)->mac_address_blacklist, 0); + _notify(setting, PROP_MAC_ADDRESS_BLACKLIST); } /** @@ -400,11 +401,11 @@ nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *setting) * Returns: the #NMSettingWired:mtu property of the setting **/ guint32 -nm_setting_wired_get_mtu (NMSettingWired *setting) +nm_setting_wired_get_mtu(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), 0); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->mtu; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->mtu; } /** @@ -418,12 +419,12 @@ nm_setting_wired_get_mtu (NMSettingWired *setting) * Returns: (transfer none) (element-type utf8): array of strings, each specifying * one subchannel the s390 device uses to communicate to the host. **/ -const char * const * -nm_setting_wired_get_s390_subchannels (NMSettingWired *setting) +const char *const * +nm_setting_wired_get_s390_subchannels(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return (const char * const *) NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels; + return (const char *const *) NM_SETTING_WIRED_GET_PRIVATE(setting)->s390_subchannels; } /** @@ -436,11 +437,11 @@ nm_setting_wired_get_s390_subchannels (NMSettingWired *setting) * Returns: the s390 device type **/ const char * -nm_setting_wired_get_s390_nettype (NMSettingWired *setting) +nm_setting_wired_get_s390_nettype(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_nettype; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->s390_nettype; } /** @@ -454,11 +455,11 @@ nm_setting_wired_get_s390_nettype (NMSettingWired *setting) * Returns: the number of s390-specific device options **/ guint32 -nm_setting_wired_get_num_s390_options (NMSettingWired *setting) +nm_setting_wired_get_num_s390_options(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), 0); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), 0); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_options.len; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->s390_options.len; } /** @@ -483,29 +484,29 @@ nm_setting_wired_get_num_s390_options (NMSettingWired *setting) * currently held by the setting) **/ gboolean -nm_setting_wired_get_s390_option (NMSettingWired *setting, - guint32 idx, - const char **out_key, - const char **out_value) +nm_setting_wired_get_s390_option(NMSettingWired *setting, + guint32 idx, + const char ** out_key, + const char ** out_value) { - NMSettingWiredPrivate *priv; + NMSettingWiredPrivate *priv; - /* with LTO and optimization, the compiler complains that the + /* with LTO and optimization, the compiler complains that the * output variables are not initialized. In practice, the function * only sets the output on success. But make the compiler happy. */ - NM_SET_OUT (out_key, NULL); - NM_SET_OUT (out_value, NULL); + NM_SET_OUT(out_key, NULL); + NM_SET_OUT(out_value, NULL); - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - g_return_val_if_fail (idx < priv->s390_options.len, FALSE); + g_return_val_if_fail(idx < priv->s390_options.len, FALSE); - NM_SET_OUT (out_key, priv->s390_options.arr[idx].name); - NM_SET_OUT (out_value, priv->s390_options.arr[idx].value_str); - return TRUE; + NM_SET_OUT(out_key, priv->s390_options.arr[idx].name); + NM_SET_OUT(out_value, priv->s390_options.arr[idx].value_str); + return TRUE; } /** @@ -520,24 +521,20 @@ nm_setting_wired_get_s390_option (NMSettingWired *setting, * 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) +nm_setting_wired_get_s390_option_by_key(NMSettingWired *setting, const char *key) { - NMSettingWiredPrivate *priv; - gssize idx; + NMSettingWiredPrivate *priv; + gssize idx; - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); - g_return_val_if_fail (key && key[0], NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); + g_return_val_if_fail(key && key[0], NULL); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - idx = nm_utils_named_value_list_find (priv->s390_options.arr, - priv->s390_options.len, - key, - TRUE); - if (idx < 0) - return NULL; - return priv->s390_options.arr[idx].value_str; + idx = nm_utils_named_value_list_find(priv->s390_options.arr, priv->s390_options.len, key, TRUE); + if (idx < 0) + return NULL; + return priv->s390_options.arr[idx].value_str; } /** @@ -555,57 +552,52 @@ nm_setting_wired_get_s390_option_by_key (NMSettingWired *setting, * list, %FALSE if it was not. **/ gboolean -nm_setting_wired_add_s390_option (NMSettingWired *setting, - const char *key, - const char *value) +nm_setting_wired_add_s390_option(NMSettingWired *setting, const char *key, const char *value) { - NMSettingWiredPrivate *priv; - gssize idx; - NMUtilsNamedValue *v; - - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); - g_return_val_if_fail (value, FALSE); - - if (!valid_s390_opts_check (key)) { - g_return_val_if_fail (key, FALSE); - return FALSE; - } - - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - - idx = nm_utils_named_value_list_find (priv->s390_options.arr, - priv->s390_options.len, - key, - TRUE); - if (idx < 0) { - gsize dst_idx = ~idx; - - if (priv->s390_options.n_alloc < priv->s390_options.len + 1) { - priv->s390_options.n_alloc = NM_MAX (4, - (priv->s390_options.len + 1) * 2); - priv->s390_options.arr = g_realloc (priv->s390_options.arr, - priv->s390_options.n_alloc * sizeof (NMUtilsNamedValue)); - } - if (dst_idx < priv->s390_options.len) { - memmove (&priv->s390_options.arr[dst_idx + 1], - &priv->s390_options.arr[dst_idx], - (priv->s390_options.len - dst_idx) * sizeof (NMUtilsNamedValue)); - } - priv->s390_options.arr[dst_idx] = (NMUtilsNamedValue) { - .name = g_strdup (key), - .value_str = g_strdup (value), - }; - priv->s390_options.len++; - } else { - v = &priv->s390_options.arr[idx]; - if (nm_streq (value, v->value_str)) - return TRUE; - g_free ((char *) v->value_str); - v->value_str = g_strdup (value); - } - - _notify (setting, PROP_S390_OPTIONS); - return TRUE; + NMSettingWiredPrivate *priv; + gssize idx; + NMUtilsNamedValue * v; + + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); + g_return_val_if_fail(value, FALSE); + + if (!valid_s390_opts_check(key)) { + g_return_val_if_fail(key, FALSE); + return FALSE; + } + + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + + idx = nm_utils_named_value_list_find(priv->s390_options.arr, priv->s390_options.len, key, TRUE); + if (idx < 0) { + gsize dst_idx = ~idx; + + if (priv->s390_options.n_alloc < priv->s390_options.len + 1) { + priv->s390_options.n_alloc = NM_MAX(4, (priv->s390_options.len + 1) * 2); + priv->s390_options.arr = + g_realloc(priv->s390_options.arr, + priv->s390_options.n_alloc * sizeof(NMUtilsNamedValue)); + } + if (dst_idx < priv->s390_options.len) { + memmove(&priv->s390_options.arr[dst_idx + 1], + &priv->s390_options.arr[dst_idx], + (priv->s390_options.len - dst_idx) * sizeof(NMUtilsNamedValue)); + } + priv->s390_options.arr[dst_idx] = (NMUtilsNamedValue){ + .name = g_strdup(key), + .value_str = g_strdup(value), + }; + priv->s390_options.len++; + } else { + v = &priv->s390_options.arr[idx]; + if (nm_streq(value, v->value_str)) + return TRUE; + g_free((char *) v->value_str); + v->value_str = g_strdup(value); + } + + _notify(setting, PROP_S390_OPTIONS); + return TRUE; } /** @@ -620,61 +612,57 @@ nm_setting_wired_add_s390_option (NMSettingWired *setting, * list, %FALSE if it was not. **/ gboolean -nm_setting_wired_remove_s390_option (NMSettingWired *setting, - const char *key) +nm_setting_wired_remove_s390_option(NMSettingWired *setting, const char *key) { - NMSettingWiredPrivate *priv; - gsize dst_idx; - gssize idx; + NMSettingWiredPrivate *priv; + gsize dst_idx; + gssize idx; - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), FALSE); - g_return_val_if_fail (key, FALSE); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), FALSE); + g_return_val_if_fail(key, FALSE); - priv = NM_SETTING_WIRED_GET_PRIVATE (setting); + priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - idx = nm_utils_named_value_list_find (priv->s390_options.arr, - priv->s390_options.len, - key, - TRUE); - if (idx < 0) - return FALSE; + idx = nm_utils_named_value_list_find(priv->s390_options.arr, priv->s390_options.len, key, TRUE); + if (idx < 0) + return FALSE; - dst_idx = idx; + dst_idx = idx; - g_free ((char *) priv->s390_options.arr[dst_idx].name); - g_free ((char *) priv->s390_options.arr[dst_idx].value_str); - if (dst_idx + 1 != priv->s390_options.len) { - memmove (&priv->s390_options.arr[dst_idx], - &priv->s390_options.arr[dst_idx + 1], - (priv->s390_options.len - dst_idx - 1) * sizeof (NMUtilsNamedValue)); - } + g_free((char *) priv->s390_options.arr[dst_idx].name); + g_free((char *) priv->s390_options.arr[dst_idx].value_str); + if (dst_idx + 1 != priv->s390_options.len) { + memmove(&priv->s390_options.arr[dst_idx], + &priv->s390_options.arr[dst_idx + 1], + (priv->s390_options.len - dst_idx - 1) * sizeof(NMUtilsNamedValue)); + } - priv->s390_options.len--; + priv->s390_options.len--; - _notify (setting, PROP_S390_OPTIONS); - return TRUE; + _notify(setting, PROP_S390_OPTIONS); + return TRUE; } static void -_s390_options_clear (NMSettingWiredPrivate *priv) +_s390_options_clear(NMSettingWiredPrivate *priv) { - guint i; - - for (i = 0; i < priv->s390_options.len; i++) { - g_free ((char *) priv->s390_options.arr[i].name); - g_free ((char *) priv->s390_options.arr[i].value_str); - } - nm_clear_g_free (&priv->s390_options.arr); - priv->s390_options.len = 0; - priv->s390_options.n_alloc = 0; + guint i; + + for (i = 0; i < priv->s390_options.len; i++) { + g_free((char *) priv->s390_options.arr[i].name); + g_free((char *) priv->s390_options.arr[i].value_str); + } + nm_clear_g_free(&priv->s390_options.arr); + priv->s390_options.len = 0; + priv->s390_options.n_alloc = 0; } void -_nm_setting_wired_clear_s390_options (NMSettingWired *setting) +_nm_setting_wired_clear_s390_options(NMSettingWired *setting) { - g_return_if_fail (NM_IS_SETTING_WIRED (setting)); + g_return_if_fail(NM_IS_SETTING_WIRED(setting)); - _s390_options_clear (NM_SETTING_WIRED_GET_PRIVATE (setting)); + _s390_options_clear(NM_SETTING_WIRED_GET_PRIVATE(setting)); } /** @@ -689,9 +677,9 @@ _nm_setting_wired_clear_s390_options (NMSettingWired *setting) * Returns: (transfer none): a %NULL-terminated array of strings of valid s390 options. **/ const char ** -nm_setting_wired_get_valid_s390_options (NMSettingWired *setting) +nm_setting_wired_get_valid_s390_options(NMSettingWired *setting) { - return valid_s390_opts; + return valid_s390_opts; } /** @@ -705,11 +693,11 @@ nm_setting_wired_get_valid_s390_options (NMSettingWired *setting) * Since: 1.2 */ NMSettingWiredWakeOnLan -nm_setting_wired_get_wake_on_lan (NMSettingWired *setting) +nm_setting_wired_get_wake_on_lan(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NM_SETTING_WIRED_WAKE_ON_LAN_NONE); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NM_SETTING_WIRED_WAKE_ON_LAN_NONE); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->wol; } /** @@ -724,436 +712,456 @@ nm_setting_wired_get_wake_on_lan (NMSettingWired *setting) * Since: 1.2 */ const char * -nm_setting_wired_get_wake_on_lan_password (NMSettingWired *setting) +nm_setting_wired_get_wake_on_lan_password(NMSettingWired *setting) { - g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL); + g_return_val_if_fail(NM_IS_SETTING_WIRED(setting), NULL); - return NM_SETTING_WIRED_GET_PRIVATE (setting)->wol_password; + return NM_SETTING_WIRED_GET_PRIVATE(setting)->wol_password; } static gboolean -verify (NMSetting *setting, NMConnection *connection, GError **error) +verify(NMSetting *setting, NMConnection *connection, GError **error) { - NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - GError *local = NULL; - guint i; - - if (!NM_IN_STRSET (priv->port, NULL, "tp", "aui", "bnc", "mii")) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid Ethernet port value"), - priv->port); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_PORT); - return FALSE; - } - - if (!NM_IN_STRSET (priv->duplex, NULL, "half", "full")) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid duplex value"), - priv->duplex); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_DUPLEX); - return FALSE; - } - - if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid MAC address"), - priv->device_mac_address); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS); - return FALSE; - } - - for (i = 0; i < priv->mac_address_blacklist->len; i++) { - const char *mac = g_array_index (priv->mac_address_blacklist, const char *, i); - - if (!nm_utils_hwaddr_valid (mac, ETH_ALEN)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid MAC address"), - mac); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST); - return FALSE; - } - } - - if (priv->s390_subchannels) { - guint len = g_strv_length (priv->s390_subchannels); - - if (len != 2 && len != 3) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS); - return FALSE; - } - } - - if (!NM_IN_STRSET (priv->s390_nettype, NULL, "qeth", "lcs", "ctc")) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("property is invalid")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_NETTYPE); - return FALSE; - } - - for (i = 0; i < priv->s390_options.len; i++) { - const NMUtilsNamedValue *v = &priv->s390_options.arr[i]; - - nm_assert (v->name); - - if ( !valid_s390_opts_check (v->name) - || v->value_str[0] == '\0' - || strlen (v->value_str) > 200) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("invalid '%s' or its value '%s'"), - v->name, v->value_str); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_OPTIONS); - return FALSE; - } - } - - if ( priv->cloned_mac_address - && !NM_CLONED_MAC_IS_SPECIAL (priv->cloned_mac_address) - && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid MAC address"), - priv->cloned_mac_address); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_CLONED_MAC_ADDRESS); - return FALSE; - } - - /* generate-mac-address-mask only makes sense with cloned-mac-address "random" or + NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + GError * local = NULL; + guint i; + + if (!NM_IN_STRSET(priv->port, NULL, "tp", "aui", "bnc", "mii")) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid Ethernet port value"), + priv->port); + g_prefix_error(error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_PORT); + return FALSE; + } + + if (!NM_IN_STRSET(priv->duplex, NULL, "half", "full")) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid duplex value"), + priv->duplex); + g_prefix_error(error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_DUPLEX); + return FALSE; + } + + if (priv->device_mac_address && !nm_utils_hwaddr_valid(priv->device_mac_address, ETH_ALEN)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid MAC address"), + priv->device_mac_address); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_MAC_ADDRESS); + return FALSE; + } + + for (i = 0; i < priv->mac_address_blacklist->len; i++) { + const char *mac = g_array_index(priv->mac_address_blacklist, const char *, i); + + if (!nm_utils_hwaddr_valid(mac, ETH_ALEN)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid MAC address"), + mac); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST); + return FALSE; + } + } + + if (priv->s390_subchannels) { + guint len = g_strv_length(priv->s390_subchannels); + + if (len != 2 && len != 3) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("property is invalid")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_S390_SUBCHANNELS); + return FALSE; + } + } + + if (!NM_IN_STRSET(priv->s390_nettype, NULL, "qeth", "lcs", "ctc")) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("property is invalid")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_S390_NETTYPE); + return FALSE; + } + + for (i = 0; i < priv->s390_options.len; i++) { + const NMUtilsNamedValue *v = &priv->s390_options.arr[i]; + + nm_assert(v->name); + + if (!valid_s390_opts_check(v->name) || v->value_str[0] == '\0' + || strlen(v->value_str) > 200) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("invalid '%s' or its value '%s'"), + v->name, + v->value_str); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_S390_OPTIONS); + return FALSE; + } + } + + if (priv->cloned_mac_address && !NM_CLONED_MAC_IS_SPECIAL(priv->cloned_mac_address) + && !nm_utils_hwaddr_valid(priv->cloned_mac_address, ETH_ALEN)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid MAC address"), + priv->cloned_mac_address); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_CLONED_MAC_ADDRESS); + return FALSE; + } + + /* generate-mac-address-mask only makes sense with cloned-mac-address "random" or * "stable". Still, let's not be so strict about that and accept the value * even if it is unused. */ - if (!_nm_utils_generate_mac_address_mask_parse (priv->generate_mac_address_mask, - NULL, NULL, NULL, &local)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - local->message); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK); - g_error_free (local); - return FALSE; - } - - if ( NM_FLAGS_ANY (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS) - && !nm_utils_is_power_of_two (priv->wol)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Wake-on-LAN mode 'default' and 'ignore' are exclusive flags")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN); - return FALSE; - } - - if (priv->wol_password && !NM_FLAGS_HAS (priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("Wake-on-LAN password can only be used with magic packet mode")); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); - return FALSE; - } - - if (priv->wol_password && !nm_utils_hwaddr_valid (priv->wol_password, ETH_ALEN)) { - g_set_error (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - _("'%s' is not a valid MAC address"), - priv->wol_password); - g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); - return FALSE; - } - - /* Normalizable properties - just return NM_SETTING_VERIFY_NORMALIZABLE for compatibility + if (!_nm_utils_generate_mac_address_mask_parse(priv->generate_mac_address_mask, + NULL, + NULL, + NULL, + &local)) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + local->message); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK); + g_error_free(local); + return FALSE; + } + + if (NM_FLAGS_ANY(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS) + && !nm_utils_is_power_of_two(priv->wol)) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Wake-on-LAN mode 'default' and 'ignore' are exclusive flags")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_WAKE_ON_LAN); + return FALSE; + } + + if (priv->wol_password && !NM_FLAGS_HAS(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) { + g_set_error_literal(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("Wake-on-LAN password can only be used with magic packet mode")); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); + return FALSE; + } + + if (priv->wol_password && !nm_utils_hwaddr_valid(priv->wol_password, ETH_ALEN)) { + g_set_error(error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + _("'%s' is not a valid MAC address"), + priv->wol_password); + g_prefix_error(error, + "%s.%s: ", + NM_SETTING_WIRED_SETTING_NAME, + NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD); + return FALSE; + } + + /* Normalizable properties - just return NM_SETTING_VERIFY_NORMALIZABLE for compatibility * with legacy nm-connection-editor which used to save "full" duplex connection as default */ - if ( ((priv->speed) && (!priv->duplex)) - || ((!priv->speed) && (priv->duplex))) { - - g_set_error_literal (error, - NM_CONNECTION_ERROR, - NM_CONNECTION_ERROR_INVALID_PROPERTY, - priv->auto_negotiate ? - _("both speed and duplex should have a valid value or both should be unset") - : _("both speed and duplex are required for static link configuration")); - return NM_SETTING_VERIFY_NORMALIZABLE; - } - - return TRUE; + if (((priv->speed) && (!priv->duplex)) || ((!priv->speed) && (priv->duplex))) { + g_set_error_literal( + error, + NM_CONNECTION_ERROR, + NM_CONNECTION_ERROR_INVALID_PROPERTY, + priv->auto_negotiate + ? _("both speed and duplex should have a valid value or both should be unset") + : _("both speed and duplex are required for static link configuration")); + return NM_SETTING_VERIFY_NORMALIZABLE; + } + + return TRUE; } static NMTernary -compare_property (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *con_a, - NMSetting *set_a, - NMConnection *con_b, - NMSetting *set_b, - NMSettingCompareFlags flags) +compare_property(const NMSettInfoSetting *sett_info, + guint property_idx, + NMConnection * con_a, + NMSetting * set_a, + NMConnection * con_b, + NMSetting * set_b, + NMSettingCompareFlags flags) { - - if (nm_streq (sett_info->property_infos[property_idx].name, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)) { - return !set_b - || nm_streq0 (NM_SETTING_WIRED_GET_PRIVATE (set_a)->cloned_mac_address, - NM_SETTING_WIRED_GET_PRIVATE (set_b)->cloned_mac_address); - } - - return NM_SETTING_CLASS (nm_setting_wired_parent_class)->compare_property (sett_info, - property_idx, - con_a, - set_a, - con_b, - set_b, - flags); + if (nm_streq(sett_info->property_infos[property_idx].name, + NM_SETTING_WIRED_CLONED_MAC_ADDRESS)) { + return !set_b + || nm_streq0(NM_SETTING_WIRED_GET_PRIVATE(set_a)->cloned_mac_address, + NM_SETTING_WIRED_GET_PRIVATE(set_b)->cloned_mac_address); + } + + return NM_SETTING_CLASS(nm_setting_wired_parent_class) + ->compare_property(sett_info, property_idx, con_a, set_a, con_b, set_b, flags); } static GVariant * -_override_autoneg_get (const NMSettInfoSetting *sett_info, - guint property_idx, - NMConnection *connection, - NMSetting *setting, - NMConnectionSerializationFlags flags, - const NMConnectionSerializationOptions *options) +_override_autoneg_get(const NMSettInfoSetting * sett_info, + guint property_idx, + NMConnection * connection, + NMSetting * setting, + NMConnectionSerializationFlags flags, + const NMConnectionSerializationOptions *options) { - return g_variant_new_boolean (nm_setting_wired_get_auto_negotiate ((NMSettingWired *) setting)); + return g_variant_new_boolean(nm_setting_wired_get_auto_negotiate((NMSettingWired *) setting)); } /*****************************************************************************/ static void -clear_blacklist_item (char **item_p) +clear_blacklist_item(char **item_p) { - g_free (*item_p); + g_free(*item_p); } /*****************************************************************************/ static void -get_property (GObject *object, guint prop_id, - GValue *value, GParamSpec *pspec) +get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NMSettingWired *setting = NM_SETTING_WIRED (object); - NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); - GHashTable *hash; - guint i; - - switch (prop_id) { - case PROP_PORT: - g_value_set_string (value, nm_setting_wired_get_port (setting)); - break; - case PROP_SPEED: - g_value_set_uint (value, nm_setting_wired_get_speed (setting)); - break; - case PROP_DUPLEX: - g_value_set_string (value, nm_setting_wired_get_duplex (setting)); - break; - case PROP_AUTO_NEGOTIATE: - g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting)); - break; - case PROP_MAC_ADDRESS: - g_value_set_string (value, nm_setting_wired_get_mac_address (setting)); - break; - case PROP_CLONED_MAC_ADDRESS: - g_value_set_string (value, nm_setting_wired_get_cloned_mac_address (setting)); - break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_value_set_string (value, nm_setting_wired_get_generate_mac_address_mask (setting)); - break; - case PROP_MAC_ADDRESS_BLACKLIST: - g_value_set_boxed (value, (char **) priv->mac_address_blacklist->data); - break; - case PROP_MTU: - g_value_set_uint (value, nm_setting_wired_get_mtu (setting)); - break; - case PROP_S390_SUBCHANNELS: - g_value_set_boxed (value, priv->s390_subchannels); - break; - case PROP_S390_NETTYPE: - g_value_set_string (value, nm_setting_wired_get_s390_nettype (setting)); - break; - case PROP_S390_OPTIONS: - hash = g_hash_table_new_full (nm_str_hash, - g_str_equal, - g_free, - g_free); - for (i = 0; i < priv->s390_options.len; i++) { - g_hash_table_insert (hash, - g_strdup (priv->s390_options.arr[i].name), - g_strdup (priv->s390_options.arr[i].value_str)); - } - g_value_take_boxed (value, hash); - break; - case PROP_WAKE_ON_LAN: - g_value_set_uint (value, priv->wol); - break; - case PROP_WAKE_ON_LAN_PASSWORD: - g_value_set_string (value, priv->wol_password); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + NMSettingWired * setting = NM_SETTING_WIRED(object); + NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); + GHashTable * hash; + guint i; + + switch (prop_id) { + case PROP_PORT: + g_value_set_string(value, nm_setting_wired_get_port(setting)); + break; + case PROP_SPEED: + g_value_set_uint(value, nm_setting_wired_get_speed(setting)); + break; + case PROP_DUPLEX: + g_value_set_string(value, nm_setting_wired_get_duplex(setting)); + break; + case PROP_AUTO_NEGOTIATE: + g_value_set_boolean(value, nm_setting_wired_get_auto_negotiate(setting)); + break; + case PROP_MAC_ADDRESS: + g_value_set_string(value, nm_setting_wired_get_mac_address(setting)); + break; + case PROP_CLONED_MAC_ADDRESS: + g_value_set_string(value, nm_setting_wired_get_cloned_mac_address(setting)); + break; + case PROP_GENERATE_MAC_ADDRESS_MASK: + g_value_set_string(value, nm_setting_wired_get_generate_mac_address_mask(setting)); + break; + case PROP_MAC_ADDRESS_BLACKLIST: + g_value_set_boxed(value, (char **) priv->mac_address_blacklist->data); + break; + case PROP_MTU: + g_value_set_uint(value, nm_setting_wired_get_mtu(setting)); + break; + case PROP_S390_SUBCHANNELS: + g_value_set_boxed(value, priv->s390_subchannels); + break; + case PROP_S390_NETTYPE: + g_value_set_string(value, nm_setting_wired_get_s390_nettype(setting)); + break; + case PROP_S390_OPTIONS: + hash = g_hash_table_new_full(nm_str_hash, g_str_equal, g_free, g_free); + for (i = 0; i < priv->s390_options.len; i++) { + g_hash_table_insert(hash, + g_strdup(priv->s390_options.arr[i].name), + g_strdup(priv->s390_options.arr[i].value_str)); + } + g_value_take_boxed(value, hash); + break; + case PROP_WAKE_ON_LAN: + g_value_set_uint(value, priv->wol); + break; + case PROP_WAKE_ON_LAN_PASSWORD: + g_value_set_string(value, priv->wol_password); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } } static void -set_property (GObject *object, guint prop_id, - const GValue *value, GParamSpec *pspec) +set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object); - const char * const *blacklist; - const char *mac; - - switch (prop_id) { - case PROP_PORT: - g_free (priv->port); - priv->port = g_value_dup_string (value); - break; - case PROP_SPEED: - priv->speed = g_value_get_uint (value); - break; - case PROP_DUPLEX: - g_free (priv->duplex); - priv->duplex = g_value_dup_string (value); - break; - case PROP_AUTO_NEGOTIATE: - priv->auto_negotiate = g_value_get_boolean (value); - break; - case PROP_MAC_ADDRESS: - g_free (priv->device_mac_address); - priv->device_mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value), - ETH_ALEN); - break; - case PROP_CLONED_MAC_ADDRESS: - g_free (priv->cloned_mac_address); - priv->cloned_mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value), - ETH_ALEN); - break; - case PROP_GENERATE_MAC_ADDRESS_MASK: - g_free (priv->generate_mac_address_mask); - priv->generate_mac_address_mask = g_value_dup_string (value); - break; - case PROP_MAC_ADDRESS_BLACKLIST: - blacklist = g_value_get_boxed (value); - g_array_set_size (priv->mac_address_blacklist, 0); - if (blacklist && *blacklist) { - guint i; - - for (i = 0; blacklist[i]; i++) { - mac = _nm_utils_hwaddr_canonical_or_invalid (blacklist[i], ETH_ALEN); - g_array_append_val (priv->mac_address_blacklist, mac); - } - } - break; - case PROP_MTU: - priv->mtu = g_value_get_uint (value); - break; - case PROP_S390_SUBCHANNELS: - if (priv->s390_subchannels) - g_strfreev (priv->s390_subchannels); - priv->s390_subchannels = g_value_dup_boxed (value); - break; - case PROP_S390_NETTYPE: - g_free (priv->s390_nettype); - priv->s390_nettype = g_value_dup_string (value); - break; - case PROP_S390_OPTIONS: - { - GHashTable *hash; - - _s390_options_clear (priv); - - hash = g_value_get_boxed (value); - - priv->s390_options.n_alloc = hash ? g_hash_table_size (hash) : 0u; - - if (priv->s390_options.n_alloc > 0) { - gboolean invalid_content = FALSE; - GHashTableIter iter; - const char *key; - const char *val; - guint i, j; - - priv->s390_options.arr = g_new (NMUtilsNamedValue, priv->s390_options.n_alloc); - g_hash_table_iter_init (&iter, hash); - while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &val)) { - if (!key || !val) { - invalid_content = TRUE; - continue; - } - nm_assert (priv->s390_options.len < priv->s390_options.n_alloc); - priv->s390_options.arr[priv->s390_options.len] = (NMUtilsNamedValue) { - .name = g_strdup (key), - .value_str = g_strdup (val), - }; - priv->s390_options.len++; - } - if (priv->s390_options.len > 1) { - nm_utils_named_value_list_sort (priv->s390_options.arr, - priv->s390_options.len, - NULL, - NULL); - /* prune duplicate keys. This is only possible if @hash does not use + NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(object); + const char *const * blacklist; + const char * mac; + + switch (prop_id) { + case PROP_PORT: + g_free(priv->port); + priv->port = g_value_dup_string(value); + break; + case PROP_SPEED: + priv->speed = g_value_get_uint(value); + break; + case PROP_DUPLEX: + g_free(priv->duplex); + priv->duplex = g_value_dup_string(value); + break; + case PROP_AUTO_NEGOTIATE: + priv->auto_negotiate = g_value_get_boolean(value); + break; + case PROP_MAC_ADDRESS: + g_free(priv->device_mac_address); + priv->device_mac_address = + _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); + break; + case PROP_CLONED_MAC_ADDRESS: + g_free(priv->cloned_mac_address); + priv->cloned_mac_address = + _nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN); + break; + case PROP_GENERATE_MAC_ADDRESS_MASK: + g_free(priv->generate_mac_address_mask); + priv->generate_mac_address_mask = g_value_dup_string(value); + break; + case PROP_MAC_ADDRESS_BLACKLIST: + blacklist = g_value_get_boxed(value); + g_array_set_size(priv->mac_address_blacklist, 0); + if (blacklist && *blacklist) { + guint i; + + for (i = 0; blacklist[i]; i++) { + mac = _nm_utils_hwaddr_canonical_or_invalid(blacklist[i], ETH_ALEN); + g_array_append_val(priv->mac_address_blacklist, mac); + } + } + break; + case PROP_MTU: + priv->mtu = g_value_get_uint(value); + break; + case PROP_S390_SUBCHANNELS: + if (priv->s390_subchannels) + g_strfreev(priv->s390_subchannels); + priv->s390_subchannels = g_value_dup_boxed(value); + break; + case PROP_S390_NETTYPE: + g_free(priv->s390_nettype); + priv->s390_nettype = g_value_dup_string(value); + break; + case PROP_S390_OPTIONS: + { + GHashTable *hash; + + _s390_options_clear(priv); + + hash = g_value_get_boxed(value); + + priv->s390_options.n_alloc = hash ? g_hash_table_size(hash) : 0u; + + if (priv->s390_options.n_alloc > 0) { + gboolean invalid_content = FALSE; + GHashTableIter iter; + const char * key; + const char * val; + guint i, j; + + priv->s390_options.arr = g_new(NMUtilsNamedValue, priv->s390_options.n_alloc); + g_hash_table_iter_init(&iter, hash); + while (g_hash_table_iter_next(&iter, (gpointer *) &key, (gpointer *) &val)) { + if (!key || !val) { + invalid_content = TRUE; + continue; + } + nm_assert(priv->s390_options.len < priv->s390_options.n_alloc); + priv->s390_options.arr[priv->s390_options.len] = (NMUtilsNamedValue){ + .name = g_strdup(key), + .value_str = g_strdup(val), + }; + priv->s390_options.len++; + } + if (priv->s390_options.len > 1) { + nm_utils_named_value_list_sort(priv->s390_options.arr, + priv->s390_options.len, + NULL, + NULL); + /* prune duplicate keys. This is only possible if @hash does not use * g_str_equal() as compare function (which would be a bug). * Still, handle this, because we use later binary sort and rely * on unique names. One bug here, should not bork the remainder * of the program. */ - j = 1; - for (i = 1; i < priv->s390_options.len; i++) { - if (nm_streq (priv->s390_options.arr[j - 1].name, - priv->s390_options.arr[i].name)) { - g_free ((char *) priv->s390_options.arr[i].name); - g_free ((char *) priv->s390_options.arr[i].value_str); - invalid_content = TRUE; - continue; - } - priv->s390_options.arr[j++] = priv->s390_options.arr[i]; - } - priv->s390_options.len = j; - } - - g_return_if_fail (!invalid_content); - } - } - break; - case PROP_WAKE_ON_LAN: - priv->wol = g_value_get_uint (value); - break; - case PROP_WAKE_ON_LAN_PASSWORD: - g_free (priv->wol_password); - priv->wol_password = g_value_dup_string (value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + j = 1; + for (i = 1; i < priv->s390_options.len; i++) { + if (nm_streq(priv->s390_options.arr[j - 1].name, + priv->s390_options.arr[i].name)) { + g_free((char *) priv->s390_options.arr[i].name); + g_free((char *) priv->s390_options.arr[i].value_str); + invalid_content = TRUE; + continue; + } + priv->s390_options.arr[j++] = priv->s390_options.arr[i]; + } + priv->s390_options.len = j; + } + + g_return_if_fail(!invalid_content); + } + } break; + case PROP_WAKE_ON_LAN: + priv->wol = g_value_get_uint(value); + break; + case PROP_WAKE_ON_LAN_PASSWORD: + g_free(priv->wol_password); + priv->wol_password = g_value_dup_string(value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); + break; + } } /*****************************************************************************/ static void -nm_setting_wired_init (NMSettingWired *setting) +nm_setting_wired_init(NMSettingWired *setting) { - NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (setting); + NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(setting); - /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */ - priv->mac_address_blacklist = g_array_new (TRUE, FALSE, sizeof (char *)); - g_array_set_clear_func (priv->mac_address_blacklist, (GDestroyNotify) clear_blacklist_item); + /* We use GArray rather than GPtrArray so it will automatically be NULL-terminated */ + priv->mac_address_blacklist = g_array_new(TRUE, FALSE, sizeof(char *)); + g_array_set_clear_func(priv->mac_address_blacklist, (GDestroyNotify) clear_blacklist_item); - priv->wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; + priv->wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT; } /** @@ -1164,52 +1172,52 @@ nm_setting_wired_init (NMSettingWired *setting) * Returns: (transfer full): the new empty #NMSettingWired object **/ NMSetting * -nm_setting_wired_new (void) +nm_setting_wired_new(void) { - return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRED, NULL); + return (NMSetting *) g_object_new(NM_TYPE_SETTING_WIRED, NULL); } static void -finalize (GObject *object) +finalize(GObject *object) { - NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object); + NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE(object); - g_free (priv->port); - g_free (priv->duplex); - g_free (priv->s390_nettype); + g_free(priv->port); + g_free(priv->duplex); + g_free(priv->s390_nettype); - _s390_options_clear (priv); + _s390_options_clear(priv); - g_free (priv->device_mac_address); - g_free (priv->cloned_mac_address); - g_free (priv->generate_mac_address_mask); - g_array_unref (priv->mac_address_blacklist); + g_free(priv->device_mac_address); + g_free(priv->cloned_mac_address); + g_free(priv->generate_mac_address_mask); + g_array_unref(priv->mac_address_blacklist); - if (priv->s390_subchannels) - g_strfreev (priv->s390_subchannels); + if (priv->s390_subchannels) + g_strfreev(priv->s390_subchannels); - g_free (priv->wol_password); + g_free(priv->wol_password); - G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object); + G_OBJECT_CLASS(nm_setting_wired_parent_class)->finalize(object); } static void -nm_setting_wired_class_init (NMSettingWiredClass *klass) +nm_setting_wired_class_init(NMSettingWiredClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - NMSettingClass *setting_class = NM_SETTING_CLASS (klass); - GArray *properties_override = _nm_sett_info_property_override_create_array (); + GObjectClass * object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); + GArray * properties_override = _nm_sett_info_property_override_create_array(); - g_type_class_add_private (klass, sizeof (NMSettingWiredPrivate)); + g_type_class_add_private(klass, sizeof(NMSettingWiredPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; - object_class->finalize = finalize; + object_class->get_property = get_property; + object_class->set_property = set_property; + object_class->finalize = finalize; - setting_class->verify = verify; - setting_class->compare_property = compare_property; + setting_class->verify = verify; + setting_class->compare_property = compare_property; - /** + /** * NMSettingWired:port: * * Specific port type to use if the device supports multiple @@ -1217,19 +1225,19 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * Interface), "bnc" (Thin Ethernet) or "mii" (Media Independent Interface). * If the device supports only one port type, this setting is ignored. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: port * variable: (none) * description: The property is not saved by the plugin. * ---end--- */ - obj_properties[PROP_PORT] = - g_param_spec_string (NM_SETTING_WIRED_PORT, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); + obj_properties[PROP_PORT] = g_param_spec_string(NM_SETTING_WIRED_PORT, + "", + "", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - /** + /** * NMSettingWired:speed: * * When a value greater than 0 is set, configures the device to use @@ -1246,20 +1254,22 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * Must be set together with the "duplex" property when non-zero. * Before specifying a speed value be sure your device supports it. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: speed * variable: ETHTOOL_OPTS * description: Fixed speed for the ethernet link. It is added as "speed" * parameter in the ETHTOOL_OPTS variable. * ---end--- */ - obj_properties[PROP_SPEED] = - g_param_spec_uint (NM_SETTING_WIRED_SPEED, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_SPEED] = g_param_spec_uint(NM_SETTING_WIRED_SPEED, + "", + "", + 0, + G_MAXUINT32, + 0, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:duplex: * * When a value is set, either "half" or "full", configures the device @@ -1275,20 +1285,20 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * Must be set together with the "speed" property if specified. * Before specifying a duplex mode be sure your device supports it. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: duplex * variable: ETHTOOL_OPTS * description: Fixed duplex mode for the ethernet link. It is added as * "duplex" parameter in the ETHOOL_OPTS variable. * ---end--- */ - obj_properties[PROP_DUPLEX] = - g_param_spec_string (NM_SETTING_WIRED_DUPLEX, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); + obj_properties[PROP_DUPLEX] = g_param_spec_string(NM_SETTING_WIRED_DUPLEX, + "", + "", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); - /** + /** * NMSettingWired:auto-negotiate: * * When %TRUE, enforce auto-negotiation of speed and duplex mode. @@ -1300,7 +1310,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * When %FALSE, "speed" and "duplex" properties should be both set or * link configuration will be skipped. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: auto-negotiate * variable: ETHTOOL_OPTS * description: Whether link speed and duplex autonegotiation is enabled. @@ -1308,26 +1318,25 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * "speed" and "duplex" parameters (skips link configuration). * ---end--- */ - obj_properties[PROP_AUTO_NEGOTIATE] = - g_param_spec_boolean (NM_SETTING_WIRED_AUTO_NEGOTIATE, "", "", - FALSE, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj (properties_override, - obj_properties[PROP_AUTO_NEGOTIATE], - NM_SETT_INFO_PROPERT_TYPE ( - .dbus_type = G_VARIANT_TYPE_BOOLEAN, - .to_dbus_fcn = _override_autoneg_get, - )); - - /** + obj_properties[PROP_AUTO_NEGOTIATE] = + g_param_spec_boolean(NM_SETTING_WIRED_AUTO_NEGOTIATE, + "", + "", + FALSE, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + _nm_properties_override_gobj(properties_override, + obj_properties[PROP_AUTO_NEGOTIATE], + NM_SETT_INFO_PROPERT_TYPE(.dbus_type = G_VARIANT_TYPE_BOOLEAN, + .to_dbus_fcn = _override_autoneg_get, )); + + /** * NMSettingWired:mac-address: * * If specified, this connection will only apply to the Ethernet device * whose permanent MAC address matches. This property does not change the * MAC address of the device (i.e. MAC spoofing). **/ - /* ---keyfile--- + /* ---keyfile--- * property: mac-address * format: usual hex-digits-and-colons notation * description: MAC address in traditional hex-digits-and-colons notation @@ -1344,15 +1353,17 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * permanent MAC address exists, the MAC address initially configured on the device. * ---end--- */ - obj_properties[PROP_MAC_ADDRESS] = - g_param_spec_string (NM_SETTING_WIRED_MAC_ADDRESS, "", "", - NULL, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj (properties_override, obj_properties[PROP_MAC_ADDRESS], &nm_sett_info_propert_type_mac_address); - - /** + obj_properties[PROP_MAC_ADDRESS] = g_param_spec_string( + NM_SETTING_WIRED_MAC_ADDRESS, + "", + "", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_properties_override_gobj(properties_override, + obj_properties[PROP_MAC_ADDRESS], + &nm_sett_info_propert_type_mac_address); + + /** * NMSettingWired:cloned-mac-address: * * If specified, request that the device use this MAC address instead. @@ -1374,7 +1385,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * On D-Bus, this field is expressed as "assigned-mac-address" or the deprecated * "cloned-mac-address". **/ - /* ---keyfile--- + /* ---keyfile--- * property: cloned-mac-address * format: usual hex-digits-and-colons notation * description: Cloned MAC address in traditional hex-digits-and-colons notation @@ -1395,15 +1406,17 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * For libnm and nmcli, this field is called "cloned-mac-address". * ---end--- */ - obj_properties[PROP_CLONED_MAC_ADDRESS] = - g_param_spec_string (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "", "", - NULL, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj (properties_override, obj_properties[PROP_CLONED_MAC_ADDRESS], &nm_sett_info_propert_type_cloned_mac_address); - - /* ---dbus--- + obj_properties[PROP_CLONED_MAC_ADDRESS] = g_param_spec_string( + NM_SETTING_WIRED_CLONED_MAC_ADDRESS, + "", + "", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_properties_override_gobj(properties_override, + obj_properties[PROP_CLONED_MAC_ADDRESS], + &nm_sett_info_propert_type_cloned_mac_address); + + /* ---dbus--- * property: assigned-mac-address * format: string * description: The new field for the cloned MAC address. It can be either @@ -1415,9 +1428,11 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * "cloned-mac-address". * ---end--- */ - _nm_properties_override_dbus (properties_override, "assigned-mac-address", &nm_sett_info_propert_type_assigned_mac_address); + _nm_properties_override_dbus(properties_override, + "assigned-mac-address", + &nm_sett_info_propert_type_assigned_mac_address); - /** + /** * NMSettingWired:generate-mac-address-mask: * * With #NMSettingWired:cloned-mac-address setting "random" or "stable", @@ -1449,21 +1464,21 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * will create a fully scrambled MAC address, randomly locally or globally * administered. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: generate-mac-address-mask * variable: GENERATE_MAC_ADDRESS_MASK(+) * description: the MAC address mask for generating randomized and stable * cloned-mac-address. * ---end--- */ - obj_properties[PROP_GENERATE_MAC_ADDRESS_MASK] = - g_param_spec_string (NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, "", "", - NULL, - G_PARAM_READWRITE | - NM_SETTING_PARAM_FUZZY_IGNORE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_GENERATE_MAC_ADDRESS_MASK] = g_param_spec_string( + NM_SETTING_WIRED_GENERATE_MAC_ADDRESS_MASK, + "", + "", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:mac-address-blacklist: * * If specified, this connection will never apply to the Ethernet device @@ -1471,7 +1486,7 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * address is in the standard hex-digits-and-colons notation * (00:11:22:33:44:55). **/ - /* ---keyfile--- + /* ---keyfile--- * property: mac-address-blacklist * format: list of MACs (separated with semicolons) * description: MAC address blacklist. @@ -1485,33 +1500,35 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * example: HWADDR_BLACKLIST="00:22:68:11:69:08 00:11:22:11:44:55" * ---end--- */ - obj_properties[PROP_MAC_ADDRESS_BLACKLIST] = - g_param_spec_boxed (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "", - G_TYPE_STRV, - G_PARAM_READWRITE | - NM_SETTING_PARAM_FUZZY_IGNORE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_MAC_ADDRESS_BLACKLIST] = g_param_spec_boxed( + NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, + "", + "", + G_TYPE_STRV, + G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:mtu: * * If non-zero, only transmit packets of the specified size or smaller, * breaking larger packets up into multiple Ethernet frames. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: mtu * variable: MTU * description: MTU of the interface. * ---end--- */ - obj_properties[PROP_MTU] = - g_param_spec_uint (NM_SETTING_WIRED_MTU, "", "", - 0, G_MAXUINT32, 0, - G_PARAM_READWRITE | - NM_SETTING_PARAM_FUZZY_IGNORE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_WIRED_MTU, + "", + "", + 0, + G_MAXUINT32, + 0, + G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE + | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:s390-subchannels: * * Identifies specific subchannels that this network device uses for @@ -1522,27 +1539,27 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * and each string may only be composed of hexadecimal characters and the * period (.) character. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: s390-subchannels * variable: SUBCHANNELS * description: Subchannels for IBM S390 hosts. * example: SUBCHANNELS=0.0.b00a,0.0.b00b,0.0.b00c * ---end--- */ - obj_properties[PROP_S390_SUBCHANNELS] = - g_param_spec_boxed (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "", - G_TYPE_STRV, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_S390_SUBCHANNELS] = g_param_spec_boxed( + NM_SETTING_WIRED_S390_SUBCHANNELS, + "", + "", + G_TYPE_STRV, + G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:s390-nettype: * * s390 network device type; one of "qeth", "lcs", or "ctc", representing * the different types of virtual network devices available on s390 systems. **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: s390-nettype * variable: NETTYPE * values: "qeth", "lcs" or "ctc" @@ -1550,14 +1567,14 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * example: NETTYPE=qeth * ---end--- */ - obj_properties[PROP_S390_NETTYPE] = - g_param_spec_string (NM_SETTING_WIRED_S390_NETTYPE, "", "", - NULL, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_S390_NETTYPE] = g_param_spec_string( + NM_SETTING_WIRED_S390_NETTYPE, + "", + "", + NULL, + G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:s390-options: (type GHashTable(utf8,utf8)): * * Dictionary of key/value pairs of s390-specific device options. Both keys @@ -1565,22 +1582,24 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * "portname", "protocol", among others. Key names must contain only * alphanumeric characters (ie, [a-zA-Z0-9]). **/ - /* ---ifcfg-rh--- + /* ---ifcfg-rh--- * property: s390-options * variable: OPTIONS and PORTNAME, CTCPROTO, * description: S390 device options. All options go to OPTIONS, except for * "portname" and "ctcprot" that have their own variables. * ---end--- */ - obj_properties[PROP_S390_OPTIONS] = - g_param_spec_boxed (NM_SETTING_WIRED_S390_OPTIONS, "", "", - G_TYPE_HASH_TABLE, - G_PARAM_READWRITE | - NM_SETTING_PARAM_INFERRABLE | - G_PARAM_STATIC_STRINGS); - _nm_properties_override_gobj (properties_override, obj_properties[PROP_S390_OPTIONS], &nm_sett_info_propert_type_strdict); - - /** + obj_properties[PROP_S390_OPTIONS] = g_param_spec_boxed( + NM_SETTING_WIRED_S390_OPTIONS, + "", + "", + G_TYPE_HASH_TABLE, + G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS); + _nm_properties_override_gobj(properties_override, + obj_properties[PROP_S390_OPTIONS], + &nm_sett_info_propert_type_strdict); + + /** * NMSettingWired:wake-on-lan: * * The #NMSettingWiredWakeOnLan options to enable. Not all devices support all options. @@ -1594,13 +1613,16 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_WAKE_ON_LAN] = - g_param_spec_uint (NM_SETTING_WIRED_WAKE_ON_LAN, "", "", - 0, G_MAXUINT32, NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - - /** + obj_properties[PROP_WAKE_ON_LAN] = + g_param_spec_uint(NM_SETTING_WIRED_WAKE_ON_LAN, + "", + "", + 0, + G_MAXUINT32, + NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + /** * NMSettingWired:wake-on-lan-password: * * If specified, the password used with magic-packet-based @@ -1609,14 +1631,17 @@ nm_setting_wired_class_init (NMSettingWiredClass *klass) * * Since: 1.2 **/ - obj_properties[PROP_WAKE_ON_LAN_PASSWORD] = - g_param_spec_string (NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, "", "", - NULL, - G_PARAM_READWRITE | - G_PARAM_STATIC_STRINGS); - - g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties); - - _nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_WIRED, - NULL, properties_override); + obj_properties[PROP_WAKE_ON_LAN_PASSWORD] = + g_param_spec_string(NM_SETTING_WIRED_WAKE_ON_LAN_PASSWORD, + "", + "", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); + + _nm_setting_class_commit_full(setting_class, + NM_META_SETTING_TYPE_WIRED, + NULL, + properties_override); } |