mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 01:47:58 +02:00
libnm: merge branch 'th/libnm-settings-properties-3'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1055
This commit is contained in:
commit
c5399847f7
43 changed files with 1990 additions and 2700 deletions
|
|
@ -205,9 +205,11 @@ read_client_id(const char *str)
|
|||
{
|
||||
gs_free char *s = NULL;
|
||||
char *p;
|
||||
int i = 0, j = 0;
|
||||
int i = 0;
|
||||
int j = 0;
|
||||
gsize l;
|
||||
|
||||
nm_assert(!strncmp(str, CLIENTID_TAG, NM_STRLEN(CLIENTID_TAG)));
|
||||
nm_assert(NM_STR_HAS_PREFIX(str, CLIENTID_TAG));
|
||||
str += NM_STRLEN(CLIENTID_TAG);
|
||||
|
||||
if (!g_ascii_isspace(*str))
|
||||
|
|
@ -248,8 +250,9 @@ read_client_id(const char *str)
|
|||
/* Otherwise, try to read a hexadecimal sequence */
|
||||
s = g_strdup(str);
|
||||
g_strchomp(s);
|
||||
if (s[strlen(s) - 1] == ';')
|
||||
s[strlen(s) - 1] = '\0';
|
||||
l = strlen(s);
|
||||
if (l > 0 && s[l - 1] == ';')
|
||||
s[l - 1] = '\0';
|
||||
|
||||
return nm_utils_hexstr2bin(s);
|
||||
}
|
||||
|
|
@ -384,11 +387,10 @@ nm_dhcp_dhclient_create_config(const char *interface,
|
|||
* fail the dhcp process before dhcp-timeout. So, always skip importing timeout
|
||||
* as we will need to add one greater than dhcp-timeout.
|
||||
*/
|
||||
if (!strncmp(p, TIMEOUT_TAG, strlen(TIMEOUT_TAG))
|
||||
|| !strncmp(p, RETRY_TAG, strlen(RETRY_TAG)))
|
||||
if (NM_STR_HAS_PREFIX(p, TIMEOUT_TAG) || NM_STR_HAS_PREFIX(p, RETRY_TAG))
|
||||
continue;
|
||||
|
||||
if (!strncmp(p, CLIENTID_TAG, strlen(CLIENTID_TAG))) {
|
||||
if (NM_STR_HAS_PREFIX(p, CLIENTID_TAG)) {
|
||||
/* Override config file "dhcp-client-id" and use one from the connection */
|
||||
if (client_id)
|
||||
continue;
|
||||
|
|
@ -401,16 +403,16 @@ nm_dhcp_dhclient_create_config(const char *interface,
|
|||
|
||||
/* Override config file hostname and use one from the connection */
|
||||
if (hostname) {
|
||||
if (strncmp(p, HOSTNAME4_TAG, strlen(HOSTNAME4_TAG)) == 0)
|
||||
if (NM_STR_HAS_PREFIX(p, HOSTNAME4_TAG))
|
||||
continue;
|
||||
if (strncmp(p, FQDN_TAG, strlen(FQDN_TAG)) == 0)
|
||||
if (NM_STR_HAS_PREFIX(p, FQDN_TAG))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* To let user's FQDN options (except "fqdn.fqdn") override the
|
||||
* default ones set by NM, add them later
|
||||
*/
|
||||
if (!strncmp(p, FQDN_TAG_PREFIX, NM_STRLEN(FQDN_TAG_PREFIX))) {
|
||||
if (NM_STR_HAS_PREFIX(p, FQDN_TAG_PREFIX)) {
|
||||
if (!fqdn_opts)
|
||||
fqdn_opts = g_ptr_array_new_full(5, g_free);
|
||||
g_ptr_array_add(fqdn_opts, g_strdup(p + NM_STRLEN(FQDN_TAG_PREFIX)));
|
||||
|
|
@ -422,9 +424,9 @@ nm_dhcp_dhclient_create_config(const char *interface,
|
|||
continue;
|
||||
|
||||
/* Check for "request" */
|
||||
if (!strncmp(p, REQ_TAG, strlen(REQ_TAG))) {
|
||||
if (NM_STR_HAS_PREFIX(p, REQ_TAG)) {
|
||||
in_req = TRUE;
|
||||
p += strlen(REQ_TAG);
|
||||
p += NM_STRLEN(REQ_TAG);
|
||||
g_ptr_array_set_size(reqs, 0);
|
||||
reset_reqlist = TRUE;
|
||||
}
|
||||
|
|
@ -436,9 +438,9 @@ nm_dhcp_dhclient_create_config(const char *interface,
|
|||
}
|
||||
|
||||
/* Check for "also require" */
|
||||
if (!strncmp(p, ALSOREQ_TAG, strlen(ALSOREQ_TAG))) {
|
||||
if (NM_STR_HAS_PREFIX(p, ALSOREQ_TAG)) {
|
||||
in_alsoreq = TRUE;
|
||||
p += strlen(ALSOREQ_TAG);
|
||||
p += NM_STRLEN(ALSOREQ_TAG);
|
||||
}
|
||||
|
||||
if (in_alsoreq) {
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ ip4_process_classless_routes(const char *iface,
|
|||
if (!str)
|
||||
str = g_hash_table_lookup(options, "ms_classless_static_routes");
|
||||
|
||||
if (!str || !strlen(str))
|
||||
if (nm_str_is_empty(str))
|
||||
return FALSE;
|
||||
|
||||
p = str;
|
||||
|
|
|
|||
|
|
@ -711,7 +711,7 @@ write_wireless_security_setting(NMConnection *connection,
|
|||
numbered_tag(tag, "KEY", i + 1);
|
||||
|
||||
/* Add 's:' prefix for ASCII keys */
|
||||
if (strlen(key) == 5 || strlen(key) == 13) {
|
||||
if (NM_IN_SET(strlen(key), 5, 13)) {
|
||||
ascii_key = g_strdup_printf("s:%s", key);
|
||||
key = ascii_key;
|
||||
}
|
||||
|
|
@ -759,7 +759,7 @@ write_wireless_security_setting(NMConnection *connection,
|
|||
g_free(tmp);
|
||||
}
|
||||
}
|
||||
if (strlen(str->str) && (dynamic_wep == FALSE))
|
||||
if (nm_str_not_empty(str->str) && !dynamic_wep)
|
||||
svSetValueStr(ifcfg, "CIPHER_PAIRWISE", str->str);
|
||||
g_string_free(str, TRUE);
|
||||
|
||||
|
|
@ -2915,7 +2915,7 @@ write_ip4_aliases(NMConnection *connection, const char *base_ifcfg_path)
|
|||
base_ifcfg_name_len = strlen(base_ifcfg_name);
|
||||
if (!g_str_has_prefix(base_ifcfg_name, IFCFG_TAG))
|
||||
g_return_if_reached();
|
||||
base_name = base_ifcfg_name + strlen(IFCFG_TAG);
|
||||
base_name = base_ifcfg_name + NM_STRLEN(IFCFG_TAG);
|
||||
base_name_len = strlen(base_name);
|
||||
|
||||
/* Remove all existing aliases for this file first */
|
||||
|
|
|
|||
|
|
@ -2504,7 +2504,7 @@ need_secrets_password(NMSetting8021x *self, GPtrArray *secrets, gboolean phase2)
|
|||
{
|
||||
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE(self);
|
||||
|
||||
if ((!priv->password || !strlen(priv->password))
|
||||
if (nm_str_is_empty(priv->password)
|
||||
&& (!priv->password_raw || !g_bytes_get_size(priv->password_raw))) {
|
||||
g_ptr_array_add(secrets, NM_SETTING_802_1X_PASSWORD);
|
||||
g_ptr_array_add(secrets, NM_SETTING_802_1X_PASSWORD_RAW);
|
||||
|
|
|
|||
|
|
@ -1443,8 +1443,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_SETTING_BRIDGE_MAC_ADDRESS,
|
||||
PROP_MAC_ADDRESS,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
mac_address,
|
||||
NMSettingBridge,
|
||||
_priv.mac_address,
|
||||
.direct_set_string_mac_address_len = ETH_ALEN);
|
||||
|
||||
/**
|
||||
|
|
@ -1465,8 +1465,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_STP,
|
||||
NM_BRIDGE_STP_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
stp);
|
||||
NMSettingBridge,
|
||||
_priv.stp);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:priority:
|
||||
|
|
@ -1491,8 +1491,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_PRIORITY_MAX,
|
||||
NM_BRIDGE_PRIORITY_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
priority);
|
||||
NMSettingBridge,
|
||||
_priv.priority);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:forward-delay:
|
||||
|
|
@ -1515,8 +1515,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_FORWARD_DELAY_MAX,
|
||||
NM_BRIDGE_FORWARD_DELAY_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
forward_delay);
|
||||
NMSettingBridge,
|
||||
_priv.forward_delay);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:hello-time:
|
||||
|
|
@ -1539,8 +1539,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_HELLO_TIME_MAX,
|
||||
NM_BRIDGE_HELLO_TIME_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
hello_time);
|
||||
NMSettingBridge,
|
||||
_priv.hello_time);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:max-age:
|
||||
|
|
@ -1563,8 +1563,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MAX_AGE_MAX,
|
||||
NM_BRIDGE_MAX_AGE_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
max_age);
|
||||
NMSettingBridge,
|
||||
_priv.max_age);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:ageing-time:
|
||||
|
|
@ -1587,8 +1587,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_AGEING_TIME_MAX,
|
||||
NM_BRIDGE_AGEING_TIME_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
ageing_time);
|
||||
NMSettingBridge,
|
||||
_priv.ageing_time);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:group-forward-mask:
|
||||
|
|
@ -1610,8 +1610,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
0xFFFF,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
group_forward_mask);
|
||||
NMSettingBridge,
|
||||
_priv.group_forward_mask);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-snooping:
|
||||
|
|
@ -1637,8 +1637,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_MULTICAST_SNOOPING,
|
||||
NM_BRIDGE_MULTICAST_SNOOPING_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_snooping);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_snooping);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:vlan-filtering:
|
||||
|
|
@ -1661,8 +1661,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_VLAN_FILTERING,
|
||||
FALSE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
vlan_filtering);
|
||||
NMSettingBridge,
|
||||
_priv.vlan_filtering);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:vlan-default-pvid:
|
||||
|
|
@ -1688,8 +1688,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_VLAN_VID_MAX,
|
||||
NM_BRIDGE_VLAN_DEFAULT_PVID_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
vlan_default_pvid);
|
||||
NMSettingBridge,
|
||||
_priv.vlan_default_pvid);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:vlans: (type GPtrArray(NMBridgeVlan))
|
||||
|
|
@ -1764,8 +1764,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_SETTING_BRIDGE_GROUP_ADDRESS,
|
||||
PROP_GROUP_ADDRESS,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
group_address,
|
||||
NMSettingBridge,
|
||||
_priv.group_address,
|
||||
.direct_set_string_mac_address_len = ETH_ALEN);
|
||||
|
||||
/**
|
||||
|
|
@ -1792,8 +1792,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_SETTING_BRIDGE_VLAN_PROTOCOL,
|
||||
PROP_VLAN_PROTOCOL,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
vlan_protocol);
|
||||
NMSettingBridge,
|
||||
_priv.vlan_protocol);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:vlan-stats-enabled:
|
||||
|
|
@ -1815,8 +1815,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_VLAN_STATS_ENABLED,
|
||||
NM_BRIDGE_VLAN_STATS_ENABLED_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
vlan_stats_enabled);
|
||||
NMSettingBridge,
|
||||
_priv.vlan_stats_enabled);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-router:
|
||||
|
|
@ -1843,8 +1843,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_SETTING_BRIDGE_MULTICAST_ROUTER,
|
||||
PROP_MULTICAST_ROUTER,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_router);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_router);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-query-use-ifaddr:
|
||||
|
|
@ -1868,8 +1868,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_MULTICAST_QUERY_USE_IFADDR,
|
||||
NM_BRIDGE_MULTICAST_QUERY_USE_IFADDR_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_query_use_ifaddr);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_query_use_ifaddr);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-querier:
|
||||
|
|
@ -1892,8 +1892,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
PROP_MULTICAST_QUERIER,
|
||||
NM_BRIDGE_MULTICAST_QUERIER_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_querier);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_querier);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-hash-max:
|
||||
|
|
@ -1917,8 +1917,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_HASH_MAX_MAX,
|
||||
NM_BRIDGE_MULTICAST_HASH_MAX_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_hash_max);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_hash_max);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-last-member-count:
|
||||
|
|
@ -1944,8 +1944,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_MAX,
|
||||
NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_last_member_count);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_last_member_count);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-last-member-interval:
|
||||
|
|
@ -1970,8 +1970,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_last_member_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_last_member_interval);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-membership-interval:
|
||||
|
|
@ -1997,8 +1997,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_membership_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_membership_interval);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-querier-interval:
|
||||
|
|
@ -2023,8 +2023,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_querier_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_querier_interval);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-query-interval:
|
||||
|
|
@ -2049,8 +2049,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_QUERY_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_query_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_query_interval);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-query-response-interval:
|
||||
|
|
@ -2075,8 +2075,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_query_response_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_query_response_interval);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-startup-query-count:
|
||||
|
|
@ -2100,8 +2100,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_MAX,
|
||||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_startup_query_count);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_startup_query_count);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:multicast-startup-query-interval:
|
||||
|
|
@ -2126,8 +2126,8 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_MAX,
|
||||
NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingBridgePrivate,
|
||||
multicast_startup_query_interval);
|
||||
NMSettingBridge,
|
||||
_priv.multicast_startup_query_interval);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
@ -2135,5 +2135,5 @@ nm_setting_bridge_class_init(NMSettingBridgeClass *klass)
|
|||
NM_META_SETTING_TYPE_BRIDGE,
|
||||
NULL,
|
||||
properties_override,
|
||||
G_STRUCT_OFFSET(NMSettingBridge, _priv));
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1908,7 +1908,8 @@ nm_setting_connection_class_init(NMSettingConnectionClass *klass)
|
|||
PROP_TYPE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingConnectionPrivate,
|
||||
type);
|
||||
type,
|
||||
.direct_string_is_refstr = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingConnection:permissions:
|
||||
|
|
|
|||
|
|
@ -39,14 +39,14 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_AUTO_CONFIG,
|
|||
PROP_MTU, );
|
||||
|
||||
typedef struct {
|
||||
char *number; /* For dialing, duh */
|
||||
char *number;
|
||||
char *username;
|
||||
char *password;
|
||||
char *device_id;
|
||||
char *sim_id;
|
||||
char *sim_operator_id;
|
||||
char *apn; /* NULL for dynamic */
|
||||
char *network_id; /* for manual registration or NULL for automatic */
|
||||
char *apn;
|
||||
char *network_id;
|
||||
char *pin;
|
||||
guint password_flags;
|
||||
guint pin_flags;
|
||||
|
|
@ -480,120 +480,6 @@ need_secrets(NMSetting *setting)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingGsm *setting = NM_SETTING_GSM(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_CONFIG:
|
||||
g_value_set_boolean(value, nm_setting_gsm_get_auto_config(setting));
|
||||
break;
|
||||
case PROP_NUMBER:
|
||||
g_value_set_string(value, nm_setting_gsm_get_number(setting));
|
||||
break;
|
||||
case PROP_USERNAME:
|
||||
g_value_set_string(value, nm_setting_gsm_get_username(setting));
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_value_set_string(value, nm_setting_gsm_get_password(setting));
|
||||
break;
|
||||
case PROP_APN:
|
||||
g_value_set_string(value, nm_setting_gsm_get_apn(setting));
|
||||
break;
|
||||
case PROP_NETWORK_ID:
|
||||
g_value_set_string(value, nm_setting_gsm_get_network_id(setting));
|
||||
break;
|
||||
case PROP_PIN:
|
||||
g_value_set_string(value, nm_setting_gsm_get_pin(setting));
|
||||
break;
|
||||
case PROP_HOME_ONLY:
|
||||
g_value_set_boolean(value, nm_setting_gsm_get_home_only(setting));
|
||||
break;
|
||||
case PROP_DEVICE_ID:
|
||||
g_value_set_string(value, nm_setting_gsm_get_device_id(setting));
|
||||
break;
|
||||
case PROP_SIM_ID:
|
||||
g_value_set_string(value, nm_setting_gsm_get_sim_id(setting));
|
||||
break;
|
||||
case PROP_SIM_OPERATOR_ID:
|
||||
g_value_set_string(value, nm_setting_gsm_get_sim_operator_id(setting));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint(value, nm_setting_gsm_get_mtu(setting));
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(object);
|
||||
char *tmp;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_AUTO_CONFIG:
|
||||
priv->auto_config = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_NUMBER:
|
||||
g_free(priv->number);
|
||||
priv->number = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_USERNAME:
|
||||
g_free(priv->username);
|
||||
priv->username = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_PASSWORD:
|
||||
g_free(priv->password);
|
||||
priv->password = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_APN:
|
||||
g_free(priv->apn);
|
||||
priv->apn = NULL;
|
||||
tmp = g_value_dup_string(value);
|
||||
if (tmp)
|
||||
priv->apn = g_strstrip(tmp);
|
||||
break;
|
||||
case PROP_NETWORK_ID:
|
||||
g_free(priv->network_id);
|
||||
priv->network_id = NULL;
|
||||
tmp = g_value_dup_string(value);
|
||||
if (tmp)
|
||||
priv->network_id = g_strstrip(tmp);
|
||||
break;
|
||||
case PROP_PIN:
|
||||
g_free(priv->pin);
|
||||
priv->pin = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_HOME_ONLY:
|
||||
priv->home_only = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_DEVICE_ID:
|
||||
g_free(priv->device_id);
|
||||
priv->device_id = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_SIM_ID:
|
||||
g_free(priv->sim_id);
|
||||
priv->sim_id = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_SIM_OPERATOR_ID:
|
||||
g_free(priv->sim_operator_id);
|
||||
priv->sim_operator_id = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_gsm_init(NMSettingGsm *setting)
|
||||
{}
|
||||
|
|
@ -611,24 +497,6 @@ nm_setting_gsm_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_GSM, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->number);
|
||||
g_free(priv->username);
|
||||
g_free(priv->password);
|
||||
g_free(priv->apn);
|
||||
g_free(priv->network_id);
|
||||
g_free(priv->pin);
|
||||
g_free(priv->device_id);
|
||||
g_free(priv->sim_id);
|
||||
g_free(priv->sim_operator_id);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_gsm_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
||||
{
|
||||
|
|
@ -638,9 +506,8 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingGsmPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
setting_class->verify_secrets = verify_secrets;
|
||||
|
|
@ -672,11 +539,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
*
|
||||
* Deprecated: 1.16: User-provided values for this setting are no longer used.
|
||||
**/
|
||||
obj_properties[PROP_NUMBER] = g_param_spec_string(NM_SETTING_GSM_NUMBER,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_NUMBER,
|
||||
PROP_NUMBER,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
number);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:username:
|
||||
|
|
@ -685,11 +554,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
* providers do not require a username, or accept any username. But if a
|
||||
* username is required, it is specified here.
|
||||
**/
|
||||
obj_properties[PROP_USERNAME] = g_param_spec_string(NM_SETTING_GSM_USERNAME,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_USERNAME,
|
||||
PROP_USERNAME,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
username);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:password:
|
||||
|
|
@ -698,12 +569,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
* providers do not require a password, or accept any password. But if a
|
||||
* password is required, it is specified here.
|
||||
**/
|
||||
obj_properties[PROP_PASSWORD] =
|
||||
g_param_spec_string(NM_SETTING_GSM_PASSWORD,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_PASSWORD,
|
||||
PROP_PASSWORD,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingGsmPrivate,
|
||||
password);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:password-flags:
|
||||
|
|
@ -727,11 +599,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
* The APN may only be composed of the characters a-z, 0-9, ., and - per GSM
|
||||
* 03.60 Section 14.9.
|
||||
**/
|
||||
obj_properties[PROP_APN] = g_param_spec_string(NM_SETTING_GSM_APN,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_APN,
|
||||
PROP_APN,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
apn,
|
||||
.direct_set_string_strip = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:network-id:
|
||||
|
|
@ -742,12 +617,14 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
* This can be used to ensure that the device does not roam when direct
|
||||
* roaming control of the device is not otherwise possible.
|
||||
**/
|
||||
obj_properties[PROP_NETWORK_ID] =
|
||||
g_param_spec_string(NM_SETTING_GSM_NETWORK_ID,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_NETWORK_ID,
|
||||
PROP_NETWORK_ID,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
network_id,
|
||||
.direct_set_string_strip = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:pin:
|
||||
|
|
@ -756,12 +633,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
* operations are requested. Specify the PIN here to allow operation of the
|
||||
* device.
|
||||
**/
|
||||
obj_properties[PROP_PIN] =
|
||||
g_param_spec_string(NM_SETTING_GSM_PIN,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_PIN,
|
||||
PROP_PIN,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingGsmPrivate,
|
||||
pin);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:pin-flags:
|
||||
|
|
@ -799,12 +677,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_DEVICE_ID] =
|
||||
g_param_spec_string(NM_SETTING_GSM_DEVICE_ID,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_DEVICE_ID,
|
||||
PROP_DEVICE_ID,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
device_id);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:sim-id:
|
||||
|
|
@ -816,11 +695,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_SIM_ID] = g_param_spec_string(NM_SETTING_GSM_SIM_ID,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_SIM_ID,
|
||||
PROP_SIM_ID,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
sim_id);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:sim-operator-id:
|
||||
|
|
@ -833,12 +714,13 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_SIM_OPERATOR_ID] =
|
||||
g_param_spec_string(NM_SETTING_GSM_SIM_OPERATOR_ID,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_SIM_OPERATOR_ID,
|
||||
PROP_SIM_OPERATOR_ID,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingGsmPrivate,
|
||||
sim_operator_id);
|
||||
|
||||
/**
|
||||
* NMSettingGsm:mtu:
|
||||
|
|
@ -848,14 +730,16 @@ nm_setting_gsm_class_init(NMSettingGsmClass *klass)
|
|||
*
|
||||
* Since: 1.8
|
||||
**/
|
||||
obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_GSM_MTU,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_GSM_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingGsmPrivate,
|
||||
mtu);
|
||||
|
||||
/* Ignore incoming deprecated properties */
|
||||
_nm_properties_override_dbus(properties_override,
|
||||
|
|
|
|||
|
|
@ -36,7 +36,9 @@ typedef struct {
|
|||
char *transport_mode;
|
||||
char *parent;
|
||||
char *virtual_iface_name;
|
||||
int p_key;
|
||||
gsize virtual_iface_name_parent_length;
|
||||
gint32 virtual_iface_name_p_key;
|
||||
gint32 p_key;
|
||||
guint32 mtu;
|
||||
} NMSettingInfinibandPrivate;
|
||||
|
||||
|
|
@ -156,14 +158,24 @@ const char *
|
|||
nm_setting_infiniband_get_virtual_interface_name(NMSettingInfiniband *setting)
|
||||
{
|
||||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(setting);
|
||||
gsize len;
|
||||
|
||||
if (priv->p_key == -1 || !priv->parent)
|
||||
if (priv->p_key == -1 || !priv->parent) {
|
||||
nm_clear_g_free(&priv->virtual_iface_name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!priv->virtual_iface_name)
|
||||
len = strlen(priv->parent);
|
||||
if (!priv->virtual_iface_name || priv->virtual_iface_name_p_key != priv->p_key
|
||||
|| priv->virtual_iface_name_parent_length != len
|
||||
|| memcmp(priv->parent, priv->virtual_iface_name, len) != 0) {
|
||||
priv->virtual_iface_name_p_key = priv->p_key;
|
||||
priv->virtual_iface_name_parent_length = len;
|
||||
g_free(priv->virtual_iface_name);
|
||||
priv->virtual_iface_name = g_strdup_printf("%s.%04x", priv->parent, priv->p_key);
|
||||
}
|
||||
|
||||
return NM_SETTING_INFINIBAND_GET_PRIVATE(setting)->virtual_iface_name;
|
||||
return priv->virtual_iface_name;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -237,10 +249,12 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
const char *interface_name = nm_setting_connection_get_interface_name(s_con);
|
||||
|
||||
if (interface_name && priv->p_key != -1) {
|
||||
if (!priv->virtual_iface_name)
|
||||
priv->virtual_iface_name = g_strdup_printf("%s.%04x", priv->parent, priv->p_key);
|
||||
const char *virtual_iface_name;
|
||||
|
||||
if (strcmp(interface_name, priv->virtual_iface_name) != 0) {
|
||||
virtual_iface_name =
|
||||
nm_setting_infiniband_get_virtual_interface_name(NM_SETTING_INFINIBAND(setting));
|
||||
|
||||
if (!nm_streq(interface_name, virtual_iface_name)) {
|
||||
/* We don't support renaming software infiniband devices. Later we might, but
|
||||
* for now just reject such connections.
|
||||
**/
|
||||
|
|
@ -249,7 +263,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("interface name of software infiniband device must be '%s' or unset "
|
||||
"(instead it is '%s')"),
|
||||
priv->virtual_iface_name,
|
||||
virtual_iface_name,
|
||||
interface_name);
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
|
|
@ -290,75 +304,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingInfiniband *setting = NM_SETTING_INFINIBAND(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_string(value, nm_setting_infiniband_get_mac_address(setting));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint(value, nm_setting_infiniband_get_mtu(setting));
|
||||
break;
|
||||
case PROP_TRANSPORT_MODE:
|
||||
g_value_set_string(value, nm_setting_infiniband_get_transport_mode(setting));
|
||||
break;
|
||||
case PROP_P_KEY:
|
||||
g_value_set_int(value, nm_setting_infiniband_get_p_key(setting));
|
||||
break;
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, nm_setting_infiniband_get_parent(setting));
|
||||
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)
|
||||
{
|
||||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_free(priv->mac_address);
|
||||
priv->mac_address =
|
||||
_nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), INFINIBAND_ALEN);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_TRANSPORT_MODE:
|
||||
g_free(priv->transport_mode);
|
||||
priv->transport_mode = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_P_KEY:
|
||||
priv->p_key = g_value_get_int(value);
|
||||
nm_clear_g_free(&priv->virtual_iface_name);
|
||||
break;
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
nm_clear_g_free(&priv->virtual_iface_name);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_infiniband_init(NMSettingInfiniband *self)
|
||||
{
|
||||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(self);
|
||||
|
||||
priv->p_key = -1;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* nm_setting_infiniband_new:
|
||||
|
|
@ -378,8 +326,6 @@ finalize(GObject *object)
|
|||
{
|
||||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->transport_mode);
|
||||
g_free(priv->parent);
|
||||
g_free(priv->virtual_iface_name);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_infiniband_parent_class)->finalize(object);
|
||||
|
|
@ -394,8 +340,8 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingInfinibandPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
|
@ -447,14 +393,16 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
* description: MTU of the interface.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_INFINIBAND_MTU,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_INFINIBAND_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingInfinibandPrivate,
|
||||
mtu);
|
||||
|
||||
/**
|
||||
* NMSettingInfiniband:transport-mode:
|
||||
|
|
@ -470,12 +418,13 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
* "datagram" mode
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_TRANSPORT_MODE] = g_param_spec_string(
|
||||
NM_SETTING_INFINIBAND_TRANSPORT_MODE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_INFINIBAND_TRANSPORT_MODE,
|
||||
PROP_TRANSPORT_MODE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingInfinibandPrivate,
|
||||
transport_mode);
|
||||
|
||||
/**
|
||||
* NMSettingInfiniband:p-key:
|
||||
|
|
@ -495,14 +444,16 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
* example: PKEY=yes PKEY_ID=2 PHYSDEV=mlx4_ib0 DEVICE=mlx4_ib0.8002
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_P_KEY] =
|
||||
g_param_spec_int(NM_SETTING_INFINIBAND_P_KEY,
|
||||
"",
|
||||
"",
|
||||
-1,
|
||||
0xFFFF,
|
||||
-1,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_INFINIBAND_P_KEY,
|
||||
PROP_P_KEY,
|
||||
-1,
|
||||
0xFFFF,
|
||||
-1,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingInfinibandPrivate,
|
||||
p_key);
|
||||
|
||||
/**
|
||||
* NMSettingInfiniband:parent:
|
||||
|
|
@ -520,12 +471,13 @@ nm_setting_infiniband_class_init(NMSettingInfinibandClass *klass)
|
|||
* example: PHYSDEV=ib0
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_PARENT] = g_param_spec_string(
|
||||
NM_SETTING_INFINIBAND_PARENT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_INFINIBAND_PARENT,
|
||||
PROP_PARENT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingInfinibandPrivate,
|
||||
parent);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -5555,9 +5555,10 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_nm_utils_validate_dhcp_hostname_flags(priv->dhcp_hostname_flags,
|
||||
NM_SETTING_IP_CONFIG_GET_FAMILY(setting),
|
||||
error)) {
|
||||
if (priv->dhcp_hostname_flags != (NMDhcpHostnameFlags) priv->dhcp_hostname_flags
|
||||
|| !_nm_utils_validate_dhcp_hostname_flags(priv->dhcp_hostname_flags,
|
||||
NM_SETTING_IP_CONFIG_GET_FAMILY(setting),
|
||||
error)) {
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
nm_setting_get_name(setting),
|
||||
|
|
@ -5788,7 +5789,8 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct_ip_config_gateway),
|
||||
.direct_offset = NM_STRUCT_OFFSET_ENSURE_TYPE(char *, NMSettingIPConfigPrivate, gateway),
|
||||
.direct_set_string_ip_address_addr_family = addr_family);
|
||||
.direct_set_string_ip_address_addr_family = addr_family + 1,
|
||||
.direct_set_string_ip_address_addr_family_map_zero_to_null = TRUE);
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
|
|
@ -5824,6 +5826,20 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, ignore_auto_routes));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_ROUTE_TABLE],
|
||||
&nm_sett_info_propert_type_direct_uint32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, NMSettingIPConfigPrivate, route_table));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_ROUTE_METRIC],
|
||||
&nm_sett_info_propert_type_direct_int64,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, NMSettingIPConfigPrivate, route_metric));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_IGNORE_AUTO_DNS],
|
||||
|
|
@ -5831,6 +5847,34 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, ignore_auto_dns));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DNS_PRIORITY],
|
||||
&nm_sett_info_propert_type_direct_int32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dns_priority));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DHCP_TIMEOUT],
|
||||
&nm_sett_info_propert_type_direct_int32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dhcp_timeout));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_REQUIRED_TIMEOUT],
|
||||
&nm_sett_info_propert_type_direct_int32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, required_timeout));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DAD_TIMEOUT],
|
||||
&nm_sett_info_propert_type_direct_int32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint32, NMSettingIPConfigPrivate, dad_timeout));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DHCP_SEND_HOSTNAME],
|
||||
|
|
@ -5838,6 +5882,13 @@ _nm_sett_info_property_override_create_array_ip_config(int addr_family)
|
|||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(bool, NMSettingIPConfigPrivate, dhcp_send_hostname));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_DHCP_HOSTNAME_FLAGS],
|
||||
&nm_sett_info_propert_type_direct_uint32,
|
||||
.direct_offset =
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(guint32, NMSettingIPConfigPrivate, dhcp_hostname_flags));
|
||||
|
||||
_nm_properties_override_gobj(
|
||||
properties_override,
|
||||
obj_properties[PROP_NEVER_DEFAULT],
|
||||
|
|
@ -5863,9 +5914,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingIPConfigPrivate *priv = NM_SETTING_IP_CONFIG_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_METHOD:
|
||||
g_value_set_string(value, nm_setting_ip_config_get_method(setting));
|
||||
break;
|
||||
case PROP_DNS:
|
||||
g_value_take_boxed(value, _nm_utils_ptrarray_to_strv(priv->dns));
|
||||
break;
|
||||
|
|
@ -5877,68 +5925,23 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
priv->dns_options ? _nm_utils_ptrarray_to_strv(priv->dns_options)
|
||||
: NULL);
|
||||
break;
|
||||
case PROP_DNS_PRIORITY:
|
||||
g_value_set_int(value, priv->dns_priority);
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
g_value_take_boxed(value,
|
||||
_nm_utils_copy_array(priv->addresses,
|
||||
(NMUtilsCopyFunc) nm_ip_address_dup,
|
||||
(GDestroyNotify) nm_ip_address_unref));
|
||||
break;
|
||||
case PROP_GATEWAY:
|
||||
g_value_set_string(value, nm_setting_ip_config_get_gateway(setting));
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
g_value_take_boxed(value,
|
||||
_nm_utils_copy_array(priv->routes,
|
||||
(NMUtilsCopyFunc) nm_ip_route_dup,
|
||||
(GDestroyNotify) nm_ip_route_unref));
|
||||
break;
|
||||
case PROP_ROUTE_METRIC:
|
||||
g_value_set_int64(value, priv->route_metric);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
g_value_set_uint(value, priv->route_table);
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
g_value_set_boolean(value, nm_setting_ip_config_get_ignore_auto_routes(setting));
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_DNS:
|
||||
g_value_set_boolean(value, nm_setting_ip_config_get_ignore_auto_dns(setting));
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME:
|
||||
g_value_set_string(value, nm_setting_ip_config_get_dhcp_hostname(setting));
|
||||
break;
|
||||
case PROP_DHCP_SEND_HOSTNAME:
|
||||
g_value_set_boolean(value, nm_setting_ip_config_get_dhcp_send_hostname(setting));
|
||||
break;
|
||||
case PROP_NEVER_DEFAULT:
|
||||
g_value_set_boolean(value, priv->never_default);
|
||||
break;
|
||||
case PROP_MAY_FAIL:
|
||||
g_value_set_boolean(value, priv->may_fail);
|
||||
break;
|
||||
case PROP_DAD_TIMEOUT:
|
||||
g_value_set_int(value, nm_setting_ip_config_get_dad_timeout(setting));
|
||||
break;
|
||||
case PROP_DHCP_TIMEOUT:
|
||||
g_value_set_int(value, nm_setting_ip_config_get_dhcp_timeout(setting));
|
||||
break;
|
||||
case PROP_REQUIRED_TIMEOUT:
|
||||
g_value_set_int(value, nm_setting_ip_config_get_required_timeout(setting));
|
||||
break;
|
||||
case PROP_DHCP_IAID:
|
||||
g_value_set_string(value, nm_setting_ip_config_get_dhcp_iaid(setting));
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME_FLAGS:
|
||||
g_value_set_uint(value, nm_setting_ip_config_get_dhcp_hostname_flags(setting));
|
||||
break;
|
||||
case PROP_DHCP_REJECT_SERVERS:
|
||||
g_value_set_boxed(value, nm_strvarray_get_strv_non_empty(priv->dhcp_reject_servers, NULL));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -5952,10 +5955,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
guint i;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_METHOD:
|
||||
g_free(priv->method);
|
||||
priv->method = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DNS:
|
||||
g_ptr_array_unref(priv->dns);
|
||||
priv->dns = nm_strv_to_ptrarray(g_value_get_boxed(value));
|
||||
|
|
@ -5983,73 +5982,23 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PROP_DNS_PRIORITY:
|
||||
priv->dns_priority = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
g_ptr_array_unref(priv->addresses);
|
||||
priv->addresses = _nm_utils_copy_array(g_value_get_boxed(value),
|
||||
(NMUtilsCopyFunc) nm_ip_address_dup,
|
||||
(GDestroyNotify) nm_ip_address_unref);
|
||||
break;
|
||||
case PROP_GATEWAY:
|
||||
g_free(priv->gateway);
|
||||
priv->gateway =
|
||||
_nm_utils_ipaddr_canonical_or_invalid(NM_SETTING_IP_CONFIG_GET_FAMILY(setting),
|
||||
g_value_get_string(value));
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
g_ptr_array_unref(priv->routes);
|
||||
priv->routes = _nm_utils_copy_array(g_value_get_boxed(value),
|
||||
(NMUtilsCopyFunc) nm_ip_route_dup,
|
||||
(GDestroyNotify) nm_ip_route_unref);
|
||||
break;
|
||||
case PROP_ROUTE_METRIC:
|
||||
priv->route_metric = g_value_get_int64(value);
|
||||
break;
|
||||
case PROP_ROUTE_TABLE:
|
||||
priv->route_table = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
priv->ignore_auto_routes = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_DNS:
|
||||
priv->ignore_auto_dns = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME:
|
||||
g_free(priv->dhcp_hostname);
|
||||
priv->dhcp_hostname = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DHCP_SEND_HOSTNAME:
|
||||
priv->dhcp_send_hostname = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_NEVER_DEFAULT:
|
||||
priv->never_default = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_MAY_FAIL:
|
||||
priv->may_fail = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_DAD_TIMEOUT:
|
||||
priv->dad_timeout = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_DHCP_TIMEOUT:
|
||||
priv->dhcp_timeout = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_REQUIRED_TIMEOUT:
|
||||
priv->required_timeout = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_DHCP_IAID:
|
||||
g_free(priv->dhcp_iaid);
|
||||
priv->dhcp_iaid = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DHCP_HOSTNAME_FLAGS:
|
||||
priv->dhcp_hostname_flags = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_DHCP_REJECT_SERVERS:
|
||||
nm_strvarray_set_strv(&priv->dhcp_reject_servers, g_value_get_boxed(value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -6061,13 +6010,10 @@ _nm_setting_ip_config_private_init(gpointer self, NMSettingIPConfigPrivate *priv
|
|||
{
|
||||
nm_assert(NM_IS_SETTING_IP_CONFIG(self));
|
||||
|
||||
priv->dns = g_ptr_array_new_with_free_func(g_free);
|
||||
priv->dns_search = g_ptr_array_new_with_free_func(g_free);
|
||||
priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref);
|
||||
priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref);
|
||||
priv->route_metric = -1;
|
||||
priv->dad_timeout = -1;
|
||||
priv->required_timeout = -1;
|
||||
priv->dns = g_ptr_array_new_with_free_func(g_free);
|
||||
priv->dns_search = g_ptr_array_new_with_free_func(g_free);
|
||||
priv->addresses = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_address_unref);
|
||||
priv->routes = g_ptr_array_new_with_free_func((GDestroyNotify) nm_ip_route_unref);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -6084,13 +6030,11 @@ finalize(GObject *object)
|
|||
|
||||
g_ptr_array_unref(priv->dns);
|
||||
g_ptr_array_unref(priv->dns_search);
|
||||
if (priv->dns_options)
|
||||
g_ptr_array_unref(priv->dns_options);
|
||||
nm_g_ptr_array_unref(priv->dns_options);
|
||||
g_ptr_array_unref(priv->addresses);
|
||||
g_ptr_array_unref(priv->routes);
|
||||
if (priv->routing_rules)
|
||||
g_ptr_array_unref(priv->routing_rules);
|
||||
nm_clear_pointer(&priv->dhcp_reject_servers, g_array_unref);
|
||||
nm_g_ptr_array_unref(priv->routing_rules);
|
||||
nm_g_array_unref(priv->dhcp_reject_servers);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_ip_config_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,19 +32,19 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT,
|
|||
PROP_FLAGS, );
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
char *local;
|
||||
char *remote;
|
||||
char *input_key;
|
||||
char *output_key;
|
||||
guint ttl;
|
||||
guint tos;
|
||||
guint encapsulation_limit;
|
||||
guint flow_label;
|
||||
NMIPTunnelMode mode;
|
||||
guint32 mtu;
|
||||
guint32 flags;
|
||||
bool path_mtu_discovery;
|
||||
char *parent;
|
||||
char *local;
|
||||
char *remote;
|
||||
char *input_key;
|
||||
char *output_key;
|
||||
guint32 ttl;
|
||||
guint32 tos;
|
||||
guint32 encapsulation_limit;
|
||||
guint32 flow_label;
|
||||
guint32 mode;
|
||||
guint32 mtu;
|
||||
guint32 flags;
|
||||
bool path_mtu_discovery;
|
||||
} NMSettingIPTunnelPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -502,117 +502,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingIPTunnel *setting = NM_SETTING_IP_TUNNEL(object);
|
||||
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, priv->parent);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_value_set_uint(value, priv->mode);
|
||||
break;
|
||||
case PROP_LOCAL:
|
||||
g_value_set_string(value, priv->local);
|
||||
break;
|
||||
case PROP_REMOTE:
|
||||
g_value_set_string(value, priv->remote);
|
||||
break;
|
||||
case PROP_TTL:
|
||||
g_value_set_uint(value, priv->ttl);
|
||||
break;
|
||||
case PROP_TOS:
|
||||
g_value_set_uint(value, priv->tos);
|
||||
break;
|
||||
case PROP_PATH_MTU_DISCOVERY:
|
||||
g_value_set_boolean(value, priv->path_mtu_discovery);
|
||||
break;
|
||||
case PROP_INPUT_KEY:
|
||||
g_value_set_string(value, priv->input_key);
|
||||
break;
|
||||
case PROP_OUTPUT_KEY:
|
||||
g_value_set_string(value, priv->output_key);
|
||||
break;
|
||||
case PROP_ENCAPSULATION_LIMIT:
|
||||
g_value_set_uint(value, priv->encapsulation_limit);
|
||||
break;
|
||||
case PROP_FLOW_LABEL:
|
||||
g_value_set_uint(value, priv->flow_label);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint(value, priv->mtu);
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
g_value_set_uint(value, priv->flags);
|
||||
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)
|
||||
{
|
||||
NMSettingIPTunnel *setting = NM_SETTING_IP_TUNNEL(object);
|
||||
NMSettingIPTunnelPrivate *priv = NM_SETTING_IP_TUNNEL_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
priv->mode = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_LOCAL:
|
||||
g_free(priv->local);
|
||||
priv->local = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_REMOTE:
|
||||
g_free(priv->remote);
|
||||
priv->remote = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_TTL:
|
||||
priv->ttl = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_TOS:
|
||||
priv->tos = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_PATH_MTU_DISCOVERY:
|
||||
priv->path_mtu_discovery = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_INPUT_KEY:
|
||||
g_free(priv->input_key);
|
||||
priv->input_key = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_OUTPUT_KEY:
|
||||
g_free(priv->output_key);
|
||||
priv->output_key = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_ENCAPSULATION_LIMIT:
|
||||
priv->encapsulation_limit = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_FLOW_LABEL:
|
||||
priv->flow_label = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
priv->flags = g_value_get_uint(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ip_tunnel_init(NMSettingIPTunnel *self)
|
||||
{}
|
||||
|
|
@ -641,8 +530,8 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingIPTunnelPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -671,14 +560,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_MODE] =
|
||||
g_param_spec_uint(NM_SETTING_IP_TUNNEL_MODE,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_MODE,
|
||||
PROP_MODE,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_IP_TUNNEL_MODE_UNKNOWN,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
mode);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:local:
|
||||
|
|
@ -720,14 +611,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_TTL] =
|
||||
g_param_spec_uint(NM_SETTING_IP_TUNNEL_TTL,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_TTL,
|
||||
PROP_TTL,
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
ttl);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:tos
|
||||
|
|
@ -737,14 +630,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_TOS] =
|
||||
g_param_spec_uint(NM_SETTING_IP_TUNNEL_TOS,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_TOS,
|
||||
PROP_TOS,
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
tos);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:path-mtu-discovery
|
||||
|
|
@ -802,14 +697,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_ENCAPSULATION_LIMIT] =
|
||||
g_param_spec_uint(NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_ENCAPSULATION_LIMIT,
|
||||
PROP_ENCAPSULATION_LIMIT,
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
encapsulation_limit);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:flow-label:
|
||||
|
|
@ -819,14 +716,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_FLOW_LABEL] =
|
||||
g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLOW_LABEL,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
(1 << 20) - 1,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_FLOW_LABEL,
|
||||
PROP_FLOW_LABEL,
|
||||
0,
|
||||
(1 << 20) - 1,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
flow_label);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:mtu:
|
||||
|
|
@ -836,14 +735,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_MTU,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
mtu);
|
||||
|
||||
/**
|
||||
* NMSettingIPTunnel:flags:
|
||||
|
|
@ -856,14 +757,16 @@ nm_setting_ip_tunnel_class_init(NMSettingIPTunnelClass *klass)
|
|||
*
|
||||
* Since: 1.12
|
||||
**/
|
||||
obj_properties[PROP_FLAGS] = g_param_spec_uint(NM_SETTING_IP_TUNNEL_FLAGS,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP_TUNNEL_FLAGS,
|
||||
PROP_FLAGS,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingIPTunnelPrivate,
|
||||
flags);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -522,53 +522,6 @@ ip4_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DHCP_CLIENT_ID:
|
||||
g_value_set_string(value, nm_setting_ip4_config_get_dhcp_client_id(s_ip4));
|
||||
break;
|
||||
case PROP_DHCP_FQDN:
|
||||
g_value_set_string(value, nm_setting_ip4_config_get_dhcp_fqdn(s_ip4));
|
||||
break;
|
||||
case PROP_DHCP_VENDOR_CLASS_IDENTIFIER:
|
||||
g_value_set_string(value, nm_setting_ip4_config_get_dhcp_vendor_class_identifier(s_ip4));
|
||||
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)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DHCP_CLIENT_ID:
|
||||
g_free(priv->dhcp_client_id);
|
||||
priv->dhcp_client_id = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DHCP_FQDN:
|
||||
g_free(priv->dhcp_fqdn);
|
||||
priv->dhcp_fqdn = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DHCP_VENDOR_CLASS_IDENTIFIER:
|
||||
g_free(priv->dhcp_vendor_class_identifier);
|
||||
priv->dhcp_vendor_class_identifier = g_value_dup_string(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ip4_config_init(NMSettingIP4Config *setting)
|
||||
{
|
||||
|
|
@ -600,8 +553,8 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingIP4ConfigPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_IP6_PRIVACY,
|
|||
typedef struct {
|
||||
NMSettingIPConfigPrivate parent;
|
||||
|
||||
char *token;
|
||||
char *dhcp_duid;
|
||||
int ip6_privacy;
|
||||
NMSettingIP6ConfigAddrGenMode addr_gen_mode;
|
||||
gint32 ra_timeout;
|
||||
char *token;
|
||||
char *dhcp_duid;
|
||||
int ip6_privacy;
|
||||
gint32 addr_gen_mode;
|
||||
gint32 ra_timeout;
|
||||
} NMSettingIP6ConfigPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -501,66 +501,12 @@ ip6_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ADDR_GEN_MODE:
|
||||
g_value_set_int(value, priv->addr_gen_mode);
|
||||
break;
|
||||
case PROP_TOKEN:
|
||||
g_value_set_string(value, priv->token);
|
||||
break;
|
||||
case PROP_DHCP_DUID:
|
||||
g_value_set_string(value, priv->dhcp_duid);
|
||||
break;
|
||||
case PROP_RA_TIMEOUT:
|
||||
g_value_set_int(value, priv->ra_timeout);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_ADDR_GEN_MODE:
|
||||
priv->addr_gen_mode = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_TOKEN:
|
||||
g_free(priv->token);
|
||||
priv->token = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_DHCP_DUID:
|
||||
g_free(priv->dhcp_duid);
|
||||
priv->dhcp_duid = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_RA_TIMEOUT:
|
||||
priv->ra_timeout = g_value_get_int(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ip6_config_init(NMSettingIP6Config *setting)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE(setting);
|
||||
|
||||
_nm_setting_ip_config_private_init(setting, &priv->parent);
|
||||
|
||||
priv->addr_gen_mode = NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -586,8 +532,8 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingIP6ConfigPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -847,14 +793,16 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* example: IPV6_ADDR_GEN_MODE=stable-privacy
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_ADDR_GEN_MODE] =
|
||||
g_param_spec_int(NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE,
|
||||
"",
|
||||
"",
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE,
|
||||
PROP_ADDR_GEN_MODE,
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
NM_SETTING_IP6_CONFIG_ADDR_GEN_MODE_STABLE_PRIVACY,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingIP6ConfigPrivate,
|
||||
addr_gen_mode);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:token:
|
||||
|
|
@ -897,15 +845,16 @@ nm_setting_ip6_config_class_init(NMSettingIP6ConfigClass *klass)
|
|||
* example: IPV6_RA_TIMEOUT=10
|
||||
* ---end---
|
||||
*/
|
||||
|
||||
obj_properties[PROP_RA_TIMEOUT] = g_param_spec_int(
|
||||
NM_SETTING_IP6_CONFIG_RA_TIMEOUT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_IP6_CONFIG_RA_TIMEOUT,
|
||||
PROP_RA_TIMEOUT,
|
||||
0,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingIP6ConfigPrivate,
|
||||
ra_timeout);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:dhcp-duid:
|
||||
|
|
|
|||
|
|
@ -38,15 +38,15 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT,
|
|||
PROP_SEND_SCI, );
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
char *mka_cak;
|
||||
char *mka_ckn;
|
||||
int port;
|
||||
guint mka_cak_flags;
|
||||
NMSettingMacsecMode mode;
|
||||
NMSettingMacsecValidation validation;
|
||||
bool encrypt;
|
||||
bool send_sci;
|
||||
char *parent;
|
||||
char *mka_cak;
|
||||
char *mka_ckn;
|
||||
guint mka_cak_flags;
|
||||
gint32 mode;
|
||||
gint32 validation;
|
||||
gint32 port;
|
||||
bool encrypt;
|
||||
bool send_sci;
|
||||
} NMSettingMacsecPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -84,6 +84,7 @@ const char *
|
|||
nm_setting_macsec_get_parent(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->parent;
|
||||
}
|
||||
|
||||
|
|
@ -99,6 +100,7 @@ NMSettingMacsecMode
|
|||
nm_setting_macsec_get_mode(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NM_SETTING_MACSEC_MODE_PSK);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mode;
|
||||
}
|
||||
|
||||
|
|
@ -129,6 +131,7 @@ const char *
|
|||
nm_setting_macsec_get_mka_cak(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mka_cak;
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +163,7 @@ const char *
|
|||
nm_setting_macsec_get_mka_ckn(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NULL);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->mka_ckn;
|
||||
}
|
||||
|
||||
|
|
@ -175,6 +179,7 @@ int
|
|||
nm_setting_macsec_get_port(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), 1);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->port;
|
||||
}
|
||||
|
||||
|
|
@ -190,6 +195,7 @@ NMSettingMacsecValidation
|
|||
nm_setting_macsec_get_validation(NMSettingMacsec *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACSEC(setting), NM_SETTING_MACSEC_VALIDATION_DISABLE);
|
||||
|
||||
return NM_SETTING_MACSEC_GET_PRIVATE(setting)->validation;
|
||||
}
|
||||
|
||||
|
|
@ -374,15 +380,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->port <= 0 || priv->port > 65534) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
||||
_("invalid port %d"),
|
||||
priv->port);
|
||||
g_prefix_error(error, "%s.%s: ", NM_SETTING_MACSEC_SETTING_NAME, NM_SETTING_MACSEC_PORT);
|
||||
return FALSE;
|
||||
}
|
||||
nm_assert(priv->port >= 1 && priv->port <= 65534);
|
||||
|
||||
if (priv->mode != NM_SETTING_MACSEC_MODE_PSK && (priv->mka_cak || priv->mka_ckn)) {
|
||||
g_set_error_literal(error,
|
||||
|
|
@ -401,94 +399,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingMacsec *setting = NM_SETTING_MACSEC(object);
|
||||
NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, priv->parent);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_value_set_int(value, priv->mode);
|
||||
break;
|
||||
case PROP_ENCRYPT:
|
||||
g_value_set_boolean(value, priv->encrypt);
|
||||
break;
|
||||
case PROP_MKA_CAK:
|
||||
g_value_set_string(value, priv->mka_cak);
|
||||
break;
|
||||
case PROP_MKA_CKN:
|
||||
g_value_set_string(value, priv->mka_ckn);
|
||||
break;
|
||||
case PROP_PORT:
|
||||
g_value_set_int(value, priv->port);
|
||||
break;
|
||||
case PROP_VALIDATION:
|
||||
g_value_set_int(value, priv->validation);
|
||||
break;
|
||||
case PROP_SEND_SCI:
|
||||
g_value_set_boolean(value, priv->send_sci);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingMacsec *setting = NM_SETTING_MACSEC(object);
|
||||
NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
priv->mode = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_ENCRYPT:
|
||||
priv->encrypt = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_MKA_CAK:
|
||||
nm_free_secret(priv->mka_cak);
|
||||
priv->mka_cak = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MKA_CKN:
|
||||
g_free(priv->mka_ckn);
|
||||
priv->mka_ckn = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_PORT:
|
||||
priv->port = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_VALIDATION:
|
||||
priv->validation = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_SEND_SCI:
|
||||
priv->send_sci = g_value_get_boolean(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_macsec_init(NMSettingMacsec *self)
|
||||
{
|
||||
NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(self);
|
||||
|
||||
nm_assert(priv->mode == NM_SETTING_MACSEC_MODE_PSK);
|
||||
priv->port = 1;
|
||||
priv->validation = NM_SETTING_MACSEC_VALIDATION_STRICT;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* nm_setting_macsec_new:
|
||||
|
|
@ -505,19 +418,6 @@ nm_setting_macsec_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_MACSEC, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingMacsec *setting = NM_SETTING_MACSEC(object);
|
||||
NMSettingMacsecPrivate *priv = NM_SETTING_MACSEC_GET_PRIVATE(setting);
|
||||
|
||||
g_free(priv->parent);
|
||||
nm_free_secret(priv->mka_cak);
|
||||
g_free(priv->mka_ckn);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_macsec_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
||||
{
|
||||
|
|
@ -527,9 +427,8 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingMacsecPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
setting_class->need_secrets = need_secrets;
|
||||
|
|
@ -544,12 +443,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_PARENT] = g_param_spec_string(
|
||||
NM_SETTING_MACSEC_PARENT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_PARENT,
|
||||
PROP_PARENT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacsecPrivate,
|
||||
parent);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:mode:
|
||||
|
|
@ -559,14 +459,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_MODE] =
|
||||
g_param_spec_int(NM_SETTING_MACSEC_MODE,
|
||||
"",
|
||||
"",
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
NM_SETTING_MACSEC_MODE_PSK,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_MODE,
|
||||
PROP_MODE,
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
NM_SETTING_MACSEC_MODE_PSK,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacsecPrivate,
|
||||
mode);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:encrypt:
|
||||
|
|
@ -592,12 +494,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_MKA_CAK] =
|
||||
g_param_spec_string(NM_SETTING_MACSEC_MKA_CAK,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_MKA_CAK,
|
||||
PROP_MKA_CAK,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingMacsecPrivate,
|
||||
mka_cak);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:mka-cak-flags:
|
||||
|
|
@ -622,11 +525,13 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_MKA_CKN] = g_param_spec_string(NM_SETTING_MACSEC_MKA_CKN,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_MKA_CKN,
|
||||
PROP_MKA_CKN,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingMacsecPrivate,
|
||||
mka_ckn);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:port:
|
||||
|
|
@ -635,14 +540,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_PORT] =
|
||||
g_param_spec_int(NM_SETTING_MACSEC_PORT,
|
||||
"",
|
||||
"",
|
||||
1,
|
||||
65534,
|
||||
1,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_PORT,
|
||||
PROP_PORT,
|
||||
1,
|
||||
65534,
|
||||
1,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacsecPrivate,
|
||||
port);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:validation:
|
||||
|
|
@ -651,14 +558,16 @@ nm_setting_macsec_class_init(NMSettingMacsecClass *klass)
|
|||
*
|
||||
* Since: 1.6
|
||||
**/
|
||||
obj_properties[PROP_VALIDATION] =
|
||||
g_param_spec_int(NM_SETTING_MACSEC_VALIDATION,
|
||||
"",
|
||||
"",
|
||||
G_MININT,
|
||||
G_MAXINT,
|
||||
NM_SETTING_MACSEC_VALIDATION_STRICT,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACSEC_VALIDATION,
|
||||
PROP_VALIDATION,
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
NM_SETTING_MACSEC_VALIDATION_STRICT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacsecPrivate,
|
||||
validation);
|
||||
|
||||
/**
|
||||
* NMSettingMacsec:send-sci:
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@
|
|||
NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT, PROP_MODE, PROP_PROMISCUOUS, PROP_TAP, );
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
NMSettingMacvlanMode mode;
|
||||
bool promiscuous;
|
||||
bool tap;
|
||||
char *parent;
|
||||
guint32 mode;
|
||||
bool promiscuous;
|
||||
bool tap;
|
||||
} NMSettingMacvlanPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -69,6 +69,7 @@ const char *
|
|||
nm_setting_macvlan_get_parent(NMSettingMacvlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NULL);
|
||||
|
||||
return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->parent;
|
||||
}
|
||||
|
||||
|
|
@ -84,6 +85,7 @@ NMSettingMacvlanMode
|
|||
nm_setting_macvlan_get_mode(NMSettingMacvlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_MACVLAN(setting), NM_SETTING_MACVLAN_MODE_UNKNOWN);
|
||||
|
||||
return NM_SETTING_MACVLAN_GET_PRIVATE(setting)->mode;
|
||||
}
|
||||
|
||||
|
|
@ -179,59 +181,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object);
|
||||
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, priv->parent);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_value_set_uint(value, priv->mode);
|
||||
break;
|
||||
case PROP_PROMISCUOUS:
|
||||
g_value_set_boolean(value, priv->promiscuous);
|
||||
break;
|
||||
case PROP_TAP:
|
||||
g_value_set_boolean(value, priv->tap);
|
||||
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)
|
||||
{
|
||||
NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object);
|
||||
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
priv->mode = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_PROMISCUOUS:
|
||||
priv->promiscuous = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_TAP:
|
||||
priv->tap = g_value_get_boolean(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_macvlan_init(NMSettingMacvlan *self)
|
||||
{}
|
||||
|
|
@ -251,17 +200,6 @@ nm_setting_macvlan_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_MACVLAN, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingMacvlan *setting = NM_SETTING_MACVLAN(object);
|
||||
NMSettingMacvlanPrivate *priv = NM_SETTING_MACVLAN_GET_PRIVATE(setting);
|
||||
|
||||
g_free(priv->parent);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_macvlan_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
|
||||
{
|
||||
|
|
@ -271,9 +209,8 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingMacvlanPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -287,12 +224,13 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_PARENT] = g_param_spec_string(
|
||||
NM_SETTING_MACVLAN_PARENT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACVLAN_PARENT,
|
||||
PROP_PARENT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacvlanPrivate,
|
||||
parent);
|
||||
|
||||
/**
|
||||
* NMSettingMacvlan:mode:
|
||||
|
|
@ -302,14 +240,16 @@ nm_setting_macvlan_class_init(NMSettingMacvlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_MODE] =
|
||||
g_param_spec_uint(NM_SETTING_MACVLAN_MODE,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_MACVLAN_MODE,
|
||||
PROP_MODE,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_MACVLAN_MODE_UNKNOWN,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingMacvlanPrivate,
|
||||
mode);
|
||||
|
||||
/**
|
||||
* NMSettingMacvlan:promiscuous:
|
||||
|
|
|
|||
|
|
@ -198,64 +198,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FAIL_MODE:
|
||||
g_value_set_string(value, self->fail_mode);
|
||||
break;
|
||||
case PROP_MCAST_SNOOPING_ENABLE:
|
||||
g_value_set_boolean(value, self->mcast_snooping_enable);
|
||||
break;
|
||||
case PROP_RSTP_ENABLE:
|
||||
g_value_set_boolean(value, self->rstp_enable);
|
||||
break;
|
||||
case PROP_STP_ENABLE:
|
||||
g_value_set_boolean(value, self->stp_enable);
|
||||
break;
|
||||
case PROP_DATAPATH_TYPE:
|
||||
g_value_set_string(value, self->datapath_type);
|
||||
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)
|
||||
{
|
||||
NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FAIL_MODE:
|
||||
g_free(self->fail_mode);
|
||||
self->fail_mode = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MCAST_SNOOPING_ENABLE:
|
||||
self->mcast_snooping_enable = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_RSTP_ENABLE:
|
||||
self->rstp_enable = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_STP_ENABLE:
|
||||
self->stp_enable = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_DATAPATH_TYPE:
|
||||
g_free(self->datapath_type);
|
||||
self->datapath_type = g_value_dup_string(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ovs_bridge_init(NMSettingOvsBridge *self)
|
||||
{}
|
||||
|
|
@ -275,17 +217,6 @@ nm_setting_ovs_bridge_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_OVS_BRIDGE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingOvsBridge *self = NM_SETTING_OVS_BRIDGE(object);
|
||||
|
||||
g_free(self->fail_mode);
|
||||
g_free(self->datapath_type);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_ovs_bridge_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass)
|
||||
{
|
||||
|
|
@ -293,9 +224,8 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass)
|
|||
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
|
||||
GArray *properties_override = _nm_sett_info_property_override_create_array();
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -306,12 +236,13 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass)
|
|||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
obj_properties[PROP_FAIL_MODE] = g_param_spec_string(
|
||||
NM_SETTING_OVS_BRIDGE_FAIL_MODE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_OVS_BRIDGE_FAIL_MODE,
|
||||
PROP_FAIL_MODE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingOvsBridge,
|
||||
fail_mode);
|
||||
|
||||
/**
|
||||
* NMSettingOvsBridge:mcast-snooping-enable:
|
||||
|
|
@ -368,12 +299,13 @@ nm_setting_ovs_bridge_class_init(NMSettingOvsBridgeClass *klass)
|
|||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
obj_properties[PROP_DATAPATH_TYPE] = g_param_spec_string(
|
||||
NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_OVS_BRIDGE_DATAPATH_TYPE,
|
||||
PROP_DATAPATH_TYPE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingOvsBridge,
|
||||
datapath_type);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,39 +78,6 @@ nm_setting_ovs_dpdk_get_n_rxq(NMSettingOvsDpdk *self)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DEVARGS:
|
||||
g_value_set_string(value, self->devargs);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_DEVARGS:
|
||||
g_free(self->devargs);
|
||||
self->devargs = g_value_dup_string(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ovs_dpdk_init(NMSettingOvsDpdk *self)
|
||||
{}
|
||||
|
|
@ -130,16 +97,6 @@ nm_setting_ovs_dpdk_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_OVS_DPDK, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingOvsDpdk *self = NM_SETTING_OVS_DPDK(object);
|
||||
|
||||
g_free(self->devargs);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_ovs_dpdk_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
|
||||
{
|
||||
|
|
@ -147,9 +104,8 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
|
|||
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
|
||||
GArray *properties_override = _nm_sett_info_property_override_create_array();
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
/**
|
||||
* NMSettingOvsDpdk:devargs:
|
||||
|
|
@ -158,12 +114,13 @@ nm_setting_ovs_dpdk_class_init(NMSettingOvsDpdkClass *klass)
|
|||
*
|
||||
* Since: 1.20
|
||||
**/
|
||||
obj_properties[PROP_DEVARGS] = g_param_spec_string(
|
||||
NM_SETTING_OVS_DPDK_DEVARGS,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_OVS_DPDK_DEVARGS,
|
||||
PROP_DEVARGS,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingOvsDpdk,
|
||||
devargs);
|
||||
|
||||
/**
|
||||
* NMSettingOvsDpdk:n-rxq:
|
||||
|
|
|
|||
|
|
@ -543,5 +543,5 @@ nm_setting_ovs_external_ids_class_init(NMSettingOvsExternalIDsClass *klass)
|
|||
NM_META_SETTING_TYPE_OVS_EXTERNAL_IDS,
|
||||
NULL,
|
||||
properties_override,
|
||||
G_STRUCT_OFFSET(NMSettingOvsExternalIDs, _priv));
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,39 +333,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TYPE:
|
||||
g_value_set_string(value, self->type);
|
||||
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)
|
||||
{
|
||||
NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TYPE:
|
||||
g_free(self->type);
|
||||
self->type = g_value_dup_string(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ovs_interface_init(NMSettingOvsInterface *self)
|
||||
{}
|
||||
|
|
@ -385,25 +352,15 @@ nm_setting_ovs_interface_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_OVS_INTERFACE, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingOvsInterface *self = NM_SETTING_OVS_INTERFACE(object);
|
||||
|
||||
g_free(self->type);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_ovs_interface_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS(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();
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -414,14 +371,19 @@ nm_setting_ovs_interface_class_init(NMSettingOvsInterfaceClass *klass)
|
|||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
obj_properties[PROP_TYPE] = g_param_spec_string(NM_SETTING_OVS_INTERFACE_TYPE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_OVS_INTERFACE_TYPE,
|
||||
PROP_TYPE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingOvsInterface,
|
||||
type);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_INTERFACE, NULL, NULL, 0);
|
||||
_nm_setting_class_commit(setting_class,
|
||||
NM_META_SETTING_TYPE_OVS_INTERFACE,
|
||||
NULL,
|
||||
properties_override,
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,39 +93,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PEER:
|
||||
g_value_set_string(value, self->peer);
|
||||
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)
|
||||
{
|
||||
NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PEER:
|
||||
g_free(self->peer);
|
||||
self->peer = g_value_dup_string(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_ovs_patch_init(NMSettingOvsPatch *self)
|
||||
{}
|
||||
|
|
@ -145,25 +112,15 @@ nm_setting_ovs_patch_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_OVS_PATCH, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingOvsPatch *self = NM_SETTING_OVS_PATCH(object);
|
||||
|
||||
g_free(self->peer);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_ovs_patch_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS(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();
|
||||
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -175,14 +132,19 @@ nm_setting_ovs_patch_class_init(NMSettingOvsPatchClass *klass)
|
|||
*
|
||||
* Since: 1.10
|
||||
**/
|
||||
obj_properties[PROP_PEER] = g_param_spec_string(NM_SETTING_OVS_PATCH_PEER,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_OVS_PATCH_PEER,
|
||||
PROP_PEER,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingOvsPatch,
|
||||
peer);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_OVS_PATCH, NULL, NULL, 0);
|
||||
_nm_setting_class_commit(setting_class,
|
||||
NM_META_SETTING_TYPE_OVS_PATCH,
|
||||
NULL,
|
||||
properties_override,
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -140,12 +140,12 @@ typedef struct {
|
|||
char *dhcp_hostname;
|
||||
char *dhcp_iaid;
|
||||
gint64 route_metric;
|
||||
guint dhcp_hostname_flags;
|
||||
int dns_priority;
|
||||
int dad_timeout;
|
||||
int dhcp_timeout;
|
||||
int required_timeout;
|
||||
gint32 required_timeout;
|
||||
gint32 dad_timeout;
|
||||
gint32 dhcp_timeout;
|
||||
gint32 dns_priority;
|
||||
guint32 route_table;
|
||||
guint32 dhcp_hostname_flags;
|
||||
bool ignore_auto_routes;
|
||||
bool ignore_auto_dns;
|
||||
bool dhcp_send_hostname;
|
||||
|
|
@ -270,12 +270,10 @@ extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_interfac
|
|||
extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_i;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u;
|
||||
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_i;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_plain_u;
|
||||
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int32;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_string;
|
||||
extern const NMSettInfoPropertType nm_sett_info_propert_type_direct_bytes;
|
||||
|
|
@ -585,6 +583,52 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _nm_setting_property_define_direct_int64(properties_override, \
|
||||
obj_properties, \
|
||||
prop_name, \
|
||||
prop_id, \
|
||||
min_value, \
|
||||
max_value, \
|
||||
default_value, \
|
||||
param_flags, \
|
||||
private_struct_type, \
|
||||
private_struct_field, \
|
||||
... /* extra NMSettInfoProperty fields */) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
GParamSpec *_param_spec; \
|
||||
\
|
||||
G_STATIC_ASSERT( \
|
||||
!NM_FLAGS_ANY((param_flags), \
|
||||
~(NM_SETTING_PARAM_FUZZY_IGNORE | NM_SETTING_PARAM_INFERRABLE))); \
|
||||
G_STATIC_ASSERT((min_value) >= G_MININT64); \
|
||||
G_STATIC_ASSERT((min_value) <= (default_value)); \
|
||||
G_STATIC_ASSERT((default_value) <= (max_value)); \
|
||||
G_STATIC_ASSERT((max_value) <= G_MAXINT64); \
|
||||
\
|
||||
_param_spec = \
|
||||
g_param_spec_int64("" prop_name "", \
|
||||
"", \
|
||||
"", \
|
||||
(min_value), \
|
||||
(max_value), \
|
||||
(default_value), \
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | (param_flags)); \
|
||||
\
|
||||
(obj_properties)[(prop_id)] = _param_spec; \
|
||||
\
|
||||
_nm_properties_override_gobj( \
|
||||
(properties_override), \
|
||||
_param_spec, \
|
||||
&nm_sett_info_propert_type_direct_int64, \
|
||||
.direct_offset = \
|
||||
NM_STRUCT_OFFSET_ENSURE_TYPE(gint64, private_struct_type, private_struct_field), \
|
||||
__VA_ARGS__); \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define _nm_setting_property_define_direct_uint64(properties_override, \
|
||||
obj_properties, \
|
||||
prop_name, \
|
||||
|
|
@ -646,7 +690,7 @@ _nm_properties_override(GArray *properties_override, const NMSettInfoProperty *p
|
|||
\
|
||||
G_STATIC_ASSERT(!NM_FLAGS_ANY((param_flags), \
|
||||
~(NM_SETTING_PARAM_SECRET | NM_SETTING_PARAM_FUZZY_IGNORE \
|
||||
| NM_SETTING_PARAM_INFERRABLE \
|
||||
| NM_SETTING_PARAM_INFERRABLE | NM_SETTING_PARAM_REQUIRED \
|
||||
| NM_SETTING_PARAM_REAPPLY_IMMEDIATELY))); \
|
||||
\
|
||||
nm_assert(_property_type); \
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingSriov, PROP_TOTAL_VFS, PROP_VFS, PROP_AUTO
|
|||
struct _NMSettingSriov {
|
||||
NMSetting parent;
|
||||
GPtrArray *vfs;
|
||||
guint total_vfs;
|
||||
int autoprobe_drivers;
|
||||
guint32 total_vfs;
|
||||
};
|
||||
|
||||
struct _NMSettingSriovClass {
|
||||
|
|
@ -1138,9 +1138,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingSriov *self = NM_SETTING_SRIOV(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TOTAL_VFS:
|
||||
g_value_set_uint(value, self->total_vfs);
|
||||
break;
|
||||
case PROP_VFS:
|
||||
g_value_take_boxed(value,
|
||||
_nm_utils_copy_array(self->vfs,
|
||||
|
|
@ -1159,9 +1156,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
NMSettingSriov *self = NM_SETTING_SRIOV(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_TOTAL_VFS:
|
||||
self->total_vfs = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_VFS:
|
||||
g_ptr_array_unref(self->vfs);
|
||||
self->vfs = _nm_utils_copy_array(g_value_get_boxed(value),
|
||||
|
|
@ -1240,14 +1234,16 @@ nm_setting_sriov_class_init(NMSettingSriovClass *klass)
|
|||
* example: SRIOV_TOTAL_VFS=16
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_TOTAL_VFS] = g_param_spec_uint(
|
||||
NM_SETTING_SRIOV_TOTAL_VFS,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_SRIOV_TOTAL_VFS,
|
||||
PROP_TOTAL_VFS,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingSriov,
|
||||
total_vfs);
|
||||
|
||||
/**
|
||||
* NMSettingSriov:vfs: (type GPtrArray(NMSriovVF))
|
||||
|
|
|
|||
|
|
@ -576,5 +576,5 @@ nm_setting_user_class_init(NMSettingUserClass *klass)
|
|||
NM_META_SETTING_TYPE_USER,
|
||||
NULL,
|
||||
properties_override,
|
||||
G_STRUCT_OFFSET(NMSettingUser, _priv));
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,7 @@ const char *
|
|||
nm_setting_veth_get_peer(NMSettingVeth *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VETH(setting), NULL);
|
||||
|
||||
return NM_SETTING_VETH_GET_PRIVATE(setting)->peer;
|
||||
}
|
||||
|
||||
|
|
@ -100,35 +101,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingVeth *setting = NM_SETTING_VETH(object);
|
||||
NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PEER:
|
||||
g_value_set_string(value, priv->peer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingVeth *setting = NM_SETTING_VETH(object);
|
||||
NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PEER:
|
||||
g_free(priv->peer);
|
||||
priv->peer = g_value_dup_string(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_veth_init(NMSettingVeth *setting)
|
||||
{}
|
||||
|
|
@ -148,28 +120,15 @@ nm_setting_veth_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_VETH, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingVeth *setting = NM_SETTING_VETH(object);
|
||||
NMSettingVethPrivate *priv = NM_SETTING_VETH_GET_PRIVATE(setting);
|
||||
|
||||
g_free(priv->peer);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_veth_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_veth_class_init(NMSettingVethClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS(klass);
|
||||
NMSettingClass *setting_class = NM_SETTING_CLASS(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();
|
||||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingVethPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -181,14 +140,19 @@ nm_setting_veth_class_init(NMSettingVethClass *klass)
|
|||
*
|
||||
* Since: 1.30
|
||||
**/
|
||||
obj_properties[PROP_PEER] = g_param_spec_string(NM_SETTING_VETH_PEER,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VETH_PEER,
|
||||
PROP_PEER,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVeth,
|
||||
_priv.peer);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
_nm_setting_class_commit(setting_class, NM_META_SETTING_TYPE_VETH, NULL, NULL, 0);
|
||||
_nm_setting_class_commit(setting_class,
|
||||
NM_META_SETTING_TYPE_VETH,
|
||||
NULL,
|
||||
properties_override,
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ const char *
|
|||
nm_setting_vlan_get_parent(NMSettingVlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VLAN(setting), NULL);
|
||||
|
||||
return NM_SETTING_VLAN_GET_PRIVATE(setting)->parent;
|
||||
}
|
||||
|
||||
|
|
@ -736,9 +737,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, priv->parent);
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
g_value_set_flags(value, priv->flags);
|
||||
break;
|
||||
|
|
@ -761,10 +759,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_FLAGS:
|
||||
priv->flags = g_value_get_flags(value);
|
||||
break;
|
||||
|
|
@ -813,7 +807,6 @@ finalize(GObject *object)
|
|||
NMSettingVlan *setting = NM_SETTING_VLAN(object);
|
||||
NMSettingVlanPrivate *priv = NM_SETTING_VLAN_GET_PRIVATE(setting);
|
||||
|
||||
g_free(priv->parent);
|
||||
g_slist_free_full(priv->ingress_priority_map, g_free);
|
||||
g_slist_free_full(priv->egress_priority_map, g_free);
|
||||
|
||||
|
|
@ -849,12 +842,13 @@ nm_setting_vlan_class_init(NMSettingVlanClass *klass)
|
|||
* description: Parent interface of the VLAN.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_PARENT] = g_param_spec_string(
|
||||
NM_SETTING_VLAN_PARENT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VLAN_PARENT,
|
||||
PROP_PARENT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVlanPrivate,
|
||||
parent);
|
||||
|
||||
/**
|
||||
* NMSettingVlan:id:
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ typedef struct {
|
|||
*/
|
||||
GHashTable *secrets;
|
||||
|
||||
/* Timeout for the VPN service to establish the connection */
|
||||
guint32 timeout;
|
||||
|
||||
/* Whether the VPN stays up across link changes, until the user
|
||||
|
|
@ -970,26 +969,14 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE_TYPE:
|
||||
g_value_set_string(value, nm_setting_vpn_get_service_type(setting));
|
||||
break;
|
||||
case PROP_USER_NAME:
|
||||
g_value_set_string(value, nm_setting_vpn_get_user_name(setting));
|
||||
break;
|
||||
case PROP_PERSISTENT:
|
||||
g_value_set_boolean(value, priv->persistent);
|
||||
break;
|
||||
case PROP_DATA:
|
||||
g_value_take_boxed(value, _nm_utils_copy_strdict(priv->data));
|
||||
break;
|
||||
case PROP_SECRETS:
|
||||
g_value_take_boxed(value, _nm_utils_copy_strdict(priv->secrets));
|
||||
break;
|
||||
case PROP_TIMEOUT:
|
||||
g_value_set_uint(value, nm_setting_vpn_get_timeout(setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1000,17 +987,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE_TYPE:
|
||||
g_free(priv->service_type);
|
||||
priv->service_type = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_USER_NAME:
|
||||
g_free(priv->user_name);
|
||||
priv->user_name = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_PERSISTENT:
|
||||
priv->persistent = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_DATA:
|
||||
case PROP_SECRETS:
|
||||
{
|
||||
|
|
@ -1046,11 +1022,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
}
|
||||
} break;
|
||||
case PROP_TIMEOUT:
|
||||
priv->timeout = g_value_get_uint(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1079,12 +1052,8 @@ finalize(GObject *object)
|
|||
{
|
||||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->service_type);
|
||||
g_free(priv->user_name);
|
||||
if (priv->data)
|
||||
g_hash_table_unref(priv->data);
|
||||
if (priv->secrets)
|
||||
g_hash_table_unref(priv->secrets);
|
||||
nm_g_hash_table_unref(priv->data);
|
||||
nm_g_hash_table_unref(priv->secrets);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_vpn_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
@ -1118,12 +1087,13 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass)
|
|||
* its network. i.e. org.freedesktop.NetworkManager.vpnc for the vpnc
|
||||
* plugin.
|
||||
**/
|
||||
obj_properties[PROP_SERVICE_TYPE] =
|
||||
g_param_spec_string(NM_SETTING_VPN_SERVICE_TYPE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VPN_SERVICE_TYPE,
|
||||
PROP_SERVICE_TYPE,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingVpnPrivate,
|
||||
service_type);
|
||||
|
||||
/**
|
||||
* NMSettingVpn:user-name:
|
||||
|
|
@ -1135,12 +1105,13 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass)
|
|||
* will automatically supply the username of the user which requested the
|
||||
* VPN connection.
|
||||
**/
|
||||
obj_properties[PROP_USER_NAME] =
|
||||
g_param_spec_string(NM_SETTING_VPN_USER_NAME,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VPN_USER_NAME,
|
||||
PROP_USER_NAME,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingVpnPrivate,
|
||||
user_name);
|
||||
|
||||
/**
|
||||
* NMSettingVpn:persistent:
|
||||
|
|
@ -1221,13 +1192,16 @@ nm_setting_vpn_class_init(NMSettingVpnClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_TIMEOUT] = g_param_spec_uint(NM_SETTING_VPN_TIMEOUT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VPN_TIMEOUT,
|
||||
PROP_TIMEOUT,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingVpnPrivate,
|
||||
timeout);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,22 +42,22 @@ NM_GOBJECT_PROPERTIES_DEFINE_BASE(PROP_PARENT,
|
|||
PROP_L3_MISS, );
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
char *local;
|
||||
char *remote;
|
||||
guint id;
|
||||
guint source_port_min;
|
||||
guint source_port_max;
|
||||
guint destination_port;
|
||||
guint tos;
|
||||
guint ttl;
|
||||
guint ageing;
|
||||
guint limit;
|
||||
bool proxy;
|
||||
bool learning;
|
||||
bool rsc;
|
||||
bool l2_miss;
|
||||
bool l3_miss;
|
||||
char *parent;
|
||||
char *local;
|
||||
char *remote;
|
||||
guint32 id;
|
||||
guint32 source_port_min;
|
||||
guint32 source_port_max;
|
||||
guint32 destination_port;
|
||||
guint32 tos;
|
||||
guint32 ttl;
|
||||
guint32 ageing;
|
||||
guint32 limit;
|
||||
bool proxy;
|
||||
bool learning;
|
||||
bool rsc;
|
||||
bool l2_miss;
|
||||
bool l3_miss;
|
||||
} NMSettingVxlanPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -95,6 +95,7 @@ const char *
|
|||
nm_setting_vxlan_get_parent(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->parent;
|
||||
}
|
||||
|
||||
|
|
@ -110,6 +111,7 @@ guint
|
|||
nm_setting_vxlan_get_id(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->id;
|
||||
}
|
||||
|
||||
|
|
@ -125,6 +127,7 @@ const char *
|
|||
nm_setting_vxlan_get_local(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->local;
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +143,7 @@ const char *
|
|||
nm_setting_vxlan_get_remote(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), NULL);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->remote;
|
||||
}
|
||||
|
||||
|
|
@ -155,6 +159,7 @@ guint
|
|||
nm_setting_vxlan_get_source_port_min(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->source_port_min;
|
||||
}
|
||||
|
||||
|
|
@ -170,6 +175,7 @@ guint
|
|||
nm_setting_vxlan_get_source_port_max(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->source_port_max;
|
||||
}
|
||||
|
||||
|
|
@ -185,6 +191,7 @@ guint
|
|||
nm_setting_vxlan_get_destination_port(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), DST_PORT_DEFAULT);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->destination_port;
|
||||
}
|
||||
|
||||
|
|
@ -215,6 +222,7 @@ guint
|
|||
nm_setting_vxlan_get_ageing(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->ageing;
|
||||
}
|
||||
|
||||
|
|
@ -230,6 +238,7 @@ guint
|
|||
nm_setting_vxlan_get_limit(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->limit;
|
||||
}
|
||||
|
||||
|
|
@ -245,6 +254,7 @@ guint
|
|||
nm_setting_vxlan_get_tos(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->tos;
|
||||
}
|
||||
|
||||
|
|
@ -260,6 +270,7 @@ guint
|
|||
nm_setting_vxlan_get_ttl(NMSettingVxlan *setting)
|
||||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_VXLAN(setting), 0);
|
||||
|
||||
return NM_SETTING_VXLAN_GET_PRIVATE(setting)->ttl;
|
||||
}
|
||||
|
||||
|
|
@ -391,152 +402,9 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
_addrstr_set(char **dst, const char *src)
|
||||
{
|
||||
gs_free char *old = NULL;
|
||||
|
||||
old = *dst;
|
||||
if (!src)
|
||||
*dst = NULL;
|
||||
else if (!nm_utils_parse_inaddr(AF_UNSPEC, src, dst))
|
||||
*dst = g_strdup(src);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingVxlan *setting = NM_SETTING_VXLAN(object);
|
||||
NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_value_set_string(value, priv->parent);
|
||||
break;
|
||||
case PROP_ID:
|
||||
g_value_set_uint(value, priv->id);
|
||||
break;
|
||||
case PROP_LOCAL:
|
||||
g_value_set_string(value, priv->local);
|
||||
break;
|
||||
case PROP_REMOTE:
|
||||
g_value_set_string(value, priv->remote);
|
||||
break;
|
||||
case PROP_SOURCE_PORT_MIN:
|
||||
g_value_set_uint(value, priv->source_port_min);
|
||||
break;
|
||||
case PROP_SOURCE_PORT_MAX:
|
||||
g_value_set_uint(value, priv->source_port_max);
|
||||
break;
|
||||
case PROP_DESTINATION_PORT:
|
||||
g_value_set_uint(value, priv->destination_port);
|
||||
break;
|
||||
case PROP_TOS:
|
||||
g_value_set_uint(value, priv->tos);
|
||||
break;
|
||||
case PROP_AGEING:
|
||||
g_value_set_uint(value, priv->ageing);
|
||||
break;
|
||||
case PROP_LIMIT:
|
||||
g_value_set_uint(value, priv->limit);
|
||||
break;
|
||||
case PROP_PROXY:
|
||||
g_value_set_boolean(value, priv->proxy);
|
||||
break;
|
||||
case PROP_TTL:
|
||||
g_value_set_uint(value, priv->ttl);
|
||||
break;
|
||||
case PROP_LEARNING:
|
||||
g_value_set_boolean(value, priv->learning);
|
||||
break;
|
||||
case PROP_RSC:
|
||||
g_value_set_boolean(value, priv->rsc);
|
||||
break;
|
||||
case PROP_L2_MISS:
|
||||
g_value_set_boolean(value, priv->l2_miss);
|
||||
break;
|
||||
case PROP_L3_MISS:
|
||||
g_value_set_boolean(value, priv->l3_miss);
|
||||
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)
|
||||
{
|
||||
NMSettingVxlan *setting = NM_SETTING_VXLAN(object);
|
||||
NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PARENT:
|
||||
g_free(priv->parent);
|
||||
priv->parent = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_ID:
|
||||
priv->id = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_LOCAL:
|
||||
_addrstr_set(&priv->local, g_value_get_string(value));
|
||||
break;
|
||||
case PROP_REMOTE:
|
||||
_addrstr_set(&priv->remote, g_value_get_string(value));
|
||||
break;
|
||||
case PROP_SOURCE_PORT_MIN:
|
||||
priv->source_port_min = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_SOURCE_PORT_MAX:
|
||||
priv->source_port_max = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_DESTINATION_PORT:
|
||||
priv->destination_port = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_TOS:
|
||||
priv->tos = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_AGEING:
|
||||
priv->ageing = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_LIMIT:
|
||||
priv->limit = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_PROXY:
|
||||
priv->proxy = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_TTL:
|
||||
priv->ttl = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_LEARNING:
|
||||
priv->learning = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_RSC:
|
||||
priv->rsc = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_L2_MISS:
|
||||
priv->l2_miss = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_L3_MISS:
|
||||
priv->l3_miss = g_value_get_boolean(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_vxlan_init(NMSettingVxlan *self)
|
||||
{
|
||||
NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(self);
|
||||
|
||||
priv->destination_port = DST_PORT_DEFAULT;
|
||||
priv->ageing = 300;
|
||||
}
|
||||
{}
|
||||
|
||||
/**
|
||||
* nm_setting_vxlan_new:
|
||||
|
|
@ -553,19 +421,6 @@ nm_setting_vxlan_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_VXLAN, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingVxlan *setting = NM_SETTING_VXLAN(object);
|
||||
NMSettingVxlanPrivate *priv = NM_SETTING_VXLAN_GET_PRIVATE(setting);
|
||||
|
||||
g_free(priv->parent);
|
||||
g_free(priv->local);
|
||||
g_free(priv->remote);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_vxlan_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
||||
{
|
||||
|
|
@ -575,9 +430,8 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingVxlanPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -588,12 +442,13 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_PARENT] = g_param_spec_string(
|
||||
NM_SETTING_VXLAN_PARENT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_PARENT,
|
||||
PROP_PARENT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
parent);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:id:
|
||||
|
|
@ -603,14 +458,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_ID] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_ID,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
(1 << 24) - 1,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_ID,
|
||||
PROP_ID,
|
||||
0,
|
||||
(1 << 24) - 1,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
id);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:local:
|
||||
|
|
@ -619,12 +476,15 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_LOCAL] = g_param_spec_string(NM_SETTING_VXLAN_LOCAL,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_LOCAL,
|
||||
PROP_LOCAL,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
local,
|
||||
.direct_set_string_ip_address_addr_family =
|
||||
AF_UNSPEC + 1);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:remote:
|
||||
|
|
@ -635,12 +495,15 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_REMOTE] = g_param_spec_string(
|
||||
NM_SETTING_VXLAN_REMOTE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_REMOTE,
|
||||
PROP_REMOTE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
remote,
|
||||
.direct_set_string_ip_address_addr_family =
|
||||
AF_UNSPEC + 1);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:source-port-min:
|
||||
|
|
@ -650,14 +513,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_SOURCE_PORT_MIN] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_SOURCE_PORT_MIN,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_SOURCE_PORT_MIN,
|
||||
PROP_SOURCE_PORT_MIN,
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
source_port_min);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:source-port-max:
|
||||
|
|
@ -667,14 +532,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_SOURCE_PORT_MAX] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_SOURCE_PORT_MAX,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_SOURCE_PORT_MAX,
|
||||
PROP_SOURCE_PORT_MAX,
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
source_port_max);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:destination-port:
|
||||
|
|
@ -684,14 +551,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_DESTINATION_PORT] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_DESTINATION_PORT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
DST_PORT_DEFAULT,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_DESTINATION_PORT,
|
||||
PROP_DESTINATION_PORT,
|
||||
0,
|
||||
G_MAXUINT16,
|
||||
DST_PORT_DEFAULT,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
destination_port);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:ageing:
|
||||
|
|
@ -700,14 +569,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_AGEING] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_AGEING,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
300,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_AGEING,
|
||||
PROP_AGEING,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
300,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
ageing);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:limit:
|
||||
|
|
@ -717,14 +588,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_LIMIT] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_LIMIT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_LIMIT,
|
||||
PROP_LIMIT,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
limit);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:tos:
|
||||
|
|
@ -733,14 +606,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_TOS] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_TOS,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_TOS,
|
||||
PROP_TOS,
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
tos);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:ttl:
|
||||
|
|
@ -749,14 +624,16 @@ nm_setting_vxlan_class_init(NMSettingVxlanClass *klass)
|
|||
*
|
||||
* Since: 1.2
|
||||
**/
|
||||
obj_properties[PROP_TTL] =
|
||||
g_param_spec_uint(NM_SETTING_VXLAN_TTL,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_VXLAN_TTL,
|
||||
PROP_TTL,
|
||||
0,
|
||||
255,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingVxlanPrivate,
|
||||
ttl);
|
||||
|
||||
/**
|
||||
* NMSettingVxlan:proxy:
|
||||
|
|
|
|||
|
|
@ -101,23 +101,12 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
{
|
||||
NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(setting);
|
||||
|
||||
if (!priv->network_name) {
|
||||
if (nm_str_is_empty(priv->network_name)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_MISSING_PROPERTY,
|
||||
_("property is missing"));
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_WIMAX_SETTING_NAME,
|
||||
NM_SETTING_WIMAX_NETWORK_NAME);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!strlen(priv->network_name)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("property is empty"));
|
||||
!priv->network_name ? _("property is missing")
|
||||
: _("property is empty"));
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_WIMAX_SETTING_NAME,
|
||||
|
|
@ -142,47 +131,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWimax *setting = NM_SETTING_WIMAX(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_NETWORK_NAME:
|
||||
g_value_set_string(value, nm_setting_wimax_get_network_name(setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_string(value, nm_setting_wimax_get_mac_address(setting));
|
||||
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)
|
||||
{
|
||||
NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_NETWORK_NAME:
|
||||
g_free(priv->network_name);
|
||||
priv->network_name = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_free(priv->mac_address);
|
||||
priv->mac_address =
|
||||
_nm_utils_hwaddr_canonical_or_invalid(g_value_get_string(value), ETH_ALEN);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
nm_setting_wimax_init(NMSettingWimax *setting)
|
||||
{}
|
||||
|
|
@ -202,16 +150,6 @@ nm_setting_wimax_new(void)
|
|||
return g_object_new(NM_TYPE_SETTING_WIMAX, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize(GObject *object)
|
||||
{
|
||||
NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->network_name);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_wimax_parent_class)->finalize(object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_setting_wimax_class_init(NMSettingWimaxClass *klass)
|
||||
{
|
||||
|
|
@ -221,9 +159,8 @@ nm_setting_wimax_class_init(NMSettingWimaxClass *klass)
|
|||
|
||||
g_type_class_add_private(klass, sizeof(NMSettingWimaxPrivate));
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->finalize = finalize;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
||||
|
|
@ -235,12 +172,13 @@ nm_setting_wimax_class_init(NMSettingWimaxClass *klass)
|
|||
*
|
||||
* Deprecated: 1.2: WiMAX is no longer supported.
|
||||
**/
|
||||
obj_properties[PROP_NETWORK_NAME] =
|
||||
g_param_spec_string(NM_SETTING_WIMAX_NETWORK_NAME,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIMAX_NETWORK_NAME,
|
||||
PROP_NETWORK_NAME,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWimaxPrivate,
|
||||
network_name);
|
||||
|
||||
/**
|
||||
* NMSettingWimax:mac-address:
|
||||
|
|
|
|||
|
|
@ -53,20 +53,20 @@ typedef struct {
|
|||
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;
|
||||
int accept_all_mac_addresses;
|
||||
NMSettingWiredWakeOnLan wol;
|
||||
guint32 speed;
|
||||
guint32 mtu;
|
||||
bool auto_negotiate;
|
||||
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;
|
||||
int accept_all_mac_addresses;
|
||||
guint32 wake_on_lan;
|
||||
guint32 speed;
|
||||
guint32 mtu;
|
||||
bool auto_negotiate;
|
||||
} NMSettingWiredPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -731,7 +731,7 @@ 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);
|
||||
|
||||
return NM_SETTING_WIRED_GET_PRIVATE(setting)->wol;
|
||||
return NM_SETTING_WIRED_GET_PRIVATE(setting)->wake_on_lan;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -919,8 +919,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (NM_FLAGS_ANY(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
||||
&& !nm_utils_is_power_of_two(priv->wol)) {
|
||||
if (NM_FLAGS_ANY(priv->wake_on_lan, NM_SETTING_WIRED_WAKE_ON_LAN_EXCLUSIVE_FLAGS)
|
||||
&& !nm_utils_is_power_of_two(priv->wake_on_lan)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -932,7 +932,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->wol_password && !NM_FLAGS_HAS(priv->wol, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) {
|
||||
if (priv->wol_password
|
||||
&& !NM_FLAGS_HAS(priv->wake_on_lan, NM_SETTING_WIRED_WAKE_ON_LAN_MAGIC)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1002,39 +1003,15 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
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++) {
|
||||
|
|
@ -1044,12 +1021,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
}
|
||||
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:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1064,34 +1035,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
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);
|
||||
|
|
@ -1104,18 +1052,11 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
|
@ -1178,13 +1119,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
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:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1201,8 +1135,6 @@ nm_setting_wired_init(NMSettingWired *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);
|
||||
|
||||
priv->wol = NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1227,9 +1159,7 @@ finalize(GObject *object)
|
|||
|
||||
g_free(priv->cloned_mac_address);
|
||||
g_array_unref(priv->mac_address_blacklist);
|
||||
|
||||
if (priv->s390_subchannels)
|
||||
g_strfreev(priv->s390_subchannels);
|
||||
g_strfreev(priv->s390_subchannels);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_wired_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
@ -1295,13 +1225,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass)
|
|||
* 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);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRED_SPEED,
|
||||
PROP_SPEED,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWiredPrivate,
|
||||
speed);
|
||||
|
||||
/**
|
||||
* NMSettingWired:duplex:
|
||||
|
|
@ -1559,14 +1492,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass)
|
|||
* 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);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRED_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWiredPrivate,
|
||||
mtu);
|
||||
|
||||
/**
|
||||
* NMSettingWired:s390-subchannels:
|
||||
|
|
@ -1667,14 +1602,16 @@ nm_setting_wired_class_init(NMSettingWiredClass *klass)
|
|||
* in the ethtool manual page.
|
||||
* ---end---
|
||||
*/
|
||||
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);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN,
|
||||
PROP_WAKE_ON_LAN,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRED_WAKE_ON_LAN_DEFAULT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWiredPrivate,
|
||||
wake_on_lan);
|
||||
|
||||
/**
|
||||
* NMSettingWired:wake-on-lan-password:
|
||||
|
|
|
|||
|
|
@ -901,7 +901,7 @@ typedef struct {
|
|||
int ip6_auto_default_route;
|
||||
guint32 fwmark;
|
||||
guint32 mtu;
|
||||
guint16 listen_port;
|
||||
guint32 listen_port;
|
||||
bool peer_routes;
|
||||
bool private_key_valid : 1;
|
||||
} NMSettingWireGuardPrivate;
|
||||
|
|
@ -1771,7 +1771,7 @@ verify_secrets(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting);
|
||||
guint i;
|
||||
|
||||
if (priv->private_key && !priv->private_key_valid) {
|
||||
if (!priv->private_key_valid) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1806,7 +1806,7 @@ need_secrets(NMSetting *setting)
|
|||
GPtrArray *secrets = NULL;
|
||||
guint i;
|
||||
|
||||
if (!priv->private_key || !priv->private_key_valid) {
|
||||
if (!priv->private_key_valid) {
|
||||
secrets = g_ptr_array_new_full(1, g_free);
|
||||
g_ptr_array_add(secrets, g_strdup(NM_SETTING_WIREGUARD_PRIVATE_KEY));
|
||||
}
|
||||
|
|
@ -2258,71 +2258,35 @@ for_each_secret(NMSetting *setting,
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
||||
static gboolean
|
||||
_set_string_fcn_public_key(const NMSettInfoSetting *sett_info,
|
||||
const NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
const char *str)
|
||||
{
|
||||
NMSettingWireGuard *setting = NM_SETTING_WIREGUARD(object);
|
||||
NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting);
|
||||
NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(setting);
|
||||
gboolean valid;
|
||||
char *new = NULL;
|
||||
char *old;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FWMARK:
|
||||
g_value_set_uint(value, priv->fwmark);
|
||||
break;
|
||||
case PROP_LISTEN_PORT:
|
||||
g_value_set_uint(value, priv->listen_port);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint(value, priv->mtu);
|
||||
break;
|
||||
case PROP_PEER_ROUTES:
|
||||
g_value_set_boolean(value, priv->peer_routes);
|
||||
break;
|
||||
case PROP_PRIVATE_KEY:
|
||||
g_value_set_string(value, priv->private_key);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
if (str)
|
||||
valid = nm_utils_base64secret_normalize(str, NM_WIREGUARD_PUBLIC_KEY_LEN, &new);
|
||||
else
|
||||
valid = FALSE;
|
||||
|
||||
if (nm_streq0(new ?: str, priv->private_key)) {
|
||||
nm_assert(priv->private_key_valid == valid);
|
||||
nm_free_secret(new);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(object);
|
||||
const char *str;
|
||||
priv->private_key_valid = valid;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FWMARK:
|
||||
priv->fwmark = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_LISTEN_PORT:
|
||||
priv->listen_port = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_PEER_ROUTES:
|
||||
priv->peer_routes = g_value_get_boolean(value);
|
||||
break;
|
||||
case PROP_PRIVATE_KEY:
|
||||
nm_clear_pointer(&priv->private_key, nm_free_secret);
|
||||
str = g_value_get_string(value);
|
||||
if (str) {
|
||||
if (nm_utils_base64secret_normalize(str,
|
||||
NM_WIREGUARD_PUBLIC_KEY_LEN,
|
||||
&priv->private_key))
|
||||
priv->private_key_valid = TRUE;
|
||||
else {
|
||||
priv->private_key = g_strdup(str);
|
||||
priv->private_key_valid = FALSE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
}
|
||||
old = priv->private_key;
|
||||
priv->private_key = new ?: g_strdup(str);
|
||||
nm_free_secret(old);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -2356,8 +2320,6 @@ finalize(GObject *object)
|
|||
{
|
||||
NMSettingWireGuardPrivate *priv = NM_SETTING_WIREGUARD_GET_PRIVATE(object);
|
||||
|
||||
nm_free_secret(priv->private_key);
|
||||
|
||||
_peers_clear(priv);
|
||||
g_ptr_array_unref(priv->peers_arr);
|
||||
g_hash_table_unref(priv->peers_hash);
|
||||
|
|
@ -2372,8 +2334,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
NMSettingClass *setting_class = NM_SETTING_CLASS(klass);
|
||||
GArray *properties_override = _nm_sett_info_property_override_create_array();
|
||||
|
||||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = _nm_setting_property_get_property_direct;
|
||||
object_class->set_property = _nm_setting_property_set_property_direct;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
setting_class->verify = verify;
|
||||
|
|
@ -2395,12 +2357,15 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_PRIVATE_KEY] =
|
||||
g_param_spec_string(NM_SETTING_WIREGUARD_PRIVATE_KEY,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIREGUARD_PRIVATE_KEY,
|
||||
PROP_PRIVATE_KEY,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWireGuard,
|
||||
_priv.private_key,
|
||||
.direct_hook.set_string_fcn =
|
||||
_set_string_fcn_public_key);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:private-key-flags:
|
||||
|
|
@ -2414,8 +2379,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
obj_properties,
|
||||
NM_SETTING_WIREGUARD_PRIVATE_KEY_FLAGS,
|
||||
PROP_PRIVATE_KEY_FLAGS,
|
||||
NMSettingWireGuardPrivate,
|
||||
private_key_flags);
|
||||
NMSettingWireGuard,
|
||||
_priv.private_key_flags);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:fwmark:
|
||||
|
|
@ -2428,14 +2393,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_FWMARK] =
|
||||
g_param_spec_uint(NM_SETTING_WIREGUARD_FWMARK,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIREGUARD_FWMARK,
|
||||
PROP_FWMARK,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingWireGuard,
|
||||
_priv.fwmark);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:listen-port:
|
||||
|
|
@ -2445,14 +2412,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_LISTEN_PORT] =
|
||||
g_param_spec_uint(NM_SETTING_WIREGUARD_LISTEN_PORT,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
65535,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIREGUARD_LISTEN_PORT,
|
||||
PROP_LISTEN_PORT,
|
||||
0,
|
||||
65535,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingWireGuard,
|
||||
_priv.listen_port);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:peer-routes:
|
||||
|
|
@ -2477,8 +2446,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
PROP_PEER_ROUTES,
|
||||
TRUE,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingWireGuardPrivate,
|
||||
peer_routes);
|
||||
NMSettingWireGuard,
|
||||
_priv.peer_routes);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:mtu:
|
||||
|
|
@ -2492,14 +2461,16 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
*
|
||||
* Since: 1.16
|
||||
**/
|
||||
obj_properties[PROP_MTU] =
|
||||
g_param_spec_uint(NM_SETTING_WIREGUARD_MTU,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_INFERRABLE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIREGUARD_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_INFERRABLE,
|
||||
NMSettingWireGuard,
|
||||
_priv.mtu);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:ip4-auto-default-route:
|
||||
|
|
@ -2526,8 +2497,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
NM_SETTING_WIREGUARD_IP4_AUTO_DEFAULT_ROUTE,
|
||||
PROP_IP4_AUTO_DEFAULT_ROUTE,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWireGuardPrivate,
|
||||
ip4_auto_default_route);
|
||||
NMSettingWireGuard,
|
||||
_priv.ip4_auto_default_route);
|
||||
|
||||
/**
|
||||
* NMSettingWireGuard:ip6-auto-default-route:
|
||||
|
|
@ -2541,8 +2512,8 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
NM_SETTING_WIREGUARD_IP6_AUTO_DEFAULT_ROUTE,
|
||||
PROP_IP6_AUTO_DEFAULT_ROUTE,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWireGuardPrivate,
|
||||
ip6_auto_default_route);
|
||||
NMSettingWireGuard,
|
||||
_priv.ip6_auto_default_route);
|
||||
|
||||
/* ---dbus---
|
||||
* property: peers
|
||||
|
|
@ -2564,5 +2535,5 @@ nm_setting_wireguard_class_init(NMSettingWireGuardClass *klass)
|
|||
NM_META_SETTING_TYPE_WIREGUARD,
|
||||
NULL,
|
||||
properties_override,
|
||||
G_STRUCT_OFFSET(NMSettingWireGuard, _priv));
|
||||
0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,26 +62,26 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWirelessSecurity,
|
|||
PROP_FILS, );
|
||||
|
||||
typedef struct {
|
||||
GSList *proto; /* GSList of strings */
|
||||
GSList *pairwise; /* GSList of strings */
|
||||
GSList *group; /* GSList of strings */
|
||||
char *key_mgmt;
|
||||
char *auth_alg;
|
||||
char *leap_username;
|
||||
char *leap_password;
|
||||
char *wep_key0;
|
||||
char *wep_key1;
|
||||
char *wep_key2;
|
||||
char *wep_key3;
|
||||
char *psk;
|
||||
guint leap_password_flags;
|
||||
guint wep_key_flags;
|
||||
guint psk_flags;
|
||||
NMSettingWirelessSecurityPmf pmf;
|
||||
NMWepKeyType wep_key_type;
|
||||
NMSettingWirelessSecurityWpsMethod wps_method;
|
||||
NMSettingWirelessSecurityFils fils;
|
||||
guint32 wep_tx_keyidx;
|
||||
GSList *proto; /* GSList of strings */
|
||||
GSList *pairwise; /* GSList of strings */
|
||||
GSList *group; /* GSList of strings */
|
||||
char *key_mgmt;
|
||||
char *auth_alg;
|
||||
char *leap_username;
|
||||
char *leap_password;
|
||||
char *wep_key0;
|
||||
char *wep_key1;
|
||||
char *wep_key2;
|
||||
char *wep_key3;
|
||||
char *psk;
|
||||
guint leap_password_flags;
|
||||
guint wep_key_flags;
|
||||
guint psk_flags;
|
||||
NMWepKeyType wep_key_type;
|
||||
gint32 pmf;
|
||||
gint32 fils;
|
||||
guint32 wep_tx_keyidx;
|
||||
guint32 wps_method;
|
||||
} NMSettingWirelessSecurityPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -993,7 +993,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->leap_username && !strlen(priv->leap_username)) {
|
||||
if (priv->leap_username && nm_str_is_empty(priv->leap_username)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1005,19 +1005,6 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->wep_tx_keyidx > 3) {
|
||||
g_set_error(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
_("'%d' value is out of range <0-3>"),
|
||||
priv->wep_tx_keyidx);
|
||||
g_prefix_error(error,
|
||||
"%s.%s: ",
|
||||
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->wep_key_type > NM_WEP_KEY_TYPE_LAST) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
|
|
@ -1314,15 +1301,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_KEY_MGMT:
|
||||
g_value_set_string(value, priv->key_mgmt);
|
||||
break;
|
||||
case PROP_WEP_TX_KEYIDX:
|
||||
g_value_set_uint(value, priv->wep_tx_keyidx);
|
||||
break;
|
||||
case PROP_AUTH_ALG:
|
||||
g_value_set_string(value, priv->auth_alg);
|
||||
break;
|
||||
case PROP_PROTO:
|
||||
g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->proto, TRUE));
|
||||
break;
|
||||
|
|
@ -1332,39 +1310,9 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
case PROP_GROUP:
|
||||
g_value_take_boxed(value, _nm_utils_slist_to_strv(priv->group, TRUE));
|
||||
break;
|
||||
case PROP_PMF:
|
||||
g_value_set_int(value, nm_setting_wireless_security_get_pmf(setting));
|
||||
break;
|
||||
case PROP_LEAP_USERNAME:
|
||||
g_value_set_string(value, priv->leap_username);
|
||||
break;
|
||||
case PROP_WEP_KEY0:
|
||||
g_value_set_string(value, priv->wep_key0);
|
||||
break;
|
||||
case PROP_WEP_KEY1:
|
||||
g_value_set_string(value, priv->wep_key1);
|
||||
break;
|
||||
case PROP_WEP_KEY2:
|
||||
g_value_set_string(value, priv->wep_key2);
|
||||
break;
|
||||
case PROP_WEP_KEY3:
|
||||
g_value_set_string(value, priv->wep_key3);
|
||||
break;
|
||||
case PROP_PSK:
|
||||
g_value_set_string(value, priv->psk);
|
||||
break;
|
||||
case PROP_LEAP_PASSWORD:
|
||||
g_value_set_string(value, priv->leap_password);
|
||||
break;
|
||||
case PROP_WEP_KEY_TYPE:
|
||||
g_value_set_enum(value, priv->wep_key_type);
|
||||
break;
|
||||
case PROP_WPS_METHOD:
|
||||
g_value_set_uint(value, priv->wps_method);
|
||||
break;
|
||||
case PROP_FILS:
|
||||
g_value_set_int(value, nm_setting_wireless_security_get_fils(setting));
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1376,22 +1324,8 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
{
|
||||
NMSettingWirelessSecurity *setting = NM_SETTING_WIRELESS_SECURITY(object);
|
||||
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(setting);
|
||||
const char *str;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_KEY_MGMT:
|
||||
g_free(priv->key_mgmt);
|
||||
str = g_value_get_string(value);
|
||||
priv->key_mgmt = str ? g_ascii_strdown(str, -1) : NULL;
|
||||
break;
|
||||
case PROP_WEP_TX_KEYIDX:
|
||||
priv->wep_tx_keyidx = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_AUTH_ALG:
|
||||
g_free(priv->auth_alg);
|
||||
str = g_value_get_string(value);
|
||||
priv->auth_alg = str ? g_ascii_strdown(str, -1) : NULL;
|
||||
break;
|
||||
case PROP_PROTO:
|
||||
g_slist_free_full(priv->proto, g_free);
|
||||
priv->proto = nm_strv_to_gslist(g_value_get_boxed(value), TRUE);
|
||||
|
|
@ -1404,46 +1338,9 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
g_slist_free_full(priv->group, g_free);
|
||||
priv->group = nm_strv_to_gslist(g_value_get_boxed(value), TRUE);
|
||||
break;
|
||||
case PROP_PMF:
|
||||
priv->pmf = g_value_get_int(value);
|
||||
break;
|
||||
case PROP_LEAP_USERNAME:
|
||||
g_free(priv->leap_username);
|
||||
priv->leap_username = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_WEP_KEY0:
|
||||
nm_free_secret(priv->wep_key0);
|
||||
priv->wep_key0 = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_WEP_KEY1:
|
||||
nm_free_secret(priv->wep_key1);
|
||||
priv->wep_key1 = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_WEP_KEY2:
|
||||
nm_free_secret(priv->wep_key2);
|
||||
priv->wep_key2 = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_WEP_KEY3:
|
||||
nm_free_secret(priv->wep_key3);
|
||||
priv->wep_key3 = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_PSK:
|
||||
nm_free_secret(priv->psk);
|
||||
priv->psk = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_LEAP_PASSWORD:
|
||||
nm_free_secret(priv->leap_password);
|
||||
priv->leap_password = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_WEP_KEY_TYPE:
|
||||
priv->wep_key_type = g_value_get_enum(value);
|
||||
break;
|
||||
case PROP_WPS_METHOD:
|
||||
priv->wps_method = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_FILS:
|
||||
priv->fils = g_value_get_int(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1457,8 +1354,6 @@ nm_setting_wireless_security_init(NMSettingWirelessSecurity *self)
|
|||
{
|
||||
nm_assert(NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self)->wep_key_type
|
||||
== NM_WEP_KEY_TYPE_UNKNOWN);
|
||||
nm_assert(NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self)->wps_method
|
||||
== NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1480,16 +1375,6 @@ finalize(GObject *object)
|
|||
NMSettingWirelessSecurity *self = NM_SETTING_WIRELESS_SECURITY(object);
|
||||
NMSettingWirelessSecurityPrivate *priv = NM_SETTING_WIRELESS_SECURITY_GET_PRIVATE(self);
|
||||
|
||||
g_free(priv->key_mgmt);
|
||||
g_free(priv->auth_alg);
|
||||
g_free(priv->leap_username);
|
||||
nm_free_secret(priv->wep_key0);
|
||||
nm_free_secret(priv->wep_key1);
|
||||
nm_free_secret(priv->wep_key2);
|
||||
nm_free_secret(priv->wep_key3);
|
||||
nm_free_secret(priv->psk);
|
||||
nm_free_secret(priv->leap_password);
|
||||
|
||||
g_slist_free_full(priv->proto, g_free);
|
||||
g_slist_free_full(priv->pairwise, g_free);
|
||||
g_slist_free_full(priv->group, g_free);
|
||||
|
|
@ -1534,12 +1419,14 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: Key management method.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_KEY_MGMT] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_KEY_MGMT,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_REQUIRED | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_KEY_MGMT,
|
||||
PROP_KEY_MGMT,
|
||||
NM_SETTING_PARAM_REQUIRED,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
key_mgmt,
|
||||
.direct_set_string_ascii_strdown = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-tx-keyidx:
|
||||
|
|
@ -1554,17 +1441,20 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* variable: DEFAULTKEY
|
||||
* values: 1, 2, 3, 4
|
||||
* default: 1
|
||||
* description: Index of active WEP key.
|
||||
* description: Index of active WEP key. Note that in ifcfg format the index starts counting
|
||||
* at 1, while NetworkManager API otherwise is zero based.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WEP_TX_KEYIDX] =
|
||||
g_param_spec_uint(NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX,
|
||||
PROP_WEP_TX_KEYIDX,
|
||||
0,
|
||||
3,
|
||||
0,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wep_tx_keyidx);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:auth-alg:
|
||||
|
|
@ -1582,11 +1472,14 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: Authentication algorithm for WEP.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_AUTH_ALG] = g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_AUTH_ALG,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_AUTH_ALG,
|
||||
PROP_AUTH_ALG,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
auth_alg,
|
||||
.direct_set_string_ascii_strdown = TRUE);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:proto:
|
||||
|
|
@ -1675,14 +1568,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* example: PMF=required
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_PMF] = g_param_spec_int(NM_SETTING_WIRELESS_SECURITY_PMF,
|
||||
"",
|
||||
"",
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_PMF,
|
||||
PROP_PMF,
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
pmf);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:leap-username:
|
||||
|
|
@ -1696,12 +1591,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: Login name for LEAP.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_LEAP_USERNAME] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME,
|
||||
PROP_LEAP_USERNAME,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
leap_username);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-key0:
|
||||
|
|
@ -1715,12 +1611,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: The first WEP key (used in most networks). See also DEFAULTKEY for key index.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WEP_KEY0] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY0,
|
||||
PROP_WEP_KEY0,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wep_key0);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-key1:
|
||||
|
|
@ -1734,12 +1631,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: WEP key with index 1. See also DEFAULTKEY for key index.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WEP_KEY1] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY1,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY1,
|
||||
PROP_WEP_KEY1,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wep_key1);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-key2:
|
||||
|
|
@ -1753,12 +1651,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: WEP key with index 2. See also DEFAULTKEY for key index.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WEP_KEY2] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY2,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY2,
|
||||
PROP_WEP_KEY2,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wep_key2);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-key3:
|
||||
|
|
@ -1772,12 +1671,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: WEP key with index 3. See also DEFAULTKEY for key index.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WEP_KEY3] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_WEP_KEY3,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WEP_KEY3,
|
||||
PROP_WEP_KEY3,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wep_key3);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:wep-key-flags:
|
||||
|
|
@ -1815,12 +1715,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* description: Pre-Shared-Key for WPA networks.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_PSK] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_PSK,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_PSK,
|
||||
PROP_PSK,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
psk);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:psk-flags:
|
||||
|
|
@ -1856,12 +1757,13 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* lookaside file, or it can be owned by a secret agent.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_LEAP_PASSWORD] =
|
||||
g_param_spec_string(NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_SECRET | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD,
|
||||
PROP_LEAP_PASSWORD,
|
||||
NM_SETTING_PARAM_SECRET,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
leap_password);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:leap-password-flags:
|
||||
|
|
@ -1942,14 +1844,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* example: WPS_METHOD=disabled, WPS_METHOD="pin pbc"
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_WPS_METHOD] = g_param_spec_uint(
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD,
|
||||
PROP_WPS_METHOD,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_SECURITY_WPS_METHOD_DEFAULT,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
wps_method);
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:fils:
|
||||
|
|
@ -1973,14 +1877,16 @@ nm_setting_wireless_security_class_init(NMSettingWirelessSecurityClass *klass)
|
|||
* example: FILS=required
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_FILS] = g_param_spec_int(NM_SETTING_WIRELESS_SECURITY_FILS,
|
||||
"",
|
||||
"",
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_int32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_SECURITY_FILS,
|
||||
PROP_FILS,
|
||||
G_MININT32,
|
||||
G_MAXINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessSecurityPrivate,
|
||||
fils);
|
||||
|
||||
g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,24 +46,24 @@ NM_GOBJECT_PROPERTIES_DEFINE(NMSettingWireless,
|
|||
PROP_AP_ISOLATION, );
|
||||
|
||||
typedef struct {
|
||||
GBytes *ssid;
|
||||
GArray *mac_address_blacklist;
|
||||
GPtrArray *seen_bssids;
|
||||
char *mode;
|
||||
char *band;
|
||||
char *bssid;
|
||||
char *device_mac_address;
|
||||
char *cloned_mac_address;
|
||||
char *generate_mac_address_mask;
|
||||
int ap_isolation;
|
||||
NMSettingMacRandomization mac_address_randomization;
|
||||
guint32 channel;
|
||||
guint32 rate;
|
||||
guint32 tx_power;
|
||||
guint32 mtu;
|
||||
guint32 powersave;
|
||||
guint32 wowl;
|
||||
bool hidden;
|
||||
GBytes *ssid;
|
||||
GArray *mac_address_blacklist;
|
||||
GPtrArray *seen_bssids;
|
||||
char *mode;
|
||||
char *band;
|
||||
char *bssid;
|
||||
char *device_mac_address;
|
||||
char *cloned_mac_address;
|
||||
char *generate_mac_address_mask;
|
||||
int ap_isolation;
|
||||
guint32 mac_address_randomization;
|
||||
guint32 channel;
|
||||
guint32 rate;
|
||||
guint32 tx_power;
|
||||
guint32 mtu;
|
||||
guint32 powersave;
|
||||
guint32 wake_on_wlan;
|
||||
bool hidden;
|
||||
} NMSettingWirelessPrivate;
|
||||
|
||||
/**
|
||||
|
|
@ -1035,8 +1035,8 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (NM_FLAGS_ANY(priv->wowl, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
|
||||
if (!nm_utils_is_power_of_two(priv->wowl)) {
|
||||
if (NM_FLAGS_ANY(priv->wake_on_wlan, NM_SETTING_WIRELESS_WAKE_ON_WLAN_EXCLUSIVE_FLAGS)) {
|
||||
if (!nm_utils_is_power_of_two(priv->wake_on_wlan)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1047,7 +1047,7 @@ verify(NMSetting *setting, NMConnection *connection, GError **error)
|
|||
NM_SETTING_WIRELESS_WAKE_ON_WLAN);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (NM_FLAGS_ANY(priv->wowl, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
|
||||
} else if (NM_FLAGS_ANY(priv->wake_on_wlan, ~NM_SETTING_WIRELESS_WAKE_ON_WLAN_ALL)) {
|
||||
g_set_error_literal(error,
|
||||
NM_CONNECTION_ERROR,
|
||||
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1148,7 +1148,7 @@ nm_setting_wireless_get_wake_on_wlan(NMSettingWireless *setting)
|
|||
{
|
||||
g_return_val_if_fail(NM_IS_SETTING_WIRELESS(setting), NM_SETTING_WIRELESS_WAKE_ON_WLAN_NONE);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->wowl;
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE(setting)->wake_on_wlan;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1166,33 +1166,12 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MODE:
|
||||
g_value_set_string(value, nm_setting_wireless_get_mode(setting));
|
||||
break;
|
||||
case PROP_BAND:
|
||||
g_value_set_string(value, nm_setting_wireless_get_band(setting));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_channel(setting));
|
||||
break;
|
||||
case PROP_RATE:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_rate(setting));
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_tx_power(setting));
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
g_value_set_string(value, nm_setting_wireless_get_cloned_mac_address(setting));
|
||||
break;
|
||||
case PROP_GENERATE_MAC_ADDRESS_MASK:
|
||||
g_value_set_string(value, nm_setting_wireless_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_wireless_get_mtu(setting));
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
g_value_take_boxed(
|
||||
value,
|
||||
|
|
@ -1200,15 +1179,6 @@ get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|||
? nm_strv_dup((char **) priv->seen_bssids->pdata, priv->seen_bssids->len, TRUE)
|
||||
: NULL);
|
||||
break;
|
||||
case PROP_POWERSAVE:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_powersave(setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_RANDOMIZATION:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_mac_address_randomization(setting));
|
||||
break;
|
||||
case PROP_WAKE_ON_WLAN:
|
||||
g_value_set_uint(value, nm_setting_wireless_get_wake_on_wlan(setting));
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_get_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1224,23 +1194,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
gboolean bool_val;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MODE:
|
||||
g_free(priv->mode);
|
||||
priv->mode = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_BAND:
|
||||
g_free(priv->band);
|
||||
priv->band = g_value_dup_string(value);
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
priv->channel = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_RATE:
|
||||
priv->rate = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
priv->tx_power = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
bool_val = !!priv->cloned_mac_address;
|
||||
g_free(priv->cloned_mac_address);
|
||||
|
|
@ -1255,10 +1208,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
}
|
||||
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);
|
||||
|
|
@ -1271,9 +1220,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
}
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
{
|
||||
gs_unref_ptrarray GPtrArray *arr_old = NULL;
|
||||
|
|
@ -1292,15 +1238,6 @@ set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *ps
|
|||
}
|
||||
break;
|
||||
}
|
||||
case PROP_POWERSAVE:
|
||||
priv->powersave = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_RANDOMIZATION:
|
||||
priv->mac_address_randomization = g_value_get_uint(value);
|
||||
break;
|
||||
case PROP_WAKE_ON_WLAN:
|
||||
priv->wowl = g_value_get_uint(value);
|
||||
break;
|
||||
default:
|
||||
_nm_setting_property_set_property_direct(object, prop_id, value, pspec);
|
||||
break;
|
||||
|
|
@ -1317,8 +1254,6 @@ nm_setting_wireless_init(NMSettingWireless *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);
|
||||
|
||||
priv->wowl = NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1339,13 +1274,9 @@ finalize(GObject *object)
|
|||
{
|
||||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE(object);
|
||||
|
||||
g_free(priv->mode);
|
||||
g_free(priv->band);
|
||||
|
||||
g_free(priv->cloned_mac_address);
|
||||
g_free(priv->generate_mac_address_mask);
|
||||
g_array_unref(priv->mac_address_blacklist);
|
||||
nm_clear_pointer(&priv->seen_bssids, g_ptr_array_unref);
|
||||
nm_g_ptr_array_unref(priv->seen_bssids);
|
||||
|
||||
G_OBJECT_CLASS(nm_setting_wireless_parent_class)->finalize(object);
|
||||
}
|
||||
|
|
@ -1404,11 +1335,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* description: Wi-Fi network mode.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MODE] = g_param_spec_string(NM_SETTING_WIRELESS_MODE,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_MODE,
|
||||
PROP_MODE,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
mode);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:band:
|
||||
|
|
@ -1429,11 +1362,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* example: BAND=bg
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_BAND] = g_param_spec_string(NM_SETTING_WIRELESS_BAND,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_BAND,
|
||||
PROP_BAND,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
band);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:channel:
|
||||
|
|
@ -1452,13 +1387,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* example: CHANNEL=6
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_CHANNEL] = g_param_spec_uint(NM_SETTING_WIRELESS_CHANNEL,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_CHANNEL,
|
||||
PROP_CHANNEL,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
channel);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:bssid:
|
||||
|
|
@ -1498,14 +1436,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* description: This property is not handled by ifcfg-rh plugin.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_RATE] = g_param_spec_uint(NM_SETTING_WIRELESS_RATE,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_RATE,
|
||||
PROP_RATE,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessPrivate,
|
||||
rate);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:tx-power:
|
||||
|
|
@ -1520,14 +1460,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* description: This property is not handled by ifcfg-rh plugin.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_TX_POWER] = g_param_spec_uint(
|
||||
NM_SETTING_WIRELESS_TX_POWER,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_TX_POWER,
|
||||
PROP_TX_POWER,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessPrivate,
|
||||
tx_power);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mac-address:
|
||||
|
|
@ -1674,12 +1616,13 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* cloned-mac-address.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_GENERATE_MAC_ADDRESS_MASK] = g_param_spec_string(
|
||||
NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK,
|
||||
"",
|
||||
"",
|
||||
NULL,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_string(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_GENERATE_MAC_ADDRESS_MASK,
|
||||
PROP_GENERATE_MAC_ADDRESS_MASK,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessPrivate,
|
||||
generate_mac_address_mask);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mac-address-blacklist:
|
||||
|
|
@ -1750,14 +1693,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* description: MTU of the wireless interface.
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MTU] = g_param_spec_uint(NM_SETTING_WIRELESS_MTU,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
G_PARAM_READWRITE | NM_SETTING_PARAM_FUZZY_IGNORE
|
||||
| G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_MTU,
|
||||
PROP_MTU,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
0,
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE,
|
||||
NMSettingWirelessPrivate,
|
||||
mtu);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:hidden:
|
||||
|
|
@ -1811,13 +1756,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* example: POWERSAVE=enable
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_POWERSAVE] = g_param_spec_uint(NM_SETTING_WIRELESS_POWERSAVE,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_POWERSAVE,
|
||||
PROP_POWERSAVE,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_POWERSAVE_DEFAULT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
powersave);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mac-address-randomization:
|
||||
|
|
@ -1840,14 +1788,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
* example: MAC_ADDRESS_RANDOMIZATION=always
|
||||
* ---end---
|
||||
*/
|
||||
obj_properties[PROP_MAC_ADDRESS_RANDOMIZATION] =
|
||||
g_param_spec_uint(NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_MAC_ADDRESS_RANDOMIZATION,
|
||||
PROP_MAC_ADDRESS_RANDOMIZATION,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_MAC_RANDOMIZATION_DEFAULT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
mac_address_randomization);
|
||||
|
||||
/* Compatibility for deprecated property */
|
||||
/* ---ifcfg-rh---
|
||||
|
|
@ -1888,14 +1838,16 @@ nm_setting_wireless_class_init(NMSettingWirelessClass *klass)
|
|||
*
|
||||
* Since: 1.12
|
||||
**/
|
||||
obj_properties[PROP_WAKE_ON_WLAN] =
|
||||
g_param_spec_uint(NM_SETTING_WIRELESS_WAKE_ON_WLAN,
|
||||
"",
|
||||
"",
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT,
|
||||
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
|
||||
_nm_setting_property_define_direct_uint32(properties_override,
|
||||
obj_properties,
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN,
|
||||
PROP_WAKE_ON_WLAN,
|
||||
0,
|
||||
G_MAXUINT32,
|
||||
NM_SETTING_WIRELESS_WAKE_ON_WLAN_DEFAULT,
|
||||
NM_SETTING_PARAM_NONE,
|
||||
NMSettingWirelessPrivate,
|
||||
wake_on_wlan);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:ap-isolation
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@
|
|||
|
||||
#include "nm-setting.h"
|
||||
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "libnm-core-intern/nm-core-internal.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "libnm-glib-aux/nm-ref-string.h"
|
||||
#include "libnm-glib-aux/nm-secret-utils.h"
|
||||
#include "nm-property-compare.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-utils.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting
|
||||
|
|
@ -375,35 +377,21 @@ _nm_setting_class_commit(NMSettingClass *setting_class,
|
|||
nm_assert(p->param_spec);
|
||||
|
||||
vtype = p->param_spec->value_type;
|
||||
if (vtype == G_TYPE_INT)
|
||||
p->property_type = &nm_sett_info_propert_type_plain_i;
|
||||
else if (vtype == G_TYPE_UINT)
|
||||
p->property_type = &nm_sett_info_propert_type_plain_u;
|
||||
else if (vtype == G_TYPE_INT64)
|
||||
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
|
||||
G_VARIANT_TYPE_INT64,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
|
||||
.from_dbus_is_full = TRUE);
|
||||
else if (vtype == G_TYPE_STRING) {
|
||||
nm_assert(nm_streq(p->name, NM_SETTING_NAME)
|
||||
== (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE)));
|
||||
if (!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE))
|
||||
p->property_type = &nm_sett_info_propert_type_setting_name;
|
||||
else {
|
||||
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
|
||||
G_VARIANT_TYPE_STRING,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
|
||||
.from_dbus_is_full = TRUE);
|
||||
}
|
||||
} else if (vtype == G_TYPE_DOUBLE)
|
||||
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
|
||||
G_VARIANT_TYPE_DOUBLE,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
|
||||
.from_dbus_is_full = TRUE);
|
||||
else if (vtype == G_TYPE_STRV)
|
||||
|
||||
if (vtype == G_TYPE_STRING) {
|
||||
/* The "name" property is a bit special because it's defined in the
|
||||
* parent class NMSetting. We set the property_type here, because
|
||||
* it's more convenient (albeit a bit ugly).
|
||||
*
|
||||
* FIXME: let _nm_sett_info_property_override_create_array() always add
|
||||
* the handling of the name property.*/
|
||||
nm_assert(nm_streq(p->name, NM_SETTING_NAME));
|
||||
nm_assert(!NM_FLAGS_HAS(p->param_spec->flags, G_PARAM_WRITABLE));
|
||||
p->property_type = &nm_sett_info_propert_type_setting_name;
|
||||
goto has_property_type;
|
||||
}
|
||||
|
||||
if (vtype == G_TYPE_STRV)
|
||||
p->property_type = NM_SETT_INFO_PROPERT_TYPE_GPROP(
|
||||
G_VARIANT_TYPE_STRING_ARRAY,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
|
|
@ -642,23 +630,64 @@ _nm_setting_use_legacy_property(NMSetting *setting,
|
|||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
_property_direct_set_string(const NMSettInfoProperty *property_info, char **dst, const char *src)
|
||||
_property_direct_set_string(const NMSettInfoSetting *sett_info,
|
||||
const NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
const char *src)
|
||||
{
|
||||
if (property_info->direct_set_string_ascii_strdown)
|
||||
return nm_strdup_reset_take(dst, src ? g_ascii_strdown(src, -1) : NULL);
|
||||
char **dst;
|
||||
char *s;
|
||||
|
||||
nm_assert(property_info->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
nm_assert(((!!property_info->direct_set_string_ascii_strdown)
|
||||
+ (!!property_info->direct_set_string_strip)
|
||||
+ (!!property_info->direct_string_is_refstr)
|
||||
+ (property_info->direct_set_string_mac_address_len > 0)
|
||||
+ (property_info->direct_set_string_ip_address_addr_family != 0))
|
||||
<= (property_info->direct_hook.set_string_fcn ? 0 : 1));
|
||||
|
||||
if (property_info->direct_hook.set_string_fcn) {
|
||||
return property_info->direct_hook.set_string_fcn(sett_info, property_info, setting, src);
|
||||
}
|
||||
|
||||
dst = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
if (property_info->direct_string_is_refstr) {
|
||||
nm_assert(property_info->param_spec);
|
||||
nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET));
|
||||
return nm_ref_string_reset_str_upcast((const char **) dst, src);
|
||||
}
|
||||
|
||||
if (property_info->direct_set_string_ascii_strdown) {
|
||||
s = src ? g_ascii_strdown(src, -1) : NULL;
|
||||
goto out_take;
|
||||
}
|
||||
if (property_info->direct_set_string_strip) {
|
||||
s = nm_strstrip_dup(src);
|
||||
goto out_take;
|
||||
}
|
||||
if (property_info->direct_set_string_mac_address_len > 0) {
|
||||
return nm_strdup_reset_take(dst,
|
||||
_nm_utils_hwaddr_canonical_or_invalid(
|
||||
src,
|
||||
property_info->direct_set_string_mac_address_len));
|
||||
s = _nm_utils_hwaddr_canonical_or_invalid(src,
|
||||
property_info->direct_set_string_mac_address_len);
|
||||
goto out_take;
|
||||
}
|
||||
if (property_info->direct_set_string_ip_address_addr_family != 0) {
|
||||
return nm_strdup_reset_take(dst,
|
||||
_nm_utils_ipaddr_canonical_or_invalid(
|
||||
property_info->direct_set_string_ip_address_addr_family,
|
||||
src));
|
||||
}
|
||||
s = _nm_utils_ipaddr_canonical_or_invalid(
|
||||
property_info->direct_set_string_ip_address_addr_family - 1,
|
||||
src,
|
||||
property_info->direct_set_string_ip_address_addr_family_map_zero_to_null);
|
||||
goto out_take;
|
||||
} else
|
||||
nm_assert(!property_info->direct_set_string_ip_address_addr_family_map_zero_to_null);
|
||||
|
||||
if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET))
|
||||
return nm_strdup_reset_secret(dst, src);
|
||||
|
||||
return nm_strdup_reset(dst, src);
|
||||
|
||||
out_take:
|
||||
nm_assert(!NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET));
|
||||
return nm_strdup_reset_take(dst, s);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -683,56 +712,56 @@ _nm_setting_property_get_property_direct(GObject *object,
|
|||
switch (property_info->property_type->direct_type) {
|
||||
case NM_VALUE_TYPE_BOOL:
|
||||
{
|
||||
const bool *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_boolean(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_INT32:
|
||||
{
|
||||
const gint32 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_int(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT32:
|
||||
{
|
||||
const guint32 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_uint(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
{
|
||||
const gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_int64(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
{
|
||||
const guint64 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_uint64(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
{
|
||||
const int *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_enum(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_FLAGS:
|
||||
{
|
||||
const guint *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_flags(value, *p_val);
|
||||
return;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRING:
|
||||
{
|
||||
const char *const *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
const char *const *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_string(value, *p_val);
|
||||
return;
|
||||
|
|
@ -740,7 +769,7 @@ _nm_setting_property_get_property_direct(GObject *object,
|
|||
case NM_VALUE_TYPE_BYTES:
|
||||
{
|
||||
const GBytes *const *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
_nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
g_value_set_boxed(value, *p_val);
|
||||
return;
|
||||
|
|
@ -777,7 +806,7 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
switch (property_info->property_type->direct_type) {
|
||||
case NM_VALUE_TYPE_BOOL:
|
||||
{
|
||||
bool *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
gboolean v;
|
||||
|
||||
v = g_value_get_boolean(value);
|
||||
|
|
@ -788,7 +817,7 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
}
|
||||
case NM_VALUE_TYPE_INT32:
|
||||
{
|
||||
gint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
int v;
|
||||
|
||||
v = g_value_get_int(value);
|
||||
|
|
@ -803,7 +832,7 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
}
|
||||
case NM_VALUE_TYPE_UINT32:
|
||||
{
|
||||
guint32 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint v;
|
||||
|
||||
v = g_value_get_uint(value);
|
||||
|
|
@ -816,9 +845,20 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
nm_assert(*p_val == v);
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
{
|
||||
gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
gint64 v;
|
||||
|
||||
v = g_value_get_int64(value);
|
||||
if (*p_val == v)
|
||||
return;
|
||||
*p_val = v;
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
{
|
||||
guint64 *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint64 v;
|
||||
|
||||
v = g_value_get_uint64(value);
|
||||
|
|
@ -829,7 +869,7 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
}
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
{
|
||||
int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
int v;
|
||||
|
||||
v = g_value_get_enum(value);
|
||||
|
|
@ -840,7 +880,7 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
}
|
||||
case NM_VALUE_TYPE_FLAGS:
|
||||
{
|
||||
guint *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint v;
|
||||
|
||||
v = g_value_get_flags(value);
|
||||
|
|
@ -850,15 +890,15 @@ _nm_setting_property_set_property_direct(GObject *object,
|
|||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_STRING:
|
||||
if (!_property_direct_set_string(
|
||||
property_info,
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset),
|
||||
g_value_get_string(value)))
|
||||
if (!_property_direct_set_string(sett_info,
|
||||
property_info,
|
||||
setting,
|
||||
g_value_get_string(value)))
|
||||
return;
|
||||
goto out_notify;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
{
|
||||
GBytes **p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
GBytes **p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
GBytes *v;
|
||||
_nm_unused gs_unref_bytes GBytes *old = NULL;
|
||||
|
||||
|
|
@ -909,7 +949,7 @@ _init_direct(NMSetting *setting)
|
|||
break;
|
||||
case NM_VALUE_TYPE_BOOL:
|
||||
{
|
||||
bool *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
bool *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
gboolean def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec);
|
||||
|
|
@ -919,9 +959,8 @@ _init_direct(NMSetting *setting)
|
|||
}
|
||||
case NM_VALUE_TYPE_INT32:
|
||||
{
|
||||
gint32 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
int def_val;
|
||||
gint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
int def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec);
|
||||
nm_assert(*p_val == 0);
|
||||
|
|
@ -930,20 +969,28 @@ _init_direct(NMSetting *setting)
|
|||
}
|
||||
case NM_VALUE_TYPE_UINT32:
|
||||
{
|
||||
guint32 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint def_val;
|
||||
guint32 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec);
|
||||
nm_assert(*p_val == 0);
|
||||
*p_val = def_val;
|
||||
break;
|
||||
}
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
{
|
||||
gint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
gint64 def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_INT64(property_info->param_spec);
|
||||
nm_assert(*p_val == 0);
|
||||
*p_val = def_val;
|
||||
break;
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
{
|
||||
guint64 *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint64 def_val;
|
||||
guint64 *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint64 def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec);
|
||||
nm_assert(*p_val == 0);
|
||||
|
|
@ -952,7 +999,7 @@ _init_direct(NMSetting *setting)
|
|||
}
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
{
|
||||
int *p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
int *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
int def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec);
|
||||
|
|
@ -962,9 +1009,8 @@ _init_direct(NMSetting *setting)
|
|||
}
|
||||
case NM_VALUE_TYPE_FLAGS:
|
||||
{
|
||||
guint *p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
guint def_val;
|
||||
guint *p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
guint def_val;
|
||||
|
||||
def_val = NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec);
|
||||
nm_assert(*p_val == 0);
|
||||
|
|
@ -973,14 +1019,12 @@ _init_direct(NMSetting *setting)
|
|||
}
|
||||
case NM_VALUE_TYPE_STRING:
|
||||
nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec));
|
||||
nm_assert(!(
|
||||
*((const char *const *)
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset))));
|
||||
nm_assert(!(*((const char *const *)
|
||||
_nm_setting_get_private_field(setting, sett_info, property_info))));
|
||||
break;
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
nm_assert(!(
|
||||
*((const GBytes *const *)
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset))));
|
||||
nm_assert(!(*((const GBytes *const *)
|
||||
_nm_setting_get_private_field(setting, sett_info, property_info))));
|
||||
break;
|
||||
default:
|
||||
nm_assert_not_reached();
|
||||
|
|
@ -1013,22 +1057,26 @@ _finalize_direct(NMSetting *setting)
|
|||
case NM_VALUE_TYPE_BOOL:
|
||||
case NM_VALUE_TYPE_INT32:
|
||||
case NM_VALUE_TYPE_UINT32:
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
case NM_VALUE_TYPE_FLAGS:
|
||||
break;
|
||||
case NM_VALUE_TYPE_STRING:
|
||||
{
|
||||
char **p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
char **p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
nm_clear_g_free(p_val);
|
||||
if (property_info->direct_string_is_refstr)
|
||||
nm_clear_pointer(p_val, nm_ref_string_unref_upcast);
|
||||
else if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET))
|
||||
nm_clear_pointer(p_val, nm_free_secret);
|
||||
else
|
||||
nm_clear_g_free(p_val);
|
||||
break;
|
||||
}
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
{
|
||||
GBytes **p_val =
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
GBytes **p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
|
||||
nm_clear_pointer(p_val, g_bytes_unref);
|
||||
break;
|
||||
|
|
@ -1050,7 +1098,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
{
|
||||
gboolean val;
|
||||
|
||||
val = *((bool *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((bool *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_BOOLEAN(property_info->param_spec))
|
||||
return NULL;
|
||||
|
|
@ -1060,8 +1108,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
{
|
||||
gint32 val;
|
||||
|
||||
val =
|
||||
*((gint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((gint32 *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_INT(property_info->param_spec))
|
||||
return NULL;
|
||||
|
|
@ -1071,19 +1118,27 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
{
|
||||
guint32 val;
|
||||
|
||||
val = *(
|
||||
(guint32 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((guint32 *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT(property_info->param_spec))
|
||||
return NULL;
|
||||
return g_variant_new_uint32(val);
|
||||
}
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
{
|
||||
gint64 val;
|
||||
|
||||
val = *((gint64 *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_INT64(property_info->param_spec))
|
||||
return NULL;
|
||||
return g_variant_new_int64(val);
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
{
|
||||
guint64 val;
|
||||
|
||||
val = *(
|
||||
(guint64 *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((guint64 *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(property_info->param_spec))
|
||||
return NULL;
|
||||
|
|
@ -1093,7 +1148,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
{
|
||||
int val;
|
||||
|
||||
val = *((int *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((int *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(property_info->param_spec))
|
||||
return NULL;
|
||||
|
|
@ -1103,8 +1158,7 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
{
|
||||
guint val;
|
||||
|
||||
val =
|
||||
*((guint *) _nm_setting_get_private(setting, sett_info, property_info->direct_offset));
|
||||
val = *((guint *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!property_info->to_dbus_including_default
|
||||
&& val == NM_G_PARAM_SPEC_GET_DEFAULT_FLAGS(property_info->param_spec))
|
||||
return NULL;
|
||||
|
|
@ -1122,9 +1176,8 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec));
|
||||
nm_assert(!property_info->to_dbus_including_default);
|
||||
|
||||
val = *((const char *const *) _nm_setting_get_private(setting,
|
||||
sett_info,
|
||||
property_info->direct_offset));
|
||||
val = *(
|
||||
(const char *const *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
if (!val)
|
||||
return NULL;
|
||||
if (!val[0])
|
||||
|
|
@ -1139,9 +1192,9 @@ _nm_setting_property_to_dbus_fcn_direct(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_
|
|||
* (but it could have). */
|
||||
nm_assert(!property_info->to_dbus_including_default);
|
||||
|
||||
val = *((const GBytes *const *) _nm_setting_get_private(setting,
|
||||
sett_info,
|
||||
property_info->direct_offset));
|
||||
val = *((const GBytes *const *) _nm_setting_get_private_field(setting,
|
||||
sett_info,
|
||||
property_info));
|
||||
if (!val)
|
||||
return NULL;
|
||||
return nm_g_bytes_to_variant_ay(val);
|
||||
|
|
@ -1161,9 +1214,7 @@ _nm_setting_property_to_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_TO_DBUS_F
|
|||
nm_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(property_info->param_spec));
|
||||
nm_assert(!property_info->to_dbus_including_default);
|
||||
|
||||
val = *((const char *const *) _nm_setting_get_private(setting,
|
||||
sett_info,
|
||||
property_info->direct_offset));
|
||||
val = *((const char *const *) _nm_setting_get_private_field(setting, sett_info, property_info));
|
||||
return nm_utils_hwaddr_to_dbus(val);
|
||||
}
|
||||
|
||||
|
|
@ -1231,9 +1282,8 @@ _nm_setting_property_from_dbus_fcn_direct_mac_address(_NM_SETT_INFO_PROP_FROM_DB
|
|||
|
||||
array = g_variant_get_fixed_array(value, &length, 1);
|
||||
|
||||
if (nm_strdup_reset_take(
|
||||
_nm_setting_get_private(setting, sett_info, property_info->direct_offset),
|
||||
length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) {
|
||||
if (nm_strdup_reset_take(_nm_setting_get_private_field(setting, sett_info, property_info),
|
||||
length > 0 ? nm_utils_hwaddr_ntoa(array, length) : NULL)) {
|
||||
g_object_notify_by_pspec(G_OBJECT(setting), property_info->param_spec);
|
||||
} else
|
||||
*out_is_modified = FALSE;
|
||||
|
|
@ -1289,7 +1339,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
v = !!v;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
*p_val = v;
|
||||
|
|
@ -1313,7 +1363,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -1341,7 +1391,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -1351,6 +1401,33 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
*p_val = v;
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
{
|
||||
const GParamSpecInt64 *param_spec;
|
||||
gint64 *p_val;
|
||||
gint64 v;
|
||||
|
||||
if (g_variant_is_of_type(value, G_VARIANT_TYPE_INT64))
|
||||
v = g_variant_get_int64(value);
|
||||
else {
|
||||
if (!_variant_get_value_transform(property_info,
|
||||
value,
|
||||
G_TYPE_INT64,
|
||||
g_value_get_int64,
|
||||
&v))
|
||||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
param_spec = NM_G_PARAM_SPEC_CAST_INT64(property_info->param_spec);
|
||||
if (v < param_spec->minimum || v > param_spec->maximum)
|
||||
goto out_error_param_spec_validation;
|
||||
*p_val = v;
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
{
|
||||
const GParamSpecUInt64 *param_spec;
|
||||
|
|
@ -1368,7 +1445,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -1398,7 +1475,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -1427,7 +1504,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
goto out_error_wrong_dbus_type;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (*p_val == v)
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -1439,8 +1516,8 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
case NM_VALUE_TYPE_STRING:
|
||||
{
|
||||
gs_free char *v_free = NULL;
|
||||
char **p_val;
|
||||
const char *v;
|
||||
gboolean changed;
|
||||
|
||||
if (g_variant_is_of_type(value, G_VARIANT_TYPE_STRING)) {
|
||||
v = g_variant_get_string(value, NULL);
|
||||
|
|
@ -1454,10 +1531,13 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
v = v_free;
|
||||
}
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
if (!_property_direct_set_string(property_info, p_val, v))
|
||||
goto out_unchanged;
|
||||
changed = _property_direct_set_string(sett_info, property_info, setting, v);
|
||||
|
||||
if (NM_FLAGS_HAS(property_info->param_spec->flags, NM_SETTING_PARAM_SECRET))
|
||||
nm_clear_pointer(&v_free, nm_free_secret);
|
||||
|
||||
if (!changed)
|
||||
goto out_unchanged;
|
||||
goto out_notify;
|
||||
}
|
||||
case NM_VALUE_TYPE_BYTES:
|
||||
|
|
@ -1470,7 +1550,7 @@ _nm_setting_property_from_dbus_fcn_direct(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS
|
|||
|
||||
v = nm_g_bytes_new_from_variant_ay(value);
|
||||
|
||||
p_val = _nm_setting_get_private(setting, sett_info, property_info->direct_offset);
|
||||
p_val = _nm_setting_get_private_field(setting, sett_info, property_info);
|
||||
if (nm_g_bytes_equal0(*p_val, v))
|
||||
goto out_unchanged;
|
||||
|
||||
|
|
@ -2363,8 +2443,8 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_
|
|||
if (!set_b)
|
||||
return TRUE;
|
||||
|
||||
p_a = _nm_setting_get_private(set_a, sett_info, property_info->direct_offset);
|
||||
p_b = _nm_setting_get_private(set_b, sett_info, property_info->direct_offset);
|
||||
p_a = _nm_setting_get_private_field(set_a, sett_info, property_info);
|
||||
p_b = _nm_setting_get_private_field(set_b, sett_info, property_info);
|
||||
|
||||
switch (property_info->property_type->direct_type) {
|
||||
case NM_VALUE_TYPE_BOOL:
|
||||
|
|
@ -2373,6 +2453,8 @@ _nm_setting_property_compare_fcn_direct(_NM_SETT_INFO_PROP_COMPARE_FCN_ARGS _nm_
|
|||
return *((const gint32 *) p_a) == *((const gint32 *) p_b);
|
||||
case NM_VALUE_TYPE_UINT32:
|
||||
return *((const guint32 *) p_a) == *((const guint32 *) p_b);
|
||||
case NM_VALUE_TYPE_INT64:
|
||||
return *((const gint64 *) p_a) == *((const gint64 *) p_b);
|
||||
case NM_VALUE_TYPE_UINT64:
|
||||
return *((const guint64 *) p_a) == *((const guint64 *) p_b);
|
||||
case NM_VALUE_TYPE_ENUM:
|
||||
|
|
@ -3387,18 +3469,6 @@ const NMSettInfoPropertType nm_sett_info_propert_type_deprecated_ignore_u =
|
|||
/* No functions set. This property type is to silently ignore the value on D-Bus. */
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_ignore);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_i =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_INT32,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
|
||||
.from_dbus_is_full = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_plain_u =
|
||||
NM_SETT_INFO_PROPERT_TYPE_GPROP_INIT(G_VARIANT_TYPE_UINT32,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_default,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_gprop,
|
||||
.from_dbus_is_full = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_direct_boolean =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_BOOLEAN,
|
||||
.direct_type = NM_VALUE_TYPE_BOOL,
|
||||
|
|
@ -3426,6 +3496,15 @@ const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint32 =
|
|||
.from_dbus_is_full = TRUE,
|
||||
.from_dbus_direct_allow_transform = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_direct_int64 =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_INT64,
|
||||
.direct_type = NM_VALUE_TYPE_INT64,
|
||||
.compare_fcn = _nm_setting_property_compare_fcn_direct,
|
||||
.to_dbus_fcn = _nm_setting_property_to_dbus_fcn_direct,
|
||||
.from_dbus_fcn = _nm_setting_property_from_dbus_fcn_direct,
|
||||
.from_dbus_is_full = TRUE,
|
||||
.from_dbus_direct_allow_transform = TRUE);
|
||||
|
||||
const NMSettInfoPropertType nm_sett_info_propert_type_direct_uint64 =
|
||||
NM_SETT_INFO_PROPERT_TYPE_DBUS_INIT(G_VARIANT_TYPE_UINT64,
|
||||
.direct_type = NM_VALUE_TYPE_UINT64,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ void _nm_utils_bytes_from_dbus(GVariant *dbus_value, GValue *prop_value);
|
|||
|
||||
char *_nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length);
|
||||
|
||||
char *_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip);
|
||||
char *
|
||||
_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean map_zero_to_null);
|
||||
|
||||
gboolean _nm_utils_hwaddr_link_local_valid(const char *mac);
|
||||
|
||||
|
|
@ -66,4 +67,8 @@ void _nm_team_settings_property_from_dbus_link_watchers(
|
|||
GVariant *_nm_utils_ip4_dns_to_variant(const char *const *dns, gssize len);
|
||||
GVariant *_nm_utils_ip6_dns_to_variant(const char *const *dns, gssize len);
|
||||
|
||||
const char *const *nmtst_system_encodings_for_lang(const char *lang);
|
||||
const char *const *nmtst_system_encodings_get_default(void);
|
||||
const char *const *nmtst_system_encodings_get(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -328,169 +328,181 @@ good:
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
struct IsoLangToEncodings {
|
||||
const char *lang;
|
||||
const char *const *encodings;
|
||||
};
|
||||
typedef const char *const StrvArray4Type[4];
|
||||
|
||||
#define LANG_ENCODINGS(l, ...) \
|
||||
{ \
|
||||
.lang = l, .encodings = NM_MAKE_STRV(__VA_ARGS__), \
|
||||
#define LL(l, ...) \
|
||||
{ \
|
||||
.name = l, .value = {__VA_ARGS__, NULL}, \
|
||||
}
|
||||
|
||||
/* 5-letter language codes */
|
||||
static const struct IsoLangToEncodings isoLangEntries5[] = {
|
||||
/* Simplified Chinese */
|
||||
LANG_ENCODINGS("zh_cn", "euc-cn", "gb2312", "gb18030"), /* PRC */
|
||||
LANG_ENCODINGS("zh_sg", "euc-cn", "gb2312", "gb18030"), /* Singapore */
|
||||
|
||||
/* Traditional Chinese */
|
||||
LANG_ENCODINGS("zh_tw", "big5", "euc-tw"), /* Taiwan */
|
||||
LANG_ENCODINGS("zh_hk", "big5", "euc-tw", "big5-hkcs"), /* Hong Kong */
|
||||
LANG_ENCODINGS("zh_mo", "big5", "euc-tw"), /* Macau */
|
||||
|
||||
LANG_ENCODINGS(NULL, NULL)};
|
||||
static _NM_UTILS_STRING_TABLE_LOOKUP_DEFINE(
|
||||
_iso_lang_entries_5_lookup,
|
||||
StrvArray4Type,
|
||||
const char *const *,
|
||||
{ nm_assert(name); },
|
||||
{ return NULL; },
|
||||
,
|
||||
LL("zh_cn", "euc-cn", "gb2312", "gb18030"), /* Simplified Chinese, PRC */
|
||||
LL("zh_hk", "big5", "euc-tw", "big5-hkcs"), /* Traditional Chinese, Hong Kong */
|
||||
LL("zh_mo", "big5", "euc-tw"), /* Traditional Chinese, Macau */
|
||||
LL("zh_sg", "euc-cn", "gb2312", "gb18030"), /* Simplified Chinese, Singapore */
|
||||
LL("zh_tw", "big5", "euc-tw"), /* Traditional Chinese, Taiwan */
|
||||
);
|
||||
|
||||
/* 2-letter language codes; we don't care about the other 3 in this table */
|
||||
static const struct IsoLangToEncodings isoLangEntries2[] = {
|
||||
/* Japanese */
|
||||
LANG_ENCODINGS("ja", "euc-jp", "shift_jis", "iso-2022-jp"),
|
||||
static _NM_UTILS_STRING_TABLE_LOOKUP_DEFINE(
|
||||
_iso_lang_entries_2_lookup,
|
||||
StrvArray4Type,
|
||||
const char *const *,
|
||||
{ nm_assert(name); },
|
||||
{ return NULL; },
|
||||
,
|
||||
LL("ar", "iso-8859-6", "windows-1256"), /* Arabic */
|
||||
LL("be", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Belorussian */
|
||||
LL("bg", "windows-1251", "koi8-r", "iso-8859-5"), /* Cyrillic, Bulgarian */
|
||||
LL("cs", "iso-8859-2", "windows-1250"), /* Central European, Czech */
|
||||
LL("el", "iso-8859-7", "windows-1253"), /* Greek */
|
||||
LL("et", "iso-8859-4", "windows-1257"), /* Baltic, Estonian */
|
||||
LL("he", "iso-8859-8", "windows-1255"), /* Hebrew */
|
||||
LL("hr", "iso-8859-2", "windows-1250"), /* Central European, Croatian */
|
||||
LL("hu", "iso-8859-2", "windows-1250"), /* Central European, Hungarian */
|
||||
LL("iw", "iso-8859-8", "windows-1255"), /* Hebrew */
|
||||
LL("ja", "euc-jp", "shift_jis", "iso-2022-jp"), /* Japanese */
|
||||
LL("ko", "euc-kr", "iso-2022-kr", "johab"), /* Korean */
|
||||
LL("lt", "iso-8859-4", "windows-1257"), /* Baltic, Lithuanian */
|
||||
LL("lv", "iso-8859-4", "windows-1257"), /* Baltic, Latvian */
|
||||
LL("mk", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Macedonian */
|
||||
LL("pl", "iso-8859-2", "windows-1250"), /* Central European, Polish */
|
||||
LL("ro", "iso-8859-2", "windows-1250"), /* Central European, Romanian */
|
||||
LL("ru", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Russian */
|
||||
LL("sh", "iso-8859-2", "windows-1250"), /* Central European, Serbo-Croatian */
|
||||
LL("sk", "iso-8859-2", "windows-1250"), /* Central European, Slovakian */
|
||||
LL("sl", "iso-8859-2", "windows-1250"), /* Central European, Slovenian */
|
||||
LL("sr", "koi8-r", "windows-1251", "iso-8859-5"), /* Cyrillic, Serbian */
|
||||
LL("th", "iso-8859-11", "windows-874"), /* Thai */
|
||||
LL("tr", "iso-8859-9", "windows-1254"), /* Turkish */
|
||||
LL("uk", "koi8-u", "koi8-r", "windows-1251"), /* Cyrillic, Ukrainian */
|
||||
);
|
||||
|
||||
/* Korean */
|
||||
LANG_ENCODINGS("ko", "euc-kr", "iso-2022-kr", "johab"),
|
||||
|
||||
/* Thai */
|
||||
LANG_ENCODINGS("th", "iso-8859-11", "windows-874"),
|
||||
|
||||
/* Central European */
|
||||
LANG_ENCODINGS("hu", "iso-8859-2", "windows-1250"), /* Hungarian */
|
||||
LANG_ENCODINGS("cs", "iso-8859-2", "windows-1250"), /* Czech */
|
||||
LANG_ENCODINGS("hr", "iso-8859-2", "windows-1250"), /* Croatian */
|
||||
LANG_ENCODINGS("pl", "iso-8859-2", "windows-1250"), /* Polish */
|
||||
LANG_ENCODINGS("ro", "iso-8859-2", "windows-1250"), /* Romanian */
|
||||
LANG_ENCODINGS("sk", "iso-8859-2", "windows-1250"), /* Slovakian */
|
||||
LANG_ENCODINGS("sl", "iso-8859-2", "windows-1250"), /* Slovenian */
|
||||
LANG_ENCODINGS("sh", "iso-8859-2", "windows-1250"), /* Serbo-Croatian */
|
||||
|
||||
/* Cyrillic */
|
||||
LANG_ENCODINGS("ru", "koi8-r", "windows-1251", "iso-8859-5"), /* Russian */
|
||||
LANG_ENCODINGS("be", "koi8-r", "windows-1251", "iso-8859-5"), /* Belorussian */
|
||||
LANG_ENCODINGS("bg", "windows-1251", "koi8-r", "iso-8859-5"), /* Bulgarian */
|
||||
LANG_ENCODINGS("mk", "koi8-r", "windows-1251", "iso-8859-5"), /* Macedonian */
|
||||
LANG_ENCODINGS("sr", "koi8-r", "windows-1251", "iso-8859-5"), /* Serbian */
|
||||
LANG_ENCODINGS("uk", "koi8-u", "koi8-r", "windows-1251"), /* Ukrainian */
|
||||
|
||||
/* Arabic */
|
||||
LANG_ENCODINGS("ar", "iso-8859-6", "windows-1256"),
|
||||
|
||||
/* Baltic */
|
||||
LANG_ENCODINGS("et", "iso-8859-4", "windows-1257"), /* Estonian */
|
||||
LANG_ENCODINGS("lt", "iso-8859-4", "windows-1257"), /* Lithuanian */
|
||||
LANG_ENCODINGS("lv", "iso-8859-4", "windows-1257"), /* Latvian */
|
||||
|
||||
/* Greek */
|
||||
LANG_ENCODINGS("el", "iso-8859-7", "windows-1253"),
|
||||
|
||||
/* Hebrew */
|
||||
LANG_ENCODINGS("he", "iso-8859-8", "windows-1255"),
|
||||
LANG_ENCODINGS("iw", "iso-8859-8", "windows-1255"),
|
||||
|
||||
/* Turkish */
|
||||
LANG_ENCODINGS("tr", "iso-8859-9", "windows-1254"),
|
||||
|
||||
/* Table end */
|
||||
LANG_ENCODINGS(NULL, NULL)};
|
||||
|
||||
static GHashTable *langToEncodings5 = NULL;
|
||||
static GHashTable *langToEncodings2 = NULL;
|
||||
|
||||
static void
|
||||
init_lang_to_encodings_hash(void)
|
||||
static const char *const *
|
||||
_system_encodings_for_lang(const char *lang)
|
||||
{
|
||||
struct IsoLangToEncodings *enc;
|
||||
char tmp_lang[3];
|
||||
const char *const *e;
|
||||
|
||||
if (G_UNLIKELY(langToEncodings5 == NULL)) {
|
||||
/* Five-letter codes */
|
||||
enc = (struct IsoLangToEncodings *) &isoLangEntries5[0];
|
||||
langToEncodings5 = g_hash_table_new(nm_str_hash, g_str_equal);
|
||||
while (enc->lang) {
|
||||
g_hash_table_insert(langToEncodings5, (gpointer) enc->lang, (gpointer) enc->encodings);
|
||||
enc++;
|
||||
}
|
||||
nm_assert(lang);
|
||||
|
||||
if (lang[0] == '\0' || lang[1] == '\0') {
|
||||
/* need at least two characters. */
|
||||
nm_assert(!_iso_lang_entries_5_lookup(lang));
|
||||
nm_assert(!_iso_lang_entries_2_lookup(lang));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (G_UNLIKELY(langToEncodings2 == NULL)) {
|
||||
/* Two-letter codes */
|
||||
enc = (struct IsoLangToEncodings *) &isoLangEntries2[0];
|
||||
langToEncodings2 = g_hash_table_new(nm_str_hash, g_str_equal);
|
||||
while (enc->lang) {
|
||||
g_hash_table_insert(langToEncodings2, (gpointer) enc->lang, (gpointer) enc->encodings);
|
||||
enc++;
|
||||
}
|
||||
if (lang[2] != '\0') {
|
||||
nm_assert(!_iso_lang_entries_2_lookup(lang));
|
||||
|
||||
if (lang[3] != '\0' && lang[4] != '\0' && lang[5] == '\0') {
|
||||
/* lang is 5 characters long. Try it. */
|
||||
if ((e = _iso_lang_entries_5_lookup(lang)))
|
||||
return e;
|
||||
} else
|
||||
nm_assert(!_iso_lang_entries_5_lookup(lang));
|
||||
|
||||
/* extract the first 2 characters and ignore the rest. */
|
||||
tmp_lang[0] = lang[0];
|
||||
tmp_lang[1] = lang[1];
|
||||
tmp_lang[2] = '\0';
|
||||
lang = tmp_lang;
|
||||
}
|
||||
|
||||
if ((e = _iso_lang_entries_2_lookup(lang)))
|
||||
return e;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_encodings_for_lang(const char *lang, const char *const **encodings)
|
||||
const char *const *
|
||||
nmtst_system_encodings_for_lang(const char *lang)
|
||||
{
|
||||
gs_free char *tmp_lang = NULL;
|
||||
|
||||
g_return_val_if_fail(lang, FALSE);
|
||||
g_return_val_if_fail(encodings, FALSE);
|
||||
|
||||
init_lang_to_encodings_hash();
|
||||
|
||||
if ((*encodings = g_hash_table_lookup(langToEncodings5, lang)))
|
||||
return TRUE;
|
||||
|
||||
/* Truncate tmp_lang to length of 2 */
|
||||
if (strlen(lang) > 2) {
|
||||
tmp_lang = g_strdup(lang);
|
||||
tmp_lang[2] = '\0';
|
||||
if ((*encodings = g_hash_table_lookup(langToEncodings2, tmp_lang)))
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return _system_encodings_for_lang(lang);
|
||||
}
|
||||
|
||||
static const char *const *
|
||||
get_system_encodings(void)
|
||||
_system_encodings_get_default(void)
|
||||
{
|
||||
static const char *const *cached_encodings;
|
||||
static char *default_encodings[4];
|
||||
const char *const *encodings = NULL;
|
||||
char *lang;
|
||||
static gsize init_once = 0;
|
||||
static const char *default_encodings[4];
|
||||
|
||||
if (cached_encodings)
|
||||
return cached_encodings;
|
||||
if (g_once_init_enter(&init_once)) {
|
||||
const char *e_default = NULL;
|
||||
int i;
|
||||
|
||||
/* Use environment variables as encoding hint */
|
||||
lang = getenv("LC_ALL");
|
||||
if (!lang)
|
||||
lang = getenv("LC_CTYPE");
|
||||
if (!lang)
|
||||
lang = getenv("LANG");
|
||||
if (lang) {
|
||||
char *dot;
|
||||
g_get_charset(&e_default);
|
||||
|
||||
lang = g_ascii_strdown(lang, -1);
|
||||
if ((dot = strchr(lang, '.')))
|
||||
*dot = '\0';
|
||||
i = 0;
|
||||
if (e_default)
|
||||
default_encodings[i++] = e_default;
|
||||
if (!nm_streq0(e_default, "iso-8859-1"))
|
||||
default_encodings[i++] = "iso-8859-1";
|
||||
if (!nm_streq0(e_default, "windows-1251"))
|
||||
default_encodings[i++] = "windows-1251";
|
||||
default_encodings[i++] = NULL;
|
||||
nm_assert(i <= G_N_ELEMENTS(default_encodings));
|
||||
|
||||
get_encodings_for_lang(lang, &encodings);
|
||||
g_free(lang);
|
||||
}
|
||||
if (!encodings) {
|
||||
g_get_charset((const char **) &default_encodings[0]);
|
||||
default_encodings[1] = "iso-8859-1";
|
||||
default_encodings[2] = "windows-1251";
|
||||
default_encodings[3] = NULL;
|
||||
encodings = (const char *const *) default_encodings;
|
||||
g_once_init_leave(&init_once, 1);
|
||||
}
|
||||
|
||||
cached_encodings = encodings;
|
||||
return cached_encodings;
|
||||
return default_encodings;
|
||||
}
|
||||
|
||||
const char *const *
|
||||
nmtst_system_encodings_get_default(void)
|
||||
{
|
||||
return _system_encodings_get_default();
|
||||
}
|
||||
|
||||
static const char *const *
|
||||
_system_encodings_get(void)
|
||||
{
|
||||
static const char *const *cached = NULL;
|
||||
const char *const *e;
|
||||
|
||||
again:
|
||||
if (!(e = g_atomic_pointer_get(&cached))) {
|
||||
const char *lang;
|
||||
|
||||
/* Use environment variables as encoding hint */
|
||||
lang = getenv("LC_ALL") ?: getenv("LC_CTYPE") ?: getenv("LANG");
|
||||
|
||||
if (lang) {
|
||||
gs_free char *lang_down = NULL;
|
||||
char *dot;
|
||||
|
||||
lang_down = g_ascii_strdown(lang, -1);
|
||||
if ((dot = strchr(lang_down, '.')))
|
||||
*dot = '\0';
|
||||
e = _system_encodings_for_lang(lang_down);
|
||||
}
|
||||
|
||||
if (!e)
|
||||
e = _system_encodings_get_default();
|
||||
|
||||
/* in any case, @e is now a static buffer, that we may cache. */
|
||||
nm_assert(e);
|
||||
|
||||
if (!g_atomic_pointer_compare_and_exchange(&cached, NULL, e))
|
||||
goto again;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
const char *const *
|
||||
nmtst_system_encodings_get(void)
|
||||
{
|
||||
return _system_encodings_get();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -567,7 +579,7 @@ nm_utils_ssid_to_utf8(const guint8 *ssid, gsize len)
|
|||
if (g_utf8_validate((const char *) ssid, len, NULL))
|
||||
return g_strndup((const char *) ssid, len);
|
||||
|
||||
encodings = get_system_encodings();
|
||||
encodings = _system_encodings_get();
|
||||
|
||||
for (e = encodings; *e; e++) {
|
||||
converted = g_convert((const char *) ssid, len, "UTF-8", *e, NULL, NULL, NULL);
|
||||
|
|
@ -3899,19 +3911,19 @@ _nm_utils_hwaddr_canonical_or_invalid(const char *mac, gssize length)
|
|||
}
|
||||
|
||||
char *
|
||||
_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip)
|
||||
_nm_utils_ipaddr_canonical_or_invalid(int addr_family, const char *ip, gboolean map_zero_to_null)
|
||||
{
|
||||
NMIPAddr addr_bin;
|
||||
|
||||
nm_assert_addr_family(addr_family);
|
||||
nm_assert_addr_family_or_unspec(addr_family);
|
||||
|
||||
if (!ip)
|
||||
return NULL;
|
||||
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, ip, NULL, &addr_bin))
|
||||
if (!nm_utils_parse_inaddr_bin(addr_family, ip, &addr_family, &addr_bin))
|
||||
return g_strdup(ip);
|
||||
|
||||
if (nm_ip_addr_is_null(addr_family, &addr_bin))
|
||||
if (map_zero_to_null && nm_ip_addr_is_null(addr_family, &addr_bin))
|
||||
return NULL;
|
||||
|
||||
return nm_utils_inet_ntop_dup(addr_family, &addr_bin);
|
||||
|
|
|
|||
|
|
@ -13,12 +13,13 @@
|
|||
#include <linux/if_ether.h>
|
||||
#include <linux/if_infiniband.h>
|
||||
|
||||
#include "libnm-std-aux/c-list-util.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-glib-aux/nm-enum-utils.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
#include "libnm-base/nm-base.h"
|
||||
#include "libnm-glib-aux/nm-enum-utils.h"
|
||||
#include "libnm-glib-aux/nm-json-aux.h"
|
||||
#include "libnm-glib-aux/nm-ref-string.h"
|
||||
#include "libnm-glib-aux/nm-str-buf.h"
|
||||
#include "libnm-glib-aux/nm-uuid.h"
|
||||
#include "libnm-std-aux/c-list-util.h"
|
||||
#include "libnm-systemd-shared/nm-sd-utils-shared.h"
|
||||
|
||||
#include "nm-utils.h"
|
||||
|
|
@ -10666,6 +10667,146 @@ test_vpn_connection_state_reason(void)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_system_encodings(void)
|
||||
{
|
||||
const int N_RUN = 10000;
|
||||
int i_run;
|
||||
|
||||
g_assert(nmtst_system_encodings_for_lang("") == NULL);
|
||||
g_assert(nmtst_system_encodings_for_lang("zh") == NULL);
|
||||
g_assert(nmtst_system_encodings_for_lang("zh_cx") == NULL);
|
||||
|
||||
#define LL(lang, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
const char *const _lang = "" lang ""; \
|
||||
\
|
||||
nmtst_assert_strv(nmtst_system_encodings_for_lang(_lang), __VA_ARGS__); \
|
||||
\
|
||||
if (strlen(_lang) == 2) { \
|
||||
gs_free char *_lang2 = g_strdup_printf("%s%s", _lang, "x"); \
|
||||
\
|
||||
nmtst_assert_strv(nmtst_system_encodings_for_lang(_lang2), __VA_ARGS__); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
LL("zh_cn", "euc-cn", "gb2312", "gb18030");
|
||||
LL("zh_hk", "big5", "euc-tw", "big5-hkcs");
|
||||
LL("zh_mo", "big5", "euc-tw");
|
||||
LL("zh_sg", "euc-cn", "gb2312", "gb18030");
|
||||
LL("zh_tw", "big5", "euc-tw");
|
||||
|
||||
LL("ar", "iso-8859-6", "windows-1256");
|
||||
LL("be", "koi8-r", "windows-1251", "iso-8859-5");
|
||||
LL("bg", "windows-1251", "koi8-r", "iso-8859-5");
|
||||
LL("cs", "iso-8859-2", "windows-1250");
|
||||
LL("el", "iso-8859-7", "windows-1253");
|
||||
LL("et", "iso-8859-4", "windows-1257");
|
||||
LL("he", "iso-8859-8", "windows-1255");
|
||||
LL("hr", "iso-8859-2", "windows-1250");
|
||||
LL("hu", "iso-8859-2", "windows-1250");
|
||||
LL("iw", "iso-8859-8", "windows-1255");
|
||||
LL("ja", "euc-jp", "shift_jis", "iso-2022-jp");
|
||||
LL("ko", "euc-kr", "iso-2022-kr", "johab");
|
||||
LL("lt", "iso-8859-4", "windows-1257");
|
||||
LL("lv", "iso-8859-4", "windows-1257");
|
||||
LL("mk", "koi8-r", "windows-1251", "iso-8859-5");
|
||||
LL("pl", "iso-8859-2", "windows-1250");
|
||||
LL("ro", "iso-8859-2", "windows-1250");
|
||||
LL("ru", "koi8-r", "windows-1251", "iso-8859-5");
|
||||
LL("sh", "iso-8859-2", "windows-1250");
|
||||
LL("sk", "iso-8859-2", "windows-1250");
|
||||
LL("sl", "iso-8859-2", "windows-1250");
|
||||
LL("sr", "koi8-r", "windows-1251", "iso-8859-5");
|
||||
LL("th", "iso-8859-11", "windows-874");
|
||||
LL("tr", "iso-8859-9", "windows-1254");
|
||||
LL("uk", "koi8-u", "koi8-r", "windows-1251");
|
||||
|
||||
g_assert(nmtst_system_encodings_get_default());
|
||||
g_assert(nmtst_system_encodings_get());
|
||||
|
||||
for (i_run = 0; i_run < N_RUN; i_run++) {
|
||||
char buf[7];
|
||||
int n_buf;
|
||||
int i_buf;
|
||||
const char *const *e;
|
||||
|
||||
if (i_run < N_RUN / 3)
|
||||
n_buf = 2;
|
||||
else if (i_run < 2 * N_RUN / 3)
|
||||
n_buf = 5;
|
||||
else
|
||||
n_buf = nmtst_get_rand_uint32() % G_N_ELEMENTS(buf);
|
||||
|
||||
for (i_buf = 0; i_buf < n_buf; i_buf++) {
|
||||
do {
|
||||
buf[i_buf] = (char) nmtst_get_rand_uint32();
|
||||
} while (buf[i_buf] == '\0');
|
||||
}
|
||||
g_assert(i_buf < G_N_ELEMENTS(buf));
|
||||
buf[i_buf] = '\0';
|
||||
|
||||
g_assert_cmpint(n_buf, <, G_N_ELEMENTS(buf));
|
||||
g_assert_cmpint(strlen(buf), ==, n_buf);
|
||||
|
||||
e = nmtst_system_encodings_for_lang(buf);
|
||||
if (e)
|
||||
g_assert_cmpint(n_buf, >=, 2);
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static void
|
||||
test_direct_string_is_refstr(void)
|
||||
{
|
||||
gs_unref_object NMSetting *s1 = NULL;
|
||||
gs_unref_object NMSetting *s2 = NULL;
|
||||
const char *TEST_STR = "adfdsff";
|
||||
NMRefString *rstr0;
|
||||
NMRefString *rstr = NULL;
|
||||
|
||||
g_assert(!nmtst_ref_string_find(TEST_STR));
|
||||
|
||||
s1 = nm_setting_connection_new();
|
||||
g_object_set(s1,
|
||||
NM_SETTING_CONNECTION_ID,
|
||||
"uuidtest",
|
||||
NM_SETTING_CONNECTION_UUID,
|
||||
nm_uuid_generate_random_str_a(),
|
||||
NM_SETTING_CONNECTION_TYPE,
|
||||
TEST_STR,
|
||||
NULL);
|
||||
|
||||
rstr0 = nmtst_ref_string_find(TEST_STR);
|
||||
g_assert(rstr0);
|
||||
|
||||
if (nmtst_get_rand_bool()) {
|
||||
rstr = nm_ref_string_new(TEST_STR);
|
||||
g_assert(rstr);
|
||||
g_assert(rstr == rstr0);
|
||||
g_assert(rstr->str
|
||||
== nm_setting_connection_get_connection_type((NMSettingConnection *) s1));
|
||||
}
|
||||
|
||||
s2 = nm_setting_duplicate(s1);
|
||||
g_assert(rstr0->str == nm_setting_connection_get_connection_type((NMSettingConnection *) s2));
|
||||
|
||||
g_clear_object(&s1);
|
||||
if (nmtst_get_rand_bool())
|
||||
g_clear_object(&s2);
|
||||
else {
|
||||
g_object_set(s2, NM_SETTING_CONNECTION_TYPE, nmtst_get_rand_bool() ? "hallo" : NULL, NULL);
|
||||
}
|
||||
nm_ref_string_unref(rstr);
|
||||
|
||||
g_assert(!nmtst_ref_string_find(TEST_STR));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMTST_DEFINE();
|
||||
|
||||
int
|
||||
|
|
@ -11008,5 +11149,8 @@ main(int argc, char **argv)
|
|||
g_test_add_func("/core/general/test_vpn_connection_state_reason",
|
||||
test_vpn_connection_state_reason);
|
||||
|
||||
g_test_add_func("/core/general/test_system_encodings", test_system_encodings);
|
||||
g_test_add_func("/core/general/test_direct_string_is_refstr", test_direct_string_is_refstr);
|
||||
|
||||
return g_test_run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4430,6 +4430,8 @@ test_setting_metadata(void)
|
|||
GArray *property_types_data;
|
||||
guint prop_idx_val;
|
||||
gboolean can_set_including_default = FALSE;
|
||||
gboolean can_have_direct_hook = FALSE;
|
||||
int n_special_options;
|
||||
|
||||
g_assert(sip->name);
|
||||
|
||||
|
|
@ -4489,6 +4491,22 @@ test_setting_metadata(void)
|
|||
|
||||
g_assert_cmpint(pspec->maximum, <=, (guint64) G_MAXUINT32);
|
||||
|
||||
can_set_including_default = TRUE;
|
||||
} else if (sip->property_type->direct_type == NM_VALUE_TYPE_INT64) {
|
||||
const GParamSpecInt64 *pspec;
|
||||
|
||||
g_assert(sip->property_type == &nm_sett_info_propert_type_direct_int64);
|
||||
g_assert(g_variant_type_equal(sip->property_type->dbus_type, "x"));
|
||||
g_assert(sip->property_type->to_dbus_fcn
|
||||
== _nm_setting_property_to_dbus_fcn_direct);
|
||||
g_assert(sip->param_spec);
|
||||
g_assert(sip->param_spec->value_type == G_TYPE_INT64);
|
||||
|
||||
pspec = NM_G_PARAM_SPEC_CAST_INT64(sip->param_spec);
|
||||
g_assert_cmpint(pspec->minimum, <=, pspec->maximum);
|
||||
g_assert_cmpint(pspec->default_value, >=, pspec->minimum);
|
||||
g_assert_cmpint(pspec->default_value, <=, pspec->maximum);
|
||||
|
||||
can_set_including_default = TRUE;
|
||||
} else if (sip->property_type->direct_type == NM_VALUE_TYPE_UINT64) {
|
||||
const GParamSpecUInt64 *pspec;
|
||||
|
|
@ -4555,6 +4573,7 @@ test_setting_metadata(void)
|
|||
g_assert(g_variant_type_equal(sip->property_type->dbus_type, "s"));
|
||||
g_assert(sip->property_type->to_dbus_fcn
|
||||
== _nm_setting_property_to_dbus_fcn_direct);
|
||||
can_have_direct_hook = TRUE;
|
||||
}
|
||||
g_assert(sip->param_spec);
|
||||
g_assert(sip->param_spec->value_type == G_TYPE_STRING);
|
||||
|
|
@ -4569,6 +4588,13 @@ test_setting_metadata(void)
|
|||
|
||||
if (sip->direct_set_string_ascii_strdown)
|
||||
g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
if (sip->direct_set_string_strip)
|
||||
g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
if (sip->direct_string_is_refstr) {
|
||||
g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
g_assert(sip->param_spec);
|
||||
g_assert(!NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_SECRET));
|
||||
}
|
||||
|
||||
if (sip->direct_set_string_mac_address_len != 0) {
|
||||
g_assert(NM_IN_SET(sip->property_type,
|
||||
|
|
@ -4577,10 +4603,38 @@ test_setting_metadata(void)
|
|||
g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
}
|
||||
|
||||
g_assert(((sip->direct_set_string_mac_address_len != 0)
|
||||
+ (!!sip->direct_set_string_ascii_strdown)
|
||||
+ (sip->direct_set_string_ip_address_addr_family != 0))
|
||||
<= 1);
|
||||
if (!can_have_direct_hook)
|
||||
g_assert(!sip->direct_hook.set_string_fcn);
|
||||
|
||||
n_special_options = (sip->direct_set_string_mac_address_len != 0)
|
||||
+ (!!sip->direct_set_string_strip)
|
||||
+ (!!sip->direct_set_string_ascii_strdown)
|
||||
+ (sip->direct_set_string_ip_address_addr_family != 0)
|
||||
+ (!!sip->direct_string_is_refstr);
|
||||
|
||||
G_STATIC_ASSERT_EXPR(AF_UNSPEC + 1 != 0);
|
||||
g_assert(NM_IN_SET((int) sip->direct_set_string_ip_address_addr_family,
|
||||
0,
|
||||
AF_UNSPEC + 1,
|
||||
AF_INET + 1,
|
||||
AF_INET6 + 1));
|
||||
|
||||
if (sip->direct_set_string_ip_address_addr_family == 0)
|
||||
g_assert(!sip->direct_set_string_ip_address_addr_family_map_zero_to_null);
|
||||
|
||||
/* currently, we have no cases where special options are mixed. There is no problem to support
|
||||
* that, but as it's not needed, don't do it for now. */
|
||||
g_assert_cmpint(n_special_options, <=, 1);
|
||||
|
||||
if (n_special_options > 0) {
|
||||
/* currently, special options are only relevant for string properties. */
|
||||
g_assert(sip->property_type->direct_type == NM_VALUE_TYPE_STRING);
|
||||
}
|
||||
|
||||
if (sip->param_spec && NM_FLAGS_HAS(sip->param_spec->flags, NM_SETTING_PARAM_SECRET)) {
|
||||
/* Currently, special options are not supported for secrets. */
|
||||
g_assert_cmpint(n_special_options, ==, 0);
|
||||
}
|
||||
|
||||
if (!sip->property_type->to_dbus_fcn) {
|
||||
/* it's allowed to have no to_dbus_fcn(), to ignore a property. But such
|
||||
|
|
@ -4703,9 +4757,10 @@ check_done:;
|
|||
NULL);
|
||||
g_assert(!NM_G_PARAM_SPEC_GET_DEFAULT_STRING(sip->param_spec));
|
||||
|
||||
if (nm_streq(sip->name, NM_SETTING_NAME))
|
||||
if (nm_streq(sip->name, NM_SETTING_NAME)) {
|
||||
g_assert_cmpstr(g_value_get_string(&val), ==, msi->setting_name);
|
||||
else
|
||||
g_assert(sip->property_type == &nm_sett_info_propert_type_setting_name);
|
||||
} else
|
||||
g_assert_cmpstr(g_value_get_string(&val), ==, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -4850,23 +4905,6 @@ check_done:;
|
|||
!= 0)
|
||||
continue;
|
||||
|
||||
if ((pt == &nm_sett_info_propert_type_plain_i
|
||||
&& pt_2 == &nm_sett_info_propert_type_deprecated_ignore_i)
|
||||
|| (pt_2 == &nm_sett_info_propert_type_plain_i
|
||||
&& pt == &nm_sett_info_propert_type_deprecated_ignore_i)
|
||||
|| (pt == &nm_sett_info_propert_type_plain_u
|
||||
&& pt_2 == &nm_sett_info_propert_type_deprecated_ignore_u)
|
||||
|| (pt_2 == &nm_sett_info_propert_type_plain_u
|
||||
&& pt == &nm_sett_info_propert_type_deprecated_ignore_u)) {
|
||||
/* These are known to be duplicated. This is the case for
|
||||
* "gsm.network-type" and plain properties like "802-11-wireless-security.fils" ("i" D-Bus type)
|
||||
* "gsm.allowed-bands" and plain properties like "802-11-olpc-mesh.channel" ("u" D-Bus type)
|
||||
* While the content/behaviour of the property types are identical, their purpose
|
||||
* is different. So allow them.
|
||||
*/
|
||||
continue;
|
||||
}
|
||||
|
||||
/* the property-types with same content should all be shared. Here we have two that
|
||||
* are the same content, but different instances. Bug. */
|
||||
g_error("The identical property type for D-Bus type \"%s\" is used by: %s and %s. "
|
||||
|
|
|
|||
|
|
@ -746,8 +746,37 @@ struct _NMSettInfoProperty {
|
|||
|
||||
GParamSpec *param_spec;
|
||||
|
||||
/* We want that our properties follow a small number of "default" types
|
||||
* and behaviors. For example, we have int32 and string properties, but
|
||||
* most properties of a certain type should behave in a similar way.
|
||||
*
|
||||
* That common behavior is realized via the property_type, which defines
|
||||
* general behaviors for the property.
|
||||
*
|
||||
* Note that we still will need some property-specific additional tweaks.
|
||||
* Of course, the name and param_spec are per-property. But below there are
|
||||
* also flags and hooks, that can augment the behavior in the property_type.
|
||||
* For example, the property_type in general might be of type string, but
|
||||
* then we might want for some properties that the setter will strip
|
||||
* whitespace. That is for example express with the flag direct_set_string_strip,
|
||||
* which now is per-property-info, and no longer per-property-type.
|
||||
*
|
||||
* The distinction between those two is fixed. At the most extreme, we could
|
||||
* move all fields from property_type to NMSettInfoProperty or we could move
|
||||
* behavioral tweaks into the classes themselves. It's chosen this way so
|
||||
* that we still have sensible common behaviors (string type), but minor
|
||||
* tweaks are per property-info (and don't require a separate property-type). */
|
||||
const NMSettInfoPropertType *property_type;
|
||||
|
||||
union {
|
||||
/* Optional hook for direct string properties, this gets called when setting the string.
|
||||
* Return whether the value changed. */
|
||||
gboolean (*set_string_fcn)(const NMSettInfoSetting *sett_info,
|
||||
const NMSettInfoProperty *property_info,
|
||||
NMSetting *setting,
|
||||
const char *src);
|
||||
} direct_hook;
|
||||
|
||||
/* This only has meaning for direct properties (property_type->direct_type != NM_VALUE_TYPE_UNSPEC).
|
||||
* In that case, this is the offset where _nm_setting_get_private() can find
|
||||
* the direct location. */
|
||||
|
|
@ -757,16 +786,30 @@ struct _NMSettInfoProperty {
|
|||
* normalize the string via g_ascii_strdown(). */
|
||||
bool direct_set_string_ascii_strdown : 1;
|
||||
|
||||
/* If TRUE, this is a NM_VALUE_TYPE_STRING direct property, and the setter will
|
||||
* normalize the string via g_strstrip(). */
|
||||
bool direct_set_string_strip : 1;
|
||||
|
||||
/* If non-zero, this is a NM_VALUE_TYPE_STRING direct property. Actually, it is
|
||||
* a _nm_setting_property_define_direct_mac_address(), and the setter will
|
||||
* call _nm_utils_hwaddr_canonical_or_invalid() on the string, with the specified
|
||||
* MAC address length. */
|
||||
guint8 direct_set_string_mac_address_len : 5;
|
||||
|
||||
/* If non-zero, this is the addr-family (AF_INET/AF_INET6) for normalizing an IP
|
||||
* address. */
|
||||
/* If non-zero, this is the addr-family (AF_UNSPEC/AF_INET/AF_INET6) for normalizing an IP
|
||||
* address with _nm_utils_ipaddr_canonical_or_invalid().
|
||||
* Note that AF_UNSPEC is zero, so to differentiate between zero and AF_UNSPEC
|
||||
* this value is actually the address family + 1. So either zero or AF_UNSPEC+1, AF_INET+1,
|
||||
* or AF_INET6+1. */
|
||||
guint8 direct_set_string_ip_address_addr_family : 5;
|
||||
|
||||
/* Only makes sense together with direct_set_string_ip_address_addr_family. This flag
|
||||
* is passed to _nm_utils_ipaddr_canonical_or_invalid(). */
|
||||
bool direct_set_string_ip_address_addr_family_map_zero_to_null : 1;
|
||||
|
||||
/* Whether the string property is implemented as a (downcast) NMRefString. */
|
||||
bool direct_string_is_refstr : 1;
|
||||
|
||||
/* Usually, properties that are set to the default value for the GParamSpec
|
||||
* are not serialized to GVariant (and NULL is returned by to_dbus_data().
|
||||
* Set this flag to force always converting the property even if the value
|
||||
|
|
@ -846,6 +889,20 @@ _nm_setting_get_private(NMSetting *self, const NMSettInfoSetting *sett_info, gui
|
|||
return ((((char *) ((gpointer) self)) + sett_info->private_offset) + offset);
|
||||
}
|
||||
|
||||
static inline gpointer
|
||||
_nm_setting_get_private_field(NMSetting *self,
|
||||
const NMSettInfoSetting *sett_info,
|
||||
const NMSettInfoProperty *prop_info)
|
||||
{
|
||||
nm_assert(sett_info);
|
||||
nm_assert(prop_info);
|
||||
nm_assert(prop_info->property_type);
|
||||
nm_assert(prop_info->property_type->direct_type > NM_VALUE_TYPE_UNSPEC);
|
||||
nm_assert(sett_info->private_offset != 0 || prop_info->direct_offset != 0);
|
||||
|
||||
return _nm_setting_get_private(self, sett_info, prop_info->direct_offset);
|
||||
}
|
||||
|
||||
static inline const NMSettInfoProperty *
|
||||
_nm_sett_info_property_info_get_sorted(const NMSettInfoSetting *sett_info, guint16 idx)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1057,6 +1057,27 @@ nm_strstrip(char *str)
|
|||
return str ? g_strstrip(str) : NULL;
|
||||
}
|
||||
|
||||
static inline char *
|
||||
nm_strstrip_dup(const char *str)
|
||||
{
|
||||
gsize l;
|
||||
char *s;
|
||||
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
str = nm_str_skip_leading_spaces(str);
|
||||
l = strlen(str);
|
||||
|
||||
while (l > 0 && g_ascii_isspace(str[l - 1]))
|
||||
l--;
|
||||
|
||||
s = g_new(char, l + 1);
|
||||
memcpy(s, str, l);
|
||||
s[l] = '\0';
|
||||
return s;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
nm_strstrip_avoid_copy(const char *str, char **str_free)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -172,6 +172,48 @@ nm_ref_string_new_len(const char *cstr, gsize len)
|
|||
return rstr;
|
||||
}
|
||||
|
||||
/**
|
||||
* nmtst_ref_string_find_len:
|
||||
* @cstr: the string to find.
|
||||
* @len: length of @cstr.
|
||||
*
|
||||
* Returns: (transfer none): %NULL, if the string is currently
|
||||
* not interned. Otherwise a reference to the interned string.
|
||||
* Beware: this does not return ownership of the reference,
|
||||
* it is thus not thread safe. Only use this from unit tests
|
||||
* when you know that your thread holds a reference to the string
|
||||
* to keep it alive. Otherwise, this might be a dangling pointer.
|
||||
*/
|
||||
NMRefString *
|
||||
nmtst_ref_string_find_len(const char *cstr, gsize len)
|
||||
{
|
||||
NMRefString *rstr = NULL;
|
||||
|
||||
/* @len cannot be close to G_MAXSIZE. For one, that would mean our call
|
||||
* to malloc() below overflows. Also, we use G_MAXSIZE as special length
|
||||
* to indicate using _priv_lookup. */
|
||||
nm_assert(len < G_MAXSIZE - G_STRUCT_OFFSET(NMRefString, str) - 1u);
|
||||
|
||||
G_LOCK(gl_lock);
|
||||
|
||||
if (G_LIKELY(gl_hash)) {
|
||||
NMRefString rr_lookup = {
|
||||
.len = G_MAXSIZE,
|
||||
._priv_lookup =
|
||||
{
|
||||
.l_len = len,
|
||||
.l_str = cstr,
|
||||
},
|
||||
};
|
||||
|
||||
rstr = g_hash_table_lookup(gl_hash, &rr_lookup);
|
||||
}
|
||||
|
||||
G_UNLOCK(gl_lock);
|
||||
|
||||
return rstr;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_ref_string_unref_slow_path(NMRefString *rstr)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -46,6 +46,19 @@ nm_ref_string_new(const char *cstr)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
NMRefString *nmtst_ref_string_find_len(const char *cstr, gsize len);
|
||||
|
||||
static inline NMRefString *
|
||||
nmtst_ref_string_find(const char *cstr)
|
||||
{
|
||||
/* WARNING: only use for testing. See nmtst_ref_string_find_len() why. */
|
||||
if (!cstr)
|
||||
return FALSE;
|
||||
return nmtst_ref_string_find_len(cstr, strlen(cstr));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline NMRefString *
|
||||
nm_ref_string_ref(NMRefString *rstr)
|
||||
{
|
||||
|
|
@ -164,24 +177,63 @@ nm_ref_string_unref_upcast(const char *str)
|
|||
nm_ref_string_unref(NM_REF_STRING_UPCAST(str));
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_ref_string_reset_str_upcast:
|
||||
* @ptr: the destination pointer that gets updated.
|
||||
* @str: the new string to be set.
|
||||
*
|
||||
* @ptr is a location (destination pointer) of an "upcast" NMRefString.
|
||||
* That is, it holds either %NULL or some ((NMRefString *) rstr)->str.
|
||||
* In other words, @ptr holds an NMRefString which you could get via
|
||||
* NM_REF_STRING_UPCAST(*ptr).
|
||||
* This function resets @ptr to point to a NMRefString equal to @str.
|
||||
*
|
||||
* Returns: %TRUE if the pointer changed and %FALSE if the value was
|
||||
* already set to a string equal to @str.
|
||||
*/
|
||||
static inline gboolean
|
||||
nm_ref_string_reset_str_upcast(const char **ptr, const char *str)
|
||||
{
|
||||
NMRefString *rstr;
|
||||
gsize l;
|
||||
|
||||
nm_assert(ptr);
|
||||
|
||||
if (!str)
|
||||
return nm_clear_pointer(ptr, nm_ref_string_unref_upcast);
|
||||
|
||||
rstr = NM_REF_STRING_UPCAST(*ptr);
|
||||
|
||||
l = strlen(str);
|
||||
|
||||
if (rstr && rstr->len == l && (rstr->str == str || memcmp(rstr->str, str, l) == 0))
|
||||
return FALSE;
|
||||
|
||||
*ptr = nm_ref_string_new_len(str, l)->str;
|
||||
nm_ref_string_unref(rstr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_ref_string_reset_str(NMRefString **ptr, const char *str)
|
||||
{
|
||||
nm_auto_ref_string NMRefString *rstr = NULL;
|
||||
gsize l;
|
||||
NMRefString *rstr;
|
||||
gsize l;
|
||||
|
||||
nm_assert(ptr);
|
||||
|
||||
if (!str)
|
||||
return nm_clear_pointer(ptr, nm_ref_string_unref);
|
||||
|
||||
rstr = *ptr;
|
||||
|
||||
l = strlen(str);
|
||||
|
||||
if ((*ptr) && (*ptr)->len == l && ((*ptr)->str == str || memcmp((*ptr)->str, str, l) == 0))
|
||||
if (rstr && rstr->len == l && (rstr->str == str || memcmp(rstr->str, str, l) == 0))
|
||||
return FALSE;
|
||||
|
||||
rstr = *ptr;
|
||||
*ptr = nm_ref_string_new_len(str, l);
|
||||
nm_ref_string_unref(rstr);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,22 @@ char *nm_secret_strchomp(char *secret);
|
|||
|
||||
void nm_free_secret(char *secret);
|
||||
|
||||
static inline gboolean
|
||||
nm_strdup_reset_secret(char **dst, const char *src)
|
||||
{
|
||||
char *old;
|
||||
|
||||
nm_assert(dst);
|
||||
|
||||
if (nm_streq0(*dst, src))
|
||||
return FALSE;
|
||||
old = *dst;
|
||||
*dst = src ? g_strdup(src) : NULL;
|
||||
if (old)
|
||||
nm_free_secret(old);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
NM_AUTO_DEFINE_FCN0(char *, _nm_auto_free_secret, nm_free_secret);
|
||||
/**
|
||||
* nm_auto_free_secret:
|
||||
|
|
|
|||
|
|
@ -1458,6 +1458,8 @@ GParamSpec *nm_g_object_class_find_property_from_gtype(GType gtype, const char *
|
|||
_NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_INT, GParamSpecInt)
|
||||
#define NM_G_PARAM_SPEC_CAST_UINT(param_spec) \
|
||||
_NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_UINT, GParamSpecUInt)
|
||||
#define NM_G_PARAM_SPEC_CAST_INT64(param_spec) \
|
||||
_NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_INT64, GParamSpecInt64)
|
||||
#define NM_G_PARAM_SPEC_CAST_UINT64(param_spec) \
|
||||
_NM_G_PARAM_SPEC_CAST(param_spec, G_TYPE_UINT64, GParamSpecUInt64)
|
||||
#define NM_G_PARAM_SPEC_CAST_ENUM(param_spec) \
|
||||
|
|
@ -1473,6 +1475,8 @@ GParamSpec *nm_g_object_class_find_property_from_gtype(GType gtype, const char *
|
|||
(NM_G_PARAM_SPEC_CAST_INT(NM_ENSURE_NOT_NULL(param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_UINT(param_spec) \
|
||||
(NM_G_PARAM_SPEC_CAST_UINT(NM_ENSURE_NOT_NULL(param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_INT64(param_spec) \
|
||||
(NM_G_PARAM_SPEC_CAST_INT64(NM_ENSURE_NOT_NULL(param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_UINT64(param_spec) \
|
||||
(NM_G_PARAM_SPEC_CAST_UINT64(NM_ENSURE_NOT_NULL(param_spec))->default_value)
|
||||
#define NM_G_PARAM_SPEC_GET_DEFAULT_ENUM(param_spec) \
|
||||
|
|
|
|||
|
|
@ -182,6 +182,23 @@
|
|||
} \
|
||||
G_STMT_END
|
||||
|
||||
#define nmtst_assert_strv(strv, ...) \
|
||||
G_STMT_START \
|
||||
{ \
|
||||
const char *const *const _strv = (strv); \
|
||||
const char *const _exp[] = {__VA_ARGS__, NULL}; \
|
||||
const gsize _n = G_N_ELEMENTS(_exp) - 1; \
|
||||
gsize _i; \
|
||||
\
|
||||
g_assert(_n == NM_NARG(__VA_ARGS__)); \
|
||||
g_assert(_strv); \
|
||||
for (_i = 0; _i < _n; _i++) { \
|
||||
g_assert(_exp[_i]); \
|
||||
g_assert_cmpstr(_strv[_i], ==, _exp[_i]); \
|
||||
} \
|
||||
} \
|
||||
G_STMT_END
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Our nm-error error numbers use negative values to signal failure.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue