mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-28 18:00:10 +01:00
libnm-core: add NMSetting property transforms, improve object property types [bgo #734492]
This commit is contained in:
commit
fa0fde04fa
128 changed files with 4362 additions and 4534 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -137,6 +137,7 @@ valgrind-*.log
|
|||
/libgsystem/
|
||||
|
||||
/libnm-core/nm-version.h
|
||||
/libnm-core/tests/test-compare
|
||||
/libnm-core/tests/test-crypto
|
||||
/libnm-core/tests/test-settings-defaults
|
||||
/libnm-core/tests/test-general
|
||||
|
|
|
|||
|
|
@ -2456,34 +2456,23 @@ is_setting_mandatory (NMConnection *connection, NMSetting *setting)
|
|||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
static gboolean
|
||||
check_and_convert_mac (const char *mac,
|
||||
GByteArray **mac_array,
|
||||
int type,
|
||||
const char *keyword,
|
||||
GError **error)
|
||||
check_mac (const char *mac,
|
||||
int type,
|
||||
const char *keyword,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *local_mac_array = NULL;
|
||||
|
||||
g_return_val_if_fail (mac_array == NULL || *mac_array == NULL, FALSE);
|
||||
g_return_val_if_fail (type == ARPHRD_ETHER || type == ARPHRD_INFINIBAND, FALSE);
|
||||
|
||||
if (!mac)
|
||||
return TRUE;
|
||||
|
||||
local_mac_array = nm_utils_hwaddr_atoba (mac, nm_utils_hwaddr_len (type));
|
||||
if (!local_mac_array) {
|
||||
if (!nm_utils_hwaddr_valid (mac, type)) {
|
||||
g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
|
||||
_("Error: '%s': '%s' is not a valid %s MAC address."),
|
||||
keyword, mac, type == ARPHRD_INFINIBAND ? _("InfiniBand") : _("Ethernet"));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (mac_array)
|
||||
*mac_array = local_mac_array;
|
||||
else
|
||||
if (local_mac_array)
|
||||
g_byte_array_free (local_mac_array, TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -2879,7 +2868,7 @@ do_questionnaire_ethernet (gboolean ethernet, char **mtu, char **mac, char **clo
|
|||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_readline (_("MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*mac, NULL, ARPHRD_ETHER, "mac", &error);
|
||||
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -2890,7 +2879,7 @@ do_questionnaire_ethernet (gboolean ethernet, char **mtu, char **mac, char **clo
|
|||
if (!*cloned_mac) {
|
||||
do {
|
||||
*cloned_mac = nmc_readline (_("Cloned MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*cloned_mac, NULL, ARPHRD_ETHER, "cloned-mac", &error);
|
||||
once_more = !check_mac (*cloned_mac, ARPHRD_ETHER, "cloned-mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -2927,7 +2916,7 @@ do_questionnaire_infiniband (char **mtu, char **mac, char **mode, char **parent,
|
|||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_readline (_("MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*mac, NULL, ARPHRD_INFINIBAND, "mac", &error);
|
||||
once_more = !check_mac (*mac, ARPHRD_INFINIBAND, "mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -2997,7 +2986,7 @@ do_questionnaire_wimax (char **mac)
|
|||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_readline (_("MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*mac, NULL, ARPHRD_ETHER, "mac", &error);
|
||||
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -3036,7 +3025,7 @@ do_questionnaire_pppoe (char **password, char **service, char **mtu, char **mac)
|
|||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_readline (_("MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*mac, NULL, ARPHRD_ETHER, "mac", &error);
|
||||
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -3391,7 +3380,7 @@ do_questionnaire_bridge (char **stp, char **priority, char **fwd_delay, char **h
|
|||
if (!*mac) {
|
||||
do {
|
||||
*mac = nmc_get_user_input (_("MAC [none]: "));
|
||||
once_more = !check_and_convert_mac (*mac, NULL, ARPHRD_ETHER, "mac", &error);
|
||||
once_more = !check_mac (*mac, ARPHRD_ETHER, "mac", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -3490,7 +3479,7 @@ do_questionnaire_olpc (char **channel, char **dhcp_anycast)
|
|||
if (!*dhcp_anycast) {
|
||||
do {
|
||||
*dhcp_anycast = nmc_readline (_("DHCP anycast MAC address [none]: "));
|
||||
once_more = !check_and_convert_mac (*dhcp_anycast, NULL, ARPHRD_ETHER, "dhcp-anycast", &error);
|
||||
once_more = !check_mac (*dhcp_anycast, ARPHRD_ETHER, "dhcp-anycast", &error);
|
||||
if (once_more) {
|
||||
printf ("%s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
|
|
@ -3635,8 +3624,6 @@ complete_connection_by_type (NMConnection *connection,
|
|||
char *mac = NULL;
|
||||
const char *cloned_mac_c = NULL;
|
||||
char *cloned_mac = NULL;
|
||||
GByteArray *array = NULL;
|
||||
GByteArray *cloned_array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"mtu", TRUE, &mtu_c, FALSE},
|
||||
{"mac", TRUE, &mac_c, FALSE},
|
||||
{"cloned-mac", TRUE, &cloned_mac_c, FALSE},
|
||||
|
|
@ -3654,9 +3641,9 @@ complete_connection_by_type (NMConnection *connection,
|
|||
|
||||
if (!check_and_convert_mtu (mtu, &mtu_int, error))
|
||||
goto cleanup_wired;
|
||||
if (!check_and_convert_mac (mac, &array, ARPHRD_ETHER, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_ETHER, "mac", error))
|
||||
goto cleanup_wired;
|
||||
if (!check_and_convert_mac (cloned_mac, &cloned_array, ARPHRD_ETHER, "cloned-mac", error))
|
||||
if (!check_mac (cloned_mac, ARPHRD_ETHER, "cloned-mac", error))
|
||||
goto cleanup_wired;
|
||||
|
||||
/* Add ethernet setting */
|
||||
|
|
@ -3665,20 +3652,16 @@ complete_connection_by_type (NMConnection *connection,
|
|||
|
||||
if (mtu)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu_int, NULL);
|
||||
if (array)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, array, NULL);
|
||||
if (cloned_array)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, cloned_array, NULL);
|
||||
if (mac)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
|
||||
if (cloned_mac)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, cloned_mac, NULL);
|
||||
|
||||
success = TRUE;
|
||||
cleanup_wired:
|
||||
g_free (mtu);
|
||||
g_free (mac);
|
||||
g_free (cloned_mac);
|
||||
if (array)
|
||||
g_byte_array_free (array, TRUE);
|
||||
if (cloned_array)
|
||||
g_byte_array_free (cloned_array, TRUE);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -3690,7 +3673,6 @@ cleanup_wired:
|
|||
guint32 mtu_int = 0;
|
||||
const char *mac_c = NULL;
|
||||
char *mac = NULL;
|
||||
GByteArray *array = NULL;
|
||||
const char *mode_c = NULL;
|
||||
char *mode = NULL;
|
||||
const char *parent_c = NULL;
|
||||
|
|
@ -3719,7 +3701,7 @@ cleanup_wired:
|
|||
|
||||
if (!check_and_convert_mtu (mtu, &mtu_int, error))
|
||||
goto cleanup_ib;
|
||||
if (!check_and_convert_mac (mac, &array, ARPHRD_INFINIBAND, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_INFINIBAND, "mac", error))
|
||||
goto cleanup_ib;
|
||||
if (!check_infiniband_mode (&mode, error))
|
||||
goto cleanup_ib;
|
||||
|
|
@ -3741,10 +3723,8 @@ cleanup_wired:
|
|||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_TRANSPORT_MODE, mode ? mode : "datagram", NULL);
|
||||
if (mtu)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MTU, mtu_int, NULL);
|
||||
if (array) {
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
if (mac)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NULL);
|
||||
if (p_key)
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_P_KEY, p_key_int, NULL);
|
||||
if (parent)
|
||||
|
|
@ -3772,10 +3752,8 @@ cleanup_ib:
|
|||
guint32 mtu_int = 0;
|
||||
const char *mac_c = NULL;
|
||||
char *mac = NULL;
|
||||
GByteArray *mac_array = NULL;
|
||||
const char *cloned_mac_c = NULL;
|
||||
char *cloned_mac = NULL;
|
||||
GByteArray *cloned_mac_array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"ssid", TRUE, &ssid, !ask},
|
||||
{"mtu", TRUE, &mtu_c, FALSE},
|
||||
{"mac", TRUE, &mac_c, FALSE},
|
||||
|
|
@ -3802,9 +3780,9 @@ cleanup_ib:
|
|||
|
||||
if (!check_and_convert_mtu (mtu, &mtu_int, error))
|
||||
goto cleanup_wifi;
|
||||
if (!check_and_convert_mac (mac, &mac_array, ARPHRD_ETHER, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_ETHER, "mac", error))
|
||||
goto cleanup_wifi;
|
||||
if (!check_and_convert_mac (cloned_mac, &cloned_mac_array, ARPHRD_ETHER, "cloned-mac", error))
|
||||
if (!check_mac (cloned_mac, ARPHRD_ETHER, "cloned-mac", error))
|
||||
goto cleanup_wifi;
|
||||
|
||||
/* Add wifi setting */
|
||||
|
|
@ -3817,10 +3795,10 @@ cleanup_ib:
|
|||
|
||||
if (mtu)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_MTU, mtu_int, NULL);
|
||||
if (mac_array)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, mac_array, NULL);
|
||||
if (cloned_mac_array)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, cloned_mac_array, NULL);
|
||||
if (mac)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_MAC_ADDRESS, mac, NULL);
|
||||
if (cloned_mac)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, cloned_mac, NULL);
|
||||
|
||||
success = TRUE;
|
||||
cleanup_wifi:
|
||||
|
|
@ -3830,10 +3808,6 @@ cleanup_wifi:
|
|||
g_free (cloned_mac);
|
||||
if (ssid_arr)
|
||||
g_byte_array_free (ssid_arr, TRUE);
|
||||
if (mac_array)
|
||||
g_byte_array_free (mac_array, TRUE);
|
||||
if (cloned_mac_array)
|
||||
g_byte_array_free (cloned_mac_array, TRUE);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -3844,7 +3818,6 @@ cleanup_wifi:
|
|||
char *nsp_name_ask = NULL;
|
||||
const char *mac_c = NULL;
|
||||
char *mac = NULL;
|
||||
GByteArray *mac_array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"nsp", TRUE, &nsp_name, !ask},
|
||||
{"mac", TRUE, &mac_c, FALSE},
|
||||
{NULL} };
|
||||
|
|
@ -3865,7 +3838,7 @@ cleanup_wifi:
|
|||
if (ask)
|
||||
do_questionnaire_wimax (&mac);
|
||||
|
||||
if (!check_and_convert_mac (mac, &mac_array, ARPHRD_ETHER, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_ETHER, "mac", error))
|
||||
goto cleanup_wimax;
|
||||
|
||||
/* Add 'wimax' setting */
|
||||
|
|
@ -3873,10 +3846,8 @@ cleanup_wifi:
|
|||
nm_connection_add_setting (connection, NM_SETTING (s_wimax));
|
||||
g_object_set (s_wimax, NM_SETTING_WIMAX_NETWORK_NAME, nsp_name, NULL);
|
||||
|
||||
if (mac_array) {
|
||||
g_object_set (s_wimax, NM_SETTING_WIMAX_MAC_ADDRESS, mac_array, NULL);
|
||||
g_byte_array_free (mac_array, TRUE);
|
||||
}
|
||||
if (mac)
|
||||
g_object_set (s_wimax, NM_SETTING_WIMAX_MAC_ADDRESS, mac, NULL);
|
||||
|
||||
success = TRUE;
|
||||
cleanup_wimax:
|
||||
|
|
@ -3899,7 +3870,6 @@ cleanup_wimax:
|
|||
guint32 mtu_int = 0;
|
||||
const char *mac_c = NULL;
|
||||
char *mac = NULL;
|
||||
GByteArray *mac_array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"username", TRUE, &username, !ask},
|
||||
{"password", TRUE, &password_c, FALSE},
|
||||
{"service", TRUE, &service_c, FALSE},
|
||||
|
|
@ -3928,7 +3898,7 @@ cleanup_wimax:
|
|||
|
||||
if (!check_and_convert_mtu (mtu, &mtu_int, error))
|
||||
goto cleanup_pppoe;
|
||||
if (!check_and_convert_mac (mac, &mac_array, ARPHRD_ETHER, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_ETHER, "mac", error))
|
||||
goto cleanup_pppoe;
|
||||
|
||||
/* Add 'pppoe' setting */
|
||||
|
|
@ -3943,8 +3913,8 @@ cleanup_wimax:
|
|||
nm_connection_add_setting (connection, NM_SETTING (s_wired));
|
||||
if (mtu)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MTU, mtu_int, NULL);
|
||||
if (mac_array)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac_array, NULL);
|
||||
if (mac)
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
|
||||
|
||||
success = TRUE;
|
||||
cleanup_pppoe:
|
||||
|
|
@ -3953,8 +3923,6 @@ cleanup_pppoe:
|
|||
g_free (service);
|
||||
g_free (mtu);
|
||||
g_free (mac);
|
||||
if (mac_array)
|
||||
g_byte_array_free (mac_array, TRUE);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -4038,7 +4006,6 @@ cleanup_mobile:
|
|||
char *addr_ask = NULL;
|
||||
const char *bt_type_c = NULL;
|
||||
char *bt_type = NULL;
|
||||
GByteArray *array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"addr", TRUE, &addr, !ask},
|
||||
{"bt-type", TRUE, &bt_type_c, FALSE},
|
||||
{NULL} };
|
||||
|
|
@ -4053,7 +4020,7 @@ cleanup_mobile:
|
|||
_("Error: 'addr' is required."));
|
||||
return FALSE;
|
||||
}
|
||||
if (!check_and_convert_mac (addr, &array, ARPHRD_ETHER, "addr", error))
|
||||
if (!check_mac (addr, ARPHRD_ETHER, "addr", error))
|
||||
goto cleanup_bt;
|
||||
|
||||
/* Also ask for all optional arguments if '--ask' is specified. */
|
||||
|
|
@ -4069,10 +4036,8 @@ cleanup_mobile:
|
|||
s_bt = (NMSettingBluetooth *) nm_setting_bluetooth_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_bt));
|
||||
|
||||
if (array) {
|
||||
g_object_set (s_bt, NM_SETTING_BLUETOOTH_BDADDR, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
if (addr)
|
||||
g_object_set (s_bt, NM_SETTING_BLUETOOTH_BDADDR, addr, NULL);
|
||||
|
||||
/* 'dun' type requires adding 'gsm' or 'cdma' setting */
|
||||
if ( !strcmp (bt_type, NM_SETTING_BLUETOOTH_TYPE_DUN)
|
||||
|
|
@ -4517,7 +4482,6 @@ cleanup_team_slave:
|
|||
max_age_int, ageing_time_int;
|
||||
const char *mac_c = NULL;
|
||||
char *mac = NULL;
|
||||
GByteArray *mac_array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"stp", TRUE, &stp_c, FALSE},
|
||||
{"priority", TRUE, &priority_c, FALSE},
|
||||
{"forward-delay", TRUE, &fwd_delay_c, FALSE},
|
||||
|
|
@ -4588,7 +4552,7 @@ cleanup_team_slave:
|
|||
if (!bridge_prop_string_to_uint (ageing_time, "ageing-time", NM_TYPE_SETTING_BRIDGE,
|
||||
NM_SETTING_BRIDGE_AGEING_TIME, &ageing_time_int, error))
|
||||
goto cleanup_bridge;
|
||||
if (!check_and_convert_mac (mac, &mac_array, ARPHRD_ETHER, "mac", error))
|
||||
if (!check_mac (mac, ARPHRD_ETHER, "mac", error))
|
||||
goto cleanup_bridge;
|
||||
|
||||
/* Set bridge options */
|
||||
|
|
@ -4604,8 +4568,8 @@ cleanup_team_slave:
|
|||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MAX_AGE, max_age_int, NULL);
|
||||
if (ageing_time)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_AGEING_TIME, ageing_time_int, NULL);
|
||||
if (mac_array)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, mac_array, NULL);
|
||||
if (mac)
|
||||
g_object_set (s_bridge, NM_SETTING_BRIDGE_MAC_ADDRESS, mac, NULL);
|
||||
|
||||
success = TRUE;
|
||||
cleanup_bridge:
|
||||
|
|
@ -4616,8 +4580,6 @@ cleanup_bridge:
|
|||
g_free (max_age);
|
||||
g_free (ageing_time);
|
||||
g_free (mac);
|
||||
if (mac_array)
|
||||
g_byte_array_free (mac_array, TRUE);
|
||||
if (!success)
|
||||
return FALSE;
|
||||
|
||||
|
|
@ -4785,7 +4747,6 @@ cleanup_vpn:
|
|||
unsigned long chan;
|
||||
const char *dhcp_anycast_c = NULL;
|
||||
char *dhcp_anycast = NULL;
|
||||
GByteArray *array = NULL;
|
||||
nmc_arg_t exp_args[] = { {"ssid", TRUE, &ssid, !ask},
|
||||
{"channel", TRUE, &channel_c, FALSE},
|
||||
{"dhcp-anycast", TRUE, &dhcp_anycast_c, FALSE},
|
||||
|
|
@ -4816,7 +4777,7 @@ cleanup_vpn:
|
|||
goto cleanup_olpc;
|
||||
}
|
||||
}
|
||||
if (!check_and_convert_mac (dhcp_anycast, &array, ARPHRD_ETHER, "dhcp-anycast", error))
|
||||
if (!check_mac (dhcp_anycast, ARPHRD_ETHER, "dhcp-anycast", error))
|
||||
goto cleanup_olpc;
|
||||
|
||||
/* Add OLPC mesh setting */
|
||||
|
|
@ -4830,10 +4791,8 @@ cleanup_vpn:
|
|||
g_object_set (s_olpc_mesh, NM_SETTING_OLPC_MESH_CHANNEL, chan, NULL);
|
||||
else
|
||||
g_object_set (s_olpc_mesh, NM_SETTING_OLPC_MESH_CHANNEL, 1, NULL);
|
||||
if (array) {
|
||||
g_object_set (s_olpc_mesh, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
}
|
||||
if (dhcp_anycast)
|
||||
g_object_set (s_olpc_mesh, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, dhcp_anycast, NULL);
|
||||
g_byte_array_free (ssid_arr, TRUE);
|
||||
|
||||
success = TRUE;
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ fill_output_access_point (gpointer data, gpointer user_data)
|
|||
|
||||
/* Convert to strings */
|
||||
if (ssid) {
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid);
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
ssid_hex_str = ssid_to_hex ((const char *) ssid->data, ssid->len);
|
||||
}
|
||||
channel_str = g_strdup_printf ("%u", nm_utils_wifi_freq_to_channel (freq));
|
||||
|
|
@ -2052,7 +2052,8 @@ find_ap_on_device (NMDevice *device, GByteArray *bssid, const char *ssid)
|
|||
|
||||
candidate_ssid = nm_access_point_get_ssid (candidate_ap);
|
||||
if (candidate_ssid) {
|
||||
char *ssid_tmp = nm_utils_ssid_to_utf8 (candidate_ssid);
|
||||
char *ssid_tmp = nm_utils_ssid_to_utf8 (candidate_ssid->data,
|
||||
candidate_ssid->len);
|
||||
|
||||
/* Compare SSIDs */
|
||||
if (strcmp (ssid, ssid_tmp) == 0) {
|
||||
|
|
|
|||
|
|
@ -388,6 +388,88 @@ setup_signals (void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nmc_convert_strv_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
char **strings;
|
||||
|
||||
strings = g_value_get_boxed (src_value);
|
||||
if (strings)
|
||||
g_value_take_string (dest_value, g_strjoinv (",", strings));
|
||||
else
|
||||
g_value_set_string (dest_value, "");
|
||||
}
|
||||
|
||||
static void
|
||||
nmc_convert_string_hash_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GHashTable *hash;
|
||||
GHashTableIter iter;
|
||||
const char *key, *value;
|
||||
GString *string;
|
||||
|
||||
hash = (GHashTable *) g_value_get_boxed (src_value);
|
||||
|
||||
string = g_string_new (NULL);
|
||||
if (hash) {
|
||||
g_hash_table_iter_init (&iter, hash);
|
||||
while (g_hash_table_iter_next (&iter, (gpointer *) &key, (gpointer *) &value)) {
|
||||
if (string->len)
|
||||
g_string_append_c (string, ',');
|
||||
g_string_append_printf (string, "%s=%s", key, value);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (string, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
nmc_convert_bytes_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GBytes *bytes;
|
||||
const guint8 *array;
|
||||
gsize length;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
bytes = g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new ("[");
|
||||
|
||||
if (bytes) {
|
||||
array = g_bytes_get_data (bytes, &length);
|
||||
while (i < MIN (length, 35)) {
|
||||
if (i > 0)
|
||||
g_string_append_c (printable, ' ');
|
||||
g_string_append_printf (printable, "0x%02X", array[i++]);
|
||||
}
|
||||
if (i < length)
|
||||
g_string_append (printable, " ... ");
|
||||
}
|
||||
g_string_append_c (printable, ']');
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
nmc_value_transforms_register (void)
|
||||
{
|
||||
g_value_register_transform_func (G_TYPE_STRV,
|
||||
G_TYPE_STRING,
|
||||
nmc_convert_strv_to_string);
|
||||
|
||||
/* This depends on the fact that all of the hash-table-valued properties
|
||||
* in libnm-core are string->string.
|
||||
*/
|
||||
g_value_register_transform_func (G_TYPE_HASH_TABLE,
|
||||
G_TYPE_STRING,
|
||||
nmc_convert_string_hash_to_string);
|
||||
|
||||
g_value_register_transform_func (G_TYPE_BYTES,
|
||||
G_TYPE_STRING,
|
||||
nmc_convert_bytes_to_string);
|
||||
}
|
||||
|
||||
static NMClient *
|
||||
nmc_get_client (NmCli *nmc)
|
||||
{
|
||||
|
|
@ -496,6 +578,8 @@ main (int argc, char *argv[])
|
|||
*/
|
||||
rl_set_keyboard_input_timeout (10000);
|
||||
|
||||
nmc_value_transforms_register ();
|
||||
|
||||
nmc_init (&nm_cli);
|
||||
g_idle_add (start, &args_info);
|
||||
|
||||
|
|
|
|||
|
|
@ -663,19 +663,22 @@ wep_key_type_to_string (NMWepKeyType type)
|
|||
}
|
||||
|
||||
static char *
|
||||
byte_array_to_string (const GByteArray *array)
|
||||
bytes_to_string (GBytes *bytes)
|
||||
{
|
||||
const guint8 *data;
|
||||
gsize len;
|
||||
GString *cert = NULL;
|
||||
int i;
|
||||
|
||||
if (array && array->len > 0)
|
||||
cert = g_string_new (NULL);
|
||||
if (!bytes)
|
||||
return NULL;
|
||||
data = g_bytes_get_data (bytes, &len);
|
||||
|
||||
for (i = 0; array && i < array->len; i++) {
|
||||
g_string_append_printf (cert, "%02X", array->data[i]);
|
||||
}
|
||||
cert = g_string_new (NULL);
|
||||
for (i = 0; i < len; i++)
|
||||
g_string_append_printf (cert, "%02X", data[i]);
|
||||
|
||||
return cert ? g_string_free (cert, FALSE) : NULL;
|
||||
return g_string_free (cert, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
@ -789,9 +792,6 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
|
|||
GValue val = G_VALUE_INIT; \
|
||||
g_value_init (&val, G_TYPE_STRING); \
|
||||
g_object_get_property (G_OBJECT (setting), property_name, &val); \
|
||||
/* Getters return allocated values, and returning the string \
|
||||
* the GValue copied from the object without unsetting the \
|
||||
* GValue fulfills that requirement. */ \
|
||||
s = g_value_dup_string (&val); \
|
||||
g_value_unset (&val); \
|
||||
return s; \
|
||||
|
|
@ -810,22 +810,6 @@ vpn_data_item (const char *key, const char *value, gpointer user_data)
|
|||
return secret_flags_to_string (v); \
|
||||
}
|
||||
|
||||
#define DEFINE_HWADDR_GETTER(func_name, property_name) \
|
||||
static char * \
|
||||
func_name (NMSetting *setting) \
|
||||
{ \
|
||||
GValue val = G_VALUE_INIT; \
|
||||
GArray *array; \
|
||||
char *hwaddr = NULL; \
|
||||
g_value_init (&val, DBUS_TYPE_G_UCHAR_ARRAY); \
|
||||
g_object_get_property (G_OBJECT (setting), property_name, &val); \
|
||||
array = g_value_get_boxed (&val); \
|
||||
if (array && array->len) \
|
||||
hwaddr = nm_utils_hwaddr_ntoa (array->data, array->len); \
|
||||
g_value_unset (&val); \
|
||||
return hwaddr; \
|
||||
}
|
||||
|
||||
/* --- NM_SETTING_802_1X_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_802_1X_get_eap, NM_SETTING_802_1X_EAP)
|
||||
DEFINE_GETTER (nmc_property_802_1X_get_identity, NM_SETTING_802_1X_IDENTITY)
|
||||
|
|
@ -862,7 +846,7 @@ nmc_property_802_1X_get_ca_cert (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_ca_cert_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
ca_cert_str = byte_array_to_string (nm_setting_802_1x_get_ca_cert_blob (s_8021X));
|
||||
ca_cert_str = bytes_to_string (nm_setting_802_1x_get_ca_cert_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
ca_cert_str = g_strdup (nm_setting_802_1x_get_ca_cert_path (s_8021X));
|
||||
|
||||
|
|
@ -878,7 +862,7 @@ nmc_property_802_1X_get_client_cert (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_client_cert_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
client_cert_str = byte_array_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X));
|
||||
client_cert_str = bytes_to_string (nm_setting_802_1x_get_client_cert_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
client_cert_str = g_strdup (nm_setting_802_1x_get_client_cert_path (s_8021X));
|
||||
|
||||
|
|
@ -894,7 +878,7 @@ nmc_property_802_1X_get_phase2_ca_cert (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
phase2_ca_cert_str = byte_array_to_string (nm_setting_802_1x_get_phase2_ca_cert_blob (s_8021X));
|
||||
phase2_ca_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_ca_cert_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
phase2_ca_cert_str = g_strdup (nm_setting_802_1x_get_phase2_ca_cert_path (s_8021X));
|
||||
|
||||
|
|
@ -910,7 +894,7 @@ nmc_property_802_1X_get_phase2_client_cert (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
phase2_client_cert_str = byte_array_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X));
|
||||
phase2_client_cert_str = bytes_to_string (nm_setting_802_1x_get_phase2_client_cert_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
phase2_client_cert_str = g_strdup (nm_setting_802_1x_get_phase2_client_cert_path (s_8021X));
|
||||
|
||||
|
|
@ -921,7 +905,7 @@ static char *
|
|||
nmc_property_802_1X_get_password_raw (NMSetting *setting)
|
||||
{
|
||||
NMSetting8021x *s_8021X = NM_SETTING_802_1X (setting);
|
||||
return byte_array_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
|
||||
return bytes_to_string (nm_setting_802_1x_get_password_raw (s_8021X));
|
||||
}
|
||||
|
||||
static char *
|
||||
|
|
@ -933,7 +917,7 @@ nmc_property_802_1X_get_private_key (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_private_key_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
private_key_str = byte_array_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X));
|
||||
private_key_str = bytes_to_string (nm_setting_802_1x_get_private_key_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
private_key_str = g_strdup (nm_setting_802_1x_get_private_key_path (s_8021X));
|
||||
|
||||
|
|
@ -949,7 +933,7 @@ nmc_property_802_1X_get_phase2_private_key (NMSetting *setting)
|
|||
|
||||
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (s_8021X);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
phase2_private_key_str = byte_array_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X));
|
||||
phase2_private_key_str = bytes_to_string (nm_setting_802_1x_get_phase2_private_key_blob (s_8021X));
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
phase2_private_key_str = g_strdup (nm_setting_802_1x_get_phase2_private_key_path (s_8021X));
|
||||
|
||||
|
|
@ -966,7 +950,7 @@ DEFINE_GETTER (nmc_property_adsl_get_vpi, NM_SETTING_ADSL_VPI)
|
|||
DEFINE_GETTER (nmc_property_adsl_get_vci, NM_SETTING_ADSL_VCI)
|
||||
|
||||
/* --- NM_SETTING_BLUETOOTH_SETTING_NAME property get functions --- */
|
||||
DEFINE_HWADDR_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR)
|
||||
DEFINE_GETTER (nmc_property_bluetooth_get_bdaddr, NM_SETTING_BLUETOOTH_BDADDR)
|
||||
DEFINE_GETTER (nmc_property_bluetooth_get_type, NM_SETTING_BLUETOOTH_TYPE)
|
||||
|
||||
static char *
|
||||
|
|
@ -989,7 +973,7 @@ nmc_property_bond_get_options (NMSetting *setting)
|
|||
}
|
||||
|
||||
/* --- NM_SETTING_BRIDGE_SETTING_NAME property get functions --- */
|
||||
DEFINE_HWADDR_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_mac_address, NM_SETTING_BRIDGE_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_stp, NM_SETTING_BRIDGE_STP)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_priority, NM_SETTING_BRIDGE_PRIORITY)
|
||||
DEFINE_GETTER (nmc_property_bridge_get_forward_delay, NM_SETTING_BRIDGE_FORWARD_DELAY)
|
||||
|
|
@ -1181,7 +1165,7 @@ DEFINE_SECRET_FLAGS_GETTER (nmc_property_gsm_get_pin_flags, NM_SETTING_GSM_PIN_F
|
|||
DEFINE_GETTER (nmc_property_gsm_get_home_only, NM_SETTING_GSM_HOME_ONLY)
|
||||
|
||||
/* --- NM_SETTING_INFINIBAND_SETTING_NAME property get functions --- */
|
||||
DEFINE_HWADDR_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_ib_get_mac_address, NM_SETTING_INFINIBAND_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_ib_get_transport_mode, NM_SETTING_INFINIBAND_TRANSPORT_MODE)
|
||||
|
||||
static char *
|
||||
|
|
@ -1216,8 +1200,82 @@ DEFINE_GETTER (nmc_property_ib_get_parent, NM_SETTING_INFINIBAND_PARENT)
|
|||
DEFINE_GETTER (nmc_property_ipv4_get_method, NM_SETTING_IP4_CONFIG_METHOD)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_dns, NM_SETTING_IP4_CONFIG_DNS)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_dns_search, NM_SETTING_IP4_CONFIG_DNS_SEARCH)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_addresses, NM_SETTING_IP4_CONFIG_ADDRESSES)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_routes, NM_SETTING_IP4_CONFIG_ROUTES)
|
||||
|
||||
static char *
|
||||
nmc_property_ipv4_get_addresses (NMSetting *setting)
|
||||
{
|
||||
NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (setting);
|
||||
GString *printable;
|
||||
guint32 num_addresses, i;
|
||||
NMIP4Address *addr;
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
|
||||
num_addresses = nm_setting_ip4_config_get_num_addresses (s_ip4);
|
||||
for (i = 0; i < num_addresses; i++) {
|
||||
addr = nm_setting_ip4_config_get_address (s_ip4, i);
|
||||
|
||||
if (printable->len > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
|
||||
nm_utils_inet4_ntop (nm_ip4_address_get_address (addr), buf);
|
||||
g_string_append_printf (printable, "ip = %s", buf);
|
||||
|
||||
g_string_append_printf (printable, "/%u", nm_ip4_address_get_prefix (addr));
|
||||
|
||||
if (nm_ip4_address_get_gateway (addr)) {
|
||||
nm_utils_inet4_ntop (nm_ip4_address_get_gateway (addr), buf);
|
||||
g_string_append_printf (printable, ", gw = %s", buf);
|
||||
}
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
return g_string_free (printable, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
nmc_property_ipv4_get_routes (NMSetting *setting)
|
||||
{
|
||||
NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG (setting);
|
||||
GString *printable;
|
||||
guint32 num_routes, i;
|
||||
NMIP4Route *route;
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
|
||||
num_routes = nm_setting_ip4_config_get_num_routes (s_ip4);
|
||||
for (i = 0; i < num_routes; i++) {
|
||||
route = nm_setting_ip4_config_get_route (s_ip4, i);
|
||||
|
||||
if (printable->len > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
|
||||
nm_utils_inet4_ntop (nm_ip4_route_get_dest (route), buf);
|
||||
g_string_append_printf (printable, "ip = %s", buf);
|
||||
|
||||
g_string_append_printf (printable, "/%u", nm_ip4_route_get_prefix (route));
|
||||
|
||||
if (nm_ip4_route_get_next_hop (route)) {
|
||||
nm_utils_inet4_ntop (nm_ip4_route_get_next_hop (route), buf);
|
||||
g_string_append_printf (printable, ", nh = %s", buf);
|
||||
}
|
||||
|
||||
if (nm_ip4_route_get_metric (route))
|
||||
g_string_append_printf (printable, ", mt = %u", nm_ip4_route_get_metric (route));
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
return g_string_free (printable, FALSE);
|
||||
}
|
||||
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_routes, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_ROUTES)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_ignore_auto_dns, NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS)
|
||||
DEFINE_GETTER (nmc_property_ipv4_get_dhcp_client_id, NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID)
|
||||
|
|
@ -1230,8 +1288,82 @@ DEFINE_GETTER (nmc_property_ipv4_get_may_fail, NM_SETTING_IP4_CONFIG_MAY_FAIL)
|
|||
DEFINE_GETTER (nmc_property_ipv6_get_method, NM_SETTING_IP6_CONFIG_METHOD)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_dns, NM_SETTING_IP6_CONFIG_DNS)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_dns_search, NM_SETTING_IP6_CONFIG_DNS_SEARCH)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_addresses, NM_SETTING_IP6_CONFIG_ADDRESSES)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_routes, NM_SETTING_IP6_CONFIG_ROUTES)
|
||||
|
||||
static char *
|
||||
nmc_property_ipv6_get_addresses (NMSetting *setting)
|
||||
{
|
||||
NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
|
||||
GString *printable;
|
||||
guint32 num_addresses, i;
|
||||
NMIP6Address *addr;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
|
||||
num_addresses = nm_setting_ip6_config_get_num_addresses (s_ip6);
|
||||
for (i = 0; i < num_addresses; i++) {
|
||||
addr = nm_setting_ip6_config_get_address (s_ip6, i);
|
||||
|
||||
if (printable->len > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
|
||||
nm_utils_inet6_ntop (nm_ip6_address_get_address (addr), buf);
|
||||
g_string_append_printf (printable, "ip = %s", buf);
|
||||
|
||||
g_string_append_printf (printable, "/%u", nm_ip6_address_get_prefix (addr));
|
||||
|
||||
if (nm_ip6_address_get_gateway (addr)) {
|
||||
nm_utils_inet6_ntop (nm_ip6_address_get_gateway (addr), buf);
|
||||
g_string_append_printf (printable, ", gw = %s", buf);
|
||||
}
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
return g_string_free (printable, FALSE);
|
||||
}
|
||||
|
||||
static char *
|
||||
nmc_property_ipv6_get_routes (NMSetting *setting)
|
||||
{
|
||||
NMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (setting);
|
||||
GString *printable;
|
||||
guint32 num_routes, i;
|
||||
NMIP6Route *route;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
|
||||
num_routes = nm_setting_ip6_config_get_num_routes (s_ip6);
|
||||
for (i = 0; i < num_routes; i++) {
|
||||
route = nm_setting_ip6_config_get_route (s_ip6, i);
|
||||
|
||||
if (printable->len > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
|
||||
nm_utils_inet6_ntop (nm_ip6_route_get_dest (route), buf);
|
||||
g_string_append_printf (printable, "ip = %s", buf);
|
||||
|
||||
g_string_append_printf (printable, "/%u", nm_ip6_route_get_prefix (route));
|
||||
|
||||
if (nm_ip6_route_get_next_hop (route)) {
|
||||
nm_utils_inet6_ntop (nm_ip6_route_get_next_hop (route), buf);
|
||||
g_string_append_printf (printable, ", nh = %s", buf);
|
||||
}
|
||||
|
||||
if (nm_ip6_route_get_metric (route))
|
||||
g_string_append_printf (printable, ", mt = %u", nm_ip6_route_get_metric (route));
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
return g_string_free (printable, FALSE);
|
||||
}
|
||||
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_routes, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_ROUTES)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_ignore_auto_dns, NM_SETTING_IP6_CONFIG_IGNORE_AUTO_DNS)
|
||||
DEFINE_GETTER (nmc_property_ipv6_get_never_default, NM_SETTING_IP6_CONFIG_NEVER_DEFAULT)
|
||||
|
|
@ -1247,18 +1379,20 @@ nmc_property_ipv6_get_ip6_privacy (NMSetting *setting)
|
|||
|
||||
/* --- NM_SETTING_OLPC_MESH_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_olpc_get_channel, NM_SETTING_OLPC_MESH_CHANNEL)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_olpc_get_anycast_address, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS)
|
||||
|
||||
static char *
|
||||
nmc_property_olpc_get_ssid (NMSetting *setting)
|
||||
{
|
||||
NMSettingOlpcMesh *s_olpc_mesh = NM_SETTING_OLPC_MESH (setting);
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
char *ssid_str = NULL;
|
||||
|
||||
ssid = nm_setting_olpc_mesh_get_ssid (s_olpc_mesh);
|
||||
if (ssid)
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid);
|
||||
if (ssid) {
|
||||
ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
}
|
||||
|
||||
return ssid_str;
|
||||
}
|
||||
|
|
@ -1352,15 +1486,15 @@ nmc_property_vpn_get_secrets (NMSetting *setting)
|
|||
|
||||
/* --- NM_SETTING_WIMAX_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_wimax_get_network_name, NM_SETTING_WIMAX_NETWORK_NAME)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wimax_get_mac_address, NM_SETTING_WIMAX_MAC_ADDRESS)
|
||||
|
||||
/* --- NM_SETTING_WIRED_SETTING_NAME property get functions --- */
|
||||
DEFINE_GETTER (nmc_property_wired_get_port, NM_SETTING_WIRED_PORT)
|
||||
DEFINE_GETTER (nmc_property_wired_get_speed, NM_SETTING_WIRED_SPEED)
|
||||
DEFINE_GETTER (nmc_property_wired_get_duplex, NM_SETTING_WIRED_DUPLEX)
|
||||
DEFINE_GETTER (nmc_property_wired_get_auto_negotiate, NM_SETTING_WIRED_AUTO_NEGOTIATE)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wired_get_mac_address, NM_SETTING_WIRED_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wired_get_cloned_mac_address, NM_SETTING_WIRED_CLONED_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wired_get_mac_address_blacklist, NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST)
|
||||
DEFINE_GETTER (nmc_property_wired_get_s390_subchannels, NM_SETTING_WIRED_S390_SUBCHANNELS)
|
||||
DEFINE_GETTER (nmc_property_wired_get_s390_nettype, NM_SETTING_WIRED_S390_NETTYPE)
|
||||
|
|
@ -1383,11 +1517,11 @@ nmc_property_wired_get_mtu (NMSetting *setting)
|
|||
DEFINE_GETTER (nmc_property_wireless_get_mode, NM_SETTING_WIRELESS_MODE)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_band, NM_SETTING_WIRELESS_BAND)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_channel, NM_SETTING_WIRELESS_CHANNEL)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_bssid, NM_SETTING_WIRELESS_BSSID)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_rate, NM_SETTING_WIRELESS_RATE)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_tx_power, NM_SETTING_WIRELESS_TX_POWER)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS)
|
||||
DEFINE_HWADDR_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_mac_address, NM_SETTING_WIRELESS_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_cloned_mac_address, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_mac_address_blacklist, NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_seen_bssids, NM_SETTING_WIRELESS_SEEN_BSSIDS)
|
||||
DEFINE_GETTER (nmc_property_wireless_get_hidden, NM_SETTING_WIRELESS_HIDDEN)
|
||||
|
|
@ -1396,12 +1530,14 @@ static char *
|
|||
nmc_property_wireless_get_ssid (NMSetting *setting)
|
||||
{
|
||||
NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
char *ssid_str = NULL;
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
if (ssid)
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid);
|
||||
if (ssid) {
|
||||
ssid_str = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
}
|
||||
|
||||
return ssid_str;
|
||||
}
|
||||
|
|
@ -2061,18 +2197,14 @@ nmc_property_set_ssid (NMSetting *setting, const char *prop, const char *val, GE
|
|||
static gboolean
|
||||
nmc_property_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
GByteArray *array;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
array = nm_utils_hwaddr_atoba (val, ETH_ALEN);
|
||||
if (!array) {
|
||||
if (!nm_utils_hwaddr_valid (val, ETH_ALEN)) {
|
||||
g_set_error (error, 1, 0, _("'%s' is not a valid Ethernet MAC"), val);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_set (setting, prop, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
g_object_set (setting, prop, val, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -2830,18 +2962,14 @@ nmc_property_bond_allowed_options (NMSetting *setting, const char *prop)
|
|||
static gboolean
|
||||
nmc_property_ib_set_mac (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
GByteArray *array;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
array = nm_utils_hwaddr_atoba (val, INFINIBAND_ALEN);
|
||||
if (!array) {
|
||||
if (!nm_utils_hwaddr_valid (val, INFINIBAND_ALEN)) {
|
||||
g_set_error (error, 1, 0, _("'%s' is not a valid InfiniBand MAC"), val);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_object_set (setting, prop, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
g_object_set (setting, prop, val, NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -2909,19 +3037,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv4_allowed_method, ipv4_valid_methods)
|
|||
static gboolean
|
||||
nmc_property_ipv4_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
char **strv = NULL, **iter;
|
||||
char **strv = NULL, **iter, *addr;
|
||||
guint32 ip4_addr;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
strv = nmc_strsplit_set (val, " \t,", 0);
|
||||
for (iter = strv; iter && *iter; iter++) {
|
||||
if (inet_pton (AF_INET, g_strstrip (*iter), &ip4_addr) < 1) {
|
||||
g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), *iter);
|
||||
addr = g_strstrip (*iter);
|
||||
if (inet_pton (AF_INET, addr, &ip4_addr) < 1) {
|
||||
g_set_error (error, 1, 0, _("invalid IPv4 address '%s'"), addr);
|
||||
g_strfreev (strv);
|
||||
return FALSE;
|
||||
}
|
||||
nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), ip4_addr);
|
||||
nm_setting_ip4_config_add_dns (NM_SETTING_IP4_CONFIG (setting), addr);
|
||||
}
|
||||
g_strfreev (strv);
|
||||
return TRUE;
|
||||
|
|
@ -2940,7 +3069,7 @@ _validate_and_remove_ipv4_dns (NMSettingIP4Config *setting,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
ret = nm_setting_ip4_config_remove_dns_by_value (setting, ip4_addr);
|
||||
ret = nm_setting_ip4_config_remove_dns_by_value (setting, dns);
|
||||
if (!ret)
|
||||
g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
|
||||
return ret;
|
||||
|
|
@ -3254,19 +3383,20 @@ DEFINE_ALLOWED_VAL_FUNC (nmc_property_ipv6_allowed_method, ipv6_valid_methods)
|
|||
static gboolean
|
||||
nmc_property_ipv6_set_dns (NMSetting *setting, const char *prop, const char *val, GError **error)
|
||||
{
|
||||
char **strv = NULL, **iter;
|
||||
char **strv = NULL, **iter, *addr;
|
||||
struct in6_addr ip6_addr;
|
||||
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
strv = nmc_strsplit_set (val, " \t,", 0);
|
||||
for (iter = strv; iter && *iter; iter++) {
|
||||
if (inet_pton (AF_INET6, g_strstrip (*iter), &ip6_addr) < 1) {
|
||||
g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), *iter);
|
||||
addr = g_strstrip (*iter);
|
||||
if (inet_pton (AF_INET6, addr, &ip6_addr) < 1) {
|
||||
g_set_error (error, 1, 0, _("invalid IPv6 address '%s'"), addr);
|
||||
g_strfreev (strv);
|
||||
return FALSE;
|
||||
}
|
||||
nm_setting_ip6_config_add_dns (NM_SETTING_IP6_CONFIG (setting), &ip6_addr);
|
||||
nm_setting_ip6_config_add_dns (NM_SETTING_IP6_CONFIG (setting), addr);
|
||||
}
|
||||
g_strfreev (strv);
|
||||
return TRUE;
|
||||
|
|
@ -3285,7 +3415,7 @@ _validate_and_remove_ipv6_dns (NMSettingIP6Config *setting,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
ret = nm_setting_ip6_config_remove_dns_by_value (setting, &ip6_addr);
|
||||
ret = nm_setting_ip6_config_remove_dns_by_value (setting, dns);
|
||||
if (!ret)
|
||||
g_set_error (error, 1, 0, _("the property doesn't contain DNS server '%s'"), dns);
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ ip4_addresses_with_prefix_to_strv (GBinding *binding,
|
|||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *addrs;
|
||||
GArray *addr;
|
||||
NMIP4Address *addr;
|
||||
guint32 addrbytes, prefix;
|
||||
char buf[INET_ADDRSTRLEN], **strings;
|
||||
int i;
|
||||
|
|
@ -129,8 +129,8 @@ ip4_addresses_with_prefix_to_strv (GBinding *binding,
|
|||
|
||||
for (i = 0; i < addrs->len; i++) {
|
||||
addr = addrs->pdata[i];
|
||||
addrbytes = g_array_index (addr, guint32, 0);
|
||||
prefix = g_array_index (addr, guint32, 1);
|
||||
addrbytes = nm_ip4_address_get_address (addr);
|
||||
prefix = nm_ip4_address_get_prefix (addr);
|
||||
|
||||
if (addrbytes) {
|
||||
strings[i] = g_strdup_printf ("%s/%d",
|
||||
|
|
@ -152,8 +152,8 @@ ip4_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
{
|
||||
char **strings;
|
||||
GPtrArray *addrs;
|
||||
GArray *addr;
|
||||
guint32 *addrvals;
|
||||
NMIP4Address *addr;
|
||||
guint32 addrbytes, prefix;
|
||||
int i;
|
||||
|
||||
strings = g_value_get_boxed (source_value);
|
||||
|
|
@ -164,24 +164,19 @@ ip4_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (i >= addrs->len) {
|
||||
guint32 val;
|
||||
|
||||
addr = g_array_sized_new (FALSE, FALSE, sizeof (guint32), 3);
|
||||
val = 0;
|
||||
g_array_append_val (addr, val);
|
||||
val = 32;
|
||||
g_array_append_val (addr, val);
|
||||
val = 0;
|
||||
g_array_append_val (addr, val);
|
||||
addr = nm_ip4_address_new ();
|
||||
nm_ip4_address_set_prefix (addr, 32);
|
||||
g_ptr_array_add (addrs, addr);
|
||||
} else
|
||||
addr = addrs->pdata[i];
|
||||
addrvals = (guint32 *)addr->data;
|
||||
|
||||
if (!ip_string_parse (strings[i], AF_INET, &addrvals[0], &addrvals[1])) {
|
||||
if (!ip_string_parse (strings[i], AF_INET, &addrbytes, &prefix)) {
|
||||
g_ptr_array_unref (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
nm_ip4_address_set_address (addr, addrbytes);
|
||||
nm_ip4_address_set_prefix (addr, prefix);
|
||||
}
|
||||
|
||||
g_ptr_array_set_size (addrs, i);
|
||||
|
|
@ -199,16 +194,14 @@ ip4_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT property
|
||||
* @source_property on @source to the %G_TYPE_STRV property
|
||||
* @target_property on @target.
|
||||
* Binds the #GPtrArray-of-#NMIP4Address property @source_property on @source to
|
||||
* the %G_TYPE_STRV property @target_property on @target.
|
||||
*
|
||||
* Each address/prefix/gateway triplet in @source_property will be
|
||||
* converted to a string of the form "ip.ad.dr.ess/prefix" in
|
||||
* @target_property (and vice versa if %G_BINDING_BIDIRECTIONAL) is
|
||||
* specified. The "gateway" fields in @source_property are ignored
|
||||
* when converting to strings, and unmodified when converting from
|
||||
* strings.
|
||||
* Each #NMIP4Address in @source_property will be converted to a string of the
|
||||
* form "ip.ad.dr.ess/prefix" in @target_property (and vice versa if
|
||||
* %G_BINDING_BIDIRECTIONAL) is specified. The "gateway" fields in
|
||||
* @source_property are ignored when converting to strings, and unmodified when
|
||||
* converting from strings.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip4_addresses_with_prefix_to_strv (gpointer source,
|
||||
|
|
@ -226,55 +219,23 @@ nm_editor_bind_ip4_addresses_with_prefix_to_strv (gpointer source,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
ip4_addresses_to_strv (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GArray *addrs;
|
||||
guint32 addrbytes;
|
||||
char buf[INET_ADDRSTRLEN], **strings;
|
||||
int i;
|
||||
|
||||
addrs = g_value_get_boxed (source_value);
|
||||
strings = g_new0 (char *, addrs->len + 1);
|
||||
|
||||
for (i = 0; i < addrs->len; i++) {
|
||||
addrbytes = g_array_index (addrs, guint32, i);
|
||||
if (addrbytes)
|
||||
inet_ntop (AF_INET, &addrbytes, buf, sizeof (buf));
|
||||
else
|
||||
buf[0] = '\0';
|
||||
strings[i] = g_strdup (buf);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, strings);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip4_addresses_from_strv (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
ip4_addresses_check_and_copy (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
char **strings;
|
||||
GArray *addrs;
|
||||
guint32 addr;
|
||||
int i;
|
||||
|
||||
strings = g_value_get_boxed (source_value);
|
||||
addrs = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (!ip_string_parse (strings[i], AF_INET, &addr, NULL)) {
|
||||
g_array_unref (addrs);
|
||||
if (!ip_string_parse (strings[i], AF_INET, &addr, NULL))
|
||||
return FALSE;
|
||||
}
|
||||
g_array_append_val (addrs, addr);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, addrs);
|
||||
g_value_set_boxed (target_value, strings);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -288,12 +249,9 @@ ip4_addresses_from_strv (GBinding *binding,
|
|||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_UINT_ARRAY property @source_property on
|
||||
* @source to the %G_TYPE_STRV property @target_property on @target.
|
||||
*
|
||||
* Each address in @source_property will be converted to a string of
|
||||
* the form "ip.ad.dr.ess" in @target_property (and vice versa if
|
||||
* %G_BINDING_BIDIRECTIONAL) is specified.
|
||||
* Binds the %G_TYPE_STRV property @source_property on @source to the
|
||||
* %G_TYPE_STRV property @target_property on @target, verifying that
|
||||
* each string is a valid IPv4 address when copying.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip4_addresses_to_strv (gpointer source,
|
||||
|
|
@ -305,8 +263,8 @@ nm_editor_bind_ip4_addresses_to_strv (gpointer source,
|
|||
g_object_bind_property_full (source, source_property,
|
||||
target, target_property,
|
||||
flags,
|
||||
ip4_addresses_to_strv,
|
||||
ip4_addresses_from_strv,
|
||||
ip4_addresses_check_and_copy,
|
||||
ip4_addresses_check_and_copy,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +275,7 @@ ip4_gateway_to_string (GBinding *binding,
|
|||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *addrs;
|
||||
GArray *addr;
|
||||
NMIP4Address *addr;
|
||||
guint32 gateway = 0;
|
||||
const char *str;
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
|
@ -326,7 +284,7 @@ ip4_gateway_to_string (GBinding *binding,
|
|||
addrs = g_value_get_boxed (source_value);
|
||||
for (i = 0; i < addrs->len; i++) {
|
||||
addr = addrs->pdata[i];
|
||||
gateway = g_array_index (addr, guint32, 2);
|
||||
gateway = nm_ip4_address_get_gateway (addr);
|
||||
if (gateway)
|
||||
break;
|
||||
}
|
||||
|
|
@ -347,8 +305,8 @@ ip4_gateway_from_string (GBinding *binding,
|
|||
{
|
||||
const char *text;
|
||||
GPtrArray *addrs;
|
||||
GArray *addr;
|
||||
guint32 addrbytes, *addrvals;
|
||||
NMIP4Address *addr;
|
||||
guint32 addrbytes;
|
||||
int i;
|
||||
|
||||
text = g_value_get_string (source_value);
|
||||
|
|
@ -364,17 +322,15 @@ ip4_gateway_from_string (GBinding *binding,
|
|||
return FALSE;
|
||||
}
|
||||
addr = addrs->pdata[0];
|
||||
addrvals = (guint32 *)addr->data;
|
||||
if (addrbytes == addrvals[2]) {
|
||||
if (addrbytes == nm_ip4_address_get_gateway (addr)) {
|
||||
g_ptr_array_unref (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
addrvals[2] = addrbytes;
|
||||
nm_ip4_address_set_gateway (addr, addrbytes);
|
||||
|
||||
for (i = 1; i < addrs->len; i++) {
|
||||
addr = addrs->pdata[i];
|
||||
addrvals = (guint32 *)addr->data;
|
||||
addrvals[2] = 0;
|
||||
nm_ip4_address_set_gateway (addr, 0);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, addrs);
|
||||
|
|
@ -391,13 +347,12 @@ ip4_gateway_from_string (GBinding *binding,
|
|||
* (eg, "text")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT property
|
||||
* @source_property on @source to the %G_TYPE_STRING property
|
||||
* @target_property on @target.
|
||||
* Binds the #GPtrArray-of-#NMIP4Route property @source_property on @source to
|
||||
* the %G_TYPE_STRING property @target_property on @target.
|
||||
*
|
||||
* Specifically, this binds the "gateway" field of the first address
|
||||
* in @source_property; all other addresses in @source_property are
|
||||
* ignored, and its "address" and "prefix" fields are unmodified.
|
||||
* Specifically, this binds the "gateway" field of the first address in
|
||||
* @source_property; all other addresses in @source_property are ignored, and
|
||||
* its "address" and "prefix" fields are unmodified.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip4_gateway_to_string (gpointer source,
|
||||
|
|
@ -572,13 +527,13 @@ ip4_route_transform_from_metric_string (GBinding *binding,
|
|||
* @metric_target_property: the property on @metric_target
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the #NMIP4Route-valued property @source_property on @source
|
||||
* to the three indicated string-valued target properties (and vice
|
||||
* versa if %G_BINDING_BIDIRECTIONAL is specified).
|
||||
* Binds the #NMIP4Route-valued property @source_property on @source to the
|
||||
* three indicated string-valued target properties (and vice versa if
|
||||
* %G_BINDING_BIDIRECTIONAL is specified).
|
||||
*
|
||||
* @dest_target_property should be an "address/prefix" string, as with
|
||||
* nm_editor_bind_ip4_addresses_with_prefix_to_strv(). @next_hop_target
|
||||
* is a plain IP address, and @metric_target is a number.
|
||||
* nm_editor_bind_ip4_addresses_with_prefix_to_strv(). @next_hop_target_property
|
||||
* is a plain IP address, and @metric_target_property is a number.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip4_route_to_strings (gpointer source,
|
||||
|
|
@ -612,8 +567,7 @@ nm_editor_bind_ip4_route_to_strings (gpointer source,
|
|||
}
|
||||
|
||||
#define IP6_ADDRESS_SET(addr) ( addr \
|
||||
&& addr->len == sizeof (struct in6_addr) \
|
||||
&& memcmp (addr->data, &in6addr_any, addr->len) != 0)
|
||||
&& memcmp (addr, &in6addr_any, sizeof (struct in6_addr)) != 0)
|
||||
|
||||
static gboolean
|
||||
ip6_addresses_with_prefix_to_strv (GBinding *binding,
|
||||
|
|
@ -622,9 +576,8 @@ ip6_addresses_with_prefix_to_strv (GBinding *binding,
|
|||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *addrs;
|
||||
GValueArray *addr;
|
||||
GValue *val;
|
||||
GByteArray *addrbytes;
|
||||
NMIP6Address *addr;
|
||||
const struct in6_addr *addrbytes;
|
||||
guint prefix;
|
||||
char **strings, buf[INET6_ADDRSTRLEN];
|
||||
int i;
|
||||
|
|
@ -634,14 +587,12 @@ ip6_addresses_with_prefix_to_strv (GBinding *binding,
|
|||
|
||||
for (i = 0; i < addrs->len; i++) {
|
||||
addr = addrs->pdata[i];
|
||||
val = g_value_array_get_nth (addr, 0);
|
||||
addrbytes = g_value_get_boxed (val);
|
||||
val = g_value_array_get_nth (addr, 1);
|
||||
prefix = g_value_get_uint (val);
|
||||
addrbytes = nm_ip6_address_get_address (addr);
|
||||
prefix = nm_ip6_address_get_prefix (addr);
|
||||
|
||||
if (IP6_ADDRESS_SET (addrbytes)) {
|
||||
strings[i] = g_strdup_printf ("%s/%d",
|
||||
inet_ntop (AF_INET6, addrbytes->data, buf, sizeof (buf)),
|
||||
inet_ntop (AF_INET6, addrbytes, buf, sizeof (buf)),
|
||||
prefix);
|
||||
} else
|
||||
strings[i] = g_strdup ("");
|
||||
|
|
@ -659,10 +610,9 @@ ip6_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
{
|
||||
char **strings;
|
||||
GPtrArray *addrs;
|
||||
GValueArray *addr;
|
||||
NMIP6Address *addr;
|
||||
struct in6_addr addrbytes;
|
||||
guint32 prefix;
|
||||
GValue val = G_VALUE_INIT, *valp;
|
||||
GByteArray *ba;
|
||||
int i;
|
||||
|
||||
strings = g_value_get_boxed (source_value);
|
||||
|
|
@ -674,42 +624,19 @@ ip6_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (i >= addrs->len) {
|
||||
addr = g_value_array_new (3);
|
||||
|
||||
g_value_init (&val, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_sized_new (sizeof (struct in6_addr));
|
||||
g_byte_array_append (ba, (guint8 *) &in6addr_any, sizeof (struct in6_addr));
|
||||
g_value_take_boxed (&val, ba);
|
||||
g_value_array_append (addr, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
g_value_init (&val, G_TYPE_UINT);
|
||||
g_value_set_uint (&val, 128);
|
||||
g_value_array_append (addr, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
g_value_init (&val, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_sized_new (sizeof (struct in6_addr));
|
||||
g_byte_array_append (ba, (guint8 *) &in6addr_any, sizeof (struct in6_addr));
|
||||
g_value_take_boxed (&val, ba);
|
||||
g_value_array_append (addr, &val);
|
||||
g_value_unset (&val);
|
||||
|
||||
addr = nm_ip6_address_new ();
|
||||
nm_ip6_address_set_prefix (addr, 128);
|
||||
g_ptr_array_add (addrs, addr);
|
||||
} else
|
||||
addr = addrs->pdata[i];
|
||||
|
||||
valp = g_value_array_get_nth (addr, 0);
|
||||
ba = g_value_get_boxed (valp);
|
||||
g_assert (ba->len == sizeof (struct in6_addr));
|
||||
|
||||
if (!ip_string_parse (strings[i], AF_INET6, ba->data, &prefix)) {
|
||||
if (!ip_string_parse (strings[i], AF_INET6, &addrbytes, &prefix)) {
|
||||
g_ptr_array_unref (addrs);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
valp = g_value_array_get_nth (addr, 1);
|
||||
g_value_set_uint (valp, prefix);
|
||||
nm_ip6_address_set_address (addr, &addrbytes);
|
||||
nm_ip6_address_set_prefix (addr, prefix);
|
||||
}
|
||||
|
||||
g_ptr_array_set_size (addrs, i);
|
||||
|
|
@ -727,16 +654,14 @@ ip6_addresses_with_prefix_from_strv (GBinding *binding,
|
|||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS property
|
||||
* @source_property on @source to the %G_TYPE_STRV property
|
||||
* @target_property on @target.
|
||||
* Binds the #GPtrArray-of-#NMIP6Address property @source_property on @source to
|
||||
* the %G_TYPE_STRV property @target_property on @target.
|
||||
*
|
||||
* Each address/prefix/gateway triplet in @source_property will be
|
||||
* converted to a string of the form "ip::ad:dr:ess/prefix" in
|
||||
* @target_property (and vice versa if %G_BINDING_BIDIRECTIONAL) is
|
||||
* specified. The "gateway" fields in @source_property are ignored
|
||||
* when converting to strings, and unmodified when converting from
|
||||
* strings.
|
||||
* Each #NMIP6Address in triplet in @source_property will be converted to a
|
||||
* string of the form "ip::ad:dr:ess/prefix" in @target_property (and vice versa
|
||||
* if %G_BINDING_BIDIRECTIONAL) is specified. The "gateway" fields in
|
||||
* @source_property are ignored when converting to strings, and unmodified when
|
||||
* converting from strings.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip6_addresses_with_prefix_to_strv (gpointer source,
|
||||
|
|
@ -754,61 +679,23 @@ nm_editor_bind_ip6_addresses_with_prefix_to_strv (gpointer source,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
ip6_addresses_to_strv (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *addrs;
|
||||
GByteArray *addrbytes;
|
||||
char buf[INET6_ADDRSTRLEN], **strings;
|
||||
int i;
|
||||
|
||||
addrs = g_value_get_boxed (source_value);
|
||||
strings = g_new0 (char *, addrs->len + 1);
|
||||
|
||||
for (i = 0; i < addrs->len; i++) {
|
||||
addrbytes = addrs->pdata[i];
|
||||
if (IP6_ADDRESS_SET (addrbytes))
|
||||
inet_ntop (AF_INET6, addrbytes->data, buf, sizeof (buf));
|
||||
else
|
||||
buf[0] = '\0';
|
||||
strings[i] = g_strdup (buf);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, strings);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
ip6_addresses_from_strv (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
ip6_addresses_check_and_copy (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
char **strings;
|
||||
GPtrArray *addrs;
|
||||
GByteArray *addr;
|
||||
struct in6_addr addrbytes;
|
||||
struct in6_addr addr;
|
||||
int i;
|
||||
|
||||
strings = g_value_get_boxed (source_value);
|
||||
addrs = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; strings[i]; i++) {
|
||||
if (!ip_string_parse (strings[i], AF_INET6, &addrbytes, NULL)) {
|
||||
while (i--)
|
||||
g_byte_array_unref (addrs->pdata[i]);
|
||||
g_ptr_array_unref (addrs);
|
||||
if (!ip_string_parse (strings[i], AF_INET6, &addr, NULL))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
addr = g_byte_array_sized_new (sizeof (addrbytes));
|
||||
g_byte_array_append (addr, (guint8 *)&addrbytes, sizeof (addrbytes));
|
||||
g_ptr_array_add (addrs, addr);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, addrs);
|
||||
g_value_set_boxed (target_value, strings);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -822,13 +709,9 @@ ip6_addresses_from_strv (GBinding *binding,
|
|||
* (eg, "strings")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR property
|
||||
* @source_property on @source to the %G_TYPE_STRV property
|
||||
* @target_property on @target.
|
||||
*
|
||||
* Each address in @source_property will be converted to a string of
|
||||
* the form "ip::ad:dr:ess" in @target_property (and vice versa if
|
||||
* %G_BINDING_BIDIRECTIONAL) is specified.
|
||||
* Binds the %G_TYPE_STRV property @source_property on @source to the
|
||||
* %G_TYPE_STRV property @target_property on @target, verifying that
|
||||
* each string is a valid IPv6 address when copying.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip6_addresses_to_strv (gpointer source,
|
||||
|
|
@ -840,8 +723,8 @@ nm_editor_bind_ip6_addresses_to_strv (gpointer source,
|
|||
g_object_bind_property_full (source, source_property,
|
||||
target, target_property,
|
||||
flags,
|
||||
ip6_addresses_to_strv,
|
||||
ip6_addresses_from_strv,
|
||||
ip6_addresses_check_and_copy,
|
||||
ip6_addresses_check_and_copy,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -852,9 +735,8 @@ ip6_gateway_to_string (GBinding *binding,
|
|||
gpointer user_data)
|
||||
{
|
||||
GPtrArray *addrs;
|
||||
GValueArray *addr;
|
||||
GValue *val;
|
||||
GByteArray *gateway;
|
||||
NMIP6Address *addr;
|
||||
const struct in6_addr *gateway;
|
||||
char buf[INET6_ADDRSTRLEN];
|
||||
const char *str;
|
||||
|
||||
|
|
@ -863,11 +745,10 @@ ip6_gateway_to_string (GBinding *binding,
|
|||
return FALSE;
|
||||
|
||||
addr = addrs->pdata[0];
|
||||
val = g_value_array_get_nth (addr, 2);
|
||||
gateway = g_value_get_boxed (val);
|
||||
gateway = nm_ip6_address_get_gateway (addr);
|
||||
|
||||
if (IP6_ADDRESS_SET (gateway))
|
||||
str = inet_ntop (AF_INET6, gateway->data, buf, sizeof (buf));
|
||||
str = inet_ntop (AF_INET6, gateway, buf, sizeof (buf));
|
||||
else
|
||||
str = "";
|
||||
g_value_set_string (target_value, str);
|
||||
|
|
@ -882,10 +763,8 @@ ip6_gateway_from_string (GBinding *binding,
|
|||
{
|
||||
GPtrArray *addrs;
|
||||
const char *text;
|
||||
GValueArray *addr;
|
||||
NMIP6Address *addr;
|
||||
struct in6_addr gateway;
|
||||
GValue *val;
|
||||
GByteArray *ba;
|
||||
int i;
|
||||
|
||||
text = g_value_get_string (source_value);
|
||||
|
|
@ -902,20 +781,11 @@ ip6_gateway_from_string (GBinding *binding,
|
|||
}
|
||||
|
||||
addr = addrs->pdata[0];
|
||||
|
||||
ba = g_byte_array_sized_new (sizeof (gateway));
|
||||
g_byte_array_append (ba, (guint8 *) &gateway, sizeof (gateway));
|
||||
|
||||
val = g_value_array_get_nth (addr, 2);
|
||||
g_value_take_boxed (val, ba);
|
||||
nm_ip6_address_set_gateway (addr, &gateway);
|
||||
|
||||
for (i = 1; i < addrs->len; i++) {
|
||||
addr = addrs->pdata[i];
|
||||
val = g_value_array_get_nth (addr, 2);
|
||||
ba = g_value_get_boxed (val);
|
||||
|
||||
if (ba)
|
||||
memset (ba->data, 0, ba->len);
|
||||
nm_ip6_address_set_gateway (addr, &in6addr_any);
|
||||
}
|
||||
|
||||
g_value_take_boxed (target_value, addrs);
|
||||
|
|
@ -932,13 +802,12 @@ ip6_gateway_from_string (GBinding *binding,
|
|||
* (eg, "text")
|
||||
* @flags: %GBindingFlags
|
||||
*
|
||||
* Binds the %DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS property
|
||||
* @source_property on @source to the %G_TYPE_STRING property
|
||||
* @target_property on @target.
|
||||
* Binds the #GPtrArray-of-#NMIP6Address property @source_property on @source to
|
||||
* the %G_TYPE_STRING property @target_property on @target.
|
||||
*
|
||||
* Specifically, this binds the "gateway" field of the first address
|
||||
* in @source_property; all other addresses in @source_property are
|
||||
* ignored, and its "address" and "prefix" fields are unmodified.
|
||||
* Specifically, this binds the "gateway" field of the first address in
|
||||
* @source_property; all other addresses in @source_property are ignored, and
|
||||
* its "address" and "prefix" fields are unmodified.
|
||||
*/
|
||||
void
|
||||
nm_editor_bind_ip6_gateway_to_string (gpointer source,
|
||||
|
|
@ -955,8 +824,6 @@ nm_editor_bind_ip6_gateway_to_string (gpointer source,
|
|||
NULL, NULL);
|
||||
}
|
||||
|
||||
#define IN6_ADDR_SET(bytes) (memcmp (bytes, &in6addr_any, sizeof (struct in6_addr)) != 0)
|
||||
|
||||
static gboolean
|
||||
ip6_route_transform_to_dest_string (GBinding *binding,
|
||||
const GValue *source_value,
|
||||
|
|
@ -973,7 +840,7 @@ ip6_route_transform_to_dest_string (GBinding *binding,
|
|||
else
|
||||
addrbytes = &in6addr_any;
|
||||
|
||||
if (IN6_ADDR_SET (addrbytes)) {
|
||||
if (IP6_ADDRESS_SET (addrbytes)) {
|
||||
string = g_strdup_printf ("%s/%d",
|
||||
inet_ntop (AF_INET6, addrbytes, buf, sizeof (buf)),
|
||||
(int) nm_ip6_route_get_prefix (route));
|
||||
|
|
@ -999,7 +866,7 @@ ip6_route_transform_to_next_hop_string (GBinding *binding,
|
|||
else
|
||||
addrbytes = &in6addr_any;
|
||||
|
||||
if (IN6_ADDR_SET (addrbytes))
|
||||
if (IP6_ADDRESS_SET (addrbytes))
|
||||
inet_ntop (AF_INET6, addrbytes, buf, sizeof (buf));
|
||||
else
|
||||
buf[0] = '\0';
|
||||
|
|
@ -1017,7 +884,7 @@ ip6_route_transform_to_metric_string (GBinding *binding,
|
|||
char *string;
|
||||
|
||||
route = g_value_get_boxed (source_value);
|
||||
if (route && IN6_ADDR_SET (nm_ip6_route_get_dest (route))) {
|
||||
if (route && IP6_ADDRESS_SET (nm_ip6_route_get_dest (route))) {
|
||||
string = g_strdup_printf ("%lu", (gulong) nm_ip6_route_get_metric (route));
|
||||
g_value_take_string (target_value, string);
|
||||
} else
|
||||
|
|
|
|||
|
|
@ -266,6 +266,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev,
|
|||
NMAccessPoint *ap;
|
||||
const GPtrArray *aps;
|
||||
GHashTable *seen_ssids;
|
||||
const GByteArray *ssid;
|
||||
char *ap_hash;
|
||||
GSList *iter;
|
||||
int i;
|
||||
|
|
@ -292,7 +293,8 @@ add_connections_for_aps (NmtConnectDevice *nmtdev,
|
|||
nmtconn = g_slice_new0 (NmtConnectConnection);
|
||||
nmtconn->device = nmtdev->device;
|
||||
nmtconn->ap = g_object_ref (ap);
|
||||
nmtconn->ssid = nm_utils_ssid_to_utf8 (nm_access_point_get_ssid (ap));
|
||||
ssid = nm_access_point_get_ssid (ap);
|
||||
nmtconn->ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
|
||||
for (iter = connections; iter; iter = iter->next) {
|
||||
conn = iter->data;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ typedef struct {
|
|||
int arptype;
|
||||
|
||||
char *interface_name;
|
||||
GByteArray *mac_address;
|
||||
char *mac_address;
|
||||
|
||||
char *label;
|
||||
NmtNewtEntry *entry;
|
||||
|
|
@ -259,8 +259,8 @@ update_entry (NmtDeviceEntry *deventry)
|
|||
}
|
||||
|
||||
if (priv->mac_address) {
|
||||
mac = nm_utils_hwaddr_ntoa (priv->mac_address->data, priv->mac_address->len);
|
||||
mac_device = find_device_by_mac_address (deventry, mac);
|
||||
mac = g_strdup (priv->mac_address);
|
||||
mac_device = find_device_by_mac_address (deventry, priv->mac_address);
|
||||
} else {
|
||||
mac = NULL;
|
||||
mac_device = NULL;
|
||||
|
|
@ -312,25 +312,21 @@ nmt_device_entry_set_interface_name (NmtDeviceEntry *deventry,
|
|||
|
||||
static gboolean
|
||||
nmt_device_entry_set_mac_address (NmtDeviceEntry *deventry,
|
||||
GByteArray *mac_address)
|
||||
const char *mac_address)
|
||||
{
|
||||
NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE (deventry);
|
||||
gboolean changed;
|
||||
|
||||
if (mac_address)
|
||||
g_return_val_if_fail (mac_address->len == nm_utils_hwaddr_len (priv->arptype), FALSE);
|
||||
|
||||
if (mac_address && !priv->mac_address) {
|
||||
priv->mac_address = g_boxed_copy (DBUS_TYPE_G_UCHAR_ARRAY, mac_address);
|
||||
priv->mac_address = g_strdup (mac_address);
|
||||
changed = TRUE;
|
||||
} else if (!mac_address && priv->mac_address) {
|
||||
g_clear_pointer (&priv->mac_address, g_byte_array_unref);
|
||||
g_clear_pointer (&priv->mac_address, g_free);
|
||||
changed = TRUE;
|
||||
} else if ( mac_address && priv->mac_address
|
||||
&& !nm_utils_hwaddr_matches (mac_address->data, mac_address->len,
|
||||
priv->mac_address->data, priv->mac_address->len)) {
|
||||
g_byte_array_unref (priv->mac_address);
|
||||
priv->mac_address = g_boxed_copy (DBUS_TYPE_G_UCHAR_ARRAY, mac_address);
|
||||
&& !nm_utils_hwaddr_matches (mac_address, -1, priv->mac_address, -1)) {
|
||||
g_free (priv->mac_address);
|
||||
priv->mac_address = g_strdup (mac_address);
|
||||
changed = TRUE;
|
||||
} else
|
||||
changed = FALSE;
|
||||
|
|
@ -356,21 +352,11 @@ entry_text_changed (GObject *object,
|
|||
if (!device_entry_parse (deventry, text, &ifname, &mac))
|
||||
return;
|
||||
|
||||
if (ifname) {
|
||||
nmt_device_entry_set_interface_name (deventry, ifname);
|
||||
g_free (ifname);
|
||||
} else
|
||||
nmt_device_entry_set_interface_name (deventry, NULL);
|
||||
nmt_device_entry_set_interface_name (deventry, ifname);
|
||||
g_free (ifname);
|
||||
|
||||
if (mac) {
|
||||
GByteArray *mac_address;
|
||||
|
||||
mac_address = nm_utils_hwaddr_atoba (mac, nm_utils_hwaddr_len (priv->arptype));
|
||||
nmt_device_entry_set_mac_address (deventry, mac_address);
|
||||
g_byte_array_unref (mac_address);
|
||||
g_free (mac);
|
||||
} else
|
||||
nmt_device_entry_set_mac_address (deventry, NULL);
|
||||
nmt_device_entry_set_mac_address (deventry, mac);
|
||||
g_free (mac);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -410,8 +396,7 @@ nmt_device_entry_finalize (GObject *object)
|
|||
NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->interface_name);
|
||||
if (priv->mac_address)
|
||||
g_byte_array_unref (priv->mac_address);
|
||||
g_free (priv->mac_address);
|
||||
|
||||
G_OBJECT_CLASS (nmt_device_entry_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -461,7 +446,7 @@ nmt_device_entry_set_property (GObject *object,
|
|||
NmtDeviceEntry *deventry = NMT_DEVICE_ENTRY (object);
|
||||
NmtDeviceEntryPrivate *priv = NMT_DEVICE_ENTRY_GET_PRIVATE (deventry);
|
||||
const char *interface_name;
|
||||
GByteArray *mac_address;
|
||||
const char *mac_address;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_LABEL:
|
||||
|
|
@ -480,7 +465,7 @@ nmt_device_entry_set_property (GObject *object,
|
|||
update_entry (deventry);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
mac_address = g_value_get_boxed (value);
|
||||
mac_address = g_value_get_string (value);
|
||||
if (nmt_device_entry_set_mac_address (deventry, mac_address))
|
||||
update_entry (deventry);
|
||||
break;
|
||||
|
|
@ -512,7 +497,7 @@ nmt_device_entry_get_property (GObject *object,
|
|||
g_value_set_string (value, priv->interface_name);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, priv->mac_address);
|
||||
g_value_set_string (value, priv->mac_address);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -587,8 +572,8 @@ nmt_device_entry_class_init (NmtDeviceEntryClass *deventry_class)
|
|||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
g_param_spec_boxed ("mac-address", "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string ("mac-address", "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,8 +152,6 @@ nmt_mac_entry_set_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
NmtMacEntryPrivate *priv = NMT_MAC_ENTRY_GET_PRIVATE (object);
|
||||
GByteArray *addr;
|
||||
char *addr_str;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_LENGTH:
|
||||
|
|
@ -161,13 +159,7 @@ nmt_mac_entry_set_property (GObject *object,
|
|||
priv->mac_str_length = priv->mac_length * 3 - 1;
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
addr = g_value_get_boxed (value);
|
||||
if (addr) {
|
||||
addr_str = nm_utils_hwaddr_ntoa (addr->data, addr->len);
|
||||
nmt_newt_entry_set_text (NMT_NEWT_ENTRY (object), addr_str);
|
||||
g_free (addr_str);
|
||||
} else
|
||||
nmt_newt_entry_set_text (NMT_NEWT_ENTRY (object), "");
|
||||
nmt_newt_entry_set_text (NMT_NEWT_ENTRY (object), g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -182,15 +174,13 @@ nmt_mac_entry_get_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
NmtMacEntryPrivate *priv = NMT_MAC_ENTRY_GET_PRIVATE (object);
|
||||
GByteArray *addr;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_LENGTH:
|
||||
g_value_set_int (value, priv->mac_length);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
addr = nm_utils_hwaddr_atoba (nmt_newt_entry_get_text (NMT_NEWT_ENTRY (object)), ETH_ALEN);
|
||||
g_value_take_boxed (value, addr);
|
||||
g_value_set_boxed (value, nmt_newt_entry_get_text (NMT_NEWT_ENTRY (object)));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -225,13 +215,13 @@ nmt_mac_entry_class_init (NmtMacEntryClass *entry_class)
|
|||
/**
|
||||
* NmtMacEntry:mac-address:
|
||||
*
|
||||
* The MAC address, in binary (in the same format used by the various
|
||||
* #NMSetting "mac-address" properties).
|
||||
* The MAC address, as a string (as with the various #NMSetting
|
||||
* "mac-address" properties).
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
g_param_spec_boxed ("mac-address", "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string ("mac-address", "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@ permissions_transform_to_allusers (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GSList *perms = g_value_get_boxed (source_value);
|
||||
char **perms = g_value_get_boxed (source_value);
|
||||
|
||||
g_value_set_boolean (target_value, perms == NULL);
|
||||
g_value_set_boolean (target_value, g_strv_length (perms) == 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -109,12 +109,13 @@ permissions_transform_from_allusers (GBinding *binding,
|
|||
gpointer user_data)
|
||||
{
|
||||
gboolean allusers = g_value_get_boolean (source_value);
|
||||
GSList *perms = NULL;
|
||||
char **perms = NULL;
|
||||
|
||||
if (allusers) {
|
||||
char *perm = g_strdup_printf ("user:%s:", g_get_user_name ());
|
||||
perms = g_new (char *, 2);
|
||||
|
||||
perms = g_slist_prepend (perms, perm);
|
||||
perms[0] = g_strdup_printf ("user:%s:", g_get_user_name ());
|
||||
perms[1] = NULL;
|
||||
}
|
||||
g_value_take_boxed (target_value, perms);
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -134,11 +134,12 @@ ssid_transform_to_entry (GBinding *binding,
|
|||
GValue *target_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
char *utf8;
|
||||
|
||||
ssid = g_value_get_boxed (source_value);
|
||||
utf8 = nm_utils_ssid_to_utf8 (ssid);
|
||||
utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
g_value_take_string (target_value, utf8);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -151,14 +152,14 @@ ssid_transform_from_entry (GBinding *binding,
|
|||
{
|
||||
NMSettingWireless *s_wireless = user_data;
|
||||
const char *text;
|
||||
const GByteArray *old_ssid;
|
||||
GByteArray *ssid;
|
||||
GBytes *old_ssid, *ssid;
|
||||
char *utf8;
|
||||
|
||||
text = g_value_get_string (source_value);
|
||||
|
||||
old_ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
utf8 = nm_utils_ssid_to_utf8 (old_ssid);
|
||||
utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (old_ssid, NULL),
|
||||
g_bytes_get_size (old_ssid));
|
||||
|
||||
if (!g_strcmp0 (text, utf8)) {
|
||||
g_free (utf8);
|
||||
|
|
@ -166,8 +167,7 @@ ssid_transform_from_entry (GBinding *binding,
|
|||
}
|
||||
g_free (utf8);
|
||||
|
||||
ssid = g_byte_array_new ();
|
||||
g_byte_array_append (ssid, (guint8 *)text, strlen (text));
|
||||
ssid = g_bytes_new (text, strlen (text));
|
||||
g_value_take_boxed (target_value, ssid);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ typedef struct {
|
|||
int ip_entry_width;
|
||||
int metric_entry_width;
|
||||
|
||||
GSList *routes;
|
||||
GPtrArray *routes;
|
||||
NmtNewtWidget *list;
|
||||
} NmtRouteTablePrivate;
|
||||
|
||||
|
|
@ -87,7 +87,7 @@ route_list_transform_to_route (GBinding *binding,
|
|||
int n = GPOINTER_TO_INT (user_data);
|
||||
gpointer route;
|
||||
|
||||
route = g_slist_nth_data (priv->routes, n);
|
||||
route = priv->routes->pdata[n];
|
||||
if (route)
|
||||
g_value_set_boxed (target_value, route);
|
||||
return route != NULL;
|
||||
|
|
@ -102,31 +102,25 @@ route_list_transform_from_route (GBinding *binding,
|
|||
NmtRouteTable *table = NMT_ROUTE_TABLE (g_binding_get_source (binding));
|
||||
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table);
|
||||
int n = GPOINTER_TO_INT (user_data);
|
||||
GSList *routes, *nth;
|
||||
GPtrArray *routes;
|
||||
gpointer route;
|
||||
|
||||
nth = g_slist_nth (priv->routes, n);
|
||||
if (!nth)
|
||||
if (n >= priv->routes->len)
|
||||
return FALSE;
|
||||
route = priv->routes->pdata[n];
|
||||
|
||||
routes = priv->routes;
|
||||
priv->routes = NULL;
|
||||
|
||||
if (nth->data) {
|
||||
if (route) {
|
||||
if (priv->family == AF_INET)
|
||||
nm_ip4_route_unref (nth->data);
|
||||
nm_ip4_route_unref (route);
|
||||
else if (priv->family == AF_INET6)
|
||||
nm_ip6_route_unref (nth->data);
|
||||
}
|
||||
nth->data = g_value_dup_boxed (source_value);
|
||||
|
||||
if (priv->family == AF_INET) {
|
||||
nm_utils_ip4_routes_to_gvalue (routes, target_value);
|
||||
g_slist_free_full (routes, (GDestroyNotify) nm_ip4_route_unref);
|
||||
} else if (priv->family == AF_INET6) {
|
||||
nm_utils_ip6_routes_to_gvalue (routes, target_value);
|
||||
g_slist_free_full (routes, (GDestroyNotify) nm_ip6_route_unref);
|
||||
nm_ip6_route_unref (route);
|
||||
}
|
||||
routes->pdata[n] = g_value_dup_boxed (source_value);
|
||||
|
||||
g_value_take_boxed (target_value, routes);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -171,16 +165,16 @@ add_route (NmtWidgetList *list,
|
|||
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_prefix (route, 32);
|
||||
priv->routes = g_slist_append (priv->routes, route);
|
||||
nmt_widget_list_set_length (list, g_slist_length (priv->routes));
|
||||
g_ptr_array_add (priv->routes, route);
|
||||
nmt_widget_list_set_length (list, priv->routes->len);
|
||||
g_object_notify (table, "ip4-routes");
|
||||
} else {
|
||||
NMIP6Route *route;
|
||||
|
||||
route = nm_ip6_route_new ();
|
||||
nm_ip6_route_set_prefix (route, 128);
|
||||
priv->routes = g_slist_append (priv->routes, route);
|
||||
nmt_widget_list_set_length (list, g_slist_length (priv->routes));
|
||||
g_ptr_array_add (priv->routes, route);
|
||||
nmt_widget_list_set_length (list, priv->routes->len);
|
||||
g_object_notify (table, "ip6-routes");
|
||||
}
|
||||
}
|
||||
|
|
@ -191,16 +185,14 @@ remove_route (NmtWidgetList *list,
|
|||
gpointer table)
|
||||
{
|
||||
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table);
|
||||
GSList *nth;
|
||||
gpointer route;
|
||||
|
||||
nth = g_slist_nth (priv->routes, num);
|
||||
if (!nth)
|
||||
if (num >= priv->routes->len)
|
||||
return;
|
||||
|
||||
route = nth->data;
|
||||
priv->routes = g_slist_delete_link (priv->routes, nth);
|
||||
nmt_widget_list_set_length (list, g_slist_length (priv->routes));
|
||||
route = priv->routes->pdata[num];
|
||||
g_ptr_array_remove_index (priv->routes, num);
|
||||
nmt_widget_list_set_length (list, priv->routes->len);
|
||||
|
||||
if (priv->family == AF_INET) {
|
||||
nm_ip4_route_unref (route);
|
||||
|
|
@ -271,10 +263,7 @@ nmt_route_table_finalize (GObject *object)
|
|||
{
|
||||
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object);
|
||||
|
||||
if (priv->family == AF_INET)
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
|
||||
else if (priv->family == AF_INET6)
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
|
||||
g_ptr_array_unref (priv->routes);
|
||||
|
||||
G_OBJECT_CLASS (nmt_route_table_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -286,24 +275,36 @@ nmt_route_table_set_property (GObject *object,
|
|||
GParamSpec *pspec)
|
||||
{
|
||||
NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (object);
|
||||
GPtrArray *array;
|
||||
int i;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FAMILY:
|
||||
priv->family = g_value_get_int (value);
|
||||
if (priv->family == AF_INET)
|
||||
priv->routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip4_route_unref);
|
||||
else
|
||||
priv->routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip6_route_unref);
|
||||
break;
|
||||
case PROP_IP4_ROUTES:
|
||||
g_return_if_fail (priv->family == AF_INET);
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
|
||||
priv->routes = nm_utils_ip4_routes_from_gvalue (value);
|
||||
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list),
|
||||
g_slist_length (priv->routes));
|
||||
array = g_value_get_boxed (value);
|
||||
g_ptr_array_set_size (priv->routes, 0);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
nm_ip4_route_ref (array->pdata[i]);
|
||||
g_ptr_array_add (priv->routes, array->pdata[i]);
|
||||
}
|
||||
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), priv->routes->len);
|
||||
break;
|
||||
case PROP_IP6_ROUTES:
|
||||
g_return_if_fail (priv->family == AF_INET6);
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
|
||||
priv->routes = nm_utils_ip6_routes_from_gvalue (value);
|
||||
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list),
|
||||
g_slist_length (priv->routes));
|
||||
array = g_value_get_boxed (value);
|
||||
g_ptr_array_set_size (priv->routes, 0);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
nm_ip6_route_ref (array->pdata[i]);
|
||||
g_ptr_array_add (priv->routes, array->pdata[i]);
|
||||
}
|
||||
nmt_widget_list_set_length (NMT_WIDGET_LIST (priv->list), priv->routes->len);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -325,11 +326,11 @@ nmt_route_table_get_property (GObject *object,
|
|||
break;
|
||||
case PROP_IP4_ROUTES:
|
||||
g_return_if_fail (priv->family == AF_INET);
|
||||
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
|
||||
g_value_set_boxed (value, priv->routes);
|
||||
break;
|
||||
case PROP_IP6_ROUTES:
|
||||
g_return_if_fail (priv->family == AF_INET6);
|
||||
nm_utils_ip6_routes_to_gvalue (priv->routes, value);
|
||||
g_value_set_boxed (value, priv->routes);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -337,11 +338,6 @@ nmt_route_table_get_property (GObject *object,
|
|||
}
|
||||
}
|
||||
|
||||
#define DBUS_TYPE_G_ARRAY_OF_UINT (dbus_g_type_get_collection ("GArray", G_TYPE_UINT))
|
||||
#define DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_ARRAY_OF_UINT))
|
||||
#define DBUS_TYPE_G_IP6_ROUTE (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
|
||||
#define DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE (dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_IP6_ROUTE))
|
||||
|
||||
static void
|
||||
nmt_route_table_class_init (NmtRouteTableClass *table_class)
|
||||
{
|
||||
|
|
@ -373,11 +369,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class)
|
|||
* #NMSettingIP4Config:routes.
|
||||
*
|
||||
* Only valid if #NmtRouteTable:family is %AF_INET
|
||||
*
|
||||
* Element-type: NMIP4Route
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP4_ROUTES,
|
||||
g_param_spec_boxed ("ip4-routes", "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
/**
|
||||
|
|
@ -387,11 +385,13 @@ nmt_route_table_class_init (NmtRouteTableClass *table_class)
|
|||
* #NMSettingIP6Config:routes.
|
||||
*
|
||||
* Only valid if #NmtRouteTable:family is %AF_INET6
|
||||
*
|
||||
* Element-type: NMIP6Route
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_IP6_ROUTES,
|
||||
g_param_spec_boxed ("ip6-routes", "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,13 +329,16 @@ request_secrets_from_ui (NmtSecretAgentRequest *request)
|
|||
|
||||
if (nm_connection_is_type (request->connection, NM_SETTING_WIRELESS_SETTING_NAME)) {
|
||||
NMSettingWireless *s_wireless;
|
||||
char *ssid;
|
||||
GBytes *ssid;
|
||||
char *ssid_utf8;
|
||||
|
||||
s_wireless = nm_connection_get_setting_wireless (request->connection);
|
||||
ssid = nm_utils_ssid_to_utf8 (nm_setting_wireless_get_ssid (s_wireless));
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
ssid_utf8 = nm_utils_ssid_to_utf8 (g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
|
||||
title = _("Authentication required by wireless network");
|
||||
msg = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."), ssid);
|
||||
msg = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."), ssid_utf8);
|
||||
|
||||
ok = add_wireless_secrets (request, secrets);
|
||||
} else if (nm_connection_is_type (request->connection, NM_SETTING_WIRED_SETTING_NAME)) {
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ show_access_point_info (NMAccessPoint *ap)
|
|||
strength = nm_access_point_get_strength (ap);
|
||||
|
||||
/* Convert to strings */
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid);
|
||||
ssid_str = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
freq_str = g_strdup_printf ("%u MHz", freq);
|
||||
bitrate_str = g_strdup_printf ("%u Mbit/s", bitrate/1000);
|
||||
strength_str = g_strdup_printf ("%u", strength);
|
||||
|
|
@ -163,7 +163,7 @@ show_wifi_device_info (NMDevice *device)
|
|||
if (nm_device_get_state (device) == NM_DEVICE_STATE_ACTIVATED) {
|
||||
if ((active_ap = nm_device_wifi_get_active_access_point (NM_DEVICE_WIFI (device)))) {
|
||||
active_ssid = nm_access_point_get_ssid (active_ap);
|
||||
active_ssid_str = nm_utils_ssid_to_utf8 (active_ssid);
|
||||
active_ssid_str = nm_utils_ssid_to_utf8 (active_ssid->data, active_ssid->len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ libnm_core_headers = \
|
|||
|
||||
libnm_core_private_headers = \
|
||||
$(core)/crypto.h \
|
||||
$(core)/nm-core-internal.h \
|
||||
$(core)/nm-param-spec-specialized.h \
|
||||
$(core)/nm-core-internal.h \
|
||||
$(core)/nm-property-compare.h \
|
||||
$(core)/nm-setting-private.h \
|
||||
$(core)/nm-utils-private.h
|
||||
|
||||
|
|
@ -52,7 +52,7 @@ libnm_core_sources = \
|
|||
$(core_build)/nm-core-enum-types.c \
|
||||
$(core)/crypto.c \
|
||||
$(core)/nm-connection.c \
|
||||
$(core)/nm-param-spec-specialized.c \
|
||||
$(core)/nm-property-compare.c \
|
||||
$(core)/nm-setting-8021x.c \
|
||||
$(core)/nm-setting-adsl.c \
|
||||
$(core)/nm-setting-bluetooth.c \
|
||||
|
|
|
|||
|
|
@ -60,19 +60,20 @@ _nm_crypto_error_quark (void)
|
|||
|
||||
static gboolean
|
||||
find_tag (const char *tag,
|
||||
const GByteArray *array,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
gsize start_at,
|
||||
gsize *out_pos)
|
||||
{
|
||||
gsize i, taglen;
|
||||
gsize len = array->len - start_at;
|
||||
gsize len = data_len - start_at;
|
||||
|
||||
g_return_val_if_fail (out_pos != NULL, FALSE);
|
||||
|
||||
taglen = strlen (tag);
|
||||
if (len >= taglen) {
|
||||
for (i = 0; i < len - taglen + 1; i++) {
|
||||
if (memcmp (array->data + start_at + i, tag, taglen) == 0) {
|
||||
if (memcmp (data + start_at + i, tag, taglen) == 0) {
|
||||
*out_pos = start_at + i;
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -85,7 +86,8 @@ find_tag (const char *tag,
|
|||
#define PROC_TYPE_TAG "Proc-Type: "
|
||||
|
||||
static GByteArray *
|
||||
parse_old_openssl_key_file (const GByteArray *contents,
|
||||
parse_old_openssl_key_file (const guint8 *data,
|
||||
gsize data_len,
|
||||
int key_type,
|
||||
char **out_cipher,
|
||||
char **out_iv,
|
||||
|
|
@ -123,11 +125,11 @@ parse_old_openssl_key_file (const GByteArray *contents,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (!find_tag (start_tag, contents, 0, &start))
|
||||
if (!find_tag (start_tag, data, data_len, 0, &start))
|
||||
goto parse_error;
|
||||
|
||||
start += strlen (start_tag);
|
||||
if (!find_tag (end_tag, contents, start, &end)) {
|
||||
if (!find_tag (end_tag, data, data_len, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM key file had no end tag '%s'."),
|
||||
|
|
@ -135,10 +137,10 @@ parse_old_openssl_key_file (const GByteArray *contents,
|
|||
goto parse_error;
|
||||
}
|
||||
|
||||
save_end = contents->data[end];
|
||||
contents->data[end] = '\0';
|
||||
lines = g_strsplit ((const char *) (contents->data + start), "\n", 0);
|
||||
contents->data[end] = save_end;
|
||||
save_end = data[end];
|
||||
((guint8 *)data)[end] = '\0';
|
||||
lines = g_strsplit ((const char *) (data + start), "\n", 0);
|
||||
((guint8 *)data)[end] = save_end;
|
||||
|
||||
if (!lines || g_strv_length (lines) <= 1) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
|
|
@ -258,7 +260,8 @@ parse_error:
|
|||
}
|
||||
|
||||
static GByteArray *
|
||||
parse_pkcs8_key_file (const GByteArray *contents,
|
||||
parse_pkcs8_key_file (const guint8 *data,
|
||||
gsize data_len,
|
||||
gboolean *out_encrypted,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -271,11 +274,11 @@ parse_pkcs8_key_file (const GByteArray *contents,
|
|||
gboolean encrypted = FALSE;
|
||||
|
||||
/* Try encrypted first, decrypted next */
|
||||
if (find_tag (PEM_PKCS8_ENC_KEY_BEGIN, contents, 0, &start)) {
|
||||
if (find_tag (PEM_PKCS8_ENC_KEY_BEGIN, data, data_len, 0, &start)) {
|
||||
start_tag = PEM_PKCS8_ENC_KEY_BEGIN;
|
||||
end_tag = PEM_PKCS8_ENC_KEY_END;
|
||||
encrypted = TRUE;
|
||||
} else if (find_tag (PEM_PKCS8_DEC_KEY_BEGIN, contents, 0, &start)) {
|
||||
} else if (find_tag (PEM_PKCS8_DEC_KEY_BEGIN, data, data_len, 0, &start)) {
|
||||
start_tag = PEM_PKCS8_DEC_KEY_BEGIN;
|
||||
end_tag = PEM_PKCS8_DEC_KEY_END;
|
||||
encrypted = FALSE;
|
||||
|
|
@ -287,7 +290,7 @@ parse_pkcs8_key_file (const GByteArray *contents,
|
|||
}
|
||||
|
||||
start += strlen (start_tag);
|
||||
if (!find_tag (end_tag, contents, start, &end)) {
|
||||
if (!find_tag (end_tag, data, data_len, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("Failed to find expected PKCS#8 end tag '%s'."),
|
||||
|
|
@ -296,10 +299,10 @@ parse_pkcs8_key_file (const GByteArray *contents,
|
|||
}
|
||||
|
||||
/* g_base64_decode() wants a NULL-terminated string */
|
||||
save_end = contents->data[end];
|
||||
contents->data[end] = '\0';
|
||||
der = g_base64_decode ((const char *) (contents->data + start), &length);
|
||||
contents->data[end] = save_end;
|
||||
save_end = data[end];
|
||||
((guint8 *)data)[end] = '\0';
|
||||
der = g_base64_decode ((const char *) (data + start), &length);
|
||||
((guint8 *)data)[end] = save_end;
|
||||
|
||||
if (der && length) {
|
||||
key = g_byte_array_sized_new (length);
|
||||
|
|
@ -439,7 +442,8 @@ error:
|
|||
static GByteArray *
|
||||
decrypt_key (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
const char *password,
|
||||
GError **error)
|
||||
|
|
@ -464,7 +468,7 @@ decrypt_key (const char *cipher,
|
|||
goto out;
|
||||
|
||||
output = crypto_decrypt (cipher, key_type,
|
||||
data,
|
||||
data, data_len,
|
||||
bin_iv, bin_iv_len,
|
||||
key, key_len,
|
||||
&decrypted_len,
|
||||
|
|
@ -486,32 +490,33 @@ out:
|
|||
}
|
||||
|
||||
GByteArray *
|
||||
crypto_decrypt_private_key_data (const GByteArray *contents,
|
||||
crypto_decrypt_private_key_data (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error)
|
||||
{
|
||||
GByteArray *decrypted = NULL;
|
||||
NMCryptoKeyType key_type = NM_CRYPTO_KEY_TYPE_RSA;
|
||||
GByteArray *data;
|
||||
GByteArray *parsed;
|
||||
char *iv = NULL;
|
||||
char *cipher = NULL;
|
||||
|
||||
g_return_val_if_fail (contents != NULL, NULL);
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
if (out_key_type)
|
||||
g_return_val_if_fail (*out_key_type == NM_CRYPTO_KEY_TYPE_UNKNOWN, NULL);
|
||||
|
||||
/* OpenSSL non-standard legacy PEM files */
|
||||
|
||||
/* Try RSA keys first */
|
||||
data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
|
||||
if (!data) {
|
||||
parsed = parse_old_openssl_key_file (data, data_len, key_type, &cipher, &iv, error);
|
||||
if (!parsed) {
|
||||
g_clear_error (error);
|
||||
|
||||
/* DSA next */
|
||||
key_type = NM_CRYPTO_KEY_TYPE_DSA;
|
||||
data = parse_old_openssl_key_file (contents, key_type, &cipher, &iv, error);
|
||||
if (!data) {
|
||||
parsed = parse_old_openssl_key_file (data, data_len, key_type, &cipher, &iv, error);
|
||||
if (!parsed) {
|
||||
g_clear_error (error);
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
|
|
@ -519,7 +524,7 @@ crypto_decrypt_private_key_data (const GByteArray *contents,
|
|||
}
|
||||
}
|
||||
|
||||
if (data) {
|
||||
if (parsed) {
|
||||
/* return the key type even if decryption failed */
|
||||
if (out_key_type)
|
||||
*out_key_type = key_type;
|
||||
|
|
@ -527,12 +532,13 @@ crypto_decrypt_private_key_data (const GByteArray *contents,
|
|||
if (password) {
|
||||
decrypted = decrypt_key (cipher,
|
||||
key_type,
|
||||
data,
|
||||
parsed->data,
|
||||
parsed->len,
|
||||
iv,
|
||||
password,
|
||||
error);
|
||||
}
|
||||
g_byte_array_free (data, TRUE);
|
||||
g_byte_array_free (parsed, TRUE);
|
||||
}
|
||||
|
||||
g_free (cipher);
|
||||
|
|
@ -552,7 +558,8 @@ crypto_decrypt_private_key (const char *file,
|
|||
|
||||
contents = file_to_g_byte_array (file, error);
|
||||
if (contents) {
|
||||
key = crypto_decrypt_private_key_data (contents, password, out_key_type, error);
|
||||
key = crypto_decrypt_private_key_data (contents->data, contents->len,
|
||||
password, out_key_type, error);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return key;
|
||||
|
|
@ -567,7 +574,7 @@ extract_pem_cert_data (GByteArray *contents, GError **error)
|
|||
guint8 save_end;
|
||||
gsize length = 0;
|
||||
|
||||
if (!find_tag (PEM_CERT_BEGIN, contents, 0, &start)) {
|
||||
if (!find_tag (PEM_CERT_BEGIN, contents->data, contents->len, 0, &start)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM certificate had no start tag '%s'."),
|
||||
|
|
@ -576,7 +583,7 @@ extract_pem_cert_data (GByteArray *contents, GError **error)
|
|||
}
|
||||
|
||||
start += strlen (PEM_CERT_BEGIN);
|
||||
if (!find_tag (PEM_CERT_END, contents, start, &end)) {
|
||||
if (!find_tag (PEM_CERT_END, contents->data, contents->len, start, &end)) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
_("PEM certificate had no end tag '%s'."),
|
||||
|
|
@ -621,7 +628,7 @@ crypto_load_and_verify_certificate (const char *file,
|
|||
return NULL;
|
||||
|
||||
/* Check for PKCS#12 */
|
||||
if (crypto_is_pkcs12_data (contents)) {
|
||||
if (crypto_is_pkcs12_data (contents->data, contents->len)) {
|
||||
*out_file_format = NM_CRYPTO_FILE_FORMAT_PKCS12;
|
||||
return contents;
|
||||
}
|
||||
|
|
@ -649,14 +656,15 @@ crypto_load_and_verify_certificate (const char *file,
|
|||
}
|
||||
|
||||
gboolean
|
||||
crypto_is_pkcs12_data (const GByteArray *data)
|
||||
crypto_is_pkcs12_data (const guint8 *data,
|
||||
gsize data_len)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gboolean success;
|
||||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
success = crypto_verify_pkcs12 (data, NULL, &error);
|
||||
success = crypto_verify_pkcs12 (data, data_len, NULL, &error);
|
||||
if (success == FALSE) {
|
||||
/* If the error was just a decryption error, then it's pkcs#12 */
|
||||
if (error) {
|
||||
|
|
@ -678,7 +686,7 @@ crypto_is_pkcs12_file (const char *file, GError **error)
|
|||
|
||||
contents = file_to_g_byte_array (file, error);
|
||||
if (contents) {
|
||||
success = crypto_is_pkcs12_data (contents);
|
||||
success = crypto_is_pkcs12_data (contents->data, contents->len);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return success;
|
||||
|
|
@ -688,7 +696,8 @@ crypto_is_pkcs12_file (const char *file, GError **error)
|
|||
* the private key can be decrypted with that password.
|
||||
*/
|
||||
NMCryptoFileFormat
|
||||
crypto_verify_private_key_data (const GByteArray *contents,
|
||||
crypto_verify_private_key_data (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -697,23 +706,23 @@ crypto_verify_private_key_data (const GByteArray *contents,
|
|||
NMCryptoKeyType ktype = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
gboolean is_encrypted = FALSE;
|
||||
|
||||
g_return_val_if_fail (contents != NULL, FALSE);
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
/* Check for PKCS#12 first */
|
||||
if (crypto_is_pkcs12_data (contents)) {
|
||||
if (!password || crypto_verify_pkcs12 (contents, password, error))
|
||||
if (crypto_is_pkcs12_data (data, data_len)) {
|
||||
if (!password || crypto_verify_pkcs12 (data, data_len, password, error))
|
||||
format = NM_CRYPTO_FILE_FORMAT_PKCS12;
|
||||
} else {
|
||||
/* Maybe it's PKCS#8 */
|
||||
tmp = parse_pkcs8_key_file (contents, &is_encrypted, error);
|
||||
tmp = parse_pkcs8_key_file (data, data_len, &is_encrypted, error);
|
||||
if (tmp) {
|
||||
if (crypto_verify_pkcs8 (tmp, is_encrypted, password, error))
|
||||
if (crypto_verify_pkcs8 (tmp->data, tmp->len, is_encrypted, password, error))
|
||||
format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
|
||||
} else {
|
||||
g_clear_error (error);
|
||||
|
||||
/* Or it's old-style OpenSSL */
|
||||
tmp = crypto_decrypt_private_key_data (contents, password, &ktype, error);
|
||||
tmp = crypto_decrypt_private_key_data (data, data_len, password, &ktype, error);
|
||||
if (tmp)
|
||||
format = NM_CRYPTO_FILE_FORMAT_RAW_KEY;
|
||||
else if (!password && (ktype != NM_CRYPTO_KEY_TYPE_UNKNOWN))
|
||||
|
|
@ -742,7 +751,7 @@ crypto_verify_private_key (const char *filename,
|
|||
|
||||
contents = file_to_g_byte_array (filename, error);
|
||||
if (contents) {
|
||||
format = crypto_verify_private_key_data (contents, password, error);
|
||||
format = crypto_verify_private_key_data (contents->data, contents->len, password, error);
|
||||
g_byte_array_free (contents, TRUE);
|
||||
}
|
||||
return format;
|
||||
|
|
|
|||
|
|
@ -72,7 +72,8 @@ gboolean crypto_init (GError **error);
|
|||
|
||||
void crypto_deinit (void);
|
||||
|
||||
GByteArray *crypto_decrypt_private_key_data (const GByteArray *contents,
|
||||
GByteArray *crypto_decrypt_private_key_data (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
NMCryptoKeyType *out_key_type,
|
||||
GError **error);
|
||||
|
|
@ -88,9 +89,10 @@ GByteArray *crypto_load_and_verify_certificate (const char *file,
|
|||
|
||||
gboolean crypto_is_pkcs12_file (const char *file, GError **error);
|
||||
|
||||
gboolean crypto_is_pkcs12_data (const GByteArray *data);
|
||||
gboolean crypto_is_pkcs12_data (const guint8 *data, gsize len);
|
||||
|
||||
NMCryptoFileFormat crypto_verify_private_key_data (const GByteArray *contents,
|
||||
NMCryptoFileFormat crypto_verify_private_key_data (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
|
|
@ -110,7 +112,8 @@ gboolean crypto_md5_hash (const char *salt,
|
|||
|
||||
char * crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -119,7 +122,8 @@ char * crypto_decrypt (const char *cipher,
|
|||
GError **error);
|
||||
|
||||
char * crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -129,15 +133,17 @@ char * crypto_encrypt (const char *cipher,
|
|||
|
||||
gboolean crypto_randomize (void *buffer, gsize buffer_len, GError **error);
|
||||
|
||||
NMCryptoFileFormat crypto_verify_cert (const unsigned char *data,
|
||||
NMCryptoFileFormat crypto_verify_cert (const guint8 *data,
|
||||
gsize len,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_verify_pkcs12 (const GByteArray *data,
|
||||
gboolean crypto_verify_pkcs12 (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
||||
gboolean crypto_verify_pkcs8 (const GByteArray *data,
|
||||
gboolean crypto_verify_pkcs8 (const guint8 *data,
|
||||
gsize data_len,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -120,7 +120,8 @@ crypto_md5_hash (const char *salt,
|
|||
char *
|
||||
crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -160,7 +161,7 @@ crypto_decrypt (const char *cipher,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
output = g_malloc0 (data->len);
|
||||
output = g_malloc0 (data_len);
|
||||
|
||||
err = gcry_cipher_open (&ctx, cipher_mech, GCRY_CIPHER_MODE_CBC, 0);
|
||||
if (err) {
|
||||
|
|
@ -189,7 +190,7 @@ crypto_decrypt (const char *cipher,
|
|||
goto out;
|
||||
}
|
||||
|
||||
err = gcry_cipher_decrypt (ctx, output, data->len, data->data, data->len);
|
||||
err = gcry_cipher_decrypt (ctx, output, data_len, data, data_len);
|
||||
if (err) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
|
|
@ -197,7 +198,7 @@ crypto_decrypt (const char *cipher,
|
|||
gcry_strsource (err), gcry_strerror (err));
|
||||
goto out;
|
||||
}
|
||||
pad_len = output[data->len - 1];
|
||||
pad_len = output[data_len - 1];
|
||||
|
||||
/* Check if the padding at the end of the decrypted data is valid */
|
||||
if (pad_len == 0 || pad_len > real_iv_len) {
|
||||
|
|
@ -211,7 +212,7 @@ crypto_decrypt (const char *cipher,
|
|||
* should contain the padding size.
|
||||
*/
|
||||
for (i = 1; i <= pad_len; ++i) {
|
||||
if (output[data->len - i] != pad_len) {
|
||||
if (output[data_len - i] != pad_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key."));
|
||||
|
|
@ -219,14 +220,14 @@ crypto_decrypt (const char *cipher,
|
|||
}
|
||||
}
|
||||
|
||||
*out_len = data->len - pad_len;
|
||||
*out_len = data_len - pad_len;
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
if (!success) {
|
||||
if (output) {
|
||||
/* Don't expose key material */
|
||||
memset (output, 0, data->len);
|
||||
memset (output, 0, data_len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
|
|
@ -237,7 +238,8 @@ out:
|
|||
|
||||
char *
|
||||
crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -269,16 +271,16 @@ crypto_encrypt (const char *cipher,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* If data->len % ivlen == 0, then we add another complete block
|
||||
/* If data_len % ivlen == 0, then we add another complete block
|
||||
* onto the end so that the decrypter knows there's padding.
|
||||
*/
|
||||
pad_len = iv_len - (data->len % iv_len);
|
||||
output_len = padded_buf_len = data->len + pad_len;
|
||||
pad_len = iv_len - (data_len % iv_len);
|
||||
output_len = padded_buf_len = data_len + pad_len;
|
||||
padded_buf = g_malloc0 (padded_buf_len);
|
||||
|
||||
memcpy (padded_buf, data->data, data->len);
|
||||
memcpy (padded_buf, data, data_len);
|
||||
for (i = 0; i < pad_len; i++)
|
||||
padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
|
||||
padded_buf[data_len + i] = (guint8) (pad_len & 0xFF);
|
||||
|
||||
output = g_malloc0 (output_len);
|
||||
|
||||
|
|
@ -382,7 +384,8 @@ crypto_verify_cert (const unsigned char *data,
|
|||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs12 (const GByteArray *data,
|
||||
crypto_verify_pkcs12 (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -393,8 +396,8 @@ crypto_verify_pkcs12 (const GByteArray *data,
|
|||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
dt.data = (unsigned char *) data->data;
|
||||
dt.size = data->len;
|
||||
dt.data = (unsigned char *) data;
|
||||
dt.size = data_len;
|
||||
|
||||
err = gnutls_pkcs12_init (&p12);
|
||||
if (err < 0) {
|
||||
|
|
@ -435,7 +438,8 @@ out:
|
|||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs8 (const GByteArray *data,
|
||||
crypto_verify_pkcs8 (const guint8 *data,
|
||||
gsize data_len,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error)
|
||||
|
|
@ -446,8 +450,8 @@ crypto_verify_pkcs8 (const GByteArray *data,
|
|||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
dt.data = (unsigned char *) data->data;
|
||||
dt.size = data->len;
|
||||
dt.data = (unsigned char *) data;
|
||||
dt.size = data_len;
|
||||
|
||||
err = gnutls_x509_privkey_init (&p8);
|
||||
if (err < 0) {
|
||||
|
|
|
|||
|
|
@ -134,7 +134,8 @@ crypto_md5_hash (const char *salt,
|
|||
char *
|
||||
crypto_decrypt (const char *cipher,
|
||||
int key_type,
|
||||
GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
const gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -180,7 +181,7 @@ crypto_decrypt (const char *cipher,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
output = g_malloc0 (data->len);
|
||||
output = g_malloc0 (data_len);
|
||||
|
||||
slot = PK11_GetBestSlot (cipher_mech, NULL);
|
||||
if (!slot) {
|
||||
|
|
@ -221,9 +222,9 @@ crypto_decrypt (const char *cipher,
|
|||
s = PK11_CipherOp (ctx,
|
||||
(unsigned char *) output,
|
||||
&decrypted_len,
|
||||
data->len,
|
||||
data->data,
|
||||
data->len);
|
||||
data_len,
|
||||
data,
|
||||
data_len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
|
|
@ -232,7 +233,7 @@ crypto_decrypt (const char *cipher,
|
|||
goto out;
|
||||
}
|
||||
|
||||
if (decrypted_len > data->len) {
|
||||
if (decrypted_len > data_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key: decrypted data too large."));
|
||||
|
|
@ -242,7 +243,7 @@ crypto_decrypt (const char *cipher,
|
|||
s = PK11_DigestFinal (ctx,
|
||||
(unsigned char *) (output + decrypted_len),
|
||||
&extra,
|
||||
data->len - decrypted_len);
|
||||
data_len - decrypted_len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
|
|
@ -251,7 +252,7 @@ crypto_decrypt (const char *cipher,
|
|||
goto out;
|
||||
}
|
||||
decrypted_len += extra;
|
||||
pad_len = data->len - decrypted_len;
|
||||
pad_len = data_len - decrypted_len;
|
||||
|
||||
/* Check if the padding at the end of the decrypted data is valid */
|
||||
if (pad_len == 0 || pad_len > real_iv_len) {
|
||||
|
|
@ -265,7 +266,7 @@ crypto_decrypt (const char *cipher,
|
|||
* should contain the padding size.
|
||||
*/
|
||||
for (i = pad_len; i > 0; i--) {
|
||||
if (output[data->len - i] != pad_len) {
|
||||
if (output[data_len - i] != pad_len) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_CIPHER_DECRYPT_FAILED,
|
||||
_("Failed to decrypt the private key."));
|
||||
|
|
@ -289,7 +290,7 @@ out:
|
|||
if (!success) {
|
||||
if (output) {
|
||||
/* Don't expose key material */
|
||||
memset (output, 0, data->len);
|
||||
memset (output, 0, data_len);
|
||||
g_free (output);
|
||||
output = NULL;
|
||||
}
|
||||
|
|
@ -299,7 +300,8 @@ out:
|
|||
|
||||
char *
|
||||
crypto_encrypt (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *iv,
|
||||
gsize iv_len,
|
||||
const char *key,
|
||||
|
|
@ -336,13 +338,13 @@ crypto_encrypt (const char *cipher,
|
|||
/* If data->len % ivlen == 0, then we add another complete block
|
||||
* onto the end so that the decrypter knows there's padding.
|
||||
*/
|
||||
pad_len = iv_len - (data->len % iv_len);
|
||||
output_len = padded_buf_len = data->len + pad_len;
|
||||
pad_len = iv_len - (data_len % iv_len);
|
||||
output_len = padded_buf_len = data_len + pad_len;
|
||||
padded_buf = g_malloc0 (padded_buf_len);
|
||||
|
||||
memcpy (padded_buf, data->data, data->len);
|
||||
memcpy (padded_buf, data, data_len);
|
||||
for (i = 0; i < pad_len; i++)
|
||||
padded_buf[data->len + i] = (guint8) (pad_len & 0xFF);
|
||||
padded_buf[data_len + i] = (guint8) (pad_len & 0xFF);
|
||||
|
||||
output = g_malloc0 (output_len);
|
||||
|
||||
|
|
@ -440,7 +442,8 @@ crypto_verify_cert (const unsigned char *data,
|
|||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs12 (const GByteArray *data,
|
||||
crypto_verify_pkcs12 (const guint8 *data,
|
||||
gsize data_len,
|
||||
const char *password,
|
||||
GError **error)
|
||||
{
|
||||
|
|
@ -498,7 +501,7 @@ crypto_verify_pkcs12 (const GByteArray *data,
|
|||
goto error;
|
||||
}
|
||||
|
||||
s = SEC_PKCS12DecoderUpdate (p12ctx, data->data, data->len);
|
||||
s = SEC_PKCS12DecoderUpdate (p12ctx, (guint8 *)data, data_len);
|
||||
if (s != SECSuccess) {
|
||||
g_set_error (error, NM_CRYPTO_ERROR,
|
||||
NM_CRYPTO_ERR_FILE_FORMAT_INVALID,
|
||||
|
|
@ -532,7 +535,8 @@ error:
|
|||
}
|
||||
|
||||
gboolean
|
||||
crypto_verify_pkcs8 (const GByteArray *data,
|
||||
crypto_verify_pkcs8 (const guint8 *data,
|
||||
gsize data_len,
|
||||
gboolean is_encrypted,
|
||||
const char *password,
|
||||
GError **error)
|
||||
|
|
|
|||
|
|
@ -256,12 +256,11 @@ validate_permissions_type (GHashTable *hash, GError **error)
|
|||
if (s_con) {
|
||||
permissions = g_hash_table_lookup (s_con, NM_SETTING_CONNECTION_PERMISSIONS);
|
||||
if (permissions) {
|
||||
if ( !G_VALUE_HOLDS (permissions, G_TYPE_STRV)
|
||||
&& !G_VALUE_HOLDS (permissions, DBUS_TYPE_G_LIST_OF_STRING)) {
|
||||
if (!G_VALUE_HOLDS (permissions, G_TYPE_STRV)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_ERROR,
|
||||
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH,
|
||||
"Wrong permissions property type; should be a list of strings.");
|
||||
"Wrong permissions property type; should be an array of strings.");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,5 +63,14 @@ gboolean _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *s
|
|||
|
||||
GSList * _nm_utils_hash_values_to_slist (GHashTable *hash);
|
||||
|
||||
GHashTable *_nm_utils_copy_strdict (GHashTable *strdict);
|
||||
|
||||
typedef gpointer (*NMUtilsCopyFunc) (gpointer);
|
||||
|
||||
GPtrArray *_nm_utils_copy_slist_to_array (const GSList *list,
|
||||
NMUtilsCopyFunc copy_func,
|
||||
GDestroyNotify unref_func);
|
||||
GSList *_nm_utils_copy_array_to_slist (const GPtrArray *array,
|
||||
NMUtilsCopyFunc copy_func);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,43 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2008 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_PARAM_SPEC_SPECIALIZED_H__
|
||||
#define __NM_PARAM_SPEC_SPECIALIZED_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
typedef struct _NMParamSpecSpecialized NMParamSpecSpecialized;
|
||||
|
||||
#define NM_TYPE_PARAM_SPEC_SPECIALIZED (_nm_param_spec_specialized_get_type ())
|
||||
|
||||
#define NM_IS_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED))
|
||||
#define NM_PARAM_SPEC_SPECIALIZED(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), NM_TYPE_PARAM_SPEC_SPECIALIZED, NMParamSpecSpecialized))
|
||||
|
||||
GType _nm_param_spec_specialized_get_type (void);
|
||||
|
||||
GParamSpec *_nm_param_spec_specialized (const char *name,
|
||||
const char *nick,
|
||||
const char *blurb,
|
||||
GType specialized_type,
|
||||
GParamFlags flags);
|
||||
|
||||
#endif /* __NM_PARAM_SPEC_SPECIALIZED_H__ */
|
||||
|
|
@ -16,17 +16,13 @@
|
|||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2011 Red Hat, Inc.
|
||||
* Copyright 2007 - 2014 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-property-compare.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
struct _NMParamSpecSpecialized {
|
||||
GParamSpec parent;
|
||||
};
|
||||
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <netinet/in.h>
|
||||
|
|
@ -34,11 +30,6 @@ struct _NMParamSpecSpecialized {
|
|||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
/***********************************************************/
|
||||
/* _gvalues_compare */
|
||||
|
||||
static gint _gvalues_compare (const GValue *value1, const GValue *value2);
|
||||
|
||||
static gboolean
|
||||
type_is_fixed_size (GType type, gsize *tsize)
|
||||
{
|
||||
|
|
@ -84,7 +75,7 @@ type_is_fixed_size (GType type, gsize *tsize)
|
|||
#define FLOAT_FACTOR 0.00000001
|
||||
|
||||
static gint
|
||||
_gvalues_compare_fixed (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_fixed (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
|
|
@ -175,7 +166,7 @@ _gvalues_compare_fixed (const GValue *value1, const GValue *value2)
|
|||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_string (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_string (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
const char *str1 = g_value_get_string (value1);
|
||||
const char *str2 = g_value_get_string (value2);
|
||||
|
|
@ -192,7 +183,7 @@ _gvalues_compare_string (const GValue *value1, const GValue *value2)
|
|||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_strv (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_strv (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
char **strv1;
|
||||
char **strv2;
|
||||
|
|
@ -248,7 +239,7 @@ iterate_collection (const GValue *value, gpointer user_data)
|
|||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_collection (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_collection (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
gint ret;
|
||||
guint len1;
|
||||
|
|
@ -285,7 +276,7 @@ _gvalues_compare_collection (const GValue *value1, const GValue *value2)
|
|||
for (iter1 = list1, iter2 = list2, ret = 0;
|
||||
ret == 0 && iter1 && iter2;
|
||||
iter1 = iter1->next, iter2 = iter2->next)
|
||||
ret = _gvalues_compare ((GValue *) iter1->data, (GValue *) iter2->data);
|
||||
ret = nm_property_compare ((GValue *) iter1->data, (GValue *) iter2->data);
|
||||
}
|
||||
|
||||
g_slist_free_full (list1, _gvalue_destroy);
|
||||
|
|
@ -321,13 +312,13 @@ compare_one_map_item (gpointer key, gpointer val, gpointer user_data)
|
|||
|
||||
value2 = (GValue *) g_hash_table_lookup (info->hash2, key);
|
||||
if (value2)
|
||||
info->ret = _gvalues_compare ((GValue *) val, value2);
|
||||
info->ret = nm_property_compare ((GValue *) val, value2);
|
||||
else
|
||||
info->ret = 1;
|
||||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_map (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_map (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GHashTable *hash1 = NULL;
|
||||
GHashTable *hash2 = NULL;
|
||||
|
|
@ -487,10 +478,10 @@ _gvalue_ip6_route_compare (const GValue *value1, const GValue *value2)
|
|||
}
|
||||
|
||||
static gint
|
||||
_gvalues_compare_struct (const GValue *value1, const GValue *value2)
|
||||
nm_property_compare_struct (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
/* value1 and value2 must contain the same type since
|
||||
* _gvalues_compare() enforced that already.
|
||||
* nm_property_compare() enforced that already.
|
||||
*/
|
||||
|
||||
if (G_VALUE_HOLDS (value1, DBUS_TYPE_G_IP6_ADDRESS)) {
|
||||
|
|
@ -503,8 +494,8 @@ _gvalues_compare_struct (const GValue *value1, const GValue *value2)
|
|||
}
|
||||
}
|
||||
|
||||
gint
|
||||
_gvalues_compare (const GValue *value1, const GValue *value2)
|
||||
int
|
||||
nm_property_compare (const GValue *value1, const GValue *value2)
|
||||
{
|
||||
GType type1;
|
||||
GType type2;
|
||||
|
|
@ -524,9 +515,9 @@ _gvalues_compare (const GValue *value1, const GValue *value2)
|
|||
return type1 < type2 ? -1 : type1 > type2;
|
||||
|
||||
if (type_is_fixed_size (type1, NULL))
|
||||
ret = _gvalues_compare_fixed (value1, value2);
|
||||
ret = nm_property_compare_fixed (value1, value2);
|
||||
else if (type1 == G_TYPE_STRING)
|
||||
ret = _gvalues_compare_string (value1, value2);
|
||||
ret = nm_property_compare_string (value1, value2);
|
||||
else if (G_VALUE_HOLDS_BOXED (value1)) {
|
||||
gpointer p1 = g_value_get_boxed (value1);
|
||||
gpointer p2 = g_value_get_boxed (value2);
|
||||
|
|
@ -538,15 +529,15 @@ _gvalues_compare (const GValue *value1, const GValue *value2)
|
|||
else if (!p2)
|
||||
ret = -1; /* The comparision functions below don't handle NULLs */
|
||||
else if (type1 == G_TYPE_STRV)
|
||||
ret = _gvalues_compare_strv (value1, value2);
|
||||
ret = nm_property_compare_strv (value1, value2);
|
||||
else if (dbus_g_type_is_collection (type1))
|
||||
ret = _gvalues_compare_collection (value1, value2);
|
||||
ret = nm_property_compare_collection (value1, value2);
|
||||
else if (dbus_g_type_is_map (type1))
|
||||
ret = _gvalues_compare_map (value1, value2);
|
||||
ret = nm_property_compare_map (value1, value2);
|
||||
else if (dbus_g_type_is_struct (type1))
|
||||
ret = _gvalues_compare_struct (value1, value2);
|
||||
ret = nm_property_compare_struct (value1, value2);
|
||||
else if (type1 == G_TYPE_VALUE)
|
||||
ret = _gvalues_compare ((GValue *) g_value_get_boxed (value1), (GValue *) g_value_get_boxed (value2));
|
||||
ret = nm_property_compare ((GValue *) g_value_get_boxed (value1), (GValue *) g_value_get_boxed (value2));
|
||||
else {
|
||||
g_warning ("Don't know how to compare boxed types '%s'", g_type_name (type1));
|
||||
ret = value1 == value2;
|
||||
|
|
@ -558,415 +549,3 @@ _gvalues_compare (const GValue *value1, const GValue *value2)
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
|
||||
static void
|
||||
param_specialized_init (GParamSpec *pspec)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
param_specialized_set_default (GParamSpec *pspec, GValue *value)
|
||||
{
|
||||
value->data[0].v_pointer = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
param_specialized_validate (GParamSpec *pspec, GValue *value)
|
||||
{
|
||||
NMParamSpecSpecialized *sspec = NM_PARAM_SPEC_SPECIALIZED (pspec);
|
||||
GType value_type = G_VALUE_TYPE (value);
|
||||
gboolean changed = FALSE;
|
||||
|
||||
if (!g_value_type_compatible (value_type, G_PARAM_SPEC_VALUE_TYPE (sspec))) {
|
||||
g_value_reset (value);
|
||||
changed = TRUE;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
static gint
|
||||
param_specialized_values_cmp (GParamSpec *pspec,
|
||||
const GValue *value1,
|
||||
const GValue *value2)
|
||||
{
|
||||
return _gvalues_compare (value1, value2);
|
||||
}
|
||||
|
||||
GType
|
||||
_nm_param_spec_specialized_get_type (void)
|
||||
{
|
||||
static GType type;
|
||||
|
||||
if (G_UNLIKELY (type) == 0) {
|
||||
static const GParamSpecTypeInfo pspec_info = {
|
||||
sizeof (NMParamSpecSpecialized),
|
||||
0,
|
||||
param_specialized_init,
|
||||
G_TYPE_OBJECT, /* value_type */
|
||||
NULL, /* finalize */
|
||||
param_specialized_set_default,
|
||||
param_specialized_validate,
|
||||
param_specialized_values_cmp,
|
||||
};
|
||||
type = g_param_type_register_static ("NMParamSpecSpecialized", &pspec_info);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GParamSpec *
|
||||
_nm_param_spec_specialized (const char *name,
|
||||
const char *nick,
|
||||
const char *blurb,
|
||||
GType specialized_type,
|
||||
GParamFlags flags)
|
||||
{
|
||||
NMParamSpecSpecialized *pspec;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (specialized_type, G_TYPE_BOXED), NULL);
|
||||
|
||||
pspec = g_param_spec_internal (NM_TYPE_PARAM_SPEC_SPECIALIZED,
|
||||
name, nick, blurb, flags);
|
||||
|
||||
G_PARAM_SPEC (pspec)->value_type = specialized_type;
|
||||
|
||||
return G_PARAM_SPEC (pspec);
|
||||
}
|
||||
|
||||
/***********************************************************/
|
||||
/* Tests */
|
||||
|
||||
#if 0
|
||||
|
||||
static void
|
||||
compare_ints (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, G_TYPE_INT);
|
||||
g_value_init (&value2, G_TYPE_INT);
|
||||
|
||||
g_value_set_int (&value1, 5);
|
||||
g_value_set_int (&value2, 5);
|
||||
g_print ("Comparing ints 5 and 5: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_int (&value2, 10);
|
||||
g_print ("Comparing ints 5 and 10: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_int (&value2, 1);
|
||||
g_print ("Comparing ints 5 and 1: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strings (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
const char *str1 = "hello";
|
||||
const char *str2 = "world";
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRING);
|
||||
g_value_init (&value2, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (&value1, str1);
|
||||
g_value_set_string (&value2, str1);
|
||||
g_print ("Comparing identical strings: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_string (&value2, str2);
|
||||
g_print ("Comparing different strings: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strv (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
char *strv1[] = { "foo", "bar", "baz", NULL };
|
||||
char *strv2[] = { "foo", "bar", "bar", NULL };
|
||||
char *strv3[] = { "foo", "bar", NULL };
|
||||
char *strv4[] = { "foo", "bar", "baz", "bam", NULL };
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRV);
|
||||
g_value_init (&value2, G_TYPE_STRV);
|
||||
|
||||
g_value_set_boxed (&value1, strv1);
|
||||
g_value_set_boxed (&value2, strv1);
|
||||
g_print ("Comparing identical strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv2);
|
||||
g_print ("Comparing different strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv3);
|
||||
g_print ("Comparing different len (smaller) strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value2, strv4);
|
||||
g_print ("Comparing different len (longer) strv's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_garrays (void)
|
||||
{
|
||||
GArray *array1;
|
||||
GArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
int i;
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array1 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
g_value_init (&value2, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array2 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
g_array_append_val (array1, i);
|
||||
g_array_append_val (array2, i);
|
||||
}
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
|
||||
g_print ("Comparing identical arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_array_remove_index (array2, 0);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different length arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
i = 7;
|
||||
g_array_prepend_val (array2, i);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ptrarrays (void)
|
||||
{
|
||||
GPtrArray *array1;
|
||||
GPtrArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array1 = g_ptr_array_new ();
|
||||
|
||||
g_value_init (&value2, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array2 = g_ptr_array_new ();
|
||||
|
||||
g_ptr_array_add (array1, "hello");
|
||||
g_ptr_array_add (array1, "world");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
|
||||
g_ptr_array_add (array2, "hello");
|
||||
g_ptr_array_add (array2, "world");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
|
||||
g_print ("Comparing identical ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_ptr_array_add (array2, "boo");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different len ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_ptr_array_add (array1, "booz");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_print ("Comparing different ptr arrays's: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_str_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", "hello");
|
||||
g_hash_table_insert (hash1, "key2", "world");
|
||||
|
||||
g_hash_table_insert (hash2, "key1", "hello");
|
||||
g_hash_table_insert (hash2, "key2", "world");
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing identical str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_insert (hash2, "key2", "moon");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static GValue *
|
||||
str_to_gvalue (const char *str)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, str);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
int_to_gvalue (int i)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_INT);
|
||||
g_value_set_int (value, i);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
compare_gvalue_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", str_to_gvalue ("hello"));
|
||||
g_hash_table_insert (hash1, "key2", int_to_gvalue (5));
|
||||
|
||||
g_hash_table_insert (hash2, "key1", str_to_gvalue ("hello"));
|
||||
g_hash_table_insert (hash2, "key2", int_to_gvalue (5));
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing identical gvalue hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different length str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_hash_table_insert (hash2, "key2", str_to_gvalue ("moon"));
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_print ("Comparing different str hashes: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ip6_addresses (void)
|
||||
{
|
||||
GValueArray *array1;
|
||||
GValueArray *array2;
|
||||
GValueArray *array3;
|
||||
GByteArray *ba1;
|
||||
GByteArray *ba2;
|
||||
GByteArray *ba3;
|
||||
GValue element = G_VALUE_INIT;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
struct in6_addr addr1;
|
||||
struct in6_addr addr2;
|
||||
struct in6_addr addr3;
|
||||
guint32 prefix1 = 64;
|
||||
guint32 prefix2 = 64;
|
||||
guint32 prefix3 = 0;
|
||||
|
||||
inet_pton (AF_INET6, "1:2:3:4:5:6:7:8", &addr1, sizeof (struct in6_addr));
|
||||
inet_pton (AF_INET6, "ffff:2:3:4:5:6:7:8", &addr2, sizeof (struct in6_addr));
|
||||
inet_pton (AF_INET6, "::", &addr3, sizeof (struct in6_addr));
|
||||
|
||||
/* address 1 */
|
||||
ba1 = g_byte_array_new ();
|
||||
array1 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba1, (guint8 *) addr1.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 2 */
|
||||
ba2 = g_byte_array_new ();
|
||||
array2 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba2, (guint8 *) addr2.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 3 */
|
||||
ba3 = g_byte_array_new ();
|
||||
array3 = g_value_array_new (2);
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba3, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
g_value_init (&value2, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array1);
|
||||
g_print ("Comparing identical IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array3);
|
||||
g_print ("Comparing different IPv6 address structures: %d\n", _gvalues_compare (&value1, &value2));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 35, 0)
|
||||
g_type_init ();
|
||||
#endif
|
||||
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
|
||||
|
||||
compare_ints ();
|
||||
compare_strings ();
|
||||
compare_strv ();
|
||||
compare_garrays ();
|
||||
compare_ptrarrays ();
|
||||
compare_str_hash ();
|
||||
compare_gvalue_hash ();
|
||||
compare_ip6_addresses ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
30
libnm-core/nm-property-compare.h
Normal file
30
libnm-core/nm-property-compare.h
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2014 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#ifndef __NM_PROPERTY_COMPARE_H__
|
||||
#define __NM_PROPERTY_COMPARE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
int nm_property_compare (const GValue *value1, const GValue *value2);
|
||||
|
||||
#endif /* __NM_PROPERTY_COMPARE_H__ */
|
||||
|
|
@ -25,7 +25,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "crypto.h"
|
||||
|
|
@ -95,31 +94,31 @@ typedef struct {
|
|||
char *identity;
|
||||
char *anonymous_identity;
|
||||
char *pac_file;
|
||||
GByteArray *ca_cert;
|
||||
GBytes *ca_cert;
|
||||
char *ca_path;
|
||||
char *subject_match;
|
||||
GSList *altsubject_matches;
|
||||
GByteArray *client_cert;
|
||||
GBytes *client_cert;
|
||||
char *phase1_peapver;
|
||||
char *phase1_peaplabel;
|
||||
char *phase1_fast_provisioning;
|
||||
char *phase2_auth;
|
||||
char *phase2_autheap;
|
||||
GByteArray *phase2_ca_cert;
|
||||
GBytes *phase2_ca_cert;
|
||||
char *phase2_ca_path;
|
||||
char *phase2_subject_match;
|
||||
GSList *phase2_altsubject_matches;
|
||||
GByteArray *phase2_client_cert;
|
||||
GBytes *phase2_client_cert;
|
||||
char *password;
|
||||
NMSettingSecretFlags password_flags;
|
||||
GByteArray *password_raw;
|
||||
GBytes *password_raw;
|
||||
NMSettingSecretFlags password_raw_flags;
|
||||
char *pin;
|
||||
NMSettingSecretFlags pin_flags;
|
||||
GByteArray *private_key;
|
||||
GBytes *private_key;
|
||||
char *private_key_password;
|
||||
NMSettingSecretFlags private_key_password_flags;
|
||||
GByteArray *phase2_private_key;
|
||||
GBytes *phase2_private_key;
|
||||
char *phase2_private_key_password;
|
||||
NMSettingSecretFlags phase2_private_key_password_flags;
|
||||
gboolean system_ca_certs;
|
||||
|
|
@ -417,13 +416,20 @@ nm_setting_802_1x_get_system_ca_certs (NMSetting8021x *setting)
|
|||
}
|
||||
|
||||
static NMSetting8021xCKScheme
|
||||
get_cert_scheme (GByteArray *array)
|
||||
get_cert_scheme (GBytes *bytes)
|
||||
{
|
||||
if (!array || !array->len)
|
||||
gconstpointer data;
|
||||
gsize length;
|
||||
|
||||
if (!bytes)
|
||||
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
|
||||
|
||||
if ( (array->len > strlen (SCHEME_PATH))
|
||||
&& !memcmp (array->data, SCHEME_PATH, strlen (SCHEME_PATH)))
|
||||
data = g_bytes_get_data (bytes, &length);
|
||||
if (!length)
|
||||
return NM_SETTING_802_1X_CK_SCHEME_UNKNOWN;
|
||||
|
||||
if ( (length > strlen (SCHEME_PATH))
|
||||
&& !memcmp (data, SCHEME_PATH, strlen (SCHEME_PATH)))
|
||||
return NM_SETTING_802_1X_CK_SCHEME_PATH;
|
||||
|
||||
return NM_SETTING_802_1X_CK_SCHEME_BLOB;
|
||||
|
|
@ -460,7 +466,7 @@ nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the CA certificate data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -490,16 +496,18 @@ const char *
|
|||
nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_ca_cert_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->ca_cert, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
static GBytes *
|
||||
path_to_scheme_value (const char *path)
|
||||
{
|
||||
GByteArray *array;
|
||||
|
|
@ -508,11 +516,11 @@ path_to_scheme_value (const char *path)
|
|||
|
||||
/* Add the path scheme tag to the front, then the fielname */
|
||||
array = g_byte_array_sized_new (strlen (path) + strlen (SCHEME_PATH) + 1);
|
||||
g_assert (array);
|
||||
g_byte_array_append (array, (const guint8 *) SCHEME_PATH, strlen (SCHEME_PATH));
|
||||
g_byte_array_append (array, (const guint8 *) path, strlen (path));
|
||||
g_byte_array_append (array, (const guint8 *) "\0", 1);
|
||||
return array;
|
||||
|
||||
return g_byte_array_free_to_bytes (array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -559,11 +567,7 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||
|
||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||
|
||||
/* Clear out any previous ca_cert blob */
|
||||
if (priv->ca_cert) {
|
||||
g_byte_array_free (priv->ca_cert, TRUE);
|
||||
priv->ca_cert = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->ca_cert, g_bytes_unref);
|
||||
|
||||
if (!cert_path) {
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
||||
|
|
@ -577,9 +581,10 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||
if (out_format)
|
||||
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
||||
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
priv->ca_cert = g_byte_array_ref (data);
|
||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
priv->ca_cert = g_byte_array_free_to_bytes (data);
|
||||
data = NULL;
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->ca_cert = path_to_scheme_value (cert_path);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
|
@ -590,7 +595,8 @@ nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
|||
_("CA certificate must be in X.509 format"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CA_CERT);
|
||||
}
|
||||
g_byte_array_unref (data);
|
||||
if (data)
|
||||
g_byte_array_unref (data);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CA_CERT);
|
||||
|
|
@ -789,7 +795,7 @@ nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the client certificate data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -816,13 +822,15 @@ const char *
|
|||
nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_client_cert_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->client_cert, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -873,11 +881,7 @@ nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
|||
|
||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||
|
||||
/* Clear out any previous ca_cert blob */
|
||||
if (priv->client_cert) {
|
||||
g_byte_array_free (priv->client_cert, TRUE);
|
||||
priv->client_cert = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->client_cert, g_bytes_unref);
|
||||
|
||||
if (!cert_path) {
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||
|
|
@ -909,14 +913,16 @@ nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
|||
}
|
||||
|
||||
if (valid) {
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
priv->client_cert = g_byte_array_ref (data);
|
||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
priv->client_cert = g_byte_array_free_to_bytes (data);
|
||||
data = NULL;
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->client_cert = path_to_scheme_value (cert_path);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_byte_array_unref (data);
|
||||
if (data)
|
||||
g_byte_array_unref (data);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||
|
|
@ -1055,7 +1061,7 @@ nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the "phase 2" CA certificate data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -1085,13 +1091,15 @@ const char *
|
|||
nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_phase2_ca_cert_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_ca_cert, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1138,11 +1146,7 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||
|
||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||
|
||||
/* Clear out any previous ca_cert blob */
|
||||
if (priv->phase2_ca_cert) {
|
||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
||||
priv->phase2_ca_cert = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->phase2_ca_cert, g_bytes_unref);
|
||||
|
||||
if (!cert_path) {
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||
|
|
@ -1156,9 +1160,10 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||
if (out_format)
|
||||
*out_format = NM_SETTING_802_1X_CK_FORMAT_X509;
|
||||
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
priv->phase2_ca_cert = g_byte_array_ref (data);
|
||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
priv->phase2_ca_cert = g_byte_array_free_to_bytes (data);
|
||||
data = NULL;
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->phase2_ca_cert = path_to_scheme_value (cert_path);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
|
|
@ -1169,7 +1174,8 @@ nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
|||
_("invalid certificate format"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||
}
|
||||
g_byte_array_unref (data);
|
||||
if (data)
|
||||
g_byte_array_unref (data);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CA_CERT);
|
||||
|
|
@ -1372,7 +1378,7 @@ nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the "phase 2" client certificate data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -1399,13 +1405,15 @@ const char *
|
|||
nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_phase2_client_cert_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_client_cert, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1456,11 +1464,7 @@ nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
|||
|
||||
priv = NM_SETTING_802_1X_GET_PRIVATE (setting);
|
||||
|
||||
/* Clear out any previous ca_cert blob */
|
||||
if (priv->phase2_client_cert) {
|
||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
||||
priv->phase2_client_cert = NULL;
|
||||
}
|
||||
g_clear_pointer (&priv->phase2_client_cert, g_bytes_unref);
|
||||
|
||||
if (!cert_path) {
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||
|
|
@ -1493,14 +1497,16 @@ nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
|||
}
|
||||
|
||||
if (valid) {
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB)
|
||||
priv->phase2_client_cert = g_byte_array_ref (data);
|
||||
else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
priv->phase2_client_cert = g_byte_array_free_to_bytes (data);
|
||||
data = NULL;
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->phase2_client_cert = path_to_scheme_value (cert_path);
|
||||
else
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
g_byte_array_unref (data);
|
||||
if (data)
|
||||
g_byte_array_unref (data);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||
|
|
@ -1544,7 +1550,7 @@ nm_setting_802_1x_get_password_flags (NMSetting8021x *setting)
|
|||
* UTF-8-encoded array of bytes, as specified by the
|
||||
* #NMSetting8021x:password-raw property
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_password_raw (NMSetting8021x *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
|
@ -1631,7 +1637,7 @@ nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the private key data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -1658,17 +1664,28 @@ const char *
|
|||
nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_private_key_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->private_key, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
file_to_byte_array (const char *filename)
|
||||
static void
|
||||
free_secure_bytes (gpointer data)
|
||||
{
|
||||
GByteArray *array = data;
|
||||
|
||||
memset (array->data, 0, array->len);
|
||||
g_byte_array_unref (array);
|
||||
}
|
||||
|
||||
static GBytes *
|
||||
file_to_secure_bytes (const char *filename)
|
||||
{
|
||||
char *contents;
|
||||
GByteArray *array = NULL;
|
||||
|
|
@ -1680,7 +1697,7 @@ file_to_byte_array (const char *filename)
|
|||
g_assert (array->len == length);
|
||||
g_free (contents);
|
||||
}
|
||||
return array;
|
||||
return g_bytes_new_with_free_func (array->data, array->len, free_secure_bytes, array);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1767,9 +1784,7 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||
|
||||
/* Clear out any previous private key data */
|
||||
if (priv->private_key) {
|
||||
/* Try not to leave the private key around in memory */
|
||||
memset (priv->private_key->data, 0, priv->private_key->len);
|
||||
g_byte_array_free (priv->private_key, TRUE);
|
||||
g_bytes_unref (priv->private_key);
|
||||
priv->private_key = NULL;
|
||||
key_cleared = TRUE;
|
||||
}
|
||||
|
|
@ -1791,7 +1806,7 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||
priv->private_key_password = g_strdup (password);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
/* Shouldn't fail this since we just verified the private key above */
|
||||
priv->private_key = file_to_byte_array (key_path);
|
||||
priv->private_key = file_to_secure_bytes (key_path);
|
||||
g_assert (priv->private_key);
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->private_key = path_to_scheme_value (key_path);
|
||||
|
|
@ -1804,10 +1819,8 @@ nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
|||
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
||||
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
||||
if (priv->client_cert)
|
||||
g_byte_array_free (priv->client_cert, TRUE);
|
||||
|
||||
priv->client_cert = g_byte_array_sized_new (priv->private_key->len);
|
||||
g_byte_array_append (priv->client_cert, priv->private_key->data, priv->private_key->len);
|
||||
g_bytes_unref (priv->client_cert);
|
||||
priv->client_cert = g_bytes_ref (priv->private_key);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_CLIENT_CERT);
|
||||
}
|
||||
|
||||
|
|
@ -1873,7 +1886,8 @@ nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting)
|
|||
|
||||
switch (nm_setting_802_1x_get_private_key_scheme (setting)) {
|
||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||
if (crypto_is_pkcs12_data (priv->private_key))
|
||||
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->private_key, NULL),
|
||||
g_bytes_get_size (priv->private_key)))
|
||||
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
||||
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||
|
|
@ -1958,7 +1972,7 @@ nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting)
|
|||
*
|
||||
* Returns: the "phase 2" private key data
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
|
|
@ -1985,13 +1999,15 @@ const char *
|
|||
nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting)
|
||||
{
|
||||
NMSetting8021xCKScheme scheme;
|
||||
gconstpointer data;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_802_1X (setting), NULL);
|
||||
|
||||
scheme = nm_setting_802_1x_get_phase2_private_key_scheme (setting);
|
||||
g_return_val_if_fail (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH, NULL);
|
||||
|
||||
return (const char *) (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key->data + strlen (SCHEME_PATH));
|
||||
data = g_bytes_get_data (NM_SETTING_802_1X_GET_PRIVATE (setting)->phase2_private_key, NULL);
|
||||
return (const char *)data + strlen (SCHEME_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2078,9 +2094,7 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||
|
||||
/* Clear out any previous private key data */
|
||||
if (priv->phase2_private_key) {
|
||||
/* Try not to leave the private key around in memory */
|
||||
memset (priv->phase2_private_key->data, 0, priv->phase2_private_key->len);
|
||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
||||
g_bytes_unref (priv->phase2_private_key);
|
||||
priv->phase2_private_key = NULL;
|
||||
key_cleared = TRUE;
|
||||
}
|
||||
|
|
@ -2102,7 +2116,7 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||
priv->phase2_private_key_password = g_strdup (password);
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
/* Shouldn't fail this since we just verified the private key above */
|
||||
priv->phase2_private_key = file_to_byte_array (key_path);
|
||||
priv->phase2_private_key = file_to_secure_bytes (key_path);
|
||||
g_assert (priv->phase2_private_key);
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH)
|
||||
priv->phase2_private_key = path_to_scheme_value (key_path);
|
||||
|
|
@ -2115,10 +2129,9 @@ nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
|||
g_assert (format != NM_CRYPTO_FILE_FORMAT_UNKNOWN);
|
||||
if (format == NM_CRYPTO_FILE_FORMAT_PKCS12) {
|
||||
if (priv->phase2_client_cert)
|
||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
||||
g_bytes_unref (priv->phase2_client_cert);
|
||||
|
||||
priv->phase2_client_cert = g_byte_array_sized_new (priv->phase2_private_key->len);
|
||||
g_byte_array_append (priv->phase2_client_cert, priv->phase2_private_key->data, priv->phase2_private_key->len);
|
||||
priv->phase2_client_cert = g_bytes_ref (priv->phase2_private_key);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||
}
|
||||
|
||||
|
|
@ -2153,7 +2166,8 @@ nm_setting_802_1x_get_phase2_private_key_format (NMSetting8021x *setting)
|
|||
|
||||
switch (nm_setting_802_1x_get_phase2_private_key_scheme (setting)) {
|
||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||
if (crypto_is_pkcs12_data (priv->phase2_private_key))
|
||||
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->phase2_private_key, NULL),
|
||||
g_bytes_get_size (priv->phase2_private_key)))
|
||||
return NM_SETTING_802_1X_CK_FORMAT_PKCS12;
|
||||
return NM_SETTING_802_1X_CK_FORMAT_RAW_KEY;
|
||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||
|
|
@ -2181,7 +2195,7 @@ need_secrets_password (NMSetting8021x *self,
|
|||
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
||||
|
||||
if ( (!priv->password || !strlen (priv->password))
|
||||
&& (!priv->password_raw || !priv->password_raw->len)) {
|
||||
&& (!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);
|
||||
}
|
||||
|
|
@ -2199,7 +2213,7 @@ need_secrets_sim (NMSetting8021x *self,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
need_private_key_password (const GByteArray *blob,
|
||||
need_private_key_password (GBytes *blob,
|
||||
const char *path,
|
||||
const char *password)
|
||||
{
|
||||
|
|
@ -2210,7 +2224,9 @@ need_private_key_password (const GByteArray *blob,
|
|||
if (path)
|
||||
format = crypto_verify_private_key (path, password, NULL);
|
||||
else if (blob)
|
||||
format = crypto_verify_private_key_data (blob, password, NULL);
|
||||
format = crypto_verify_private_key_data (g_bytes_get_data (blob, NULL),
|
||||
g_bytes_get_size (blob),
|
||||
password, NULL);
|
||||
else
|
||||
g_warning ("%s: unknown private key password scheme", __func__);
|
||||
}
|
||||
|
|
@ -2225,7 +2241,7 @@ need_secrets_tls (NMSetting8021x *self,
|
|||
{
|
||||
NMSetting8021xPrivate *priv = NM_SETTING_802_1X_GET_PRIVATE (self);
|
||||
NMSetting8021xCKScheme scheme;
|
||||
const GByteArray *blob = NULL;
|
||||
GBytes *blob = NULL;
|
||||
const char *path = NULL;
|
||||
|
||||
if (phase2) {
|
||||
|
|
@ -2272,7 +2288,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||
return FALSE;
|
||||
} else if (!priv->phase2_client_cert->len) {
|
||||
} else if (!g_bytes_get_size (priv->phase2_client_cert)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2289,7 +2305,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
|
||||
return FALSE;
|
||||
} else if (!priv->phase2_private_key->len) {
|
||||
} else if (!g_bytes_get_size (priv->phase2_private_key)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2299,20 +2315,9 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
}
|
||||
|
||||
/* If the private key is PKCS#12, check that it matches the client cert */
|
||||
if (crypto_is_pkcs12_data (priv->phase2_private_key)) {
|
||||
if (priv->phase2_private_key->len != priv->phase2_client_cert->len) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
_("has to match '%s' property for PKCS#12"),
|
||||
NM_SETTING_802_1X_PHASE2_PRIVATE_KEY);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PHASE2_CLIENT_CERT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (memcmp (priv->phase2_private_key->data,
|
||||
priv->phase2_client_cert->data,
|
||||
priv->phase2_private_key->len)) {
|
||||
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->phase2_private_key, NULL),
|
||||
g_bytes_get_size (priv->phase2_private_key))) {
|
||||
if (!g_bytes_equal (priv->phase2_private_key, priv->phase2_client_cert)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2330,7 +2335,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
|
||||
return FALSE;
|
||||
} else if (!priv->client_cert->len) {
|
||||
} else if (!g_bytes_get_size (priv->client_cert)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2347,7 +2352,7 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
_("property is missing"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_PRIVATE_KEY);
|
||||
return FALSE;
|
||||
} else if (!priv->private_key->len) {
|
||||
} else if (!g_bytes_get_size (priv->private_key)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2357,20 +2362,9 @@ verify_tls (NMSetting8021x *self, gboolean phase2, GError **error)
|
|||
}
|
||||
|
||||
/* If the private key is PKCS#12, check that it matches the client cert */
|
||||
if (crypto_is_pkcs12_data (priv->private_key)) {
|
||||
if (priv->private_key->len != priv->client_cert->len) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
_("has to match '%s' property for PKCS#12"),
|
||||
NM_SETTING_802_1X_PRIVATE_KEY);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_802_1X_SETTING_NAME, NM_SETTING_802_1X_CLIENT_CERT);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (memcmp (priv->private_key->data,
|
||||
priv->client_cert->data,
|
||||
priv->private_key->len)) {
|
||||
if (crypto_is_pkcs12_data (g_bytes_get_data (priv->private_key, NULL),
|
||||
g_bytes_get_size (priv->private_key))) {
|
||||
if (!g_bytes_equal (priv->private_key, priv->client_cert)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_802_1X_ERROR,
|
||||
NM_SETTING_802_1X_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -2590,21 +2584,25 @@ need_secrets (NMSetting *setting)
|
|||
}
|
||||
|
||||
static gboolean
|
||||
verify_cert (GByteArray *array, const char *prop_name, GError **error)
|
||||
verify_cert (GBytes *bytes, const char *prop_name, GError **error)
|
||||
{
|
||||
if (!array)
|
||||
gconstpointer data;
|
||||
gsize length;
|
||||
|
||||
if (!bytes)
|
||||
return TRUE;
|
||||
|
||||
switch (get_cert_scheme (array)) {
|
||||
switch (get_cert_scheme (bytes)) {
|
||||
case NM_SETTING_802_1X_CK_SCHEME_BLOB:
|
||||
return TRUE;
|
||||
case NM_SETTING_802_1X_CK_SCHEME_PATH:
|
||||
/* For path-based schemes, verify that the path is zero-terminated */
|
||||
if (array->data[array->len - 1] == '\0') {
|
||||
data = g_bytes_get_data (bytes, &length);
|
||||
if (((const guchar *)data)[length - 1] == '\0') {
|
||||
/* And ensure it's UTF-8 valid too so we can pass it through
|
||||
* D-Bus and stuff like that.
|
||||
*/
|
||||
if (g_utf8_validate ((const char *) (array->data + strlen (SCHEME_PATH)), -1, NULL))
|
||||
if (g_utf8_validate ((const char *)data + strlen (SCHEME_PATH), -1, NULL))
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
|
|
@ -2766,7 +2764,7 @@ finalize (GObject *object)
|
|||
g_free (priv->phase2_subject_match);
|
||||
g_free (priv->password);
|
||||
if (priv->password_raw)
|
||||
g_byte_array_free (priv->password_raw, TRUE);
|
||||
g_bytes_unref (priv->password_raw);
|
||||
g_free (priv->pin);
|
||||
|
||||
g_slist_free_full (priv->eap, g_free);
|
||||
|
|
@ -2774,39 +2772,37 @@ finalize (GObject *object)
|
|||
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
||||
|
||||
if (priv->ca_cert)
|
||||
g_byte_array_free (priv->ca_cert, TRUE);
|
||||
g_bytes_unref (priv->ca_cert);
|
||||
if (priv->client_cert)
|
||||
g_byte_array_free (priv->client_cert, TRUE);
|
||||
g_bytes_unref (priv->client_cert);
|
||||
if (priv->private_key)
|
||||
g_byte_array_free (priv->private_key, TRUE);
|
||||
g_bytes_unref (priv->private_key);
|
||||
g_free (priv->private_key_password);
|
||||
if (priv->phase2_ca_cert)
|
||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
||||
g_bytes_unref (priv->phase2_ca_cert);
|
||||
if (priv->phase2_client_cert)
|
||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
||||
g_bytes_unref (priv->phase2_client_cert);
|
||||
if (priv->phase2_private_key)
|
||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
||||
g_bytes_unref (priv->phase2_private_key);
|
||||
g_free (priv->phase2_private_key_password);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_802_1x_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static GByteArray *
|
||||
static GBytes *
|
||||
set_cert_prop_helper (const GValue *value, const char *prop_name, GError **error)
|
||||
{
|
||||
gboolean valid;
|
||||
GByteArray *data = NULL;
|
||||
GBytes *bytes = NULL;
|
||||
|
||||
data = g_value_dup_boxed (value);
|
||||
bytes = g_value_dup_boxed (value);
|
||||
/* Verify the new data */
|
||||
if (data) {
|
||||
valid = verify_cert (data, prop_name, error);
|
||||
if (!valid) {
|
||||
g_byte_array_free (data, TRUE);
|
||||
data = NULL;
|
||||
}
|
||||
if (bytes) {
|
||||
valid = verify_cert (bytes, prop_name, error);
|
||||
if (!valid)
|
||||
g_clear_pointer (&bytes, g_bytes_unref);
|
||||
}
|
||||
return data;
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2820,7 +2816,7 @@ set_property (GObject *object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_EAP:
|
||||
g_slist_free_full (priv->eap, g_free);
|
||||
priv->eap = g_value_dup_boxed (value);
|
||||
priv->eap = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_IDENTITY:
|
||||
g_free (priv->identity);
|
||||
|
|
@ -2835,10 +2831,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->pac_file = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CA_CERT:
|
||||
if (priv->ca_cert) {
|
||||
g_byte_array_free (priv->ca_cert, TRUE);
|
||||
priv->ca_cert = NULL;
|
||||
}
|
||||
if (priv->ca_cert)
|
||||
g_bytes_unref (priv->ca_cert);
|
||||
priv->ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CA_CERT, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||
|
|
@ -2856,13 +2850,11 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_ALTSUBJECT_MATCHES:
|
||||
g_slist_free_full (priv->altsubject_matches, g_free);
|
||||
priv->altsubject_matches = g_value_dup_boxed (value);
|
||||
priv->altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_CLIENT_CERT:
|
||||
if (priv->client_cert) {
|
||||
g_byte_array_free (priv->client_cert, TRUE);
|
||||
priv->client_cert = NULL;
|
||||
}
|
||||
if (priv->client_cert)
|
||||
g_bytes_unref (priv->client_cert);
|
||||
priv->client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_CLIENT_CERT, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||
|
|
@ -2891,10 +2883,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->phase2_autheap = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_PHASE2_CA_CERT:
|
||||
if (priv->phase2_ca_cert) {
|
||||
g_byte_array_free (priv->phase2_ca_cert, TRUE);
|
||||
priv->phase2_ca_cert = NULL;
|
||||
}
|
||||
if (priv->phase2_ca_cert)
|
||||
g_bytes_unref (priv->phase2_ca_cert);
|
||||
priv->phase2_ca_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CA_CERT, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||
|
|
@ -2912,13 +2902,11 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_PHASE2_ALTSUBJECT_MATCHES:
|
||||
g_slist_free_full (priv->phase2_altsubject_matches, g_free);
|
||||
priv->phase2_altsubject_matches = g_value_dup_boxed (value);
|
||||
priv->phase2_altsubject_matches = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_PHASE2_CLIENT_CERT:
|
||||
if (priv->phase2_client_cert) {
|
||||
g_byte_array_free (priv->phase2_client_cert, TRUE);
|
||||
priv->phase2_client_cert = NULL;
|
||||
}
|
||||
if (priv->phase2_client_cert)
|
||||
g_bytes_unref (priv->phase2_client_cert);
|
||||
priv->phase2_client_cert = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_CLIENT_CERT, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting certificate (invalid data): (%d) %s",
|
||||
|
|
@ -2935,17 +2923,15 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_PASSWORD_RAW:
|
||||
if (priv->password_raw)
|
||||
g_byte_array_free (priv->password_raw, TRUE);
|
||||
g_bytes_unref (priv->password_raw);
|
||||
priv->password_raw = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_PASSWORD_RAW_FLAGS:
|
||||
priv->password_raw_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_PRIVATE_KEY:
|
||||
if (priv->private_key) {
|
||||
g_byte_array_free (priv->private_key, TRUE);
|
||||
priv->private_key = NULL;
|
||||
}
|
||||
if (priv->private_key)
|
||||
g_bytes_unref (priv->private_key);
|
||||
priv->private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PRIVATE_KEY, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting private key (invalid data): (%d) %s",
|
||||
|
|
@ -2961,10 +2947,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->private_key_password_flags = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_PHASE2_PRIVATE_KEY:
|
||||
if (priv->phase2_private_key) {
|
||||
g_byte_array_free (priv->phase2_private_key, TRUE);
|
||||
priv->phase2_private_key = NULL;
|
||||
}
|
||||
if (priv->phase2_private_key)
|
||||
g_bytes_unref (priv->phase2_private_key);
|
||||
priv->phase2_private_key = set_cert_prop_helper (value, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, &error);
|
||||
if (error) {
|
||||
g_warning ("Error setting private key (invalid data): (%d) %s",
|
||||
|
|
@ -3004,7 +2988,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_EAP:
|
||||
g_value_set_boxed (value, priv->eap);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->eap));
|
||||
break;
|
||||
case PROP_IDENTITY:
|
||||
g_value_set_string (value, priv->identity);
|
||||
|
|
@ -3025,7 +3009,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, priv->subject_match);
|
||||
break;
|
||||
case PROP_ALTSUBJECT_MATCHES:
|
||||
g_value_set_boxed (value, priv->altsubject_matches);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->altsubject_matches));
|
||||
break;
|
||||
case PROP_CLIENT_CERT:
|
||||
g_value_set_boxed (value, priv->client_cert);
|
||||
|
|
@ -3055,7 +3039,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, priv->phase2_subject_match);
|
||||
break;
|
||||
case PROP_PHASE2_ALTSUBJECT_MATCHES:
|
||||
g_value_set_boxed (value, priv->phase2_altsubject_matches);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->phase2_altsubject_matches));
|
||||
break;
|
||||
case PROP_PHASE2_CLIENT_CERT:
|
||||
g_value_set_boxed (value, priv->phase2_client_cert);
|
||||
|
|
@ -3135,10 +3119,10 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_EAP,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_EAP, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_EAP, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSetting8021x:identity:
|
||||
|
|
@ -3199,10 +3183,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CA_CERT,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_CA_CERT, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_CA_CERT, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CA_CERT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:ca-path:
|
||||
|
|
@ -3241,10 +3229,10 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ALTSUBJECT_MATCHES,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_ALTSUBJECT_MATCHES, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_ALTSUBJECT_MATCHES, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSetting8021x:client-cert:
|
||||
|
|
@ -3264,10 +3252,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CLIENT_CERT,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_CLIENT_CERT, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_CLIENT_CERT, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_CLIENT_CERT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:phase1-peapver:
|
||||
|
|
@ -3373,10 +3365,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PHASE2_CA_CERT,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_CA_CERT, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CA_CERT, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CA_CERT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:phase2-ca-path:
|
||||
|
|
@ -3417,10 +3413,10 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PHASE2_ALTSUBJECT_MATCHES,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_ALTSUBJECT_MATCHES, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSetting8021x:phase2-client-cert:
|
||||
|
|
@ -3443,10 +3439,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PHASE2_CLIENT_CERT,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_CLIENT_CERT, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_CLIENT_CERT, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_CLIENT_CERT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:password:
|
||||
|
|
@ -3487,11 +3487,15 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PASSWORD_RAW,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PASSWORD_RAW, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_SECRET |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PASSWORD_RAW, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_SECRET |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PASSWORD_RAW,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:password-raw-flags:
|
||||
|
|
@ -3539,10 +3543,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIVATE_KEY,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PRIVATE_KEY, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PRIVATE_KEY, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PRIVATE_KEY,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:private-key-password:
|
||||
|
|
@ -3604,10 +3612,14 @@ nm_setting_802_1x_class_init (NMSetting8021xClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PHASE2_PRIVATE_KEY,
|
||||
_nm_param_spec_specialized (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_802_1X_PHASE2_PRIVATE_KEY, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_802_1X_PHASE2_PRIVATE_KEY,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSetting8021x:phase2-private-key-password:
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ const char * nm_setting_802_1x_get_ca_path (NMSetting8
|
|||
const char * nm_setting_802_1x_get_phase2_ca_path (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_ca_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_ca_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_ca_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_ca_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
|
|
@ -204,7 +204,7 @@ gboolean nm_setting_802_1x_remove_altsubject_match_by_value (NMSetting8
|
|||
void nm_setting_802_1x_clear_altsubject_matches (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_client_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_client_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_client_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_client_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
|
|
@ -223,7 +223,7 @@ const char * nm_setting_802_1x_get_phase2_auth (NMSetting8
|
|||
const char * nm_setting_802_1x_get_phase2_autheap (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_ca_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_phase2_ca_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_ca_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_ca_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
|
|
@ -245,7 +245,7 @@ gboolean nm_setting_802_1x_remove_phase2_altsubject_match_by_value (NMS
|
|||
void nm_setting_802_1x_clear_phase2_altsubject_matches (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_client_cert_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_phase2_client_cert_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_client_cert_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_client_cert (NMSetting8021x *setting,
|
||||
const char *cert_path,
|
||||
|
|
@ -255,14 +255,14 @@ gboolean nm_setting_802_1x_set_phase2_client_cert (NMSett
|
|||
|
||||
const char * nm_setting_802_1x_get_password (NMSetting8021x *setting);
|
||||
NMSettingSecretFlags nm_setting_802_1x_get_password_flags (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_password_raw (NMSetting8021x *setting);
|
||||
NMSettingSecretFlags nm_setting_802_1x_get_password_raw_flags (NMSetting8021x *setting);
|
||||
|
||||
const char * nm_setting_802_1x_get_pin (NMSetting8021x *setting);
|
||||
NMSettingSecretFlags nm_setting_802_1x_get_pin_flags (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_private_key_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_private_key_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_private_key_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_private_key (NMSetting8021x *setting,
|
||||
const char *key_path,
|
||||
|
|
@ -276,7 +276,7 @@ NMSettingSecretFlags nm_setting_802_1x_get_private_key_password_flags (NMSett
|
|||
NMSetting8021xCKFormat nm_setting_802_1x_get_private_key_format (NMSetting8021x *setting);
|
||||
|
||||
NMSetting8021xCKScheme nm_setting_802_1x_get_phase2_private_key_scheme (NMSetting8021x *setting);
|
||||
const GByteArray * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
|
||||
GBytes * nm_setting_802_1x_get_phase2_private_key_blob (NMSetting8021x *setting);
|
||||
const char * nm_setting_802_1x_get_phase2_private_key_path (NMSetting8021x *setting);
|
||||
gboolean nm_setting_802_1x_set_phase2_private_key (NMSetting8021x *setting,
|
||||
const char *key_path,
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@
|
|||
#include <net/ethernet.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-setting-bluetooth.h"
|
||||
#include "nm-setting-cdma.h"
|
||||
#include "nm-setting-gsm.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bluetooth
|
||||
|
|
@ -66,7 +67,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BLUETOOTH)
|
|||
#define NM_SETTING_BLUETOOTH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BLUETOOTH, NMSettingBluetoothPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *bdaddr;
|
||||
char *bdaddr;
|
||||
char *type;
|
||||
} NMSettingBluetoothPrivate;
|
||||
|
||||
|
|
@ -116,7 +117,7 @@ nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting)
|
|||
*
|
||||
* Returns: the Bluetooth address
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BLUETOOTH (setting), NULL);
|
||||
|
|
@ -138,7 +139,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->bdaddr && priv->bdaddr->len != ETH_ALEN) {
|
||||
if (!nm_utils_hwaddr_valid (priv->bdaddr, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -200,8 +201,7 @@ finalize (GObject *object)
|
|||
{
|
||||
NMSettingBluetoothPrivate *priv = NM_SETTING_BLUETOOTH_GET_PRIVATE (object);
|
||||
|
||||
if (priv->bdaddr)
|
||||
g_byte_array_free (priv->bdaddr, TRUE);
|
||||
g_free (priv->bdaddr);
|
||||
g_free (priv->type);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_bluetooth_parent_class)->finalize (object);
|
||||
|
|
@ -215,9 +215,8 @@ set_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_BDADDR:
|
||||
if (priv->bdaddr)
|
||||
g_byte_array_free (priv->bdaddr, TRUE);
|
||||
priv->bdaddr = g_value_dup_boxed (value);
|
||||
g_free (priv->bdaddr);
|
||||
priv->bdaddr = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_TYPE:
|
||||
g_free (priv->type);
|
||||
|
|
@ -237,7 +236,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_BDADDR:
|
||||
g_value_set_boxed (value, nm_setting_bluetooth_get_bdaddr (setting));
|
||||
g_value_set_string (value, nm_setting_bluetooth_get_bdaddr (setting));
|
||||
break;
|
||||
case PROP_TYPE:
|
||||
g_value_set_string (value, nm_setting_bluetooth_get_connection_type (setting));
|
||||
|
|
@ -271,11 +270,15 @@ nm_setting_bluetooth_class_init (NMSettingBluetoothClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BDADDR,
|
||||
_nm_param_spec_specialized (NM_SETTING_BLUETOOTH_BDADDR, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_BLUETOOTH_BDADDR, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_BLUETOOTH_BDADDR,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingBluetooth:type:
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ typedef struct {
|
|||
GType nm_setting_bluetooth_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_bluetooth_new (void);
|
||||
const GByteArray *nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting);
|
||||
const char * nm_setting_bluetooth_get_bdaddr (NMSettingBluetooth *setting);
|
||||
const char * nm_setting_bluetooth_get_connection_type (NMSettingBluetooth *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-bond.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
@ -670,26 +669,16 @@ finalize (GObject *object)
|
|||
G_OBJECT_CLASS (nm_setting_bond_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_hash (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingBondPrivate *priv = NM_SETTING_BOND_GET_PRIVATE (object);
|
||||
GHashTable *new_hash;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_OPTIONS:
|
||||
/* Must make a deep copy of the hash table here... */
|
||||
g_hash_table_remove_all (priv->options);
|
||||
new_hash = g_value_get_boxed (value);
|
||||
if (new_hash)
|
||||
g_hash_table_foreach (new_hash, copy_hash, priv->options);
|
||||
g_hash_table_unref (priv->options);
|
||||
priv->options = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -705,7 +694,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_OPTIONS:
|
||||
g_value_set_boxed (value, priv->options);
|
||||
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->options));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -734,14 +723,20 @@ nm_setting_bond_class_init (NMSettingBondClass *setting_class)
|
|||
* Dictionary of key/value pairs of bonding options. Both keys and values
|
||||
* must be strings. Option names must contain only alphanumeric characters
|
||||
* (ie, [a-zA-Z0-9]).
|
||||
*
|
||||
* Type: GHashTable(utf8,utf8)
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_OPTIONS,
|
||||
_nm_param_spec_specialized (NM_SETTING_BOND_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_BOND_OPTIONS, "", "",
|
||||
G_TYPE_HASH_TABLE,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_BOND_OPTIONS,
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
_nm_utils_strdict_to_dbus,
|
||||
_nm_utils_strdict_from_dbus);
|
||||
|
||||
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name", G_TYPE_STRING,
|
||||
_nm_setting_get_deprecated_virtual_interface_name,
|
||||
|
|
|
|||
|
|
@ -26,11 +26,9 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-bridge.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-bridge
|
||||
|
|
@ -65,7 +63,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_BRIDGE)
|
|||
#define NM_SETTING_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE, NMSettingBridgePrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *mac_address;
|
||||
char * mac_address;
|
||||
gboolean stp;
|
||||
guint16 priority;
|
||||
guint16 forward_delay;
|
||||
|
|
@ -105,7 +103,7 @@ nm_setting_bridge_new (void)
|
|||
*
|
||||
* Returns: the #NMSettingBridge:mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_bridge_get_mac_address (NMSettingBridge *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), NULL);
|
||||
|
|
@ -235,7 +233,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
||||
|
||||
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
|
||||
if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BRIDGE_ERROR,
|
||||
NM_SETTING_BRIDGE_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -285,8 +283,7 @@ finalize (GObject *object)
|
|||
{
|
||||
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
||||
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
g_free (priv->mac_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_bridge_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -299,9 +296,8 @@ set_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
priv->mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->mac_address);
|
||||
priv->mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_STP:
|
||||
priv->stp = g_value_get_boolean (value);
|
||||
|
|
@ -336,7 +332,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_bridge_get_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_bridge_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_STP:
|
||||
g_value_set_boolean (value, priv->stp);
|
||||
|
|
@ -386,11 +382,15 @@ nm_setting_bridge_class_init (NMSettingBridgeClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_BRIDGE_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_BRIDGE_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_BRIDGE_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingBridge:stp:
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ GType nm_setting_bridge_get_type (void);
|
|||
|
||||
NMSetting * nm_setting_bridge_new (void);
|
||||
|
||||
const GByteArray *nm_setting_bridge_get_mac_address (NMSettingBridge *setting);
|
||||
const char * nm_setting_bridge_get_mac_address (NMSettingBridge *setting);
|
||||
|
||||
gboolean nm_setting_bridge_get_stp (NMSettingBridge *setting);
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
|
|
@ -1034,14 +1033,15 @@ finalize (GObject *object)
|
|||
}
|
||||
|
||||
static GSList *
|
||||
perm_stringlist_to_permlist (GSList *strlist)
|
||||
perm_strv_to_permlist (char **strv)
|
||||
{
|
||||
GSList *list = NULL, *iter;
|
||||
GSList *list = NULL;
|
||||
int i;
|
||||
|
||||
for (iter = strlist; iter; iter = g_slist_next (iter)) {
|
||||
for (i = 0; strv[i]; i++) {
|
||||
Permission *p;
|
||||
|
||||
p = permission_new_from_str ((const char *) iter->data);
|
||||
p = permission_new_from_str (strv[i]);
|
||||
if (p)
|
||||
list = g_slist_append (list, p);
|
||||
}
|
||||
|
|
@ -1074,7 +1074,7 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_PERMISSIONS:
|
||||
g_slist_free_full (priv->permissions, (GDestroyNotify) permission_free);
|
||||
priv->permissions = perm_stringlist_to_permlist (g_value_get_boxed (value));
|
||||
priv->permissions = perm_strv_to_permlist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_AUTOCONNECT:
|
||||
priv->autoconnect = g_value_get_boolean (value);
|
||||
|
|
@ -1099,7 +1099,7 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_SECONDARIES:
|
||||
g_slist_free_full (priv->secondaries, g_free);
|
||||
priv->secondaries = g_value_dup_boxed (value);
|
||||
priv->secondaries = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_GATEWAY_PING_TIMEOUT:
|
||||
priv->gateway_ping_timeout = g_value_get_uint (value);
|
||||
|
|
@ -1110,14 +1110,18 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static GSList *
|
||||
perm_permlist_to_stringlist (GSList *permlist)
|
||||
static char **
|
||||
perm_permlist_to_strv (GSList *permlist)
|
||||
{
|
||||
GSList *list = NULL, *iter;
|
||||
GPtrArray *strings;
|
||||
GSList *iter;
|
||||
|
||||
strings = g_ptr_array_new ();
|
||||
for (iter = permlist; iter; iter = g_slist_next (iter))
|
||||
list = g_slist_append (list, permission_to_string ((Permission *) iter->data));
|
||||
return list;
|
||||
g_ptr_array_add (strings, permission_to_string ((Permission *) iter->data));
|
||||
g_ptr_array_add (strings, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (strings, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1141,7 +1145,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_setting_connection_get_connection_type (setting));
|
||||
break;
|
||||
case PROP_PERMISSIONS:
|
||||
g_value_take_boxed (value, perm_permlist_to_stringlist (priv->permissions));
|
||||
g_value_take_boxed (value, perm_permlist_to_strv (priv->permissions));
|
||||
break;
|
||||
case PROP_AUTOCONNECT:
|
||||
g_value_set_boolean (value, nm_setting_connection_get_autoconnect (setting));
|
||||
|
|
@ -1162,7 +1166,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_setting_connection_get_slave_type (setting));
|
||||
break;
|
||||
case PROP_SECONDARIES:
|
||||
g_value_set_boxed (value, priv->secondaries);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->secondaries));
|
||||
break;
|
||||
case PROP_GATEWAY_PING_TIMEOUT:
|
||||
g_value_set_uint (value, priv->gateway_ping_timeout);
|
||||
|
|
@ -1289,10 +1293,10 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
*/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PERMISSIONS,
|
||||
_nm_param_spec_specialized (NM_SETTING_CONNECTION_PERMISSIONS, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_CONNECTION_PERMISSIONS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:autoconnect:
|
||||
|
|
@ -1403,11 +1407,11 @@ nm_setting_connection_class_init (NMSettingConnectionClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SECONDARIES,
|
||||
_nm_param_spec_specialized (NM_SETTING_CONNECTION_SECONDARIES, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_CONNECTION_SECONDARIES, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingConnection:gateway-ping-timeout:
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-dcb.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
@ -750,6 +749,8 @@ nm_setting_dcb_init (NMSettingDcb *setting)
|
|||
{
|
||||
}
|
||||
|
||||
G_STATIC_ASSERT (sizeof (guint) == sizeof (gboolean));
|
||||
|
||||
static inline void
|
||||
set_uint_array (const GValue *v, uint *a, size_t len)
|
||||
{
|
||||
|
|
@ -765,6 +766,35 @@ set_uint_array (const GValue *v, uint *a, size_t len)
|
|||
}
|
||||
#define SET_UINT_ARRAY(v, a) set_uint_array (v, a, G_N_ELEMENTS (a))
|
||||
|
||||
static inline void
|
||||
take_uint_array (GValue *v, uint *a, size_t len)
|
||||
{
|
||||
GArray *dst = g_array_sized_new (FALSE, TRUE, sizeof (guint), len);
|
||||
|
||||
g_array_append_vals (dst, a, len);
|
||||
g_value_take_boxed (v, dst);
|
||||
}
|
||||
|
||||
#define TAKE_UINT_ARRAY(v, a) take_uint_array (v, a, G_N_ELEMENTS (a))
|
||||
|
||||
static void
|
||||
_nm_setting_dcb_uint_array_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GArray *src = g_value_get_boxed (prop_value);
|
||||
|
||||
take_uint_array (dbus_value, (guint *) src->data, src->len);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_setting_dcb_uint_array_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GArray *src = g_value_get_boxed (dbus_value);
|
||||
|
||||
set_uint_array (prop_value, (guint *) src->data, src->len);
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -823,14 +853,6 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
#define TAKE_UINT_ARRAY(v, a) \
|
||||
{ \
|
||||
guint len = G_N_ELEMENTS (a); \
|
||||
GArray *dst = g_array_sized_new (FALSE, TRUE, sizeof (guint), len); \
|
||||
g_array_append_vals (dst, (a), len); \
|
||||
g_value_take_boxed (v, dst); \
|
||||
}
|
||||
|
||||
static void
|
||||
get_property (GObject *object, guint prop_id,
|
||||
GValue *value, GParamSpec *pspec)
|
||||
|
|
@ -1022,17 +1044,22 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
|
|||
/**
|
||||
* NMSettingDcb:priority-flow-control:
|
||||
*
|
||||
* An array of 8 uint values, where the array index corresponds to the User
|
||||
* An array of 8 boolean values, where the array index corresponds to the User
|
||||
* Priority (0 - 7) and the value indicates whether or not the corresponding
|
||||
* priority should transmit priority pause. Allowed values are 0 (do not
|
||||
* transmit pause) and 1 (transmit pause).
|
||||
* priority should transmit priority pause.
|
||||
*
|
||||
* Element-type: gboolean
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PFC,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_FLOW_CONTROL, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_FLOW_CONTROL,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingDcb:priority-group-flags:
|
||||
|
|
@ -1054,13 +1081,19 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
|
|||
* An array of 8 uint values, where the array index corresponds to the User
|
||||
* Priority (0 - 7) and the value indicates the Priority Group ID. Allowed
|
||||
* Priority Group ID values are 0 - 7 or 15 for the unrestricted group.
|
||||
*
|
||||
* Element-type: guint
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY_GROUP_ID,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_ID, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_GROUP_ID, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_GROUP_ID,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingDcb:priority-group-bandwidth:
|
||||
|
|
@ -1069,13 +1102,19 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
|
|||
* Priority Group ID (0 - 7) and the value indicates the percentage of link
|
||||
* bandwidth allocated to that group. Allowed values are 0 - 100, and the
|
||||
* sum of all values must total 100 percent.
|
||||
*
|
||||
* Element-type: guint
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY_GROUP_BANDWIDTH,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_GROUP_BANDWIDTH,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingDcb:priority-bandwidth:
|
||||
|
|
@ -1085,29 +1124,39 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
|
|||
* the priority's assigned group that the priority may use. The sum of all
|
||||
* percentages for priorities which belong to the same group must total 100
|
||||
* percent.
|
||||
*
|
||||
* Element-type: guint
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY_BANDWIDTH,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_BANDWIDTH, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_BANDWIDTH, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_BANDWIDTH,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingDcb:priority-strict-bandwidth:
|
||||
*
|
||||
* An array of 8 uint values, where the array index corresponds to the User
|
||||
* An array of 8 boolean values, where the array index corresponds to the User
|
||||
* Priority (0 - 7) and the value indicates whether or not the priority may
|
||||
* use all of the bandwidth allocated to its assigned group. Allowed values
|
||||
* are 0 (the priority may not utilize all bandwidth) or 1 (the priority may
|
||||
* utilize all bandwidth).
|
||||
* use all of the bandwidth allocated to its assigned group.
|
||||
*
|
||||
* Element-type: gboolean
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY_STRICT,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_STRICT_BANDWIDTH,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingDcb:priority-traffic-class:
|
||||
|
|
@ -1115,11 +1164,17 @@ nm_setting_dcb_class_init (NMSettingDcbClass *setting_class)
|
|||
* An array of 8 uint values, where the array index corresponds to the User
|
||||
* Priority (0 - 7) and the value indicates the traffic class (0 - 7) to
|
||||
* which the priority is mapped.
|
||||
*
|
||||
* Element-type: guint
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PRIORITY_TRAFFIC_CLASS,
|
||||
_nm_param_spec_specialized (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS, "", "",
|
||||
G_TYPE_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_DCB_PRIORITY_TRAFFIC_CLASS,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_setting_dcb_uint_array_to_dbus,
|
||||
_nm_setting_dcb_uint_array_from_dbus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-infiniband.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
|
@ -62,7 +61,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_INFINIBAND)
|
|||
#define NM_SETTING_INFINIBAND_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_INFINIBAND, NMSettingInfinibandPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *mac_address;
|
||||
char *mac_address;
|
||||
char *transport_mode;
|
||||
guint32 mtu;
|
||||
int p_key;
|
||||
|
|
@ -99,7 +98,7 @@ nm_setting_infiniband_new (void)
|
|||
*
|
||||
* Returns: the #NMSettingInfiniband:mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_INFINIBAND (setting), NULL);
|
||||
|
|
@ -203,7 +202,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (setting);
|
||||
guint32 normerr_max_mtu = 0;
|
||||
|
||||
if (priv->mac_address && priv->mac_address->len != INFINIBAND_ALEN) {
|
||||
if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, INFINIBAND_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_INFINIBAND_ERROR,
|
||||
NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -321,8 +320,7 @@ finalize (GObject *object)
|
|||
NMSettingInfinibandPrivate *priv = NM_SETTING_INFINIBAND_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->transport_mode);
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
g_free (priv->mac_address);
|
||||
g_free (priv->parent);
|
||||
g_free (priv->virtual_iface_name);
|
||||
|
||||
|
|
@ -337,9 +335,8 @@ set_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
priv->mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->mac_address);
|
||||
priv->mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint (value);
|
||||
|
|
@ -371,7 +368,7 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_infiniband_get_mac_address (setting));
|
||||
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));
|
||||
|
|
@ -416,11 +413,15 @@ nm_setting_infiniband_class_init (NMSettingInfinibandClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_INFINIBAND_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_INFINIBAND_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_INFINIBAND_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingInfiniband:mtu:
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ typedef struct {
|
|||
GType nm_setting_infiniband_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_infiniband_new (void);
|
||||
const GByteArray *nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting);
|
||||
const char * nm_setting_infiniband_get_mac_address (NMSettingInfiniband *setting);
|
||||
guint32 nm_setting_infiniband_get_mtu (NMSettingInfiniband *setting);
|
||||
const char * nm_setting_infiniband_get_transport_mode (NMSettingInfiniband *setting);
|
||||
int nm_setting_infiniband_get_p_key (NMSettingInfiniband *setting);
|
||||
|
|
|
|||
|
|
@ -25,13 +25,12 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-ip4-config.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-core-internal.h"
|
||||
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-ip4-config
|
||||
|
|
@ -69,7 +68,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_IP4_CONFIG)
|
|||
|
||||
typedef struct {
|
||||
char *method;
|
||||
GArray *dns; /* array of guint32; elements in network byte order */
|
||||
GSList *dns; /* list of IP address strings */
|
||||
GSList *dns_search; /* list of strings */
|
||||
GSList *addresses; /* array of NMIP4Address */
|
||||
GSList *address_labels; /* list of strings */
|
||||
|
|
@ -140,7 +139,7 @@ nm_setting_ip4_config_get_num_dns (NMSettingIP4Config *setting)
|
|||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
|
||||
|
||||
return NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns->len;
|
||||
return g_slist_length (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -148,26 +147,36 @@ nm_setting_ip4_config_get_num_dns (NMSettingIP4Config *setting)
|
|||
* @setting: the #NMSettingIP4Config
|
||||
* @i: index number of the DNS server to return
|
||||
*
|
||||
* Returns: the IPv4 address (network byte order) of the DNS server at index
|
||||
* @i
|
||||
* Returns: the IPv4 address of the DNS server at index @i
|
||||
**/
|
||||
guint32
|
||||
const char *
|
||||
nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), 0);
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= priv->dns->len, 0);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->dns), NULL);
|
||||
|
||||
return g_array_index (priv->dns, guint32, i);
|
||||
return (const char *) g_slist_nth_data (priv->dns, i);
|
||||
}
|
||||
|
||||
static const char *
|
||||
canonicalize_ip (const char *ip)
|
||||
{
|
||||
in_addr_t addr;
|
||||
int ret;
|
||||
|
||||
ret = inet_pton (AF_INET, ip, &addr);
|
||||
g_return_val_if_fail (ret == 1, NULL);
|
||||
return nm_utils_inet4_ntop (addr, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_setting_ip4_config_add_dns:
|
||||
* @setting: the #NMSettingIP4Config
|
||||
* @dns: the IPv4 address (network byte order) of the DNS server to add
|
||||
* @dns: the IPv4 address of the DNS server to add
|
||||
*
|
||||
* Adds a new DNS server to the setting.
|
||||
*
|
||||
|
|
@ -175,20 +184,27 @@ nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i)
|
|||
* known
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, guint32 dns)
|
||||
nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, const char *dns)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv;
|
||||
int i;
|
||||
const char *dns_canonical;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
|
||||
g_return_val_if_fail (dns != NULL, FALSE);
|
||||
g_return_val_if_fail (dns[0] != '\0', FALSE);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
for (i = 0; i < priv->dns->len; i++) {
|
||||
if (dns == g_array_index (priv->dns, guint32, i))
|
||||
|
||||
dns_canonical = canonicalize_ip (dns);
|
||||
g_return_val_if_fail (dns_canonical != NULL, FALSE);
|
||||
|
||||
for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
|
||||
if (!strcmp (dns_canonical, (char *) iter->data))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_array_append_val (priv->dns, dns);
|
||||
priv->dns = g_slist_append (priv->dns, g_strdup (dns_canonical));
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -204,13 +220,16 @@ void
|
|||
nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv;
|
||||
GSList *elt;
|
||||
|
||||
g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_if_fail (i <= priv->dns->len);
|
||||
elt = g_slist_nth (priv->dns, i);
|
||||
g_return_if_fail (elt != NULL);
|
||||
|
||||
g_array_remove_index (priv->dns, i);
|
||||
g_free (elt->data);
|
||||
priv->dns = g_slist_delete_link (priv->dns, elt);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
|
||||
}
|
||||
|
||||
|
|
@ -222,20 +241,26 @@ nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i)
|
|||
* Removes the DNS server @dns.
|
||||
*
|
||||
* Returns: %TRUE if the DNS server was found and removed; %FALSE if it was not.
|
||||
* domain was already known
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, guint32 dns)
|
||||
nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, const char *dns)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv;
|
||||
int i;
|
||||
const char *dns_canonical;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
|
||||
g_return_val_if_fail (dns != NULL, FALSE);
|
||||
g_return_val_if_fail (dns[0] != '\0', FALSE);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
for (i = 0; i < priv->dns->len; i++) {
|
||||
if (dns == g_array_index (priv->dns, guint32, i)) {
|
||||
g_array_remove_index (priv->dns, i);
|
||||
|
||||
dns_canonical = canonicalize_ip (dns);
|
||||
g_return_val_if_fail (dns_canonical != NULL, FALSE);
|
||||
|
||||
for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
|
||||
if (!strcmp (dns_canonical, (char *) iter->data)) {
|
||||
priv->dns = g_slist_delete_link (priv->dns, iter);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -252,12 +277,10 @@ nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, guint32
|
|||
void
|
||||
nm_setting_ip4_config_clear_dns (NMSettingIP4Config *setting)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_SETTING_IP4_CONFIG (setting));
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_array_remove_range (priv->dns, 0, priv->dns->len);
|
||||
g_slist_free_full (NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns, g_free);
|
||||
NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting)->dns = NULL;
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_DNS);
|
||||
}
|
||||
|
||||
|
|
@ -290,7 +313,7 @@ nm_setting_ip4_config_get_dns_search (NMSettingIP4Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->dns_search), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->dns_search), NULL);
|
||||
|
||||
return (const char *) g_slist_nth_data (priv->dns_search, i);
|
||||
}
|
||||
|
|
@ -427,7 +450,7 @@ nm_setting_ip4_config_get_address (NMSettingIP4Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->addresses), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->addresses), NULL);
|
||||
|
||||
return (NMIP4Address *) g_slist_nth_data (priv->addresses, i);
|
||||
}
|
||||
|
|
@ -440,7 +463,7 @@ _nm_setting_ip4_config_get_address_label (NMSettingIP4Config *setting, guint32 i
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->address_labels), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->address_labels), NULL);
|
||||
|
||||
return (const char *) g_slist_nth_data (priv->address_labels, i);
|
||||
}
|
||||
|
|
@ -460,7 +483,7 @@ gboolean
|
|||
nm_setting_ip4_config_add_address (NMSettingIP4Config *setting,
|
||||
NMIP4Address *address)
|
||||
{
|
||||
return _nm_setting_ip4_config_add_address_with_label (setting, address, NULL);
|
||||
return _nm_setting_ip4_config_add_address_with_label (setting, address, "");
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
|
@ -474,6 +497,7 @@ _nm_setting_ip4_config_add_address_with_label (NMSettingIP4Config *setting,
|
|||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), FALSE);
|
||||
g_return_val_if_fail (address != NULL, FALSE);
|
||||
g_return_val_if_fail (label != NULL, FALSE);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
for (iter = priv->addresses; iter; iter = g_slist_next (iter)) {
|
||||
|
|
@ -511,8 +535,7 @@ nm_setting_ip4_config_remove_address (NMSettingIP4Config *setting, guint32 i)
|
|||
|
||||
nm_ip4_address_unref ((NMIP4Address *) addr->data);
|
||||
priv->addresses = g_slist_delete_link (priv->addresses, addr);
|
||||
if (label->data)
|
||||
g_free (label->data);
|
||||
g_free (label->data);
|
||||
priv->address_labels = g_slist_delete_link (priv->address_labels, label);
|
||||
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP4_CONFIG_ADDRESSES);
|
||||
|
|
@ -598,7 +621,7 @@ nm_setting_ip4_config_get_route (NMSettingIP4Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP4_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->routes), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->routes), NULL);
|
||||
|
||||
return (NMIP4Route *) g_slist_nth_data (priv->routes, i);
|
||||
}
|
||||
|
|
@ -841,6 +864,9 @@ verify_label (const char *label)
|
|||
const char *p;
|
||||
char *iface;
|
||||
|
||||
if (!*label)
|
||||
return TRUE;
|
||||
|
||||
p = strchr (label, ':');
|
||||
if (!p)
|
||||
return FALSE;
|
||||
|
|
@ -888,7 +914,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
} else if ( !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL)
|
||||
|| !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED)
|
||||
|| !strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_DISABLED)) {
|
||||
if (priv->dns && priv->dns->len) {
|
||||
if (priv->dns) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP4_CONFIG_ERROR,
|
||||
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -898,7 +924,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_slist_length (priv->dns_search)) {
|
||||
if (priv->dns_search) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP4_CONFIG_ERROR,
|
||||
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -910,7 +936,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
|
||||
/* Shared allows IP addresses; link-local and disabled do not */
|
||||
if (strcmp (priv->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED) != 0) {
|
||||
if (g_slist_length (priv->addresses)) {
|
||||
if (priv->addresses) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP4_CONFIG_ERROR,
|
||||
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -977,7 +1003,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (label && !verify_label (label)) {
|
||||
if (!verify_label (label)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP4_CONFIG_ERROR,
|
||||
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1025,6 +1051,22 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
/* Validate DNS */
|
||||
for (iter = priv->dns, i = 0; iter; iter = g_slist_next (iter), i++) {
|
||||
const char *dns = (const char *) iter->data;
|
||||
in_addr_t addr;
|
||||
|
||||
if (inet_pton (AF_INET, dns, &addr) != 1) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP4_CONFIG_ERROR,
|
||||
NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY,
|
||||
_("%d. DNS server address is invalid"),
|
||||
i+1);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP4_CONFIG_SETTING_NAME, NM_SETTING_IP4_CONFIG_DNS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -1032,10 +1074,6 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
static void
|
||||
nm_setting_ip4_config_init (NMSettingIP4Config *setting)
|
||||
{
|
||||
NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE (setting);
|
||||
|
||||
|
||||
priv->dns = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1048,8 +1086,7 @@ finalize (GObject *object)
|
|||
g_free (priv->dhcp_hostname);
|
||||
g_free (priv->dhcp_client_id);
|
||||
|
||||
g_array_free (priv->dns, TRUE);
|
||||
|
||||
g_slist_free_full (priv->dns, g_free);
|
||||
g_slist_free_full (priv->dns_search, g_free);
|
||||
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
|
||||
g_slist_free_full (priv->address_labels, g_free);
|
||||
|
|
@ -1072,40 +1109,33 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->method = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DNS:
|
||||
g_array_free (priv->dns, TRUE);
|
||||
priv->dns = g_value_dup_boxed (value);
|
||||
if (!priv->dns)
|
||||
priv->dns = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
|
||||
g_slist_free_full (priv->dns, g_free);
|
||||
priv->dns = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_DNS_SEARCH:
|
||||
g_slist_free_full (priv->dns_search, g_free);
|
||||
priv->dns_search = g_value_dup_boxed (value);
|
||||
priv->dns_search = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
g_slist_free_full (priv->addresses, (GDestroyNotify) nm_ip4_address_unref);
|
||||
priv->addresses = nm_utils_ip4_addresses_from_gvalue (value);
|
||||
priv->addresses = _nm_utils_copy_array_to_slist (g_value_get_boxed (value),
|
||||
(NMUtilsCopyFunc) nm_ip4_address_dup);
|
||||
|
||||
if (g_slist_length (priv->addresses) != g_slist_length (priv->address_labels)) {
|
||||
g_slist_free_full (priv->address_labels, g_free);
|
||||
priv->address_labels = NULL;
|
||||
for (iter = priv->addresses; iter; iter = iter->next)
|
||||
priv->address_labels = g_slist_prepend (priv->address_labels, NULL);
|
||||
priv->address_labels = g_slist_prepend (priv->address_labels, g_strdup (""));
|
||||
}
|
||||
break;
|
||||
case PROP_ADDRESS_LABELS:
|
||||
g_slist_free_full (priv->address_labels, g_free);
|
||||
priv->address_labels = g_value_dup_boxed (value);
|
||||
/* NULLs get converted to "" when this is sent over D-Bus. */
|
||||
for (iter = priv->address_labels; iter; iter = iter->next) {
|
||||
if (!g_strcmp0 (iter->data, "")) {
|
||||
g_free (iter->data);
|
||||
iter->data = NULL;
|
||||
}
|
||||
}
|
||||
priv->address_labels = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip4_route_unref);
|
||||
priv->routes = nm_utils_ip4_routes_from_gvalue (value);
|
||||
priv->routes = _nm_utils_copy_array_to_slist (g_value_get_boxed (value),
|
||||
(NMUtilsCopyFunc) nm_ip4_route_dup);
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
priv->ignore_auto_routes = g_value_get_boolean (value);
|
||||
|
|
@ -1148,19 +1178,19 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_setting_ip4_config_get_method (setting));
|
||||
break;
|
||||
case PROP_DNS:
|
||||
g_value_set_boxed (value, priv->dns);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns));
|
||||
break;
|
||||
case PROP_DNS_SEARCH:
|
||||
g_value_set_boxed (value, priv->dns_search);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns_search));
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
nm_utils_ip4_addresses_to_gvalue (priv->addresses, value);
|
||||
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->addresses, (NMUtilsCopyFunc) nm_ip4_address_dup, (GDestroyNotify) nm_ip4_address_unref));
|
||||
break;
|
||||
case PROP_ADDRESS_LABELS:
|
||||
g_value_set_boxed (value, priv->address_labels);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->address_labels));
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
nm_utils_ip4_routes_to_gvalue (priv->routes, value);
|
||||
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->routes, (NMUtilsCopyFunc) nm_ip4_route_dup, (GDestroyNotify) nm_ip4_route_unref));
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
g_value_set_boolean (value, nm_setting_ip4_config_get_ignore_auto_routes (setting));
|
||||
|
|
@ -1201,7 +1231,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/* Properties */
|
||||
/**
|
||||
|
|
@ -1231,7 +1261,7 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
/**
|
||||
* NMSettingIP4Config:dns:
|
||||
*
|
||||
* List of DNS servers (network byte order). For the "auto" method, these
|
||||
* Array of IPv4 addresses of DNS servers. For the 'auto' method, these
|
||||
* DNS servers are appended to those (if any) returned by automatic
|
||||
* configuration. DNS servers cannot be used with the "shared",
|
||||
* "link-local", or "disabled" methods as there is no upstream network. In
|
||||
|
|
@ -1240,10 +1270,14 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DNS,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_DNS, "", "",
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP4_CONFIG_DNS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP4_CONFIG_DNS,
|
||||
DBUS_TYPE_G_UINT_ARRAY,
|
||||
_nm_utils_ip4_dns_to_dbus,
|
||||
_nm_utils_ip4_dns_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:dns-search:
|
||||
|
|
@ -1256,30 +1290,33 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DNS_SEARCH,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_DNS_SEARCH, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP4_CONFIG_DNS_SEARCH, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:addresses:
|
||||
*
|
||||
* Array of IPv4 address structures. Each IPv4 address structure is
|
||||
* composed of 3 32-bit values; the first being the IPv4 address (network
|
||||
* byte order), the second the prefix (1 - 32), and last the IPv4 gateway
|
||||
* (network byte order). The gateway may be left as 0 if no gateway exists
|
||||
* for that subnet. For the "auto" method, given IP addresses are appended
|
||||
* Array of IPv4 addresses. The gateway may be left as 0 if no gateway exists
|
||||
* for that subnet. For the 'auto' method, given IP addresses are appended
|
||||
* to those returned by automatic configuration. Addresses cannot be used
|
||||
* with the "shared", "link-local", or "disabled" methods as addressing is
|
||||
* either automatic or disabled with these methods.
|
||||
*
|
||||
* Element-Type: NMIP4Address
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ADDRESSES,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_ADDRESSES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP4_CONFIG_ADDRESSES, "", "",
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP4_CONFIG_ADDRESSES,
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
_nm_utils_ip4_addresses_to_dbus,
|
||||
_nm_utils_ip4_addresses_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:address-labels:
|
||||
|
|
@ -1288,31 +1325,33 @@ nm_setting_ip4_config_class_init (NMSettingIP4ConfigClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ADDRESS_LABELS,
|
||||
_nm_param_spec_specialized ("address-labels", "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed ("address-labels", "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:routes:
|
||||
*
|
||||
* Array of IPv4 route structures. Each IPv4 route structure is composed of
|
||||
* 4 32-bit values; the first being the destination IPv4 network or address
|
||||
* (network byte order), the second the destination network or address
|
||||
* prefix (1 - 32), the third being the next-hop (network byte order) if
|
||||
* any, and the fourth being the route metric. For the "auto" method, given
|
||||
* IP routes are appended to those returned by automatic configuration.
|
||||
* Routes cannot be used with the "shared", "link-local", or "disabled"
|
||||
* methods because there is no upstream network.
|
||||
* Array of IPv4 routes. For the 'auto' method, given IP routes are appended
|
||||
* to those returned by automatic configuration. Routes cannot be used with
|
||||
* the 'shared', 'link-local', or 'disabled' methods because there is no
|
||||
* upstream network.
|
||||
*
|
||||
* Element-Type: NMIP4Route
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ROUTES,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP4_CONFIG_ROUTES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP4_CONFIG_ROUTES, "", "",
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP4_CONFIG_ROUTES,
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
_nm_utils_ip4_routes_to_dbus,
|
||||
_nm_utils_ip4_routes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP4Config:ignore-auto-routes:
|
||||
|
|
|
|||
|
|
@ -184,10 +184,10 @@ NMSetting * nm_setting_ip4_config_new (void);
|
|||
const char * nm_setting_ip4_config_get_method (NMSettingIP4Config *setting);
|
||||
|
||||
guint32 nm_setting_ip4_config_get_num_dns (NMSettingIP4Config *setting);
|
||||
guint32 nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, guint32 dns);
|
||||
const char * nm_setting_ip4_config_get_dns (NMSettingIP4Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip4_config_add_dns (NMSettingIP4Config *setting, const char *dns);
|
||||
void nm_setting_ip4_config_remove_dns (NMSettingIP4Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, guint32 dns);
|
||||
gboolean nm_setting_ip4_config_remove_dns_by_value (NMSettingIP4Config *setting, const char *dns);
|
||||
void nm_setting_ip4_config_clear_dns (NMSettingIP4Config *setting);
|
||||
|
||||
guint32 nm_setting_ip4_config_get_num_dns_searches (NMSettingIP4Config *setting);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-ip6-config.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
|
@ -161,18 +161,28 @@ nm_setting_ip6_config_get_num_dns (NMSettingIP6Config *setting)
|
|||
*
|
||||
* Returns: (transfer none): the IPv6 address of the DNS server at index @i
|
||||
**/
|
||||
const struct in6_addr *
|
||||
const char *
|
||||
nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv;
|
||||
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->dns), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->dns), NULL);
|
||||
|
||||
return (const struct in6_addr *) g_slist_nth_data (priv->dns, i);
|
||||
return (const char *) g_slist_nth_data (priv->dns, i);
|
||||
}
|
||||
|
||||
static const char *
|
||||
canonicalize_ip (const char *ip)
|
||||
{
|
||||
struct in6_addr addr;
|
||||
int ret;
|
||||
|
||||
ret = inet_pton (AF_INET6, ip, &addr);
|
||||
g_return_val_if_fail (ret == 1, NULL);
|
||||
return nm_utils_inet6_ntop (&addr, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -186,25 +196,28 @@ nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i)
|
|||
* known
|
||||
**/
|
||||
gboolean
|
||||
nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const struct in6_addr *addr)
|
||||
nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const char *dns)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv;
|
||||
struct in6_addr *copy;
|
||||
const char *dns_canonical;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
|
||||
g_return_val_if_fail (dns != NULL, FALSE);
|
||||
g_return_val_if_fail (dns[0] != '\0', FALSE);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
|
||||
dns_canonical = canonicalize_ip (dns);
|
||||
g_return_val_if_fail (dns_canonical != NULL, FALSE);
|
||||
|
||||
for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
|
||||
if (!memcmp (addr, (struct in6_addr *) iter->data, sizeof (struct in6_addr)))
|
||||
if (!strcmp (dns_canonical, (char *) iter->data))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
copy = g_malloc0 (sizeof (struct in6_addr));
|
||||
memcpy (copy, addr, sizeof (struct in6_addr));
|
||||
priv->dns = g_slist_append (priv->dns, copy);
|
||||
priv->dns = g_slist_append (priv->dns, g_strdup (dns_canonical));
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -243,16 +256,23 @@ nm_setting_ip6_config_remove_dns (NMSettingIP6Config *setting, guint32 i)
|
|||
**/
|
||||
gboolean
|
||||
nm_setting_ip6_config_remove_dns_by_value (NMSettingIP6Config *setting,
|
||||
const struct in6_addr *addr)
|
||||
const char *dns)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv;
|
||||
const char *dns_canonical;
|
||||
GSList *iter;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), FALSE);
|
||||
g_return_val_if_fail (dns != NULL, FALSE);
|
||||
g_return_val_if_fail (dns[0] != '\0', FALSE);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
|
||||
dns_canonical = canonicalize_ip (dns);
|
||||
g_return_val_if_fail (dns_canonical != NULL, FALSE);
|
||||
|
||||
for (iter = priv->dns; iter; iter = g_slist_next (iter)) {
|
||||
if (!memcmp (addr, (struct in6_addr *) iter->data, sizeof (struct in6_addr))) {
|
||||
if (!strcmp (dns_canonical, (char *) iter->data)) {
|
||||
priv->dns = g_slist_delete_link (priv->dns, iter);
|
||||
g_object_notify (G_OBJECT (setting), NM_SETTING_IP6_CONFIG_DNS);
|
||||
return TRUE;
|
||||
|
|
@ -306,7 +326,7 @@ nm_setting_ip6_config_get_dns_search (NMSettingIP6Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->dns_search), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->dns_search), NULL);
|
||||
|
||||
return (const char *) g_slist_nth_data (priv->dns_search, i);
|
||||
}
|
||||
|
|
@ -443,7 +463,7 @@ nm_setting_ip6_config_get_address (NMSettingIP6Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->addresses), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->addresses), NULL);
|
||||
|
||||
return (NMIP6Address *) g_slist_nth_data (priv->addresses, i);
|
||||
}
|
||||
|
|
@ -583,7 +603,7 @@ nm_setting_ip6_config_get_route (NMSettingIP6Config *setting, guint32 i)
|
|||
g_return_val_if_fail (NM_IS_SETTING_IP6_CONFIG (setting), NULL);
|
||||
|
||||
priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
g_return_val_if_fail (i <= g_slist_length (priv->routes), NULL);
|
||||
g_return_val_if_fail (i < g_slist_length (priv->routes), NULL);
|
||||
|
||||
return (NMIP6Route *) g_slist_nth_data (priv->routes, i);
|
||||
}
|
||||
|
|
@ -787,6 +807,8 @@ static gboolean
|
|||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingIP6ConfigPrivate *priv = NM_SETTING_IP6_CONFIG_GET_PRIVATE (setting);
|
||||
GSList *iter;
|
||||
int i;
|
||||
|
||||
if (!priv->method) {
|
||||
g_set_error_literal (error,
|
||||
|
|
@ -810,7 +832,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
} else if ( !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE)
|
||||
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL)
|
||||
|| !strcmp (priv->method, NM_SETTING_IP6_CONFIG_METHOD_SHARED)) {
|
||||
if (g_slist_length (priv->dns)) {
|
||||
if (priv->dns) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP6_CONFIG_ERROR,
|
||||
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -821,7 +843,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_slist_length (priv->dns_search)) {
|
||||
if (priv->dns_search) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP6_CONFIG_ERROR,
|
||||
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -831,7 +853,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (g_slist_length (priv->addresses)) {
|
||||
if (priv->addresses) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP6_CONFIG_ERROR,
|
||||
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD,
|
||||
|
|
@ -861,6 +883,21 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (iter = priv->dns, i = 0; iter; iter = g_slist_next (iter), i++) {
|
||||
const char *dns = (const char *) iter->data;
|
||||
struct in6_addr addr;
|
||||
|
||||
if (inet_pton (AF_INET6, dns, &addr) != 1) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_IP6_CONFIG_ERROR,
|
||||
NM_SETTING_IP6_CONFIG_ERROR_INVALID_PROPERTY,
|
||||
_("%d. DNS server address is invalid"),
|
||||
i+1);
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_IP6_CONFIG_SETTING_NAME, NM_SETTING_IP6_CONFIG_DNS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
@ -899,19 +936,21 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_DNS:
|
||||
g_slist_free_full (priv->dns, g_free);
|
||||
priv->dns = nm_utils_ip6_dns_from_gvalue (value);
|
||||
priv->dns = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_DNS_SEARCH:
|
||||
g_slist_free_full (priv->dns_search, g_free);
|
||||
priv->dns_search = g_value_dup_boxed (value);
|
||||
priv->dns_search = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
g_slist_free_full (priv->addresses, g_free);
|
||||
priv->addresses = nm_utils_ip6_addresses_from_gvalue (value);
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_address_unref);
|
||||
priv->addresses = _nm_utils_copy_array_to_slist (g_value_get_boxed (value),
|
||||
(NMUtilsCopyFunc) nm_ip6_address_dup);
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
g_slist_free_full (priv->routes, g_free);
|
||||
priv->routes = nm_utils_ip6_routes_from_gvalue (value);
|
||||
g_slist_free_full (priv->routes, (GDestroyNotify) nm_ip6_route_unref);
|
||||
priv->routes = _nm_utils_copy_array_to_slist (g_value_get_boxed (value),
|
||||
(NMUtilsCopyFunc) nm_ip6_route_dup);
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
priv->ignore_auto_routes = g_value_get_boolean (value);
|
||||
|
|
@ -949,16 +988,16 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, priv->method);
|
||||
break;
|
||||
case PROP_DNS:
|
||||
nm_utils_ip6_dns_to_gvalue (priv->dns, value);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns));
|
||||
break;
|
||||
case PROP_DNS_SEARCH:
|
||||
g_value_set_boxed (value, priv->dns_search);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->dns_search));
|
||||
break;
|
||||
case PROP_ADDRESSES:
|
||||
nm_utils_ip6_addresses_to_gvalue (priv->addresses, value);
|
||||
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->addresses, (NMUtilsCopyFunc) nm_ip6_address_dup, (GDestroyNotify) nm_ip6_address_unref));
|
||||
break;
|
||||
case PROP_ROUTES:
|
||||
nm_utils_ip6_routes_to_gvalue (priv->routes, value);
|
||||
g_value_take_boxed (value, _nm_utils_copy_slist_to_array (priv->routes, (NMUtilsCopyFunc) nm_ip6_route_dup, (GDestroyNotify) nm_ip6_route_unref));
|
||||
break;
|
||||
case PROP_IGNORE_AUTO_ROUTES:
|
||||
g_value_set_boolean (value, priv->ignore_auto_routes);
|
||||
|
|
@ -996,7 +1035,7 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
object_class->finalize = finalize;
|
||||
parent_class->verify = verify;
|
||||
parent_class->verify = verify;
|
||||
|
||||
/* Properties */
|
||||
/**
|
||||
|
|
@ -1037,20 +1076,23 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
/**
|
||||
* NMSettingIP6Config:dns:
|
||||
*
|
||||
* Array of DNS servers, where each member of the array is a byte array
|
||||
* containing the IPv6 address of the DNS server (in network byte order).
|
||||
* For the "auto" method, these DNS servers are appended to those (if any)
|
||||
* returned by automatic configuration. DNS servers cannot be used with the
|
||||
* "shared" or "link-local" methods as there is no usptream network. In all
|
||||
* other methods, these DNS servers are used as the only DNS servers for
|
||||
* this connection.
|
||||
* Array of IPv6 addresses of DNS servers. For the "auto" method, these DNS
|
||||
* servers are appended to those (if any) returned by automatic
|
||||
* configuration. DNS servers cannot be used with the "shared" or
|
||||
* "link-local" methods as there is no usptream network. In all other
|
||||
* methods, these DNS servers are used as the only DNS servers for this
|
||||
* connection.
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DNS,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_DNS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP6_CONFIG_DNS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP6_CONFIG_DNS,
|
||||
DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
|
||||
_nm_utils_ip6_dns_to_dbus,
|
||||
_nm_utils_ip6_dns_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:dns-search:
|
||||
|
|
@ -1063,52 +1105,53 @@ nm_setting_ip6_config_class_init (NMSettingIP6ConfigClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DNS_SEARCH,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_DNS_SEARCH, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP6_CONFIG_DNS_SEARCH, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:addresses:
|
||||
*
|
||||
* Array of IPv6 address structures. Each IPv6 address structure is
|
||||
* composed of 3 members, the first being a byte array containing the IPv6
|
||||
* address (network byte order), the second a 32-bit integer containing the
|
||||
* IPv6 address prefix, and the third a byte array containing the IPv6
|
||||
* address (network byte order) of the gateway associated with this address,
|
||||
* if any. If no gateway is given, the third element should be given as all
|
||||
* zeros. For the "auto" method, given IP addresses are appended to those
|
||||
* returned by automatic configuration. Addresses cannot be used with the
|
||||
* "shared" or "link-local" methods as the interface is automatically
|
||||
* assigned an address with these methods.
|
||||
* Array of IPv6 addresses. For the 'auto' method, given IP addresses are
|
||||
* appended to those returned by automatic configuration. Addresses cannot
|
||||
* be used with the 'shared' or 'link-local' methods as the interface is
|
||||
* automatically assigned an address with these methods.
|
||||
*
|
||||
* Element-Type: NMIP6Address
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ADDRESSES,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_ADDRESSES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP6_CONFIG_ADDRESSES, "", "",
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP6_CONFIG_ADDRESSES,
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
_nm_utils_ip6_addresses_to_dbus,
|
||||
_nm_utils_ip6_addresses_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:routes:
|
||||
*
|
||||
* Array of IPv6 route structures. Each IPv6 route structure is composed of
|
||||
* 4 members; the first being the destination IPv6 network or address
|
||||
* (network byte order) as a byte array, the second the destination network
|
||||
* or address IPv6 prefix, the third being the next-hop IPv6 address
|
||||
* (network byte order) if any, and the fourth being the route metric. For
|
||||
* the "auto" method, given IP routes are appended to those returned by
|
||||
* automatic configuration. Routes cannot be used with the "shared" or
|
||||
* "link-local" methods because there is no upstream network.
|
||||
* Array of IPv6 routes. For the 'auto' method, given IP routes are appended
|
||||
* to those returned by automatic configuration. Routes cannot be used with
|
||||
* the 'shared' or 'link-local' methods because there is no upstream network.
|
||||
*
|
||||
* Element-Type: NMIP6Route
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_ROUTES,
|
||||
_nm_param_spec_specialized (NM_SETTING_IP6_CONFIG_ROUTES, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_IP6_CONFIG_ROUTES, "", "",
|
||||
G_TYPE_PTR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_IP6_CONFIG_ROUTES,
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
|
||||
_nm_utils_ip6_routes_to_dbus,
|
||||
_nm_utils_ip6_routes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingIP6Config:ignore-auto-routes:
|
||||
|
|
|
|||
|
|
@ -214,10 +214,10 @@ NMSetting * nm_setting_ip6_config_new (void);
|
|||
const char * nm_setting_ip6_config_get_method (NMSettingIP6Config *setting);
|
||||
|
||||
guint32 nm_setting_ip6_config_get_num_dns (NMSettingIP6Config *setting);
|
||||
const struct in6_addr *nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const struct in6_addr *dns);
|
||||
const char * nm_setting_ip6_config_get_dns (NMSettingIP6Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip6_config_add_dns (NMSettingIP6Config *setting, const char *dns);
|
||||
void nm_setting_ip6_config_remove_dns (NMSettingIP6Config *setting, guint32 i);
|
||||
gboolean nm_setting_ip6_config_remove_dns_by_value (NMSettingIP6Config *setting, const struct in6_addr *dns);
|
||||
gboolean nm_setting_ip6_config_remove_dns_by_value (NMSettingIP6Config *setting, const char *dns);
|
||||
void nm_setting_ip6_config_clear_dns (NMSettingIP6Config *setting);
|
||||
|
||||
guint32 nm_setting_ip6_config_get_num_dns_searches (NMSettingIP6Config *setting);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include "nm-setting-olpc-mesh.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
|
@ -51,9 +50,9 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_OLPC_MESH)
|
|||
#define NM_SETTING_OLPC_MESH_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_OLPC_MESH, NMSettingOlpcMeshPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
guint32 channel;
|
||||
GByteArray *dhcp_anycast_addr;
|
||||
char *dhcp_anycast_addr;
|
||||
} NMSettingOlpcMeshPrivate;
|
||||
|
||||
enum {
|
||||
|
|
@ -82,7 +81,7 @@ nm_setting_olpc_mesh_init (NMSettingOlpcMesh *setting)
|
|||
{
|
||||
}
|
||||
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
|
||||
|
|
@ -98,7 +97,7 @@ nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting)
|
|||
return NM_SETTING_OLPC_MESH_GET_PRIVATE (setting)->channel;
|
||||
}
|
||||
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_OLPC_MESH (setting), NULL);
|
||||
|
|
@ -110,6 +109,7 @@ static gboolean
|
|||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (setting);
|
||||
gsize length;
|
||||
|
||||
if (!priv->ssid) {
|
||||
g_set_error_literal (error,
|
||||
|
|
@ -120,7 +120,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!priv->ssid->len || priv->ssid->len > 32) {
|
||||
length = g_bytes_get_size (priv->ssid);
|
||||
if (length == 0 || length > 32) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_OLPC_MESH_ERROR,
|
||||
NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -139,7 +140,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->dhcp_anycast_addr && priv->dhcp_anycast_addr->len != ETH_ALEN) {
|
||||
if (priv->dhcp_anycast_addr && !nm_utils_hwaddr_valid (priv->dhcp_anycast_addr, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_OLPC_MESH_ERROR,
|
||||
NM_SETTING_OLPC_MESH_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -157,9 +158,8 @@ finalize (GObject *object)
|
|||
NMSettingOlpcMeshPrivate *priv = NM_SETTING_OLPC_MESH_GET_PRIVATE (object);
|
||||
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
if (priv->dhcp_anycast_addr)
|
||||
g_byte_array_free (priv->dhcp_anycast_addr, TRUE);
|
||||
g_bytes_unref (priv->ssid);
|
||||
g_free (priv->dhcp_anycast_addr);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_olpc_mesh_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -173,16 +173,15 @@ set_property (GObject *object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_SSID:
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
g_bytes_unref (priv->ssid);
|
||||
priv->ssid = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
priv->channel = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_DHCP_ANYCAST_ADDRESS:
|
||||
if (priv->dhcp_anycast_addr)
|
||||
g_byte_array_free (priv->dhcp_anycast_addr, TRUE);
|
||||
priv->dhcp_anycast_addr = g_value_dup_boxed (value);
|
||||
g_free (priv->dhcp_anycast_addr);
|
||||
priv->dhcp_anycast_addr = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -204,7 +203,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, nm_setting_olpc_mesh_get_channel (setting));
|
||||
break;
|
||||
case PROP_DHCP_ANYCAST_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_olpc_mesh_get_dhcp_anycast_address (setting));
|
||||
g_value_set_string (value, nm_setting_olpc_mesh_get_dhcp_anycast_address (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -234,11 +233,15 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SSID,
|
||||
_nm_param_spec_specialized (NM_SETTING_OLPC_MESH_SSID, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_OLPC_MESH_SSID, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_OLPC_MESH_SSID,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingOlpcMesh:channel:
|
||||
|
|
@ -263,8 +266,12 @@ nm_setting_olpc_mesh_class_init (NMSettingOlpcMeshClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DHCP_ANYCAST_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,9 +74,9 @@ typedef struct {
|
|||
GType nm_setting_olpc_mesh_get_type (void);
|
||||
|
||||
NMSetting * nm_setting_olpc_mesh_new (void);
|
||||
const GByteArray *nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting);
|
||||
GBytes * nm_setting_olpc_mesh_get_ssid (NMSettingOlpcMesh *setting);
|
||||
guint32 nm_setting_olpc_mesh_get_channel (NMSettingOlpcMesh *setting);
|
||||
const GByteArray *nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting);
|
||||
const char * nm_setting_olpc_mesh_get_dhcp_anycast_address (NMSettingOlpcMesh *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -158,4 +158,13 @@ void _nm_setting_class_override_property (NMSettingClass *setting_class,
|
|||
NMSettingPropertySetFunc set_func,
|
||||
NMSettingPropertyNotSetFunc not_set_func);
|
||||
|
||||
typedef void (*NMSettingPropertyTransformFunc) (const GValue *from,
|
||||
GValue *to);
|
||||
|
||||
void _nm_setting_class_transform_property (NMSettingClass *setting_class,
|
||||
const char *property_name,
|
||||
GType dbus_type,
|
||||
NMSettingPropertyTransformFunc to_dbus,
|
||||
NMSettingPropertyTransformFunc from_dbus);
|
||||
|
||||
#endif /* NM_SETTING_PRIVATE_H */
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-team.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
|
|||
|
|
@ -21,13 +21,10 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-vlan.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-setting-connection.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
|
|
@ -575,14 +572,15 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
|
||||
static GSList *
|
||||
priority_stringlist_to_maplist (NMVlanPriorityMap map, GSList *strlist)
|
||||
priority_strv_to_maplist (NMVlanPriorityMap map, char **strv)
|
||||
{
|
||||
GSList *list = NULL, *iter;
|
||||
GSList *list = NULL;
|
||||
int i;
|
||||
|
||||
for (iter = strlist; iter; iter = g_slist_next (iter)) {
|
||||
for (i = 0; strv[i]; i++) {
|
||||
PriorityMap *item;
|
||||
|
||||
item = priority_map_new_from_str (map, (const char *) iter->data);
|
||||
item = priority_map_new_from_str (map, strv[i]);
|
||||
if (item)
|
||||
list = g_slist_prepend (list, item);
|
||||
}
|
||||
|
|
@ -610,12 +608,12 @@ set_property (GObject *object, guint prop_id,
|
|||
case PROP_INGRESS_PRIORITY_MAP:
|
||||
g_slist_free_full (priv->ingress_priority_map, g_free);
|
||||
priv->ingress_priority_map =
|
||||
priority_stringlist_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
|
||||
priority_strv_to_maplist (NM_VLAN_INGRESS_MAP, g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_EGRESS_PRIORITY_MAP:
|
||||
g_slist_free_full (priv->egress_priority_map, g_free);
|
||||
priv->egress_priority_map =
|
||||
priority_stringlist_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
|
||||
priority_strv_to_maplist (NM_VLAN_EGRESS_MAP, g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -623,17 +621,22 @@ set_property (GObject *object, guint prop_id,
|
|||
}
|
||||
}
|
||||
|
||||
static GSList *
|
||||
priority_maplist_to_stringlist (GSList *list)
|
||||
static char **
|
||||
priority_maplist_to_strv (GSList *list)
|
||||
{
|
||||
GSList *strlist = NULL, *iter;
|
||||
GSList *iter;
|
||||
GPtrArray *strv;
|
||||
|
||||
strv = g_ptr_array_new ();
|
||||
|
||||
for (iter = list; iter; iter = g_slist_next (iter)) {
|
||||
PriorityMap *item = iter->data;
|
||||
|
||||
strlist = g_slist_prepend (strlist, g_strdup_printf ("%d:%d", item->from, item->to));
|
||||
g_ptr_array_add (strv, g_strdup_printf ("%d:%d", item->from, item->to));
|
||||
}
|
||||
return g_slist_reverse (strlist);
|
||||
g_ptr_array_add (strv, NULL);
|
||||
|
||||
return (char **) g_ptr_array_free (strv, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -654,10 +657,10 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->flags);
|
||||
break;
|
||||
case PROP_INGRESS_PRIORITY_MAP:
|
||||
g_value_take_boxed (value, priority_maplist_to_stringlist (priv->ingress_priority_map));
|
||||
g_value_take_boxed (value, priority_maplist_to_strv (priv->ingress_priority_map));
|
||||
break;
|
||||
case PROP_EGRESS_PRIORITY_MAP:
|
||||
g_value_take_boxed (value, priority_maplist_to_stringlist (priv->egress_priority_map));
|
||||
g_value_take_boxed (value, priority_maplist_to_strv (priv->egress_priority_map));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -753,11 +756,11 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_INGRESS_PRIORITY_MAP,
|
||||
_nm_param_spec_specialized (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_VLAN_INGRESS_PRIORITY_MAP, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingVlan:egress-priority-map:
|
||||
|
|
@ -768,11 +771,11 @@ nm_setting_vlan_class_init (NMSettingVlanClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_EGRESS_PRIORITY_MAP,
|
||||
_nm_param_spec_specialized (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_VLAN_EGRESS_PRIORITY_MAP, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
_nm_setting_class_add_dbus_only_property (parent_class, "interface-name", G_TYPE_STRING,
|
||||
_nm_setting_get_deprecated_virtual_interface_name,
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-vpn.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
|
|
@ -714,20 +714,11 @@ finalize (GObject *object)
|
|||
G_OBJECT_CLASS (nm_setting_vpn_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_hash (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (value != NULL);
|
||||
g_return_if_fail (strlen (value));
|
||||
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingVpnPrivate *priv = NM_SETTING_VPN_GET_PRIVATE (object);
|
||||
GHashTable *new_hash;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SERVICE_TYPE:
|
||||
|
|
@ -739,18 +730,12 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->user_name = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_DATA:
|
||||
/* Must make a deep copy of the hash table here... */
|
||||
g_hash_table_remove_all (priv->data);
|
||||
new_hash = g_value_get_boxed (value);
|
||||
if (new_hash)
|
||||
g_hash_table_foreach (new_hash, copy_hash, priv->data);
|
||||
g_hash_table_unref (priv->data);
|
||||
priv->data = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_SECRETS:
|
||||
/* Must make a deep copy of the hash table here... */
|
||||
g_hash_table_remove_all (priv->secrets);
|
||||
new_hash = g_value_get_boxed (value);
|
||||
if (new_hash)
|
||||
g_hash_table_foreach (new_hash, copy_hash, priv->secrets);
|
||||
g_hash_table_unref (priv->secrets);
|
||||
priv->secrets = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -773,10 +758,10 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_setting_vpn_get_user_name (setting));
|
||||
break;
|
||||
case PROP_DATA:
|
||||
g_value_set_boxed (value, priv->data);
|
||||
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->data));
|
||||
break;
|
||||
case PROP_SECRETS:
|
||||
g_value_set_boxed (value, priv->secrets);
|
||||
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->secrets));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -842,25 +827,37 @@ nm_setting_vpn_class_init (NMSettingVpnClass *setting_class)
|
|||
*
|
||||
* Dictionary of key/value pairs of VPN plugin specific data. Both keys and
|
||||
* values must be strings.
|
||||
*
|
||||
* Type: GHashTable(utf8,utf8)
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_DATA,
|
||||
_nm_param_spec_specialized (NM_SETTING_VPN_DATA, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_VPN_DATA, "", "",
|
||||
G_TYPE_HASH_TABLE,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_VPN_DATA,
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
_nm_utils_strdict_to_dbus,
|
||||
_nm_utils_strdict_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingVpn:secrets:
|
||||
*
|
||||
* Dictionary of key/value pairs of VPN plugin specific secrets like
|
||||
* passwords or private keys. Both keys and values must be strings.
|
||||
*
|
||||
* Type: GHashTable(utf8,utf8)
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SECRETS,
|
||||
_nm_param_spec_specialized (NM_SETTING_VPN_SECRETS, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_SECRET |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_VPN_SECRETS, "", "",
|
||||
G_TYPE_HASH_TABLE,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_SECRET |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_VPN_SECRETS,
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
_nm_utils_strdict_to_dbus,
|
||||
_nm_utils_strdict_from_dbus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,9 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-wimax.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-setting-private.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting-wimax
|
||||
|
|
@ -63,7 +64,7 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIMAX)
|
|||
|
||||
typedef struct {
|
||||
char *network_name;
|
||||
GByteArray *mac_address;
|
||||
char *mac_address;
|
||||
} NMSettingWimaxPrivate;
|
||||
|
||||
enum {
|
||||
|
|
@ -113,7 +114,7 @@ nm_setting_wimax_get_network_name (NMSettingWimax *setting)
|
|||
*
|
||||
* Returns: the MAC address
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wimax_get_mac_address (NMSettingWimax *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIMAX (setting), NULL);
|
||||
|
|
@ -144,7 +145,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
|
||||
if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIMAX_ERROR,
|
||||
NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -167,8 +168,7 @@ finalize (GObject *object)
|
|||
NMSettingWimaxPrivate *priv = NM_SETTING_WIMAX_GET_PRIVATE (object);
|
||||
|
||||
g_free (priv->network_name);
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
g_free (priv->mac_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_wimax_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -185,9 +185,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->network_name = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
priv->mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->mac_address);
|
||||
priv->mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -206,7 +205,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, nm_setting_wimax_get_network_name (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_wimax_get_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_wimax_get_mac_address (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -251,8 +250,12 @@ nm_setting_wimax_class_init (NMSettingWimaxClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIMAX_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_WIMAX_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIMAX_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ GType nm_setting_wimax_get_type (void);
|
|||
|
||||
NMSetting *nm_setting_wimax_new (void);
|
||||
const char *nm_setting_wimax_get_network_name (NMSettingWimax *setting);
|
||||
const GByteArray *nm_setting_wimax_get_mac_address (NMSettingWimax *setting);
|
||||
const char *nm_setting_wimax_get_mac_address (NMSettingWimax *setting);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-wired.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
|
|
@ -69,11 +68,11 @@ typedef struct {
|
|||
guint32 speed;
|
||||
char *duplex;
|
||||
gboolean auto_negotiate;
|
||||
GByteArray *device_mac_address;
|
||||
GByteArray *cloned_mac_address;
|
||||
char *device_mac_address;
|
||||
char *cloned_mac_address;
|
||||
GSList *mac_address_blacklist;
|
||||
guint32 mtu;
|
||||
GPtrArray *s390_subchannels;
|
||||
char **s390_subchannels;
|
||||
char *s390_nettype;
|
||||
GHashTable *s390_options;
|
||||
} NMSettingWiredPrivate;
|
||||
|
|
@ -180,7 +179,7 @@ nm_setting_wired_get_auto_negotiate (NMSettingWired *setting)
|
|||
*
|
||||
* Returns: the #NMSettingWired:mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wired_get_mac_address (NMSettingWired *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
|
||||
|
|
@ -194,7 +193,7 @@ nm_setting_wired_get_mac_address (NMSettingWired *setting)
|
|||
*
|
||||
* Returns: the #NMSettingWired:cloned-mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
|
||||
|
|
@ -206,7 +205,7 @@ nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting)
|
|||
* nm_setting_wired_get_mac_address_blacklist:
|
||||
* @setting: the #NMSettingWired
|
||||
*
|
||||
* Returns: (element-type GLib.ByteArray): the #NMSettingWired:mac-address-blacklist
|
||||
* Returns: (element-type utf8): the #NMSettingWired:mac-address-blacklist
|
||||
* property of the setting
|
||||
**/
|
||||
const GSList *
|
||||
|
|
@ -381,15 +380,15 @@ nm_setting_wired_get_mtu (NMSettingWired *setting)
|
|||
* connection is applicable to. The connection should only be used in
|
||||
* conjunction with that device.
|
||||
*
|
||||
* Returns: (element-type utf8): #GPtrArray of strings, each specifying one
|
||||
* subchannel the s390 device uses to communicate to the host.
|
||||
* Returns: (transfer none) (element-type utf8): array of strings, each specifying
|
||||
* one subchannel the s390 device uses to communicate to the host.
|
||||
**/
|
||||
const GPtrArray *
|
||||
const char * const *
|
||||
nm_setting_wired_get_s390_subchannels (NMSettingWired *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRED (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
|
||||
return (const char * const *) NM_SETTING_WIRED_GET_PRIVATE (setting)->s390_subchannels;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -607,7 +606,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
|
||||
if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRED_ERROR,
|
||||
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -629,14 +628,17 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if ( priv->s390_subchannels
|
||||
&& !(priv->s390_subchannels->len == 3 || priv->s390_subchannels->len == 2)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRED_ERROR,
|
||||
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
|
||||
_("property is invalid"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
|
||||
return FALSE;
|
||||
if (priv->s390_subchannels) {
|
||||
int len = g_strv_length (priv->s390_subchannels);
|
||||
|
||||
if (len != 2 && len != 3) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRED_ERROR,
|
||||
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
|
||||
_("property is invalid"));
|
||||
g_prefix_error (error, "%s.%s: ", NM_SETTING_WIRED_SETTING_NAME, NM_SETTING_WIRED_S390_SUBCHANNELS);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (priv->s390_nettype && !_nm_utils_string_in_list (priv->s390_nettype, valid_nettype)) {
|
||||
|
|
@ -663,7 +665,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
|
||||
if (priv->cloned_mac_address && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRED_ERROR,
|
||||
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -694,34 +696,21 @@ finalize (GObject *object)
|
|||
|
||||
g_hash_table_destroy (priv->s390_options);
|
||||
|
||||
if (priv->device_mac_address)
|
||||
g_byte_array_free (priv->device_mac_address, TRUE);
|
||||
|
||||
if (priv->cloned_mac_address)
|
||||
g_byte_array_free (priv->cloned_mac_address, TRUE);
|
||||
|
||||
g_free (priv->device_mac_address);
|
||||
g_free (priv->cloned_mac_address);
|
||||
g_slist_free_full (priv->mac_address_blacklist, g_free);
|
||||
|
||||
if (priv->s390_subchannels) {
|
||||
g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
|
||||
g_ptr_array_free (priv->s390_subchannels, TRUE);
|
||||
}
|
||||
if (priv->s390_subchannels)
|
||||
g_strfreev (priv->s390_subchannels);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_wired_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_hash (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
g_hash_table_insert ((GHashTable *) user_data, g_strdup (key), g_strdup (value));
|
||||
}
|
||||
|
||||
static void
|
||||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWiredPrivate *priv = NM_SETTING_WIRED_GET_PRIVATE (object);
|
||||
GHashTable *new_hash;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_PORT:
|
||||
|
|
@ -739,27 +728,23 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->auto_negotiate = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (priv->device_mac_address)
|
||||
g_byte_array_free (priv->device_mac_address, TRUE);
|
||||
priv->device_mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->device_mac_address);
|
||||
priv->device_mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
if (priv->cloned_mac_address)
|
||||
g_byte_array_free (priv->cloned_mac_address, TRUE);
|
||||
priv->cloned_mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->cloned_mac_address);
|
||||
priv->cloned_mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_slist_free_full (priv->mac_address_blacklist, g_free);
|
||||
priv->mac_address_blacklist = g_value_dup_boxed (value);
|
||||
priv->mac_address_blacklist = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_S390_SUBCHANNELS:
|
||||
if (priv->s390_subchannels) {
|
||||
g_ptr_array_set_free_func (priv->s390_subchannels, g_free);
|
||||
g_ptr_array_free (priv->s390_subchannels, TRUE);
|
||||
}
|
||||
if (priv->s390_subchannels)
|
||||
g_strfreev (priv->s390_subchannels);
|
||||
priv->s390_subchannels = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_S390_NETTYPE:
|
||||
|
|
@ -767,11 +752,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->s390_nettype = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_S390_OPTIONS:
|
||||
/* Must make a deep copy of the hash table here... */
|
||||
g_hash_table_remove_all (priv->s390_options);
|
||||
new_hash = g_value_get_boxed (value);
|
||||
if (new_hash)
|
||||
g_hash_table_foreach (new_hash, copy_hash, priv->s390_options);
|
||||
g_hash_table_unref (priv->s390_options);
|
||||
priv->s390_options = _nm_utils_copy_strdict (g_value_get_boxed (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -800,25 +782,25 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_boolean (value, nm_setting_wired_get_auto_negotiate (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_wired_get_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_wired_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_wired_get_cloned_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_wired_get_cloned_mac_address (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_value_set_boxed (value, nm_setting_wired_get_mac_address_blacklist (setting));
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->mac_address_blacklist));
|
||||
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, nm_setting_wired_get_s390_subchannels (setting));
|
||||
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:
|
||||
g_value_set_boxed (value, priv->s390_options);
|
||||
g_value_take_boxed (value, _nm_utils_copy_strdict (priv->s390_options));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
|
@ -907,11 +889,15 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRED_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_WIRED_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWired:cloned-mac-address:
|
||||
|
|
@ -921,12 +907,16 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CLONED_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_param_spec_string (NM_SETTING_WIRED_CLONED_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_CLONED_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWired:mac-address-blacklist:
|
||||
*
|
||||
|
|
@ -937,11 +927,11 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS_BLACKLIST,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRED_MAC_ADDRESS_BLACKLIST, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWired:mtu:
|
||||
|
|
@ -971,11 +961,11 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_S390_SUBCHANNELS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "",
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRED_S390_SUBCHANNELS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWired:s390-nettype:
|
||||
|
|
@ -998,12 +988,18 @@ nm_setting_wired_class_init (NMSettingWiredClass *setting_class)
|
|||
* and values must be strings. Allowed keys include "portno", "layer2",
|
||||
* "portname", "protocol", among others. Key names must contain only
|
||||
* alphanumeric characters (ie, [a-zA-Z0-9]).
|
||||
*
|
||||
* Type: GHashTable(utf8,utf8)
|
||||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_S390_OPTIONS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRED_S390_OPTIONS, "", "",
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRED_S390_OPTIONS, "", "",
|
||||
G_TYPE_HASH_TABLE,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_INFERRABLE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRED_S390_OPTIONS,
|
||||
DBUS_TYPE_G_MAP_OF_STRING,
|
||||
_nm_utils_strdict_to_dbus,
|
||||
_nm_utils_strdict_from_dbus);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ const char * nm_setting_wired_get_port (NMSettingWired *setting
|
|||
guint32 nm_setting_wired_get_speed (NMSettingWired *setting);
|
||||
const char * nm_setting_wired_get_duplex (NMSettingWired *setting);
|
||||
gboolean nm_setting_wired_get_auto_negotiate (NMSettingWired *setting);
|
||||
const GByteArray *nm_setting_wired_get_mac_address (NMSettingWired *setting);
|
||||
const GByteArray *nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting);
|
||||
const char * nm_setting_wired_get_mac_address (NMSettingWired *setting);
|
||||
const char * nm_setting_wired_get_cloned_mac_address (NMSettingWired *setting);
|
||||
|
||||
const GSList *nm_setting_wired_get_mac_address_blacklist (NMSettingWired *setting);
|
||||
guint32 nm_setting_wired_get_num_mac_blacklist_items (NMSettingWired *setting);
|
||||
|
|
@ -103,7 +103,7 @@ void nm_setting_wired_clear_mac_blacklist_items (NMSettingWired *
|
|||
|
||||
guint32 nm_setting_wired_get_mtu (NMSettingWired *setting);
|
||||
|
||||
const GPtrArray * nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
|
||||
const char * const *nm_setting_wired_get_s390_subchannels (NMSettingWired *setting);
|
||||
const char * nm_setting_wired_get_s390_nettype (NMSettingWired *setting);
|
||||
|
||||
guint32 nm_setting_wired_get_num_s390_options (NMSettingWired *setting);
|
||||
|
|
|
|||
|
|
@ -22,14 +22,11 @@
|
|||
|
||||
#include <config.h>
|
||||
#include <string.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "nm-setting-wireless-security.h"
|
||||
#include "nm-setting-8021x.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-setting-private.h"
|
||||
|
||||
|
|
@ -1192,15 +1189,15 @@ set_property (GObject *object, guint prop_id,
|
|||
break;
|
||||
case PROP_PROTO:
|
||||
g_slist_free_full (priv->proto, g_free);
|
||||
priv->proto = g_value_dup_boxed (value);
|
||||
priv->proto = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_PAIRWISE:
|
||||
g_slist_free_full (priv->pairwise, g_free);
|
||||
priv->pairwise = g_value_dup_boxed (value);
|
||||
priv->pairwise = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_GROUP:
|
||||
g_slist_free_full (priv->group, g_free);
|
||||
priv->group = g_value_dup_boxed (value);
|
||||
priv->group = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_LEAP_USERNAME:
|
||||
g_free (priv->leap_username);
|
||||
|
|
@ -1266,13 +1263,13 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_string (value, priv->auth_alg);
|
||||
break;
|
||||
case PROP_PROTO:
|
||||
g_value_set_boxed (value, priv->proto);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->proto));
|
||||
break;
|
||||
case PROP_PAIRWISE:
|
||||
g_value_set_boxed (value, priv->pairwise);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->pairwise));
|
||||
break;
|
||||
case PROP_GROUP:
|
||||
g_value_set_boxed (value, priv->group);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->group));
|
||||
break;
|
||||
case PROP_LEAP_USERNAME:
|
||||
g_value_set_string (value, priv->leap_username);
|
||||
|
|
@ -1389,10 +1386,10 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PROTO,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PROTO, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:pairwise:
|
||||
|
|
@ -1404,10 +1401,10 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_PAIRWISE,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_PAIRWISE, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:group:
|
||||
|
|
@ -1419,10 +1416,10 @@ nm_setting_wireless_security_class_init (NMSettingWirelessSecurityClass *setting
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_GROUP,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SECURITY_GROUP, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWirelessSecurity:leap-username:
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#include "nm-setting-wireless.h"
|
||||
#include "nm-dbus-interface.h"
|
||||
#include "nm-param-spec-specialized.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-utils-private.h"
|
||||
|
|
@ -66,15 +65,15 @@ NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_WIRELESS)
|
|||
#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
char *mode;
|
||||
char *band;
|
||||
guint32 channel;
|
||||
GByteArray *bssid;
|
||||
char *bssid;
|
||||
guint32 rate;
|
||||
guint32 tx_power;
|
||||
GByteArray *device_mac_address;
|
||||
GByteArray *cloned_mac_address;
|
||||
char *device_mac_address;
|
||||
char *cloned_mac_address;
|
||||
GSList *mac_address_blacklist;
|
||||
guint32 mtu;
|
||||
GSList *seen_bssids;
|
||||
|
|
@ -316,7 +315,7 @@ nm_setting_wireless_new (void)
|
|||
*
|
||||
* Returns: the #NMSettingWireless:ssid property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
GBytes *
|
||||
nm_setting_wireless_get_ssid (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
|
@ -372,7 +371,7 @@ nm_setting_wireless_get_channel (NMSettingWireless *setting)
|
|||
*
|
||||
* Returns: the #NMSettingWireless:bssid property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wireless_get_bssid (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
|
@ -414,7 +413,7 @@ nm_setting_wireless_get_tx_power (NMSettingWireless *setting)
|
|||
*
|
||||
* Returns: the #NMSettingWireless:mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wireless_get_mac_address (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
|
@ -428,7 +427,7 @@ nm_setting_wireless_get_mac_address (NMSettingWireless *setting)
|
|||
*
|
||||
* Returns: the #NMSettingWireless:cloned-mac-address property of the setting
|
||||
**/
|
||||
const GByteArray *
|
||||
const char *
|
||||
nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
|
@ -440,7 +439,7 @@ nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting)
|
|||
* nm_setting_wireless_get_mac_address_blacklist:
|
||||
* @setting: the #NMSettingWireless
|
||||
*
|
||||
* Returns: (element-type GLib.ByteArray): the
|
||||
* Returns: (element-type utf8): the
|
||||
* #NMSettingWireless:mac-address-blacklist property of the setting
|
||||
**/
|
||||
const GSList *
|
||||
|
|
@ -704,6 +703,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
const char *valid_modes[] = { NM_SETTING_WIRELESS_MODE_INFRA, NM_SETTING_WIRELESS_MODE_ADHOC, NM_SETTING_WIRELESS_MODE_AP, NULL };
|
||||
const char *valid_bands[] = { "a", "bg", NULL };
|
||||
GSList *iter;
|
||||
gsize length;
|
||||
|
||||
if (!priv->ssid) {
|
||||
g_set_error_literal (error,
|
||||
|
|
@ -714,7 +714,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!priv->ssid->len || priv->ssid->len > 32) {
|
||||
length = g_bytes_get_size (priv->ssid);
|
||||
if (length == 0 || length > 32) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -765,7 +766,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (priv->bssid && priv->bssid->len != ETH_ALEN) {
|
||||
if (priv->bssid && !nm_utils_hwaddr_valid (priv->bssid, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -774,7 +775,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->device_mac_address && priv->device_mac_address->len != ETH_ALEN) {
|
||||
if (priv->device_mac_address && !nm_utils_hwaddr_valid (priv->device_mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -783,7 +784,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (priv->cloned_mac_address && priv->cloned_mac_address->len != ETH_ALEN) {
|
||||
if (priv->cloned_mac_address && !nm_utils_hwaddr_valid (priv->cloned_mac_address, ETH_ALEN)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -846,13 +847,10 @@ finalize (GObject *object)
|
|||
g_free (priv->band);
|
||||
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
if (priv->bssid)
|
||||
g_byte_array_free (priv->bssid, TRUE);
|
||||
if (priv->device_mac_address)
|
||||
g_byte_array_free (priv->device_mac_address, TRUE);
|
||||
if (priv->cloned_mac_address)
|
||||
g_byte_array_free (priv->cloned_mac_address, TRUE);
|
||||
g_bytes_unref (priv->ssid);
|
||||
g_free (priv->bssid);
|
||||
g_free (priv->device_mac_address);
|
||||
g_free (priv->cloned_mac_address);
|
||||
g_slist_free_full (priv->mac_address_blacklist, g_free);
|
||||
g_slist_free_full (priv->seen_bssids, g_free);
|
||||
|
||||
|
|
@ -868,7 +866,7 @@ set_property (GObject *object, guint prop_id,
|
|||
switch (prop_id) {
|
||||
case PROP_SSID:
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
g_bytes_unref (priv->ssid);
|
||||
priv->ssid = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
|
|
@ -883,9 +881,8 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->channel = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_BSSID:
|
||||
if (priv->bssid)
|
||||
g_byte_array_free (priv->bssid, TRUE);
|
||||
priv->bssid = g_value_dup_boxed (value);
|
||||
g_free (priv->bssid);
|
||||
priv->bssid = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_RATE:
|
||||
priv->rate = g_value_get_uint (value);
|
||||
|
|
@ -894,25 +891,23 @@ set_property (GObject *object, guint prop_id,
|
|||
priv->tx_power = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (priv->device_mac_address)
|
||||
g_byte_array_free (priv->device_mac_address, TRUE);
|
||||
priv->device_mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->device_mac_address);
|
||||
priv->device_mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
if (priv->cloned_mac_address)
|
||||
g_byte_array_free (priv->cloned_mac_address, TRUE);
|
||||
priv->cloned_mac_address = g_value_dup_boxed (value);
|
||||
g_free (priv->cloned_mac_address);
|
||||
priv->cloned_mac_address = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_slist_free_full (priv->mac_address_blacklist, g_free);
|
||||
priv->mac_address_blacklist = g_value_dup_boxed (value);
|
||||
priv->mac_address_blacklist = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
priv->mtu = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
g_slist_free_full (priv->seen_bssids, g_free);
|
||||
priv->seen_bssids = g_value_dup_boxed (value);
|
||||
priv->seen_bssids = _nm_utils_strv_to_slist (g_value_get_boxed (value));
|
||||
break;
|
||||
case PROP_HIDDEN:
|
||||
priv->hidden = g_value_get_boolean (value);
|
||||
|
|
@ -928,6 +923,7 @@ get_property (GObject *object, guint prop_id,
|
|||
GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWireless *setting = NM_SETTING_WIRELESS (object);
|
||||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SSID:
|
||||
|
|
@ -943,7 +939,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, nm_setting_wireless_get_channel (setting));
|
||||
break;
|
||||
case PROP_BSSID:
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_bssid (setting));
|
||||
g_value_set_string (value, nm_setting_wireless_get_bssid (setting));
|
||||
break;
|
||||
case PROP_RATE:
|
||||
g_value_set_uint (value, nm_setting_wireless_get_rate (setting));
|
||||
|
|
@ -952,19 +948,19 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, nm_setting_wireless_get_tx_power (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_wireless_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_CLONED_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_cloned_mac_address (setting));
|
||||
g_value_set_string (value, nm_setting_wireless_get_cloned_mac_address (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS_BLACKLIST:
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_mac_address_blacklist (setting));
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->mac_address_blacklist));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint (value, nm_setting_wireless_get_mtu (setting));
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
g_value_set_boxed (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
|
||||
g_value_take_boxed (value, _nm_utils_slist_to_strv (priv->seen_bssids));
|
||||
break;
|
||||
case PROP_HIDDEN:
|
||||
g_value_set_boolean (value, nm_setting_wireless_get_hidden (setting));
|
||||
|
|
@ -997,10 +993,14 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SSID,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SSID, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SSID, "", "",
|
||||
G_TYPE_BYTES,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRELESS_SSID,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_bytes_to_dbus,
|
||||
_nm_utils_bytes_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mode:
|
||||
|
|
@ -1058,10 +1058,14 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_BSSID,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_BSSID, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_WIRELESS_BSSID, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRELESS_BSSID,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:rate:
|
||||
|
|
@ -1105,10 +1109,14 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_WIRELESS_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRELESS_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:cloned-mac-address:
|
||||
|
|
@ -1118,10 +1126,14 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_CLONED_MAC_ADDRESS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "", "",
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_string (NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, "", "",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
_nm_setting_class_transform_property (parent_class, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
_nm_utils_hwaddr_to_dbus,
|
||||
_nm_utils_hwaddr_from_dbus);
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mac-address-blacklist:
|
||||
|
|
@ -1132,11 +1144,11 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_MAC_ADDRESS_BLACKLIST,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_MAC_ADDRESS_BLACKLIST, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWireless:seen-bssids:
|
||||
|
|
@ -1150,11 +1162,11 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
**/
|
||||
g_object_class_install_property
|
||||
(object_class, PROP_SEEN_BSSIDS,
|
||||
_nm_param_spec_specialized (NM_SETTING_WIRELESS_SEEN_BSSIDS, "", "",
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
g_param_spec_boxed (NM_SETTING_WIRELESS_SEEN_BSSIDS, "", "",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
NM_SETTING_PARAM_FUZZY_IGNORE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
/**
|
||||
* NMSettingWireless:mtu:
|
||||
|
|
|
|||
|
|
@ -116,15 +116,15 @@ GType nm_setting_wireless_get_type (void);
|
|||
|
||||
NMSetting *nm_setting_wireless_new (void);
|
||||
|
||||
const GByteArray *nm_setting_wireless_get_ssid (NMSettingWireless *setting);
|
||||
GBytes *nm_setting_wireless_get_ssid (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_mode (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_band (NMSettingWireless *setting);
|
||||
guint32 nm_setting_wireless_get_channel (NMSettingWireless *setting);
|
||||
const GByteArray *nm_setting_wireless_get_bssid (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_bssid (NMSettingWireless *setting);
|
||||
guint32 nm_setting_wireless_get_rate (NMSettingWireless *setting);
|
||||
guint32 nm_setting_wireless_get_tx_power (NMSettingWireless *setting);
|
||||
const GByteArray *nm_setting_wireless_get_mac_address (NMSettingWireless *setting);
|
||||
const GByteArray *nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_mac_address (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_cloned_mac_address (NMSettingWireless *setting);
|
||||
|
||||
const GSList *nm_setting_wireless_get_mac_address_blacklist (NMSettingWireless *setting);
|
||||
guint32 nm_setting_wireless_get_num_mac_blacklist_items (NMSettingWireless *setting);
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#include "nm-setting-connection.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-utils-private.h"
|
||||
#include "nm-property-compare.h"
|
||||
|
||||
/**
|
||||
* SECTION:nm-setting
|
||||
|
|
@ -389,9 +390,13 @@ typedef struct {
|
|||
const char *name;
|
||||
GParamSpec *param_spec;
|
||||
GType dbus_type;
|
||||
|
||||
NMSettingPropertyGetFunc get_func;
|
||||
NMSettingPropertySetFunc set_func;
|
||||
NMSettingPropertyNotSetFunc not_set_func;
|
||||
|
||||
NMSettingPropertyTransformFunc to_dbus;
|
||||
NMSettingPropertyTransformFunc from_dbus;
|
||||
} NMSettingProperty;
|
||||
|
||||
static GQuark setting_property_overrides_quark;
|
||||
|
|
@ -422,7 +427,9 @@ add_property_override (NMSettingClass *setting_class,
|
|||
GType dbus_type,
|
||||
NMSettingPropertyGetFunc get_func,
|
||||
NMSettingPropertySetFunc set_func,
|
||||
NMSettingPropertyNotSetFunc not_set_func)
|
||||
NMSettingPropertyNotSetFunc not_set_func,
|
||||
NMSettingPropertyTransformFunc to_dbus,
|
||||
NMSettingPropertyTransformFunc from_dbus)
|
||||
{
|
||||
GType setting_type = G_TYPE_FROM_CLASS (setting_class);
|
||||
GArray *overrides;
|
||||
|
|
@ -437,6 +444,8 @@ add_property_override (NMSettingClass *setting_class,
|
|||
override.get_func = get_func;
|
||||
override.set_func = set_func;
|
||||
override.not_set_func = not_set_func;
|
||||
override.to_dbus = to_dbus;
|
||||
override.from_dbus = from_dbus;
|
||||
|
||||
overrides = g_type_get_qdata (setting_type, setting_property_overrides_quark);
|
||||
if (!overrides) {
|
||||
|
|
@ -487,7 +496,8 @@ _nm_setting_class_add_dbus_only_property (NMSettingClass *setting_class,
|
|||
|
||||
add_property_override (setting_class,
|
||||
property_name, NULL, dbus_type,
|
||||
get_func, set_func, NULL);
|
||||
get_func, set_func, NULL,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -535,7 +545,42 @@ _nm_setting_class_override_property (NMSettingClass *setting_class,
|
|||
|
||||
add_property_override (setting_class,
|
||||
property_name, param_spec, dbus_type,
|
||||
get_func, set_func, not_set_func);
|
||||
get_func, set_func, not_set_func,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* _nm_setting_class_transform_property:
|
||||
* @setting_class: the setting class
|
||||
* @property: the name of the property to transform
|
||||
* @dbus_type: the type of the property (in its D-Bus representation)
|
||||
* @to_dbus: function to convert from object to D-Bus format
|
||||
* @from_dbus: function to convert from D-Bus to object format
|
||||
*
|
||||
* Indicates that @property on @setting_class does not have the same format as
|
||||
* its corresponding D-Bus representation, and so must be transformed when
|
||||
* serializing/deserializing.
|
||||
*
|
||||
* The transformation will also be used by nm_setting_compare(), meaning that
|
||||
* the underlying object property does not need to be of a type that
|
||||
* nm_property_compare() recognizes, as long as it recognizes @dbus_type.
|
||||
*/
|
||||
void
|
||||
_nm_setting_class_transform_property (NMSettingClass *setting_class,
|
||||
const char *property,
|
||||
GType dbus_type,
|
||||
NMSettingPropertyTransformFunc to_dbus,
|
||||
NMSettingPropertyTransformFunc from_dbus)
|
||||
{
|
||||
GParamSpec *param_spec;
|
||||
|
||||
param_spec = g_object_class_find_property (G_OBJECT_CLASS (setting_class), property);
|
||||
g_return_if_fail (param_spec != NULL);
|
||||
|
||||
add_property_override (setting_class,
|
||||
property, param_spec, dbus_type,
|
||||
NULL, NULL, NULL,
|
||||
to_dbus, from_dbus);
|
||||
}
|
||||
|
||||
static GArray *
|
||||
|
|
@ -680,6 +725,16 @@ _nm_setting_to_dbus (NMSetting *setting, NMConnection *connection, NMConnectionS
|
|||
|
||||
/* Don't serialize values with default values */
|
||||
set = !g_param_value_defaults (prop_spec, value);
|
||||
|
||||
/* Convert the property value if necessary */
|
||||
if (set && property->to_dbus) {
|
||||
GValue *dbus_value = g_slice_new0 (GValue);
|
||||
|
||||
g_value_init (dbus_value, property->dbus_type);
|
||||
property->to_dbus (value, dbus_value);
|
||||
destroy_gvalue (value);
|
||||
value = dbus_value;
|
||||
}
|
||||
} else
|
||||
g_assert_not_reached ();
|
||||
|
||||
|
|
@ -780,7 +835,15 @@ _nm_setting_new_from_dbus (GType setting_type,
|
|||
if (!(property->param_spec->flags & G_PARAM_WRITABLE))
|
||||
continue;
|
||||
|
||||
g_object_set_property (G_OBJECT (setting), property->param_spec->name, value);
|
||||
if (property->from_dbus) {
|
||||
GValue object_value = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&object_value, property->param_spec->value_type);
|
||||
property->from_dbus (value, &object_value);
|
||||
g_object_set_property (G_OBJECT (setting), property->param_spec->name, &object_value);
|
||||
g_value_unset (&object_value);
|
||||
} else
|
||||
g_object_set_property (G_OBJECT (setting), property->param_spec->name, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -910,9 +973,10 @@ compare_property (NMSetting *setting,
|
|||
const GParamSpec *prop_spec,
|
||||
NMSettingCompareFlags flags)
|
||||
{
|
||||
const NMSettingProperty *property;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
gboolean different;
|
||||
int cmp;
|
||||
|
||||
/* Handle compare flags */
|
||||
if (prop_spec->flags & NM_SETTING_PARAM_SECRET) {
|
||||
|
|
@ -938,18 +1002,34 @@ compare_property (NMSetting *setting,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
property = nm_setting_class_find_property (NM_SETTING_GET_CLASS (setting), prop_spec->name);
|
||||
g_return_val_if_fail (property != NULL, FALSE);
|
||||
|
||||
g_value_init (&value1, prop_spec->value_type);
|
||||
g_object_get_property (G_OBJECT (setting), prop_spec->name, &value1);
|
||||
|
||||
g_value_init (&value2, prop_spec->value_type);
|
||||
g_object_get_property (G_OBJECT (other), prop_spec->name, &value2);
|
||||
|
||||
different = g_param_values_cmp ((GParamSpec *) prop_spec, &value1, &value2);
|
||||
if (property->to_dbus) {
|
||||
GValue dbus_value1 = G_VALUE_INIT, dbus_value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&dbus_value1, property->dbus_type);
|
||||
property->to_dbus (&value1, &dbus_value1);
|
||||
g_value_init (&dbus_value2, property->dbus_type);
|
||||
property->to_dbus (&value2, &dbus_value2);
|
||||
|
||||
cmp = nm_property_compare (&dbus_value1, &dbus_value2);
|
||||
|
||||
g_value_unset (&dbus_value1);
|
||||
g_value_unset (&dbus_value2);
|
||||
} else
|
||||
cmp = nm_property_compare (&value1, &value2);
|
||||
|
||||
g_value_unset (&value1);
|
||||
g_value_unset (&value2);
|
||||
|
||||
return different == 0 ? TRUE : FALSE;
|
||||
return cmp == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -34,4 +34,48 @@ gboolean _nm_utils_gvalue_array_validate (GValueArray *elements,
|
|||
|
||||
void _nm_value_transforms_register (void);
|
||||
|
||||
void _nm_utils_hwaddr_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_hwaddr_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
|
||||
void _nm_utils_strdict_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_strdict_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
|
||||
void _nm_utils_bytes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_bytes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
|
||||
void _nm_utils_ip4_dns_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip4_dns_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
void _nm_utils_ip4_addresses_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip4_addresses_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
void _nm_utils_ip4_routes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip4_routes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
|
||||
void _nm_utils_ip6_dns_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip6_dns_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
void _nm_utils_ip6_addresses_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip6_addresses_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
void _nm_utils_ip6_routes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value);
|
||||
void _nm_utils_ip6_routes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value);
|
||||
|
||||
GSList * _nm_utils_strv_to_slist (char **strv);
|
||||
char ** _nm_utils_slist_to_strv (GSList *slist);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -261,7 +261,8 @@ nm_utils_deinit (void)
|
|||
|
||||
/**
|
||||
* nm_utils_ssid_to_utf8:
|
||||
* @ssid: a byte array containing the SSID data
|
||||
* @ssid: pointer to a buffer containing the SSID data
|
||||
* @len: length of the SSID data in @ssid
|
||||
*
|
||||
* Wi-Fi SSIDs are byte arrays, they are _not_ strings. Thus, an SSID may
|
||||
* contain embedded NULLs and other unprintable characters. Often it is
|
||||
|
|
@ -291,15 +292,15 @@ nm_utils_deinit (void)
|
|||
* Returns %NULL on errors.
|
||||
**/
|
||||
char *
|
||||
nm_utils_ssid_to_utf8 (const GByteArray *ssid)
|
||||
nm_utils_ssid_to_utf8 (const guint8 *ssid, gsize len)
|
||||
{
|
||||
char *converted = NULL;
|
||||
char *lang, *e1 = NULL, *e2 = NULL, *e3 = NULL;
|
||||
|
||||
g_return_val_if_fail (ssid != NULL, NULL);
|
||||
|
||||
if (g_utf8_validate ((const gchar *) ssid->data, ssid->len, NULL))
|
||||
return g_strndup ((const gchar *) ssid->data, ssid->len);
|
||||
if (g_utf8_validate ((const gchar *) ssid, len, NULL))
|
||||
return g_strndup ((const gchar *) ssid, len);
|
||||
|
||||
/* LANG may be a good encoding hint */
|
||||
g_get_charset ((const char **)(&e1));
|
||||
|
|
@ -314,15 +315,15 @@ nm_utils_ssid_to_utf8 (const GByteArray *ssid)
|
|||
g_free (lang);
|
||||
}
|
||||
|
||||
converted = g_convert ((const gchar *) ssid->data, ssid->len, "UTF-8", e1, NULL, NULL, NULL);
|
||||
converted = g_convert ((const gchar *) ssid, len, "UTF-8", e1, NULL, NULL, NULL);
|
||||
if (!converted && e2)
|
||||
converted = g_convert ((const gchar *) ssid->data, ssid->len, "UTF-8", e2, NULL, NULL, NULL);
|
||||
converted = g_convert ((const gchar *) ssid, len, "UTF-8", e2, NULL, NULL, NULL);
|
||||
|
||||
if (!converted && e3)
|
||||
converted = g_convert ((const gchar *) ssid->data, ssid->len, "UTF-8", e3, NULL, NULL, NULL);
|
||||
converted = g_convert ((const gchar *) ssid, len, "UTF-8", e3, NULL, NULL, NULL);
|
||||
|
||||
if (!converted) {
|
||||
converted = g_convert_with_fallback ((const gchar *) ssid->data, ssid->len,
|
||||
converted = g_convert_with_fallback ((const gchar *) ssid, len,
|
||||
"UTF-8", e1, "?", NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +343,7 @@ nm_utils_ssid_to_utf8 (const GByteArray *ssid)
|
|||
* Returns: %TRUE if the SSID is "empty", %FALSE if it is not
|
||||
**/
|
||||
gboolean
|
||||
nm_utils_is_empty_ssid (const guint8 * ssid, int len)
|
||||
nm_utils_is_empty_ssid (const guint8 *ssid, gsize len)
|
||||
{
|
||||
/* Single white space is for Linksys APs */
|
||||
if (len == 1 && ssid[0] == ' ')
|
||||
|
|
@ -372,7 +373,7 @@ nm_utils_is_empty_ssid (const guint8 * ssid, int len)
|
|||
* and will be overwritten by subsequent calls to this function
|
||||
**/
|
||||
const char *
|
||||
nm_utils_escape_ssid (const guint8 * ssid, guint32 len)
|
||||
nm_utils_escape_ssid (const guint8 *ssid, gsize len)
|
||||
{
|
||||
static char escaped[ESSID_MAX_SIZE * 2 + 1];
|
||||
const guint8 *s = ssid;
|
||||
|
|
@ -399,8 +400,10 @@ nm_utils_escape_ssid (const guint8 * ssid, guint32 len)
|
|||
|
||||
/**
|
||||
* nm_utils_same_ssid:
|
||||
* @ssid1: first SSID data to compare
|
||||
* @ssid2: second SSID data to compare
|
||||
* @ssid1: the first SSID to compare
|
||||
* @len1: length of the SSID data in @ssid1
|
||||
* @ssid2: the second SSID to compare
|
||||
* @len2: length of the SSID data in @ssid2
|
||||
* @ignore_trailing_null: %TRUE to ignore one trailing NULL byte
|
||||
*
|
||||
* Earlier versions of the Linux kernel added a NULL byte to the end of the
|
||||
|
|
@ -413,30 +416,29 @@ nm_utils_escape_ssid (const guint8 * ssid, guint32 len)
|
|||
* Returns: %TRUE if the SSIDs are the same, %FALSE if they are not
|
||||
**/
|
||||
gboolean
|
||||
nm_utils_same_ssid (const GByteArray * ssid1,
|
||||
const GByteArray * ssid2,
|
||||
nm_utils_same_ssid (const guint8 *ssid1, gsize len1,
|
||||
const guint8 *ssid2, gsize len2,
|
||||
gboolean ignore_trailing_null)
|
||||
{
|
||||
guint32 ssid1_len, ssid2_len;
|
||||
g_return_val_if_fail (ssid1 != NULL || len1 == 0, FALSE);
|
||||
g_return_val_if_fail (ssid2 != NULL || len2 == 0, FALSE);
|
||||
|
||||
if (ssid1 == ssid2)
|
||||
if (ssid1 == ssid2 && len1 == len2)
|
||||
return TRUE;
|
||||
if (!ssid1 || !ssid2)
|
||||
return FALSE;
|
||||
|
||||
ssid1_len = ssid1->len;
|
||||
ssid2_len = ssid2->len;
|
||||
if (ssid1_len && ssid2_len && ignore_trailing_null) {
|
||||
if (ssid1->data[ssid1_len - 1] == '\0')
|
||||
ssid1_len--;
|
||||
if (ssid2->data[ssid2_len - 1] == '\0')
|
||||
ssid2_len--;
|
||||
if (ignore_trailing_null) {
|
||||
if (len1 && ssid1[len1 - 1] == '\0')
|
||||
len1--;
|
||||
if (len2 && ssid2[len2 - 1] == '\0')
|
||||
len2--;
|
||||
}
|
||||
|
||||
if (ssid1_len != ssid2_len)
|
||||
if (len1 != len2)
|
||||
return FALSE;
|
||||
|
||||
return memcmp (ssid1->data, ssid2->data, ssid1_len) == 0 ? TRUE : FALSE;
|
||||
return memcmp (ssid1, ssid2, len1) == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -564,6 +566,126 @@ _nm_utils_hash_values_to_slist (GHashTable *hash)
|
|||
return list;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_strdict_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
g_value_set_boxed (dbus_value, g_value_get_boxed (prop_value));
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_strdict_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
g_value_set_boxed (prop_value, g_value_get_boxed (dbus_value));
|
||||
}
|
||||
|
||||
GHashTable *
|
||||
_nm_utils_copy_strdict (GHashTable *strdict)
|
||||
{
|
||||
GHashTable *copy;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
copy = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||
if (strdict) {
|
||||
g_hash_table_iter_init (&iter, strdict);
|
||||
while (g_hash_table_iter_next (&iter, &key, &value))
|
||||
g_hash_table_insert (copy, g_strdup (key), g_strdup (value));
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
GPtrArray *
|
||||
_nm_utils_copy_slist_to_array (const GSList *list,
|
||||
NMUtilsCopyFunc copy_func,
|
||||
GDestroyNotify unref_func)
|
||||
{
|
||||
const GSList *iter;
|
||||
GPtrArray *array;
|
||||
|
||||
array = g_ptr_array_new_with_free_func (unref_func);
|
||||
for (iter = list; iter; iter = iter->next)
|
||||
g_ptr_array_add (array, copy_func (iter->data));
|
||||
return array;
|
||||
}
|
||||
|
||||
GSList *
|
||||
_nm_utils_copy_array_to_slist (const GPtrArray *array,
|
||||
NMUtilsCopyFunc copy_func)
|
||||
{
|
||||
GSList *slist = NULL;
|
||||
gpointer item;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < array->len; i++) {
|
||||
item = array->pdata[i];
|
||||
slist = g_slist_prepend (slist, copy_func (item));
|
||||
}
|
||||
|
||||
return g_slist_reverse (slist);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_bytes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GBytes *bytes = g_value_get_boxed (prop_value);
|
||||
GByteArray *ba = NULL;
|
||||
|
||||
if (bytes) {
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba,
|
||||
g_bytes_get_data (bytes, NULL),
|
||||
g_bytes_get_size (bytes));
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, ba);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_bytes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GByteArray *ba = g_value_dup_boxed (dbus_value);
|
||||
GBytes *bytes = NULL;
|
||||
|
||||
if (ba)
|
||||
bytes = g_byte_array_free_to_bytes (ba);
|
||||
g_value_take_boxed (prop_value, bytes);
|
||||
}
|
||||
|
||||
GSList *
|
||||
_nm_utils_strv_to_slist (char **strv)
|
||||
{
|
||||
int i;
|
||||
GSList *list = NULL;
|
||||
|
||||
g_return_val_if_fail (strv != NULL, NULL);
|
||||
|
||||
for (i = 0; strv[i]; i++)
|
||||
list = g_slist_prepend (list, g_strdup (strv[i]));
|
||||
|
||||
return g_slist_reverse (list);
|
||||
}
|
||||
|
||||
char **
|
||||
_nm_utils_slist_to_strv (GSList *slist)
|
||||
{
|
||||
GSList *iter;
|
||||
char **strv;
|
||||
int len, i = 0;
|
||||
|
||||
len = g_slist_length (slist);
|
||||
strv = g_new (char *, len + 1);
|
||||
|
||||
for (i = 0, iter = slist; iter; iter = iter->next, i++)
|
||||
strv[i] = g_strdup (iter->data);
|
||||
strv[i] = NULL;
|
||||
|
||||
return strv;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
device_supports_ap_ciphers (guint32 dev_caps,
|
||||
guint32 ap_flags,
|
||||
|
|
@ -895,6 +1017,191 @@ nm_utils_wpa_psk_valid (const char *psk)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_dns_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
char **dns;
|
||||
int i;
|
||||
GArray *array;
|
||||
|
||||
dns = g_value_get_boxed (prop_value);
|
||||
array = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
if (dns) {
|
||||
for (i = 0; dns[i]; i++) {
|
||||
guint32 ip = 0;
|
||||
|
||||
inet_pton (AF_INET, dns[i], &ip);
|
||||
g_array_append_val (array, ip);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, array);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_dns_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GArray *array;
|
||||
GPtrArray *dns;
|
||||
int i;
|
||||
|
||||
array = g_value_get_boxed (dbus_value);
|
||||
dns = g_ptr_array_new ();
|
||||
|
||||
if (array) {
|
||||
for (i = 0; i < array->len; i++) {
|
||||
guint32 ip = g_array_index (array, guint32, i);
|
||||
const char *str;
|
||||
|
||||
str = nm_utils_inet4_ntop (ip, NULL);
|
||||
g_ptr_array_add (dns, g_strdup (str));
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_add (dns, NULL);
|
||||
g_value_take_boxed (prop_value, g_ptr_array_free (dns, FALSE));
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_addresses_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GPtrArray *addresses, *dbus_addresses;
|
||||
int i;
|
||||
|
||||
addresses = g_value_get_boxed (prop_value);
|
||||
dbus_addresses = g_ptr_array_new ();
|
||||
|
||||
if (addresses) {
|
||||
for (i = 0; i < addresses->len; i++) {
|
||||
NMIP4Address *addr = addresses->pdata[i];
|
||||
GArray *array;
|
||||
guint32 tmp;
|
||||
|
||||
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
|
||||
|
||||
tmp = nm_ip4_address_get_address (addr);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
tmp = nm_ip4_address_get_prefix (addr);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
tmp = nm_ip4_address_get_gateway (addr);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
g_ptr_array_add (dbus_addresses, array);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, dbus_addresses);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_addresses_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GPtrArray *dbus_addresses;
|
||||
GPtrArray *addresses;
|
||||
int i;
|
||||
|
||||
dbus_addresses = g_value_get_boxed (dbus_value);
|
||||
addresses = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip4_address_unref);
|
||||
|
||||
if (dbus_addresses) {
|
||||
for (i = 0; i < dbus_addresses->len; i++) {
|
||||
GArray *array = dbus_addresses->pdata[i];
|
||||
NMIP4Address *addr;
|
||||
|
||||
if (array->len < 3) {
|
||||
g_warning ("Ignoring invalid IP4 address");
|
||||
continue;
|
||||
}
|
||||
|
||||
addr = nm_ip4_address_new ();
|
||||
nm_ip4_address_set_address (addr, g_array_index (array, guint32, 0));
|
||||
nm_ip4_address_set_prefix (addr, g_array_index (array, guint32, 1));
|
||||
nm_ip4_address_set_gateway (addr, g_array_index (array, guint32, 2));
|
||||
|
||||
g_ptr_array_add (addresses, addr);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (prop_value, addresses);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_routes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GPtrArray *routes, *dbus_routes;
|
||||
int i;
|
||||
|
||||
routes = g_value_get_boxed (prop_value);
|
||||
dbus_routes = g_ptr_array_new ();
|
||||
|
||||
if (routes) {
|
||||
for (i = 0; i < routes->len; i++) {
|
||||
NMIP4Route *route = routes->pdata[i];
|
||||
GArray *array;
|
||||
guint32 tmp;
|
||||
|
||||
array = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
|
||||
|
||||
tmp = nm_ip4_route_get_dest (route);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
tmp = nm_ip4_route_get_prefix (route);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
tmp = nm_ip4_route_get_next_hop (route);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
tmp = nm_ip4_route_get_metric (route);
|
||||
g_array_append_val (array, tmp);
|
||||
|
||||
g_ptr_array_add (dbus_routes, array);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, dbus_routes);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip4_routes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GPtrArray *dbus_routes, *routes;
|
||||
int i;
|
||||
|
||||
dbus_routes = g_value_get_boxed (dbus_value);
|
||||
routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip4_route_unref);
|
||||
|
||||
if (dbus_routes) {
|
||||
for (i = 0; i < dbus_routes->len; i++) {
|
||||
GArray *array = dbus_routes->pdata[i];
|
||||
NMIP4Route *route;
|
||||
|
||||
if (array->len < 4) {
|
||||
g_warning ("Ignoring invalid IP4 route");
|
||||
continue;
|
||||
}
|
||||
|
||||
route = nm_ip4_route_new ();
|
||||
nm_ip4_route_set_dest (route, g_array_index (array, guint32, 0));
|
||||
nm_ip4_route_set_prefix (route, g_array_index (array, guint32, 1));
|
||||
nm_ip4_route_set_next_hop (route, g_array_index (array, guint32, 2));
|
||||
nm_ip4_route_set_metric (route, g_array_index (array, guint32, 3));
|
||||
|
||||
g_ptr_array_add (routes, route);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (prop_value, routes);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_ip4_addresses_from_gvalue:
|
||||
* @value: #GValue containing a #GPtrArray of #GArrays of #guint32s
|
||||
|
|
@ -1134,6 +1441,289 @@ nm_utils_ip4_get_default_prefix (guint32 ip)
|
|||
return 24; /* Class C - 255.255.255.0 */
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_dns_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
char **dns;
|
||||
GPtrArray *dbus_dns;
|
||||
int i;
|
||||
|
||||
dns = g_value_get_boxed (prop_value);
|
||||
dbus_dns = g_ptr_array_new ();
|
||||
|
||||
if (dns) {
|
||||
for (i = 0; dns[i]; i++) {
|
||||
GByteArray *bytearray;
|
||||
|
||||
bytearray = g_byte_array_new ();
|
||||
g_byte_array_set_size (bytearray, 16);
|
||||
inet_pton (AF_INET6, dns[i], bytearray->data);
|
||||
g_ptr_array_add (dbus_dns, bytearray);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, dbus_dns);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_dns_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GPtrArray *dbus_dns, *dns;
|
||||
int i;
|
||||
|
||||
dbus_dns = g_value_get_boxed (dbus_value);
|
||||
dns = g_ptr_array_new ();
|
||||
|
||||
if (dbus_dns) {
|
||||
for (i = 0; i < dbus_dns->len; i++) {
|
||||
GByteArray *bytearray = dbus_dns->pdata[i];
|
||||
const char *str;
|
||||
|
||||
if (bytearray->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 address of length %d",
|
||||
__func__, bytearray->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
str = nm_utils_inet6_ntop ((struct in6_addr *) bytearray->data, NULL);
|
||||
g_ptr_array_add (dns, g_strdup (str));
|
||||
}
|
||||
}
|
||||
|
||||
g_ptr_array_add (dns, NULL);
|
||||
g_value_take_boxed (prop_value, g_ptr_array_free (dns, FALSE));
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_addresses_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GPtrArray *addresses, *dbus_addresses;
|
||||
int i;
|
||||
|
||||
addresses = g_value_get_boxed (prop_value);
|
||||
dbus_addresses = g_ptr_array_new ();
|
||||
|
||||
if (addresses) {
|
||||
for (i = 0; i < addresses->len; i++) {
|
||||
NMIP6Address *addr = addresses->pdata[i];
|
||||
GValueArray *array;
|
||||
GValue element = G_VALUE_INIT;
|
||||
GByteArray *ba;
|
||||
|
||||
array = g_value_array_new (3);
|
||||
|
||||
/* IP address */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_address (addr), 16);
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* Prefix */
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, nm_ip6_address_get_prefix (addr));
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* Gateway */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) nm_ip6_address_get_gateway (addr), 16);
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (dbus_addresses, array);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, dbus_addresses);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_addresses_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GPtrArray *addresses, *dbus_addresses;
|
||||
int i;
|
||||
|
||||
dbus_addresses = g_value_get_boxed (dbus_value);
|
||||
addresses = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip6_address_unref);
|
||||
|
||||
if (dbus_addresses) {
|
||||
for (i = 0; i < dbus_addresses->len; i++) {
|
||||
GValueArray *elements = dbus_addresses->pdata[i];
|
||||
GValue *tmp;
|
||||
GByteArray *ba_addr;
|
||||
GByteArray *ba_gw = NULL;
|
||||
NMIP6Address *addr;
|
||||
guint32 prefix;
|
||||
|
||||
if (elements->n_values < 2 || elements->n_values > 3) {
|
||||
g_warning ("%s: ignoring invalid IP6 address structure", __func__);
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Third element (gateway) is optional */
|
||||
if ( !_nm_utils_gvalue_array_validate (elements, 2, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT)
|
||||
&& !_nm_utils_gvalue_array_validate (elements, 3, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, DBUS_TYPE_G_UCHAR_ARRAY)) {
|
||||
g_warning ("%s: ignoring invalid IP6 address structure", __func__);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = g_value_array_get_nth (elements, 0);
|
||||
ba_addr = g_value_get_boxed (tmp);
|
||||
if (ba_addr->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 address of length %d",
|
||||
__func__, ba_addr->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
tmp = g_value_array_get_nth (elements, 1);
|
||||
prefix = g_value_get_uint (tmp);
|
||||
if (prefix > 128) {
|
||||
g_warning ("%s: ignoring invalid IP6 prefix %d",
|
||||
__func__, prefix);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (elements->n_values == 3) {
|
||||
tmp = g_value_array_get_nth (elements, 2);
|
||||
ba_gw = g_value_get_boxed (tmp);
|
||||
if (ba_gw->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 gateway address of length %d",
|
||||
__func__, ba_gw->len);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
addr = nm_ip6_address_new ();
|
||||
nm_ip6_address_set_prefix (addr, prefix);
|
||||
nm_ip6_address_set_address (addr, (const struct in6_addr *) ba_addr->data);
|
||||
if (ba_gw)
|
||||
nm_ip6_address_set_gateway (addr, (const struct in6_addr *) ba_gw->data);
|
||||
|
||||
g_ptr_array_add (addresses, addr);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (prop_value, addresses);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_routes_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
GPtrArray *routes, *dbus_routes;
|
||||
int i;
|
||||
|
||||
routes = g_value_get_boxed (prop_value);
|
||||
dbus_routes = g_ptr_array_new ();
|
||||
|
||||
if (routes) {
|
||||
for (i = 0; i < routes->len; i++) {
|
||||
NMIP6Route *route = routes->pdata[i];
|
||||
GValueArray *array;
|
||||
const struct in6_addr *addr;
|
||||
GByteArray *ba;
|
||||
GValue element = G_VALUE_INIT;
|
||||
|
||||
array = g_value_array_new (4);
|
||||
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
addr = nm_ip6_route_get_dest (route);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guchar *)addr, sizeof (*addr));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, nm_ip6_route_get_prefix (route));
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
addr = nm_ip6_route_get_next_hop (route);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guchar *)addr, sizeof (*addr));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, nm_ip6_route_get_metric (route));
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (dbus_routes, array);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (dbus_value, dbus_routes);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_ip6_routes_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GPtrArray *routes, *dbus_routes;
|
||||
int i;
|
||||
|
||||
dbus_routes = g_value_get_boxed (dbus_value);
|
||||
routes = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_ip6_route_unref);
|
||||
|
||||
if (dbus_routes) {
|
||||
for (i = 0; i < dbus_routes->len; i++) {
|
||||
GValueArray *route_values = dbus_routes->pdata[i];
|
||||
GByteArray *dest, *next_hop;
|
||||
guint prefix, metric;
|
||||
NMIP6Route *route;
|
||||
|
||||
if (!_nm_utils_gvalue_array_validate (route_values, 4,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT)) {
|
||||
g_warning ("Ignoring invalid IP6 route");
|
||||
continue;
|
||||
}
|
||||
|
||||
dest = g_value_get_boxed (g_value_array_get_nth (route_values, 0));
|
||||
if (dest->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 dest address of length %d",
|
||||
__func__, dest->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
prefix = g_value_get_uint (g_value_array_get_nth (route_values, 1));
|
||||
|
||||
next_hop = g_value_get_boxed (g_value_array_get_nth (route_values, 2));
|
||||
if (next_hop->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 next_hop address of length %d",
|
||||
__func__, next_hop->len);
|
||||
continue;
|
||||
}
|
||||
|
||||
metric = g_value_get_uint (g_value_array_get_nth (route_values, 3));
|
||||
|
||||
route = nm_ip6_route_new ();
|
||||
nm_ip6_route_set_dest (route, (struct in6_addr *)dest->data);
|
||||
nm_ip6_route_set_prefix (route, prefix);
|
||||
nm_ip6_route_set_next_hop (route, (struct in6_addr *)next_hop->data);
|
||||
nm_ip6_route_set_metric (route, metric);
|
||||
|
||||
g_ptr_array_add (routes, route);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_take_boxed (prop_value, routes);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_ip6_addresses_from_gvalue:
|
||||
* @value: gvalue containing a GPtrArray of GValueArrays of (GArray of guchars) and #guint32
|
||||
|
|
@ -1402,7 +1992,7 @@ nm_utils_ip6_routes_to_gvalue (GSList *list, GValue *value)
|
|||
* @value: a #GValue
|
||||
*
|
||||
* Converts a #GValue containing a #GPtrArray of IP6 DNS, represented as
|
||||
* #GByteArrays into a #GSList of <literal><type>struct in6_addr</type></literal>s.
|
||||
* #GByteArrays into a #GSList of IP address strings.
|
||||
*
|
||||
* Returns: a #GSList of IP6 addresses.
|
||||
*/
|
||||
|
|
@ -1416,7 +2006,7 @@ nm_utils_ip6_dns_from_gvalue (const GValue *value)
|
|||
dns = (GPtrArray *) g_value_get_boxed (value);
|
||||
for (i = 0; dns && (i < dns->len); i++) {
|
||||
GByteArray *bytearray = (GByteArray *) g_ptr_array_index (dns, i);
|
||||
struct in6_addr *addr;
|
||||
const char *str;
|
||||
|
||||
if (bytearray->len != 16) {
|
||||
g_warning ("%s: ignoring invalid IP6 address of length %d",
|
||||
|
|
@ -1424,9 +2014,8 @@ nm_utils_ip6_dns_from_gvalue (const GValue *value)
|
|||
continue;
|
||||
}
|
||||
|
||||
addr = g_malloc0 (sizeof (struct in6_addr));
|
||||
memcpy (addr->s6_addr, bytearray->data, bytearray->len);
|
||||
list = g_slist_prepend (list, addr);
|
||||
str = nm_utils_inet6_ntop ((struct in6_addr *) bytearray->data, NULL);
|
||||
list = g_slist_prepend (list, g_strdup (str));
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
|
|
@ -1454,11 +2043,12 @@ nm_utils_ip6_dns_to_gvalue (GSList *list, GValue *value)
|
|||
dns = g_ptr_array_new ();
|
||||
|
||||
for (iter = list; iter; iter = iter->next) {
|
||||
struct in6_addr *addr = (struct in6_addr *) iter->data;
|
||||
const char *str = iter->data;
|
||||
GByteArray *bytearray;
|
||||
|
||||
bytearray = g_byte_array_sized_new (16);
|
||||
g_byte_array_append (bytearray, (guint8 *) addr->s6_addr, 16);
|
||||
bytearray = g_byte_array_new ();
|
||||
g_byte_array_set_size (bytearray, 16);
|
||||
inet_pton (AF_INET6, str, bytearray->data);
|
||||
g_ptr_array_add (dns, bytearray);
|
||||
}
|
||||
|
||||
|
|
@ -1564,6 +2154,7 @@ make_key (const char *cipher,
|
|||
* nm_utils_rsa_key_encrypt_helper:
|
||||
* @cipher: cipher to use for encryption ("DES-EDE3-CBC" or "AES-128-CBC")
|
||||
* @data: RSA private key data to be encrypted
|
||||
* @len: length of @data
|
||||
* @in_password: (allow-none): existing password to use, if any
|
||||
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
|
||||
* and returned in this argument
|
||||
|
|
@ -1578,7 +2169,8 @@ make_key (const char *cipher,
|
|||
**/
|
||||
static GByteArray *
|
||||
nm_utils_rsa_key_encrypt_helper (const char *cipher,
|
||||
const GByteArray *data,
|
||||
const guint8 *data,
|
||||
gsize len,
|
||||
const char *in_password,
|
||||
char **out_password,
|
||||
GError **error)
|
||||
|
|
@ -1595,7 +2187,7 @@ nm_utils_rsa_key_encrypt_helper (const char *cipher,
|
|||
|
||||
g_return_val_if_fail (!g_strcmp0 (cipher, CIPHER_DES_EDE3_CBC) || !g_strcmp0 (cipher, CIPHER_AES_CBC), NULL);
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
g_return_val_if_fail (data->len > 0, NULL);
|
||||
g_return_val_if_fail (len > 0, NULL);
|
||||
if (out_password)
|
||||
g_return_val_if_fail (*out_password == NULL, NULL);
|
||||
|
||||
|
|
@ -1618,7 +2210,7 @@ nm_utils_rsa_key_encrypt_helper (const char *cipher,
|
|||
if (!key)
|
||||
goto out;
|
||||
|
||||
enc = crypto_encrypt (cipher, data, salt, salt_len, key, key_len, &enc_len, error);
|
||||
enc = crypto_encrypt (cipher, data, len, salt, salt_len, key, key_len, &enc_len, error);
|
||||
if (!enc)
|
||||
goto out;
|
||||
|
||||
|
|
@ -1672,6 +2264,7 @@ out:
|
|||
/**
|
||||
* nm_utils_rsa_key_encrypt:
|
||||
* @data: RSA private key data to be encrypted
|
||||
* @len: length of @data
|
||||
* @in_password: (allow-none): existing password to use, if any
|
||||
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
|
||||
* and returned in this argument
|
||||
|
|
@ -1685,7 +2278,8 @@ out:
|
|||
* certificate/private key file.
|
||||
**/
|
||||
GByteArray *
|
||||
nm_utils_rsa_key_encrypt (const GByteArray *data,
|
||||
nm_utils_rsa_key_encrypt (const guint8 *data,
|
||||
gsize len,
|
||||
const char *in_password,
|
||||
char **out_password,
|
||||
GError **error)
|
||||
|
|
@ -1693,7 +2287,7 @@ nm_utils_rsa_key_encrypt (const GByteArray *data,
|
|||
|
||||
|
||||
return nm_utils_rsa_key_encrypt_helper (CIPHER_DES_EDE3_CBC,
|
||||
data,
|
||||
data, len,
|
||||
in_password,
|
||||
out_password,
|
||||
error);
|
||||
|
|
@ -1702,6 +2296,7 @@ nm_utils_rsa_key_encrypt (const GByteArray *data,
|
|||
/**
|
||||
* nm_utils_rsa_key_encrypt_aes:
|
||||
* @data: RSA private key data to be encrypted
|
||||
* @len: length of @data
|
||||
* @in_password: (allow-none): existing password to use, if any
|
||||
* @out_password: (out) (allow-none): if @in_password was %NULL, a random password will be generated
|
||||
* and returned in this argument
|
||||
|
|
@ -1715,14 +2310,15 @@ nm_utils_rsa_key_encrypt (const GByteArray *data,
|
|||
* certificate/private key file.
|
||||
**/
|
||||
GByteArray *
|
||||
nm_utils_rsa_key_encrypt_aes (const GByteArray *data,
|
||||
nm_utils_rsa_key_encrypt_aes (const guint8 *data,
|
||||
gsize len,
|
||||
const char *in_password,
|
||||
char **out_password,
|
||||
GError **error)
|
||||
{
|
||||
|
||||
return nm_utils_rsa_key_encrypt_helper (CIPHER_AES_CBC,
|
||||
data,
|
||||
data, len,
|
||||
in_password,
|
||||
out_password,
|
||||
error);
|
||||
|
|
@ -2230,6 +2826,28 @@ nm_utils_hwaddr_matches (gconstpointer hwaddr1,
|
|||
return !memcmp (hwaddr1, hwaddr2, hwaddr1_len);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_hwaddr_to_dbus (const GValue *prop_value,
|
||||
GValue *dbus_value)
|
||||
{
|
||||
const char *str = g_value_get_string (prop_value);
|
||||
GByteArray *array;
|
||||
|
||||
array = str ? nm_utils_hwaddr_atoba (str, hwaddr_binary_len (str)) : NULL;
|
||||
g_value_take_boxed (dbus_value, array);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_utils_hwaddr_from_dbus (const GValue *dbus_value,
|
||||
GValue *prop_value)
|
||||
{
|
||||
GByteArray *array = g_value_get_boxed (dbus_value);
|
||||
char *str;
|
||||
|
||||
str = array ? nm_utils_hwaddr_ntoa (array->data, array->len) : NULL;
|
||||
g_value_take_string (prop_value, str);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_utils_bin2hexstr:
|
||||
* @bytes: an array of bytes
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ gboolean nm_utils_init (GError **error);
|
|||
void nm_utils_deinit (void);
|
||||
|
||||
/* SSID helpers */
|
||||
gboolean nm_utils_is_empty_ssid (const guint8 *ssid, int len);
|
||||
const char *nm_utils_escape_ssid (const guint8 *ssid, guint32 len);
|
||||
gboolean nm_utils_same_ssid (const GByteArray *ssid1,
|
||||
const GByteArray *ssid2,
|
||||
gboolean nm_utils_is_empty_ssid (const guint8 *ssid, gsize len);
|
||||
const char *nm_utils_escape_ssid (const guint8 *ssid, gsize len);
|
||||
gboolean nm_utils_same_ssid (const guint8 *ssid1, gsize len1,
|
||||
const guint8 *ssid2, gsize len2,
|
||||
gboolean ignore_trailing_null);
|
||||
char * nm_utils_ssid_to_utf8 (const GByteArray *ssid);
|
||||
char * nm_utils_ssid_to_utf8 (const guint8 *ssid, gsize len);
|
||||
|
||||
GHashTable *nm_utils_gvalue_hash_dup (GHashTable *hash);
|
||||
|
||||
|
|
@ -117,11 +117,13 @@ void nm_utils_ip6_dns_to_gvalue (GSList *list, GValue *value);
|
|||
char *nm_utils_uuid_generate (void);
|
||||
char *nm_utils_uuid_generate_from_string (const char *s);
|
||||
|
||||
GByteArray *nm_utils_rsa_key_encrypt (const GByteArray *data,
|
||||
GByteArray *nm_utils_rsa_key_encrypt (const guint8 *data,
|
||||
gsize len,
|
||||
const char *in_password,
|
||||
char **out_password,
|
||||
GError **error);
|
||||
GByteArray *nm_utils_rsa_key_encrypt_aes (const GByteArray *data,
|
||||
GByteArray *nm_utils_rsa_key_encrypt_aes (const guint8 *data,
|
||||
gsize len,
|
||||
const char *in_password,
|
||||
char **out_password,
|
||||
GError **error);
|
||||
|
|
|
|||
|
|
@ -36,80 +36,6 @@ _nm_utils_convert_op_to_string (const GValue *src_value, GValue *dest_value)
|
|||
g_value_set_string (dest_value, (const char *) g_value_get_boxed (src_value));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_strv_to_slist (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
char **str;
|
||||
GSList *list = NULL;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_TYPE_STRV));
|
||||
|
||||
str = (char **) g_value_get_boxed (src_value);
|
||||
|
||||
while (str && str[i])
|
||||
list = g_slist_prepend (list, g_strdup (str[i++]));
|
||||
|
||||
g_value_take_boxed (dest_value, g_slist_reverse (list));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_slist_to_strv (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GSList *slist;
|
||||
char **strv;
|
||||
int len, i = 0;
|
||||
|
||||
slist = g_value_get_boxed (src_value);
|
||||
len = g_slist_length (slist);
|
||||
|
||||
strv = g_new (char *, len + 1);
|
||||
for (i = 0; slist; slist = slist->next, i++)
|
||||
strv[i] = g_strdup (slist->data);
|
||||
strv[i] = NULL;
|
||||
|
||||
g_value_take_boxed (dest_value, strv);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_strv_to_ptrarray (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
char **str;
|
||||
GPtrArray *array = NULL;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), G_TYPE_STRV));
|
||||
|
||||
str = (char **) g_value_get_boxed (src_value);
|
||||
|
||||
array = g_ptr_array_sized_new (3);
|
||||
while (str && str[i])
|
||||
g_ptr_array_add (array, g_strdup (str[i++]));
|
||||
|
||||
g_value_take_boxed (dest_value, array);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_string_list_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GSList *strings;
|
||||
GString *printable;
|
||||
GSList *iter;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_LIST_OF_STRING));
|
||||
|
||||
strings = (GSList *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
for (iter = strings; iter; iter = iter->next) {
|
||||
if (iter != strings)
|
||||
g_string_append_c (printable, ',');
|
||||
g_string_append (printable, iter->data ? iter->data : "(null)");
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_string_array_to_string (const GPtrArray *strings, GValue *dest_value)
|
||||
{
|
||||
|
|
@ -126,17 +52,6 @@ _string_array_to_string (const GPtrArray *strings, GValue *dest_value)
|
|||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_string_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
const GPtrArray *strings;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_STRING));
|
||||
|
||||
strings = (const GPtrArray *) g_value_get_boxed (src_value);
|
||||
_string_array_to_string (strings, dest_value);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_op_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
|
|
@ -148,87 +63,6 @@ _nm_utils_convert_op_array_to_string (const GValue *src_value, GValue *dest_valu
|
|||
_string_array_to_string (strings, dest_value);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_uint_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GArray *array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_UINT_ARRAY));
|
||||
|
||||
array = (GArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
while (array && (i < array->len)) {
|
||||
guint32 addr;
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
addr = g_array_index (array, guint32, i++);
|
||||
g_string_append (printable, nm_utils_inet4_ntop (addr, NULL));
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_ip4_addr_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GPtrArray *ptr_array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
char buf[INET_ADDRSTRLEN];
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT));
|
||||
|
||||
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
while (ptr_array && (i < ptr_array->len)) {
|
||||
GArray *array;
|
||||
gboolean is_addr; /* array contains address x route */
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
array = (GArray *) g_ptr_array_index (ptr_array, i++);
|
||||
if (array->len < 2) {
|
||||
g_string_append (printable, "invalid");
|
||||
continue;
|
||||
}
|
||||
is_addr = (array->len < 4);
|
||||
|
||||
nm_utils_inet4_ntop (g_array_index (array, guint32, 0), buf);
|
||||
if (is_addr)
|
||||
g_string_append_printf (printable, "ip = %s", buf);
|
||||
else
|
||||
g_string_append_printf (printable, "dst = %s", buf);
|
||||
|
||||
g_string_append_printf (printable, "/%u",
|
||||
g_array_index (array, guint32, 1));
|
||||
|
||||
if (array->len > 2) {
|
||||
nm_utils_inet4_ntop (g_array_index (array, guint32, 2), buf);
|
||||
if (is_addr)
|
||||
g_string_append_printf (printable, ", gw = %s", buf);
|
||||
else
|
||||
g_string_append_printf (printable, ", nh = %s", buf);
|
||||
}
|
||||
|
||||
if (array->len > 3) {
|
||||
g_string_append_printf (printable, ", mt = %u",
|
||||
g_array_index (array, guint32, 3));
|
||||
}
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
convert_one_gvalue_hash_entry (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
|
|
@ -258,282 +92,6 @@ _nm_utils_convert_gvalue_hash_to_string (const GValue *src_value, GValue *dest_v
|
|||
g_string_free (printable, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
convert_one_string_hash_entry (gpointer key, gpointer value, gpointer user_data)
|
||||
{
|
||||
GString *printable = (GString *) user_data;
|
||||
|
||||
if (printable->len)
|
||||
g_string_append_c (printable, ',');
|
||||
g_string_append_printf (printable, "%s=%s", (const char *) key, (const char *) value);
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_string_hash_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GHashTable *hash;
|
||||
GString *printable;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_MAP_OF_STRING));
|
||||
|
||||
hash = (GHashTable *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
if (hash)
|
||||
g_hash_table_foreach (hash, convert_one_string_hash_entry, printable);
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_byte_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GArray *array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_UCHAR_ARRAY));
|
||||
|
||||
array = (GArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new ("[");
|
||||
if (array) {
|
||||
while (i < MIN (array->len, 35)) {
|
||||
if (i > 0)
|
||||
g_string_append_c (printable, ' ');
|
||||
g_string_append_printf (printable, "0x%02X",
|
||||
g_array_index (array, unsigned char, i++));
|
||||
}
|
||||
if (i < array->len)
|
||||
g_string_append (printable, " ... ");
|
||||
}
|
||||
g_string_append_c (printable, ']');
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_ip6_dns_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GPtrArray *ptr_array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR));
|
||||
|
||||
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
while (ptr_array && (i < ptr_array->len)) {
|
||||
GByteArray *bytearray;
|
||||
struct in6_addr *addr;
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
bytearray = (GByteArray *) g_ptr_array_index (ptr_array, i++);
|
||||
if (bytearray->len != 16) {
|
||||
g_string_append (printable, "invalid");
|
||||
continue;
|
||||
}
|
||||
addr = (struct in6_addr *) bytearray->data;
|
||||
g_string_append (printable, nm_utils_inet6_ntop (addr, NULL));
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_ip6_addr_struct_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GPtrArray *ptr_array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
|
||||
|
||||
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
while (ptr_array && (i < ptr_array->len)) {
|
||||
GValueArray *elements;
|
||||
GValue *tmp;
|
||||
GByteArray *ba_addr;
|
||||
struct in6_addr *addr;
|
||||
guint32 prefix;
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
|
||||
if (!_nm_utils_gvalue_array_validate (elements, 3,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY)) {
|
||||
g_string_append (printable, "invalid }");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* IPv6 address */
|
||||
tmp = g_value_array_get_nth (elements, 0);
|
||||
ba_addr = g_value_get_boxed (tmp);
|
||||
if (ba_addr->len != 16) {
|
||||
g_string_append (printable, "invalid }");
|
||||
continue;
|
||||
}
|
||||
addr = (struct in6_addr *) ba_addr->data;
|
||||
g_string_append_printf (printable, "ip = %s", nm_utils_inet6_ntop (addr, NULL));
|
||||
|
||||
/* Prefix */
|
||||
tmp = g_value_array_get_nth (elements, 1);
|
||||
prefix = g_value_get_uint (tmp);
|
||||
if (prefix > 128) {
|
||||
g_string_append (printable, "/invalid }");
|
||||
continue;
|
||||
}
|
||||
g_string_append_printf (printable, "/%u", prefix);
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
/* IPv6 Gateway */
|
||||
tmp = g_value_array_get_nth (elements, 2);
|
||||
ba_addr = g_value_get_boxed (tmp);
|
||||
if (ba_addr->len != 16) {
|
||||
g_string_append (printable, "invalid }");
|
||||
continue;
|
||||
}
|
||||
addr = (struct in6_addr *) ba_addr->data;
|
||||
g_string_append_printf (printable, "gw = %s", nm_utils_inet6_ntop (addr, NULL));
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
static void
|
||||
_nm_utils_convert_ip6_route_struct_array_to_string (const GValue *src_value, GValue *dest_value)
|
||||
{
|
||||
GPtrArray *ptr_array;
|
||||
GString *printable;
|
||||
guint i = 0;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE));
|
||||
|
||||
ptr_array = (GPtrArray *) g_value_get_boxed (src_value);
|
||||
|
||||
printable = g_string_new (NULL);
|
||||
while (ptr_array && (i < ptr_array->len)) {
|
||||
GValueArray *elements;
|
||||
GValue *tmp;
|
||||
GByteArray *ba_addr;
|
||||
struct in6_addr *addr;
|
||||
guint32 prefix, metric;
|
||||
|
||||
if (i > 0)
|
||||
g_string_append (printable, "; ");
|
||||
|
||||
g_string_append (printable, "{ ");
|
||||
elements = (GValueArray *) g_ptr_array_index (ptr_array, i++);
|
||||
if (!_nm_utils_gvalue_array_validate (elements, 4,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT,
|
||||
DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_UINT)) {
|
||||
g_string_append (printable, "invalid");
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Destination address */
|
||||
tmp = g_value_array_get_nth (elements, 0);
|
||||
ba_addr = g_value_get_boxed (tmp);
|
||||
if (ba_addr->len != 16) {
|
||||
g_string_append (printable, "invalid");
|
||||
continue;
|
||||
}
|
||||
addr = (struct in6_addr *) ba_addr->data;
|
||||
g_string_append_printf (printable, "dst = %s", nm_utils_inet6_ntop (addr, NULL));
|
||||
|
||||
/* Prefix */
|
||||
tmp = g_value_array_get_nth (elements, 1);
|
||||
prefix = g_value_get_uint (tmp);
|
||||
if (prefix > 128) {
|
||||
g_string_append (printable, "/invalid");
|
||||
continue;
|
||||
}
|
||||
g_string_append_printf (printable, "/%u", prefix);
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
/* Next hop addresses */
|
||||
tmp = g_value_array_get_nth (elements, 2);
|
||||
ba_addr = g_value_get_boxed (tmp);
|
||||
if (ba_addr->len != 16) {
|
||||
g_string_append (printable, "invalid");
|
||||
continue;
|
||||
}
|
||||
addr = (struct in6_addr *) ba_addr->data;
|
||||
g_string_append_printf (printable, "nh = %s", nm_utils_inet6_ntop (addr, NULL));
|
||||
g_string_append (printable, ", ");
|
||||
|
||||
/* Metric */
|
||||
tmp = g_value_array_get_nth (elements, 3);
|
||||
metric = g_value_get_uint (tmp);
|
||||
g_string_append_printf (printable, "mt = %u", metric);
|
||||
|
||||
g_string_append (printable, " }");
|
||||
}
|
||||
|
||||
g_value_take_string (dest_value, g_string_free (printable, FALSE));
|
||||
}
|
||||
|
||||
#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
|
||||
#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
|
||||
|
||||
static void
|
||||
_nm_utils_convert_old_ip6_addr_array (const GValue *src_value, GValue *dst_value)
|
||||
{
|
||||
GPtrArray *src_outer_array;
|
||||
GPtrArray *dst_outer_array;
|
||||
guint i;
|
||||
|
||||
g_return_if_fail (g_type_is_a (G_VALUE_TYPE (src_value), OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS));
|
||||
|
||||
src_outer_array = (GPtrArray *) g_value_get_boxed (src_value);
|
||||
dst_outer_array = g_ptr_array_new ();
|
||||
|
||||
for (i = 0; src_outer_array && (i < src_outer_array->len); i++) {
|
||||
GValueArray *src_addr_array;
|
||||
GValueArray *dst_addr_array;
|
||||
GValue element = G_VALUE_INIT;
|
||||
GValue *src_addr, *src_prefix;
|
||||
GByteArray *ba;
|
||||
|
||||
src_addr_array = (GValueArray *) g_ptr_array_index (src_outer_array, i);
|
||||
if (!_nm_utils_gvalue_array_validate (src_addr_array, 2, DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT)) {
|
||||
g_warning ("%s: invalid old IPv6 address type", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
dst_addr_array = g_value_array_new (3);
|
||||
|
||||
src_addr = g_value_array_get_nth (src_addr_array, 0);
|
||||
g_value_array_append (dst_addr_array, src_addr);
|
||||
src_prefix = g_value_array_get_nth (src_addr_array, 1);
|
||||
g_value_array_append (dst_addr_array, src_prefix);
|
||||
|
||||
/* Blank Gateway */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, (guint8 *) "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 16);
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (dst_addr_array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (dst_outer_array, dst_addr_array);
|
||||
}
|
||||
|
||||
g_value_take_boxed (dst_value, dst_outer_array);
|
||||
}
|
||||
|
||||
void
|
||||
_nm_value_transforms_register (void)
|
||||
{
|
||||
|
|
@ -543,51 +101,12 @@ _nm_value_transforms_register (void)
|
|||
g_value_register_transform_func (DBUS_TYPE_G_OBJECT_PATH,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_op_to_string);
|
||||
g_value_register_transform_func (G_TYPE_STRV,
|
||||
DBUS_TYPE_G_LIST_OF_STRING,
|
||||
_nm_utils_convert_strv_to_slist);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_TYPE_STRV,
|
||||
_nm_utils_convert_slist_to_strv);
|
||||
g_value_register_transform_func (G_TYPE_STRV,
|
||||
DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
_nm_utils_convert_strv_to_ptrarray);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_LIST_OF_STRING,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_string_list_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_STRING,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_string_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_OBJECT_PATH,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_op_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_UINT_ARRAY,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_uint_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_ip4_addr_route_struct_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_VARIANT,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_gvalue_hash_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_MAP_OF_STRING,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_string_hash_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_UCHAR_ARRAY,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_byte_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UCHAR,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_ip6_dns_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_ip6_addr_struct_array_to_string);
|
||||
g_value_register_transform_func (DBUS_TYPE_G_ARRAY_OF_IP6_ROUTE,
|
||||
G_TYPE_STRING,
|
||||
_nm_utils_convert_ip6_route_struct_array_to_string);
|
||||
g_value_register_transform_func (OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS,
|
||||
_nm_utils_convert_old_ip6_addr_array);
|
||||
registered = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ AM_CPPFLAGS = \
|
|||
-DTEST_CERT_DIR=\"$(certsdir)\"
|
||||
|
||||
noinst_PROGRAMS = \
|
||||
test-compare \
|
||||
test-crypto \
|
||||
test-general \
|
||||
test-secrets \
|
||||
|
|
|
|||
396
libnm-core/tests/test-compare.c
Normal file
396
libnm-core/tests/test-compare.c
Normal file
|
|
@ -0,0 +1,396 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
||||
/*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Copyright 2007 - 2014 Red Hat, Inc.
|
||||
* Copyright 2007 - 2008 Novell, Inc.
|
||||
*/
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <dbus/dbus-glib.h>
|
||||
|
||||
#include "nm-dbus-glib-types.h"
|
||||
#include "nm-glib-compat.h"
|
||||
|
||||
#include "nm-property-compare.h"
|
||||
|
||||
#include "nm-test-utils.h"
|
||||
|
||||
static void
|
||||
compare_ints (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, G_TYPE_INT);
|
||||
g_value_init (&value2, G_TYPE_INT);
|
||||
|
||||
g_value_set_int (&value1, 5);
|
||||
g_value_set_int (&value2, 5);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_value_set_int (&value2, 10);
|
||||
g_assert (nm_property_compare (&value1, &value2) < 0);
|
||||
|
||||
g_value_set_int (&value2, 1);
|
||||
g_assert (nm_property_compare (&value1, &value2) > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strings (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
const char *str1 = "hello";
|
||||
const char *str2 = "world";
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRING);
|
||||
g_value_init (&value2, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (&value1, str1);
|
||||
g_value_set_string (&value2, str1);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_value_set_string (&value2, str2);
|
||||
g_assert (nm_property_compare (&value1, &value2) < 0);
|
||||
|
||||
g_assert (nm_property_compare (&value2, &value1) > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_strv (void)
|
||||
{
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
char *strv1[] = { "foo", "bar", "baz", NULL };
|
||||
char *strv2[] = { "foo", "bar", "bar", NULL };
|
||||
char *strv3[] = { "foo", "bar", NULL };
|
||||
char *strv4[] = { "foo", "bar", "baz", "bam", NULL };
|
||||
|
||||
g_value_init (&value1, G_TYPE_STRV);
|
||||
g_value_init (&value2, G_TYPE_STRV);
|
||||
|
||||
g_value_set_boxed (&value1, strv1);
|
||||
g_value_set_boxed (&value2, strv1);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_value_set_boxed (&value2, strv2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_value_set_boxed (&value2, strv3);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_value_set_boxed (&value2, strv4);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_garrays (void)
|
||||
{
|
||||
GArray *array1;
|
||||
GArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
int i;
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array1 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
g_value_init (&value2, DBUS_TYPE_G_UINT_ARRAY);
|
||||
array2 = g_array_new (FALSE, FALSE, sizeof (guint32));
|
||||
|
||||
for (i = 0; i < 5; i++) {
|
||||
g_array_append_val (array1, i);
|
||||
g_array_append_val (array2, i);
|
||||
}
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_array_remove_index (array2, 0);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
i = 7;
|
||||
g_array_prepend_val (array2, i);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ptrarrays (void)
|
||||
{
|
||||
GPtrArray *array1;
|
||||
GPtrArray *array2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array1 = g_ptr_array_new ();
|
||||
|
||||
g_value_init (&value2, dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING));
|
||||
array2 = g_ptr_array_new ();
|
||||
|
||||
g_ptr_array_add (array1, "hello");
|
||||
g_ptr_array_add (array1, "world");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
|
||||
g_ptr_array_add (array2, "hello");
|
||||
g_ptr_array_add (array2, "world");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_ptr_array_add (array2, "boo");
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_ptr_array_add (array1, "booz");
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_str_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", "hello");
|
||||
g_hash_table_insert (hash1, "key2", "world");
|
||||
g_hash_table_insert (hash1, "key3", "!");
|
||||
|
||||
g_hash_table_insert (hash2, "key3", "!");
|
||||
g_hash_table_insert (hash2, "key2", "world");
|
||||
g_hash_table_insert (hash2, "key1", "hello");
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_hash_table_insert (hash2, "key2", "moon");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
static GValue *
|
||||
str_to_gvalue (const char *str)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, str);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
uint_to_gvalue (guint i)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_UINT);
|
||||
g_value_set_uint (value, i);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static GValue *
|
||||
double_to_gvalue (double d)
|
||||
{
|
||||
GValue *value;
|
||||
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, G_TYPE_DOUBLE);
|
||||
g_value_set_double (value, d);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static void
|
||||
compare_gvalue_hash (void)
|
||||
{
|
||||
GHashTable *hash1;
|
||||
GHashTable *hash2;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
|
||||
g_value_init (&value1, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
g_value_init (&value2, dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_VALUE));
|
||||
|
||||
hash1 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
hash2 = g_hash_table_new (g_str_hash, g_str_equal);
|
||||
|
||||
g_hash_table_insert (hash1, "key1", str_to_gvalue ("hello"));
|
||||
g_hash_table_insert (hash1, "key2", uint_to_gvalue (5));
|
||||
g_hash_table_insert (hash1, "key3", double_to_gvalue (123.456));
|
||||
|
||||
g_hash_table_insert (hash2, "key3", double_to_gvalue (123.456));
|
||||
g_hash_table_insert (hash2, "key2", uint_to_gvalue (5));
|
||||
g_hash_table_insert (hash2, "key1", str_to_gvalue ("hello"));
|
||||
|
||||
g_value_set_boxed (&value1, hash1);
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_hash_table_remove (hash2, "key2");
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_hash_table_insert (hash2, "key2", str_to_gvalue ("moon"));
|
||||
g_value_set_boxed (&value2, hash2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
static void
|
||||
compare_ip6_addresses (void)
|
||||
{
|
||||
GValueArray *array1;
|
||||
GValueArray *array2;
|
||||
GValueArray *array3;
|
||||
GByteArray *ba1;
|
||||
GByteArray *ba2;
|
||||
GByteArray *ba3;
|
||||
GValue element = G_VALUE_INIT;
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
GValue value2 = G_VALUE_INIT;
|
||||
struct in6_addr addr1;
|
||||
struct in6_addr addr2;
|
||||
struct in6_addr addr3;
|
||||
guint32 prefix1 = 64;
|
||||
guint32 prefix2 = 64;
|
||||
guint32 prefix3 = 0;
|
||||
|
||||
inet_pton (AF_INET6, "1:2:3:4:5:6:7:8", &addr1);
|
||||
inet_pton (AF_INET6, "ffff:2:3:4:5:6:7:8", &addr2);
|
||||
inet_pton (AF_INET6, "::", &addr3);
|
||||
|
||||
/* address 1 */
|
||||
array1 = g_value_array_new (2);
|
||||
|
||||
ba1 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba1, (guint8 *) addr1.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
ba1 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba1, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba1);
|
||||
g_value_array_append (array1, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 2 */
|
||||
array2 = g_value_array_new (2);
|
||||
|
||||
ba2 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba2, (guint8 *) addr2.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
ba2 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba2, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba2);
|
||||
g_value_array_append (array2, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* address 3 */
|
||||
array3 = g_value_array_new (2);
|
||||
|
||||
ba3 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba3, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
ba3 = g_byte_array_new ();
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_byte_array_append (ba3, (guint8 *) addr3.s6_addr, 16);
|
||||
g_value_take_boxed (&element, ba3);
|
||||
g_value_array_append (array3, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_value_init (&value1, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
g_value_init (&value2, DBUS_TYPE_G_IP6_ADDRESS);
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array1);
|
||||
g_assert (nm_property_compare (&value1, &value2) == 0);
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array2);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
|
||||
g_value_set_boxed (&value1, array1);
|
||||
g_value_set_boxed (&value2, array3);
|
||||
g_assert (nm_property_compare (&value1, &value2) != 0);
|
||||
}
|
||||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
nmtst_init (&argc, &argv, TRUE);
|
||||
|
||||
g_test_add_func ("/libnm/compare/ints", compare_ints);
|
||||
g_test_add_func ("/libnm/compare/strings", compare_strings);
|
||||
g_test_add_func ("/libnm/compare/strv", compare_strv);
|
||||
g_test_add_func ("/libnm/compare/garrays", compare_garrays);
|
||||
g_test_add_func ("/libnm/compare/ptrarrays", compare_ptrarrays);
|
||||
g_test_add_func ("/libnm/compare/str_hash", compare_str_hash);
|
||||
g_test_add_func ("/libnm/compare/gvalue_hash", compare_gvalue_hash);
|
||||
g_test_add_func ("/libnm/compare/ip6_addresses", compare_ip6_addresses);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
|
@ -301,16 +301,17 @@ test_encrypt_private_key (const char *path,
|
|||
|
||||
/* Now re-encrypt the private key */
|
||||
if (is_cipher_aes (path))
|
||||
encrypted = nm_utils_rsa_key_encrypt_aes (array, password, NULL, &error);
|
||||
encrypted = nm_utils_rsa_key_encrypt_aes (array->data, array->len, password, NULL, &error);
|
||||
else
|
||||
encrypted = nm_utils_rsa_key_encrypt (array, password, NULL, &error);
|
||||
encrypted = nm_utils_rsa_key_encrypt (array->data, array->len, password, NULL, &error);
|
||||
ASSERT (encrypted != NULL, desc,
|
||||
"couldn't re-encrypt private key file '%s': %d %s",
|
||||
path, error->code, error->message);
|
||||
|
||||
/* Then re-decrypt the private key */
|
||||
key_type = NM_CRYPTO_KEY_TYPE_UNKNOWN;
|
||||
re_decrypted = crypto_decrypt_private_key_data (encrypted, password, &key_type, &error);
|
||||
re_decrypted = crypto_decrypt_private_key_data (encrypted->data, encrypted->len,
|
||||
password, &key_type, &error);
|
||||
ASSERT (re_decrypted != NULL, desc,
|
||||
"couldn't read private key file '%s': %d %s",
|
||||
path, error->code, error->message);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ test_setting_ip4_config_labels (void)
|
|||
NMIP4Address *addr;
|
||||
const char *label;
|
||||
GPtrArray *addrs;
|
||||
GSList *labels;
|
||||
char **labels;
|
||||
GError *error = NULL;
|
||||
|
||||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
|
|
@ -331,7 +331,7 @@ test_setting_ip4_config_labels (void)
|
|||
g_assert_no_error (error);
|
||||
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 0);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
/* addr 2 */
|
||||
addr = nm_ip4_address_new ();
|
||||
|
|
@ -351,13 +351,13 @@ test_setting_ip4_config_labels (void)
|
|||
nm_ip4_address_set_address (addr, 0x03030303);
|
||||
nm_ip4_address_set_prefix (addr, 24);
|
||||
|
||||
_nm_setting_ip4_config_add_address_with_label (s_ip4, addr, NULL);
|
||||
_nm_setting_ip4_config_add_address_with_label (s_ip4, addr, "");
|
||||
nm_ip4_address_unref (addr);
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 2);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
/* Remove addr 1 and re-verify remaining addresses */
|
||||
nm_setting_ip4_config_remove_address (s_ip4, 0);
|
||||
|
|
@ -372,7 +372,7 @@ test_setting_ip4_config_labels (void)
|
|||
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
|
||||
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 1);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
|
||||
/* Test explicit property assignment */
|
||||
|
|
@ -388,7 +388,7 @@ test_setting_ip4_config_labels (void)
|
|||
g_object_set (G_OBJECT (s_ip4),
|
||||
NM_SETTING_IP4_CONFIG_ADDRESSES, addrs,
|
||||
NULL);
|
||||
g_boxed_free (DBUS_TYPE_G_ARRAY_OF_ARRAY_OF_UINT, addrs);
|
||||
g_ptr_array_unref (addrs);
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 2);
|
||||
|
|
@ -396,18 +396,18 @@ test_setting_ip4_config_labels (void)
|
|||
addr = nm_setting_ip4_config_get_address (s_ip4, 0);
|
||||
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x02020202);
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 0);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
|
||||
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 1);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
/* Setting labels now will leave addresses untouched */
|
||||
g_object_set (G_OBJECT (s_ip4),
|
||||
"address-labels", labels,
|
||||
NULL);
|
||||
g_boxed_free (DBUS_TYPE_G_LIST_OF_STRING, labels);
|
||||
g_strfreev (labels);
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_cmpint (nm_setting_ip4_config_get_num_addresses (s_ip4), ==, 2);
|
||||
|
|
@ -420,134 +420,43 @@ test_setting_ip4_config_labels (void)
|
|||
addr = nm_setting_ip4_config_get_address (s_ip4, 1);
|
||||
g_assert_cmpint (nm_ip4_address_get_address (addr), ==, 0x03030303);
|
||||
label = _nm_setting_ip4_config_get_address_label (s_ip4, 1);
|
||||
g_assert_cmpstr (label, ==, NULL);
|
||||
g_assert_cmpstr (label, ==, "");
|
||||
|
||||
/* Setting labels to a value that's too short or too long will result in
|
||||
* the setting not verifying.
|
||||
*/
|
||||
labels = g_slist_append (NULL, "eth0:2");
|
||||
labels = g_strsplit ("eth0:2", ",", -1);
|
||||
g_object_set (G_OBJECT (s_ip4),
|
||||
"address-labels", labels,
|
||||
NULL);
|
||||
g_strfreev (labels);
|
||||
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY);
|
||||
g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:"));
|
||||
g_clear_error (&error);
|
||||
|
||||
labels = g_slist_append (labels, "eth0:3");
|
||||
labels = g_strsplit ("eth0:2,eth0:3", ",", -1);
|
||||
g_object_set (G_OBJECT (s_ip4),
|
||||
"address-labels", labels,
|
||||
NULL);
|
||||
g_strfreev (labels);
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
labels = g_slist_append (labels, "eth0:4");
|
||||
labels = g_strsplit ("eth0:2,eth0:3,eth0:4", ",", -1);
|
||||
g_object_set (G_OBJECT (s_ip4),
|
||||
"address-labels", labels,
|
||||
NULL);
|
||||
g_strfreev (labels);
|
||||
nm_setting_verify (NM_SETTING (s_ip4), NULL, &error);
|
||||
g_assert_error (error, NM_SETTING_IP4_CONFIG_ERROR, NM_SETTING_IP4_CONFIG_ERROR_INVALID_PROPERTY);
|
||||
g_assert (g_str_has_prefix (error->message, "ipv4.address-labels:"));
|
||||
g_clear_error (&error);
|
||||
|
||||
|
||||
g_object_unref (s_ip4);
|
||||
}
|
||||
|
||||
#define OLD_DBUS_TYPE_G_IP6_ADDRESS (dbus_g_type_get_struct ("GValueArray", DBUS_TYPE_G_UCHAR_ARRAY, G_TYPE_UINT, G_TYPE_INVALID))
|
||||
#define OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS (dbus_g_type_get_collection ("GPtrArray", OLD_DBUS_TYPE_G_IP6_ADDRESS))
|
||||
|
||||
/* Test that setting the IPv6 setting's 'addresses' property using the old
|
||||
* IPv6 address format still works, i.e. that the GValue transformation function
|
||||
* from old->new is working correctly.
|
||||
*/
|
||||
static void
|
||||
test_setting_ip6_config_old_address_array (void)
|
||||
{
|
||||
NMSettingIP6Config *s_ip6;
|
||||
GPtrArray *addresses, *read_addresses;
|
||||
GValueArray *array, *read_array;
|
||||
GValue element = G_VALUE_INIT, written_value = G_VALUE_INIT, read_value = G_VALUE_INIT;
|
||||
GByteArray *ba;
|
||||
const guint8 addr[16] = { 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11,
|
||||
0x11, 0x22, 0x33, 0x44, 0x66, 0x77, 0x88, 0x99 };
|
||||
const guint8 gw[16] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
guint32 prefix = 56;
|
||||
GValue *read_addr, *read_prefix, *read_gw;
|
||||
|
||||
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
|
||||
ASSERT (s_ip6 != NULL,
|
||||
"ip6-old-addr", "error creating IP6 setting");
|
||||
|
||||
g_value_init (&written_value, OLD_DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
|
||||
|
||||
addresses = g_ptr_array_new ();
|
||||
array = g_value_array_new (3);
|
||||
|
||||
/* IP address */
|
||||
g_value_init (&element, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
ba = g_byte_array_new ();
|
||||
g_byte_array_append (ba, &addr[0], sizeof (addr));
|
||||
g_value_take_boxed (&element, ba);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
/* Prefix */
|
||||
g_value_init (&element, G_TYPE_UINT);
|
||||
g_value_set_uint (&element, prefix);
|
||||
g_value_array_append (array, &element);
|
||||
g_value_unset (&element);
|
||||
|
||||
g_ptr_array_add (addresses, array);
|
||||
g_value_set_boxed (&written_value, addresses);
|
||||
|
||||
/* Set the address array on the object */
|
||||
g_object_set_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &written_value);
|
||||
|
||||
/* Get it back so we can compare it */
|
||||
g_value_init (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS);
|
||||
g_object_get_property (G_OBJECT (s_ip6), NM_SETTING_IP6_CONFIG_ADDRESSES, &read_value);
|
||||
|
||||
ASSERT (G_VALUE_HOLDS (&read_value, DBUS_TYPE_G_ARRAY_OF_IP6_ADDRESS),
|
||||
"ip6-old-addr", "wrong addresses property value type '%s'",
|
||||
G_VALUE_TYPE_NAME (&read_value));
|
||||
|
||||
read_addresses = (GPtrArray *) g_value_get_boxed (&read_value);
|
||||
ASSERT (read_addresses != NULL,
|
||||
"ip6-old-addr", "missing addresses on readback");
|
||||
ASSERT (read_addresses->len == 1,
|
||||
"ip6-old-addr", "expected one address on readback");
|
||||
|
||||
read_array = (GValueArray *) g_ptr_array_index (read_addresses, 0);
|
||||
|
||||
read_addr = g_value_array_get_nth (read_array, 0);
|
||||
ba = g_value_get_boxed (read_addr);
|
||||
ASSERT (ba->len == sizeof (addr),
|
||||
"ip6-old-addr", "unexpected address item length %d", ba->len);
|
||||
ASSERT (memcmp (ba->data, &addr[0], sizeof (addr)) == 0,
|
||||
"ip6-old-addr", "unexpected failure comparing addresses");
|
||||
|
||||
read_prefix = g_value_array_get_nth (read_array, 1);
|
||||
ASSERT (g_value_get_uint (read_prefix) == prefix,
|
||||
"ip6-old-addr", "unexpected failure comparing prefix");
|
||||
|
||||
/* Ensure the gateway is all zeros, which is how the 2-item to 3-item
|
||||
* conversion happens.
|
||||
*/
|
||||
read_gw = g_value_array_get_nth (read_array, 2);
|
||||
ba = g_value_get_boxed (read_gw);
|
||||
ASSERT (ba->len == sizeof (gw),
|
||||
"ip6-old-addr", "unexpected gateway item length %d", ba->len);
|
||||
ASSERT (memcmp (ba->data, &gw[0], sizeof (gw)) == 0,
|
||||
"ip6-old-addr", "unexpected failure comparing gateways");
|
||||
|
||||
g_value_unset (&written_value);
|
||||
g_value_unset (&read_value);
|
||||
g_object_unref (s_ip6);
|
||||
}
|
||||
|
||||
static void
|
||||
test_setting_gsm_apn_spaces (void)
|
||||
{
|
||||
|
|
@ -748,6 +657,42 @@ test_setting_to_dbus_only_secrets (void)
|
|||
g_object_unref (s_wsec);
|
||||
}
|
||||
|
||||
static void
|
||||
test_setting_to_dbus_transform (void)
|
||||
{
|
||||
NMSetting *s_wired;
|
||||
GHashTable *hash;
|
||||
GValue *val;
|
||||
const char *test_mac_address = "11:22:33:44:55:66";
|
||||
GByteArray *dbus_mac_address;
|
||||
GByteArray *cmp_mac_address;
|
||||
|
||||
s_wired = nm_setting_wired_new ();
|
||||
g_object_set (s_wired,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS, test_mac_address,
|
||||
NULL);
|
||||
|
||||
g_assert_cmpstr (nm_setting_wired_get_mac_address (NM_SETTING_WIRED (s_wired)), ==, test_mac_address);
|
||||
|
||||
hash = _nm_setting_to_dbus (s_wired, NULL, NM_CONNECTION_SERIALIZE_ALL);
|
||||
g_assert (hash != NULL);
|
||||
|
||||
val = g_hash_table_lookup (hash, NM_SETTING_WIRED_MAC_ADDRESS);
|
||||
g_assert (val != NULL);
|
||||
g_assert (G_VALUE_HOLDS (val, DBUS_TYPE_G_UCHAR_ARRAY));
|
||||
|
||||
dbus_mac_address = g_value_get_boxed (val);
|
||||
|
||||
cmp_mac_address = nm_utils_hwaddr_atoba (test_mac_address, ETH_ALEN);
|
||||
|
||||
g_assert_cmpint (dbus_mac_address->len, ==, cmp_mac_address->len);
|
||||
g_assert (memcmp (dbus_mac_address->data, cmp_mac_address->data, ETH_ALEN) == 0);
|
||||
|
||||
g_byte_array_unref (cmp_mac_address);
|
||||
g_hash_table_unref (hash);
|
||||
g_object_unref (s_wired);
|
||||
}
|
||||
|
||||
static void
|
||||
test_connection_to_dbus_setting_name (void)
|
||||
{
|
||||
|
|
@ -776,7 +721,7 @@ test_connection_to_dbus_deprecated_props (void)
|
|||
{
|
||||
NMConnection *connection;
|
||||
NMSetting *s_wireless;
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
GHashTable *hash, *wireless_hash;
|
||||
GValue *sec_val;
|
||||
|
|
@ -787,12 +732,11 @@ test_connection_to_dbus_deprecated_props (void)
|
|||
NULL);
|
||||
|
||||
s_wireless = nm_setting_wireless_new ();
|
||||
ssid = g_byte_array_new ();
|
||||
g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
|
||||
ssid = g_bytes_new ("1234567", 7);
|
||||
g_object_set (s_wireless,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NULL);
|
||||
g_byte_array_unref (ssid);
|
||||
g_bytes_unref (ssid);
|
||||
nm_connection_add_setting (connection, s_wireless);
|
||||
|
||||
/* Hash should not have an 802-11-wireless.security property */
|
||||
|
|
@ -845,6 +789,32 @@ test_setting_new_from_dbus (void)
|
|||
g_object_unref (s_wsec);
|
||||
}
|
||||
|
||||
static void
|
||||
test_setting_new_from_dbus_transform (void)
|
||||
{
|
||||
NMSetting *s_wired;
|
||||
GHashTable *hash;
|
||||
GValue val = { 0, };
|
||||
const char *test_mac_address = "11:22:33:44:55:66";
|
||||
GByteArray *dbus_mac_address;
|
||||
GError *error = NULL;
|
||||
|
||||
hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_value_unset);
|
||||
|
||||
dbus_mac_address = nm_utils_hwaddr_atoba (test_mac_address, ETH_ALEN);
|
||||
g_value_init (&val, DBUS_TYPE_G_UCHAR_ARRAY);
|
||||
g_value_take_boxed (&val, dbus_mac_address);
|
||||
g_hash_table_insert (hash, NM_SETTING_WIRED_MAC_ADDRESS, &val);
|
||||
|
||||
s_wired = _nm_setting_new_from_dbus (NM_TYPE_SETTING_WIRED, hash, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_assert_cmpstr (nm_setting_wired_get_mac_address (NM_SETTING_WIRED (s_wired)), ==, test_mac_address);
|
||||
|
||||
g_hash_table_unref (hash);
|
||||
g_object_unref (s_wired);
|
||||
}
|
||||
|
||||
static NMConnection *
|
||||
new_test_connection (void)
|
||||
{
|
||||
|
|
@ -991,7 +961,7 @@ test_connection_replace_settings_from_connection ()
|
|||
gboolean success;
|
||||
NMSettingConnection *s_con;
|
||||
NMSetting *setting;
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
char *uuid = NULL;
|
||||
const char *expected_id = "Awesome connection";
|
||||
|
||||
|
|
@ -1017,13 +987,12 @@ test_connection_replace_settings_from_connection ()
|
|||
setting = nm_setting_wireless_new ();
|
||||
g_assert (setting);
|
||||
|
||||
ssid = g_byte_array_new ();
|
||||
g_byte_array_append (ssid, (const guint8 *) "1234567", 7);
|
||||
ssid = g_bytes_new ("1234567", 7);
|
||||
g_object_set (setting,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||
NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
g_bytes_unref (ssid);
|
||||
nm_connection_add_setting (replacement, setting);
|
||||
|
||||
/* Replace settings and test */
|
||||
|
|
@ -1164,7 +1133,7 @@ test_setting_connection_permissions_helpers (void)
|
|||
NMSettingConnection *s_con;
|
||||
gboolean success;
|
||||
char buf[9] = { 0x61, 0x62, 0x63, 0xff, 0xfe, 0xfd, 0x23, 0x01, 0x00 };
|
||||
GSList *list = NULL;
|
||||
char **perms;
|
||||
const char *expected_perm = "user:" TEST_UNAME ":";
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
|
||||
|
|
@ -1233,14 +1202,14 @@ test_setting_connection_permissions_helpers (void)
|
|||
check_permission (s_con, 0, TEST_UNAME, "setting-connection-permissions-helpers");
|
||||
|
||||
/* Check the actual GObject property just to be paranoid */
|
||||
g_object_get (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, &list, NULL);
|
||||
ASSERT (list != NULL,
|
||||
"setting-connection-permissions-helpers", "unexpected failure getting permissions list");
|
||||
ASSERT (g_slist_length (list) == 1,
|
||||
"setting-connection-permissions-helpers", "unexpected failure getting number of permissions in list");
|
||||
ASSERT (strcmp (list->data, expected_perm) == 0,
|
||||
g_object_get (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, &perms, NULL);
|
||||
ASSERT (perms != NULL,
|
||||
"setting-connection-permissions-helpers", "unexpected failure getting permissions");
|
||||
ASSERT (g_strv_length (perms) == 1,
|
||||
"setting-connection-permissions-helpers", "unexpected failure getting number of permissions");
|
||||
ASSERT (strcmp (perms[0], expected_perm) == 0,
|
||||
"setting-connection-permissions-helpers", "unexpected permission property data");
|
||||
g_slist_free_full (list, g_free);
|
||||
g_strfreev (perms);
|
||||
|
||||
/* Now remove that permission and ensure we have 0 permissions */
|
||||
nm_setting_connection_remove_permission (s_con, 0);
|
||||
|
|
@ -1258,7 +1227,7 @@ add_permission_property (NMSettingConnection *s_con,
|
|||
const char *detail)
|
||||
{
|
||||
GString *str;
|
||||
GSList *list = NULL;
|
||||
char *perms[2];
|
||||
|
||||
str = g_string_sized_new (50);
|
||||
if (ptype)
|
||||
|
|
@ -1277,11 +1246,11 @@ add_permission_property (NMSettingConnection *s_con,
|
|||
if (detail)
|
||||
g_string_append (str, detail);
|
||||
|
||||
list = g_slist_append (list, str->str);
|
||||
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, list, NULL);
|
||||
perms[0] = str->str;
|
||||
perms[1] = NULL;
|
||||
g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, perms, NULL);
|
||||
|
||||
g_string_free (str, TRUE);
|
||||
g_slist_free (list);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -1738,8 +1707,8 @@ test_connection_good_base_types (void)
|
|||
NMSetting *setting;
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
GByteArray *array;
|
||||
const guint8 bdaddr[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66 };
|
||||
GBytes *ssid;
|
||||
const char *bdaddr = "11:22:33:44:55:66";
|
||||
|
||||
/* Try a basic wired connection */
|
||||
connection = nm_simple_connection_new ();
|
||||
|
|
@ -1769,13 +1738,12 @@ test_connection_good_base_types (void)
|
|||
add_generic_settings (connection, NM_SETTING_WIRELESS_SETTING_NAME);
|
||||
|
||||
setting = nm_setting_wireless_new ();
|
||||
array = g_byte_array_new ();
|
||||
g_byte_array_append (array, (const guint8 *) "1234567", 7);
|
||||
ssid = g_bytes_new ("1234567", 7);
|
||||
g_object_set (setting,
|
||||
NM_SETTING_WIRELESS_SSID, array,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NM_SETTING_WIRELESS_MODE, "infrastructure",
|
||||
NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
g_bytes_unref (ssid);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
success = nm_connection_verify (connection, &error);
|
||||
|
|
@ -1788,13 +1756,10 @@ test_connection_good_base_types (void)
|
|||
add_generic_settings (connection, NM_SETTING_BLUETOOTH_SETTING_NAME);
|
||||
|
||||
setting = nm_setting_bluetooth_new ();
|
||||
array = g_byte_array_new ();
|
||||
g_byte_array_append (array, bdaddr, sizeof (bdaddr));
|
||||
g_object_set (setting,
|
||||
NM_SETTING_BLUETOOTH_BDADDR, array,
|
||||
NM_SETTING_BLUETOOTH_BDADDR, bdaddr,
|
||||
NM_SETTING_CONNECTION_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU,
|
||||
NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
success = nm_connection_verify (connection, &error);
|
||||
|
|
@ -2311,14 +2276,14 @@ test_setting_ip4_changed_signal (void)
|
|||
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
|
||||
|
||||
ASSERT_CHANGED (nm_setting_ip4_config_add_dns (s_ip4, 0x1122));
|
||||
ASSERT_CHANGED (nm_setting_ip4_config_add_dns (s_ip4, "11.22.0.0"));
|
||||
ASSERT_CHANGED (nm_setting_ip4_config_remove_dns (s_ip4, 0));
|
||||
|
||||
g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL, "*i <= priv->dns->len*");
|
||||
g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL, "*elt != NULL*");
|
||||
ASSERT_UNCHANGED (nm_setting_ip4_config_remove_dns (s_ip4, 1));
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
nm_setting_ip4_config_add_dns (s_ip4, 0x3344);
|
||||
nm_setting_ip4_config_add_dns (s_ip4, "33.44.0.0");
|
||||
ASSERT_CHANGED (nm_setting_ip4_config_clear_dns (s_ip4));
|
||||
|
||||
ASSERT_CHANGED (nm_setting_ip4_config_add_dns_search (s_ip4, "foobar.com"));
|
||||
|
|
@ -2382,14 +2347,14 @@ test_setting_ip6_changed_signal (void)
|
|||
s_ip6 = (NMSettingIP6Config *) nm_setting_ip6_config_new ();
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_ip6));
|
||||
|
||||
ASSERT_CHANGED (nm_setting_ip6_config_add_dns (s_ip6, &t));
|
||||
ASSERT_CHANGED (nm_setting_ip6_config_add_dns (s_ip6, "1:2:3::4:5:6"));
|
||||
ASSERT_CHANGED (nm_setting_ip6_config_remove_dns (s_ip6, 0));
|
||||
|
||||
g_test_expect_message ("libnm", G_LOG_LEVEL_CRITICAL, "*elt != NULL*");
|
||||
ASSERT_UNCHANGED (nm_setting_ip6_config_remove_dns (s_ip6, 1));
|
||||
g_test_assert_expected_messages ();
|
||||
|
||||
nm_setting_ip6_config_add_dns (s_ip6, &t);
|
||||
nm_setting_ip6_config_add_dns (s_ip6, "1:2:3::4:5:6");
|
||||
ASSERT_CHANGED (nm_setting_ip6_config_clear_dns (s_ip6));
|
||||
|
||||
ASSERT_CHANGED (nm_setting_ip6_config_add_dns_search (s_ip6, "foobar.com"));
|
||||
|
|
@ -2861,13 +2826,11 @@ static NMSetting *
|
|||
_add_setting_fcn_bluetooth (NMConnection *con)
|
||||
{
|
||||
NMSetting *setting;
|
||||
GByteArray *bdaddr = nm_utils_hwaddr_atoba ("11:22:33:44:55:66", ETH_ALEN);
|
||||
|
||||
setting = g_object_new (NM_TYPE_SETTING_BLUETOOTH,
|
||||
NM_SETTING_BLUETOOTH_BDADDR, bdaddr,
|
||||
NM_SETTING_BLUETOOTH_BDADDR, "11:22:33:44:55:66",
|
||||
NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU,
|
||||
NULL);
|
||||
g_byte_array_free (bdaddr, TRUE);
|
||||
|
||||
nm_connection_add_setting (con, setting);
|
||||
return setting;
|
||||
|
|
@ -2942,14 +2905,14 @@ _add_setting_fcn_olpc_mesh (NMConnection *con)
|
|||
{
|
||||
NMSetting *setting;
|
||||
const char *ssid_data = "ssid-test";
|
||||
GByteArray *ssid = g_byte_array_new ();
|
||||
GBytes *ssid;
|
||||
|
||||
g_byte_array_append (ssid, (const guint8 *) ssid_data, strlen (ssid_data));
|
||||
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||
setting = g_object_new (NM_TYPE_SETTING_OLPC_MESH,
|
||||
NM_SETTING_OLPC_MESH_SSID, ssid,
|
||||
NM_SETTING_OLPC_MESH_CHANNEL, 1,
|
||||
NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
g_bytes_unref (ssid);
|
||||
|
||||
nm_connection_add_setting (con, setting);
|
||||
return setting;
|
||||
|
|
@ -3018,13 +2981,13 @@ _add_setting_fcn_wireless (NMConnection *con)
|
|||
{
|
||||
NMSetting *setting;
|
||||
const char *ssid_data = "ssid-test";
|
||||
GByteArray *ssid = g_byte_array_new ();
|
||||
GBytes *ssid;
|
||||
|
||||
g_byte_array_append (ssid, (const guint8 *) ssid_data, strlen (ssid_data));
|
||||
ssid = g_bytes_new (ssid_data, strlen (ssid_data));
|
||||
setting = g_object_new (NM_TYPE_SETTING_WIRELESS,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
g_bytes_unref (ssid);
|
||||
|
||||
nm_connection_add_setting (con, setting);
|
||||
return setting;
|
||||
|
|
@ -3033,12 +2996,9 @@ _add_setting_fcn_wireless (NMConnection *con)
|
|||
static void
|
||||
_prepare_normalizable_fcn_vlan (NMConnection *con)
|
||||
{
|
||||
GByteArray *mac_addr = nm_utils_hwaddr_atoba ("11:22:33:44:55:66", ETH_ALEN);
|
||||
|
||||
nm_connection_add_setting (con, g_object_new (NM_TYPE_SETTING_WIRED,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS, mac_addr,
|
||||
NM_SETTING_WIRED_MAC_ADDRESS, "11:22:33:44:55:66",
|
||||
NULL));
|
||||
g_byte_array_free (mac_addr, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3195,7 +3155,6 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/core/general/test_setting_vpn_update_secrets", test_setting_vpn_update_secrets);
|
||||
g_test_add_func ("/core/general/test_setting_vpn_modify_during_foreach", test_setting_vpn_modify_during_foreach);
|
||||
g_test_add_func ("/core/general/test_setting_ip4_config_labels", test_setting_ip4_config_labels);
|
||||
g_test_add_func ("/core/general/test_setting_ip6_config_old_address_array", test_setting_ip6_config_old_address_array);
|
||||
g_test_add_func ("/core/general/test_setting_gsm_apn_spaces", test_setting_gsm_apn_spaces);
|
||||
g_test_add_func ("/core/general/test_setting_gsm_apn_bad_chars", test_setting_gsm_apn_bad_chars);
|
||||
g_test_add_func ("/core/general/test_setting_gsm_apn_underscore", test_setting_gsm_apn_underscore);
|
||||
|
|
@ -3203,6 +3162,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/core/general/test_setting_to_dbus_all", test_setting_to_dbus_all);
|
||||
g_test_add_func ("/core/general/test_setting_to_dbus_no_secrets", test_setting_to_dbus_no_secrets);
|
||||
g_test_add_func ("/core/general/test_setting_to_dbus_only_secrets", test_setting_to_dbus_only_secrets);
|
||||
g_test_add_func ("/core/general/test_setting_to_dbus_transform", test_setting_to_dbus_transform);
|
||||
g_test_add_func ("/core/general/test_setting_compare_id", test_setting_compare_id);
|
||||
#define ADD_FUNC(func, secret_flags, comp_flags, remove_secret) \
|
||||
g_test_add_data_func_full ("/core/general/" G_STRINGIFY (func), \
|
||||
|
|
@ -3221,6 +3181,7 @@ int main (int argc, char **argv)
|
|||
g_test_add_func ("/core/general/test_connection_to_dbus_setting_name", test_connection_to_dbus_setting_name);
|
||||
g_test_add_func ("/core/general/test_connection_to_dbus_deprecated_props", test_connection_to_dbus_deprecated_props);
|
||||
g_test_add_func ("/core/general/test_setting_new_from_dbus", test_setting_new_from_dbus);
|
||||
g_test_add_func ("/core/general/test_setting_new_from_dbus_transform", test_setting_new_from_dbus_transform);
|
||||
g_test_add_func ("/core/general/test_connection_replace_settings", test_connection_replace_settings);
|
||||
g_test_add_func ("/core/general/test_connection_replace_settings_from_connection", test_connection_replace_settings_from_connection);
|
||||
g_test_add_func ("/core/general/test_connection_replace_settings_bad", test_connection_replace_settings_bad);
|
||||
|
|
|
|||
|
|
@ -399,7 +399,7 @@ wifi_connection_new (void)
|
|||
NMSettingWirelessSecurity *s_wsec;
|
||||
unsigned char tmpssid[] = { 0x31, 0x33, 0x33, 0x37 };
|
||||
char *uuid;
|
||||
GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
|
||||
connection = nm_simple_connection_new ();
|
||||
g_assert (connection);
|
||||
|
|
@ -422,12 +422,11 @@ wifi_connection_new (void)
|
|||
s_wifi = (NMSettingWireless *) nm_setting_wireless_new ();
|
||||
g_assert (s_wifi);
|
||||
|
||||
ssid = g_byte_array_sized_new (sizeof (tmpssid));
|
||||
g_byte_array_append (ssid, &tmpssid[0], sizeof (tmpssid));
|
||||
ssid = g_bytes_new (tmpssid, sizeof (tmpssid));
|
||||
g_object_set (s_wifi,
|
||||
NM_SETTING_WIRELESS_SSID, ssid,
|
||||
NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
g_bytes_unref (ssid);
|
||||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||
|
||||
/* Wifi security */
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
static void
|
||||
compare_blob_data (const char *test,
|
||||
const char *key_path,
|
||||
const GByteArray *key)
|
||||
GBytes *key)
|
||||
{
|
||||
char *contents = NULL;
|
||||
gsize len = 0;
|
||||
|
|
@ -45,11 +45,11 @@ compare_blob_data (const char *test,
|
|||
|
||||
ASSERT (len > 0, test, "blob key file invalid (size 0)");
|
||||
|
||||
ASSERT (len == key->len,
|
||||
ASSERT (len == g_bytes_get_size (key),
|
||||
test, "blob key file (%d) and setting key data (%d) lengths don't match",
|
||||
len, key->len);
|
||||
len, g_bytes_get_size (key));
|
||||
|
||||
ASSERT (memcmp (contents, key->data, len) == 0,
|
||||
ASSERT (memcmp (contents, g_bytes_get_data (key, NULL), len) == 0,
|
||||
test, "blob key file and blob key data don't match");
|
||||
|
||||
g_free (contents);
|
||||
|
|
@ -58,9 +58,9 @@ compare_blob_data (const char *test,
|
|||
#define SCHEME_PATH "file://"
|
||||
|
||||
static void
|
||||
check_scheme_path (GByteArray *value, const char *path)
|
||||
check_scheme_path (GBytes *value, const char *path)
|
||||
{
|
||||
guint8 *p = value->data;
|
||||
const guint8 *p = g_bytes_get_data (value, NULL);
|
||||
|
||||
g_assert (memcmp (p, SCHEME_PATH, strlen (SCHEME_PATH)) == 0);
|
||||
p += strlen (SCHEME_PATH);
|
||||
|
|
@ -79,7 +79,7 @@ test_private_key_import (const char *path,
|
|||
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||
NMSetting8021xCKFormat tmp_fmt;
|
||||
GError *error = NULL;
|
||||
GByteArray *tmp_key = NULL, *client_cert = NULL;
|
||||
GBytes *tmp_key = NULL, *client_cert = NULL;
|
||||
const char *pw;
|
||||
|
||||
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
||||
|
|
@ -108,14 +108,14 @@ test_private_key_import (const char *path,
|
|||
"private-key-import", "failed to compare private key password");
|
||||
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
tmp_key = (GByteArray *) nm_setting_802_1x_get_private_key_blob (s_8021x);
|
||||
tmp_key = nm_setting_802_1x_get_private_key_blob (s_8021x);
|
||||
ASSERT (tmp_key != NULL, "private-key-import", "missing private key blob");
|
||||
compare_blob_data ("private-key-import", path, tmp_key);
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
||||
g_object_get (s_8021x, NM_SETTING_802_1X_PRIVATE_KEY, &tmp_key, NULL);
|
||||
ASSERT (tmp_key != NULL, "private-key-import", "missing private key value");
|
||||
check_scheme_path (tmp_key, path);
|
||||
g_byte_array_free (tmp_key, TRUE);
|
||||
g_bytes_unref (tmp_key);
|
||||
} else
|
||||
g_assert_not_reached ();
|
||||
|
||||
|
|
@ -128,13 +128,11 @@ test_private_key_import (const char *path,
|
|||
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
||||
|
||||
/* make sure they are the same */
|
||||
ASSERT (tmp_key->len == client_cert->len,
|
||||
"private-key-import", "unexpected different private key and client cert lengths");
|
||||
ASSERT (memcmp (tmp_key->data, client_cert->data, tmp_key->len) == 0,
|
||||
ASSERT (g_bytes_equal (tmp_key, client_cert),
|
||||
"private-key-import", "unexpected different private key and client cert data");
|
||||
|
||||
g_byte_array_free (tmp_key, TRUE);
|
||||
g_byte_array_free (client_cert, TRUE);
|
||||
g_bytes_unref (tmp_key);
|
||||
g_bytes_unref (client_cert);
|
||||
}
|
||||
|
||||
g_object_unref (s_8021x);
|
||||
|
|
@ -150,7 +148,7 @@ test_phase2_private_key_import (const char *path,
|
|||
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||
NMSetting8021xCKFormat tmp_fmt;
|
||||
GError *error = NULL;
|
||||
GByteArray *tmp_key = NULL, *client_cert = NULL;
|
||||
GBytes *tmp_key = NULL, *client_cert = NULL;
|
||||
const char *pw;
|
||||
|
||||
s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
|
||||
|
|
@ -179,7 +177,7 @@ test_phase2_private_key_import (const char *path,
|
|||
"phase2-private-key-import", "failed to compare private key password");
|
||||
|
||||
if (scheme == NM_SETTING_802_1X_CK_SCHEME_BLOB) {
|
||||
tmp_key = (GByteArray *) nm_setting_802_1x_get_phase2_private_key_blob (s_8021x);
|
||||
tmp_key = nm_setting_802_1x_get_phase2_private_key_blob (s_8021x);
|
||||
ASSERT (tmp_key != NULL, "phase2-private-key-import", "missing private key blob");
|
||||
compare_blob_data ("phase2-private-key-import", path, tmp_key);
|
||||
} else if (scheme == NM_SETTING_802_1X_CK_SCHEME_PATH) {
|
||||
|
|
@ -198,13 +196,11 @@ test_phase2_private_key_import (const char *path,
|
|||
ASSERT (client_cert != NULL, "private-key-import", "missing client certificate value");
|
||||
|
||||
/* make sure they are the same */
|
||||
ASSERT (tmp_key->len == client_cert->len,
|
||||
"private-key-import", "unexpected different private key and client cert lengths");
|
||||
ASSERT (memcmp (tmp_key->data, client_cert->data, tmp_key->len) == 0,
|
||||
ASSERT (g_bytes_equal (tmp_key, client_cert),
|
||||
"private-key-import", "unexpected different private key and client cert data");
|
||||
|
||||
g_byte_array_free (tmp_key, TRUE);
|
||||
g_byte_array_free (client_cert, TRUE);
|
||||
g_bytes_unref (tmp_key);
|
||||
g_bytes_unref (client_cert);
|
||||
}
|
||||
|
||||
g_object_unref (s_8021x);
|
||||
|
|
|
|||
|
|
@ -236,9 +236,11 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
|
|||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
const char *ctype, *ap_bssid;
|
||||
const GByteArray *setting_ssid;
|
||||
GBytes *setting_ssid;
|
||||
const guint8 *setting_ssid_data;
|
||||
gsize setting_ssid_len;
|
||||
const GByteArray *ap_ssid;
|
||||
const GByteArray *setting_bssid;
|
||||
const char *setting_bssid;
|
||||
const char *setting_mode;
|
||||
NM80211Mode ap_mode;
|
||||
const char *setting_band;
|
||||
|
|
@ -258,9 +260,12 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
|
|||
ap_ssid = nm_access_point_get_ssid (ap);
|
||||
g_warn_if_fail (ap_ssid != NULL);
|
||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (!setting_ssid || !ap_ssid || (setting_ssid->len != ap_ssid->len))
|
||||
if (!setting_ssid || !ap_ssid)
|
||||
return FALSE;
|
||||
if (memcmp (setting_ssid->data, ap_ssid->data, ap_ssid->len) != 0)
|
||||
setting_ssid_data = g_bytes_get_data (setting_ssid, &setting_ssid_len);
|
||||
if (setting_ssid_len != ap_ssid->len)
|
||||
return FALSE;
|
||||
if (memcmp (setting_ssid_data, ap_ssid->data, ap_ssid->len) != 0)
|
||||
return FALSE;
|
||||
|
||||
/* BSSID checks */
|
||||
|
|
@ -268,7 +273,7 @@ nm_access_point_connection_valid (NMAccessPoint *ap, NMConnection *connection)
|
|||
g_warn_if_fail (ap_bssid);
|
||||
setting_bssid = nm_setting_wireless_get_bssid (s_wifi);
|
||||
if (setting_bssid && ap_bssid) {
|
||||
if (!nm_utils_hwaddr_matches (ap_bssid, -1, setting_bssid->data, setting_bssid->len))
|
||||
if (!nm_utils_hwaddr_matches (ap_bssid, -1, setting_bssid, -1))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,8 +146,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
NMSettingConnection *s_con;
|
||||
NMSettingBluetooth *s_bt;
|
||||
const char *ctype;
|
||||
const GByteArray *mac;
|
||||
const char *hw_addr;
|
||||
const char *hw_addr, *setting_addr;
|
||||
NMBluetoothCapabilities dev_caps;
|
||||
NMBluetoothCapabilities bt_type;
|
||||
|
||||
|
|
@ -176,8 +175,8 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
"Invalid device MAC address.");
|
||||
return FALSE;
|
||||
}
|
||||
mac = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, hw_addr, -1)) {
|
||||
setting_addr = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, hw_addr, -1)) {
|
||||
g_set_error (error, NM_DEVICE_BT_ERROR, NM_DEVICE_BT_ERROR_MAC_MISMATCH,
|
||||
"The MACs of the device and the connection didn't match.");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -168,8 +168,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
}
|
||||
|
||||
if (s_wired) {
|
||||
const GByteArray *mac;
|
||||
const char *perm_addr;
|
||||
const char *perm_addr, *setting_addr;
|
||||
|
||||
/* FIXME: filter using s390 subchannels when they are exported over the bus */
|
||||
|
||||
|
|
@ -181,8 +180,8 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
"Invalid device MAC address.");
|
||||
return FALSE;
|
||||
}
|
||||
mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, perm_addr, -1)) {
|
||||
setting_addr = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (setting_addr && !nm_utils_hwaddr_matches (setting_addr, -1, perm_addr, -1)) {
|
||||
g_set_error (error, NM_DEVICE_ETHERNET_ERROR, NM_DEVICE_ETHERNET_ERROR_MAC_MISMATCH,
|
||||
"The MACs of the device and the connection didn't match.");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -105,8 +105,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
{
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
const char *ctype, *hwaddr;
|
||||
const GByteArray *mac;
|
||||
const char *ctype, *hwaddr, *setting_hwaddr;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
|
@ -132,9 +131,9 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
"Invalid device MAC address.");
|
||||
return FALSE;
|
||||
}
|
||||
mac = nm_setting_infiniband_get_mac_address (s_infiniband);
|
||||
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, hwaddr, -1)) {
|
||||
setting_hwaddr = nm_setting_infiniband_get_mac_address (s_infiniband);
|
||||
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
|
||||
g_set_error (error, NM_DEVICE_INFINIBAND_ERROR, NM_DEVICE_INFINIBAND_ERROR_MAC_MISMATCH,
|
||||
"The MACs of the device and the connection didn't match.");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -123,8 +123,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
NMSettingVlan *s_vlan;
|
||||
NMSettingWired *s_wired;
|
||||
const char *ctype, *dev_iface_name, *vlan_iface_name;
|
||||
const GByteArray *mac_address;
|
||||
char *mac_address_str;
|
||||
const char *setting_hwaddr;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
|
@ -159,16 +158,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
if (s_wired)
|
||||
mac_address = nm_setting_wired_get_mac_address (s_wired);
|
||||
setting_hwaddr = nm_setting_wired_get_mac_address (s_wired);
|
||||
else
|
||||
mac_address = NULL;
|
||||
if (mac_address) {
|
||||
mac_address_str = nm_utils_hwaddr_ntoa (mac_address->data, mac_address->len);
|
||||
if (!g_strcmp0 (mac_address_str, NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address)) {
|
||||
setting_hwaddr = NULL;
|
||||
if (setting_hwaddr) {
|
||||
if (!nm_utils_hwaddr_matches (setting_hwaddr, -1,
|
||||
NM_DEVICE_VLAN_GET_PRIVATE (device)->hw_address, -1)) {
|
||||
g_set_error (error, NM_DEVICE_VLAN_ERROR, NM_DEVICE_VLAN_ERROR_MAC_MISMATCH,
|
||||
"The hardware address of the device and the connection didn't match.");
|
||||
}
|
||||
g_free (mac_address_str);
|
||||
}
|
||||
|
||||
return NM_DEVICE_CLASS (nm_device_vlan_parent_class)->connection_compatible (device, connection, error);
|
||||
|
|
|
|||
|
|
@ -418,8 +418,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
const char *ctype;
|
||||
const GByteArray *mac;
|
||||
const char *hw_addr;
|
||||
const char *hwaddr, *setting_hwaddr;
|
||||
NMDeviceWifiCapabilities wifi_caps;
|
||||
const char *key_mgmt;
|
||||
|
||||
|
|
@ -441,15 +440,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
}
|
||||
|
||||
/* Check MAC address */
|
||||
hw_addr = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device));
|
||||
if (hw_addr) {
|
||||
if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) {
|
||||
hwaddr = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device));
|
||||
if (hwaddr) {
|
||||
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
|
||||
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_INVALID_DEVICE_MAC,
|
||||
"Invalid device MAC address.");
|
||||
return FALSE;
|
||||
}
|
||||
mac = nm_setting_wireless_get_mac_address (s_wifi);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, hw_addr, -1)) {
|
||||
setting_hwaddr = nm_setting_wireless_get_mac_address (s_wifi);
|
||||
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
|
||||
g_set_error (error, NM_DEVICE_WIFI_ERROR, NM_DEVICE_WIFI_ERROR_MAC_MISMATCH,
|
||||
"The MACs of the device and the connection didn't match.");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -322,8 +322,7 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
NMSettingConnection *s_con;
|
||||
NMSettingWimax *s_wimax;
|
||||
const char *ctype;
|
||||
const GByteArray *mac;
|
||||
const char *hw_addr;
|
||||
const char *hwaddr, *setting_hwaddr;
|
||||
|
||||
s_con = nm_connection_get_setting_connection (connection);
|
||||
g_assert (s_con);
|
||||
|
|
@ -343,15 +342,15 @@ connection_compatible (NMDevice *device, NMConnection *connection, GError **erro
|
|||
}
|
||||
|
||||
/* Check MAC address */
|
||||
hw_addr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
|
||||
if (hw_addr) {
|
||||
if (!nm_utils_hwaddr_valid (hw_addr, ETH_ALEN)) {
|
||||
hwaddr = nm_device_wimax_get_hw_address (NM_DEVICE_WIMAX (device));
|
||||
if (hwaddr) {
|
||||
if (!nm_utils_hwaddr_valid (hwaddr, ETH_ALEN)) {
|
||||
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_INVALID_DEVICE_MAC,
|
||||
"Invalid device MAC address.");
|
||||
return FALSE;
|
||||
}
|
||||
mac = nm_setting_wimax_get_mac_address (s_wimax);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, hw_addr, -1)) {
|
||||
setting_hwaddr = nm_setting_wimax_get_mac_address (s_wimax);
|
||||
if (setting_hwaddr && !nm_utils_hwaddr_matches (setting_hwaddr, -1, hwaddr, -1)) {
|
||||
g_set_error (error, NM_DEVICE_WIMAX_ERROR, NM_DEVICE_WIMAX_ERROR_MAC_MISMATCH,
|
||||
"The MACs of the device and the connection didn't match.");
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -63,30 +63,37 @@
|
|||
*
|
||||
*/
|
||||
gboolean
|
||||
nm_ethernet_address_is_valid (const guint8 *test_addr)
|
||||
nm_ethernet_address_is_valid (gconstpointer addr, gsize len)
|
||||
{
|
||||
guint8 invalid_addr1[ETH_ALEN] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
guint8 invalid_addr2[ETH_ALEN] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
guint8 invalid_addr3[ETH_ALEN] = {0x44, 0x44, 0x44, 0x44, 0x44, 0x44};
|
||||
guint8 invalid_addr4[ETH_ALEN] = {0x00, 0x30, 0xb4, 0x00, 0x00, 0x00}; /* prism54 dummy MAC */
|
||||
guchar first_octet;
|
||||
|
||||
g_return_val_if_fail (test_addr != NULL, FALSE);
|
||||
g_return_val_if_fail (addr != NULL, FALSE);
|
||||
g_return_val_if_fail (len == ETH_ALEN || len == -1, FALSE);
|
||||
|
||||
/* Compare the AP address the card has with invalid ethernet MAC addresses. */
|
||||
if (!memcmp (test_addr, invalid_addr1, ETH_ALEN))
|
||||
if (nm_utils_hwaddr_matches (addr, len, invalid_addr1, ETH_ALEN))
|
||||
return FALSE;
|
||||
|
||||
if (!memcmp (test_addr, invalid_addr2, ETH_ALEN))
|
||||
if (nm_utils_hwaddr_matches (addr, len, invalid_addr2, ETH_ALEN))
|
||||
return FALSE;
|
||||
|
||||
if (!memcmp (test_addr, invalid_addr3, ETH_ALEN))
|
||||
if (nm_utils_hwaddr_matches (addr, len, invalid_addr3, ETH_ALEN))
|
||||
return FALSE;
|
||||
|
||||
if (!memcmp (test_addr, invalid_addr4, ETH_ALEN))
|
||||
if (nm_utils_hwaddr_matches (addr, len, invalid_addr4, ETH_ALEN))
|
||||
return FALSE;
|
||||
|
||||
if (test_addr[0] & 1) /* Multicast addresses */
|
||||
return FALSE;
|
||||
/* Check for multicast address */
|
||||
if (len == -1)
|
||||
first_octet = strtoul (addr, NULL, 16);
|
||||
else
|
||||
first_octet = ((guint8 *)addr)[0];
|
||||
if (first_octet & 0x01)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1237,7 +1244,7 @@ check_connection_mac_address (NMConnection *orig,
|
|||
GHashTable *settings)
|
||||
{
|
||||
GHashTable *props;
|
||||
const GByteArray *orig_mac = NULL, *cand_mac = NULL;
|
||||
const char *orig_mac = NULL, *cand_mac = NULL;
|
||||
NMSettingWired *s_wired_orig, *s_wired_cand;
|
||||
|
||||
props = check_property_in_hash (settings,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
#include "nm-connection.h"
|
||||
#include "nm-platform.h"
|
||||
|
||||
gboolean nm_ethernet_address_is_valid (const guint8 *test_addr);
|
||||
gboolean nm_ethernet_address_is_valid (gconstpointer addr, gsize len);
|
||||
|
||||
in_addr_t nm_utils_ip4_address_clear_host_address (in_addr_t addr, guint8 plen);
|
||||
void nm_utils_ip6_address_clear_host_address (struct in6_addr *dst, const struct in6_addr *src, guint8 plen);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ typedef struct {
|
|||
NMBluetoothCapabilities connection_bt_type;
|
||||
|
||||
char *address;
|
||||
guint8 bin_address[ETH_ALEN];
|
||||
char *name;
|
||||
guint32 capabilities;
|
||||
gboolean connected;
|
||||
|
|
@ -166,7 +165,6 @@ pan_connection_check_create (NMBluezDevice *self)
|
|||
NMConnection *added;
|
||||
NMSetting *setting;
|
||||
char *uuid, *id;
|
||||
GByteArray *bdaddr_array;
|
||||
GError *error = NULL;
|
||||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
|
|
@ -200,15 +198,12 @@ pan_connection_check_create (NMBluezDevice *self)
|
|||
nm_connection_add_setting (connection, setting);
|
||||
|
||||
/* Setting: Bluetooth */
|
||||
bdaddr_array = g_byte_array_sized_new (sizeof (priv->bin_address));
|
||||
g_byte_array_append (bdaddr_array, priv->bin_address, sizeof (priv->bin_address));
|
||||
setting = nm_setting_bluetooth_new ();
|
||||
g_object_set (G_OBJECT (setting),
|
||||
NM_SETTING_BLUETOOTH_BDADDR, bdaddr_array,
|
||||
NM_SETTING_BLUETOOTH_BDADDR, priv->address,
|
||||
NM_SETTING_BLUETOOTH_TYPE, NM_SETTING_BLUETOOTH_TYPE_PANU,
|
||||
NULL);
|
||||
nm_connection_add_setting (connection, setting);
|
||||
g_byte_array_free (bdaddr_array, TRUE);
|
||||
|
||||
/* Setting: IPv4 */
|
||||
setting = nm_setting_ip4_config_new ();
|
||||
|
|
@ -300,7 +295,7 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection)
|
|||
NMBluezDevicePrivate *priv = NM_BLUEZ_DEVICE_GET_PRIVATE (self);
|
||||
NMSettingBluetooth *s_bt;
|
||||
const char *bt_type;
|
||||
const GByteArray *bdaddr;
|
||||
const char *bdaddr;
|
||||
|
||||
if (!nm_connection_is_type (connection, NM_SETTING_BLUETOOTH_SETTING_NAME))
|
||||
return FALSE;
|
||||
|
|
@ -309,14 +304,13 @@ connection_compatible (NMBluezDevice *self, NMConnection *connection)
|
|||
if (!s_bt)
|
||||
return FALSE;
|
||||
|
||||
if (!priv->address) {
|
||||
/* unless address is set, bin_address is not initialized. */
|
||||
if (!priv->address)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (!bdaddr)
|
||||
return FALSE;
|
||||
if (!nm_utils_hwaddr_matches (bdaddr->data, bdaddr->len, priv->bin_address, ETH_ALEN))
|
||||
if (!nm_utils_hwaddr_matches (bdaddr, -1, priv->address, -1))
|
||||
return FALSE;
|
||||
|
||||
bt_type = nm_setting_bluetooth_get_connection_type (s_bt);
|
||||
|
|
@ -611,8 +605,6 @@ _set_property_capabilities (NMBluezDevice *self, const char **uuids)
|
|||
/**
|
||||
* priv->address can only be set one to a certain (non NULL) value. Every later attempt
|
||||
* to reset it to another value will be ignored and a warning will be logged.
|
||||
*
|
||||
* When setting the address for the first time, we also set bin_address.
|
||||
**/
|
||||
static void
|
||||
_set_property_address (NMBluezDevice *self, const char *addr)
|
||||
|
|
@ -632,13 +624,11 @@ _set_property_address (NMBluezDevice *self, const char *addr)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!nm_utils_hwaddr_aton (addr, priv->bin_address, ETH_ALEN)) {
|
||||
if (priv->address)
|
||||
nm_log_warn (LOGD_BT, "bluez[%s] cannot reset address from '%s' to '%s' (invalid value)", priv->path, priv->address, addr);
|
||||
else
|
||||
nm_log_warn (LOGD_BT, "bluez[%s] cannot reset address from NULL to '%s' (invalid value)", priv->path, addr);
|
||||
if (!nm_utils_hwaddr_valid (addr, ETH_ALEN)) {
|
||||
nm_log_warn (LOGD_BT, "bluez[%s] cannot set address to '%s' (invalid value)", priv->path, addr);
|
||||
return;
|
||||
}
|
||||
|
||||
priv->address = g_strdup (addr);
|
||||
g_object_notify (G_OBJECT (self), NM_BLUEZ_DEVICE_ADDRESS);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingBluetooth *s_bt;
|
||||
const GByteArray *array;
|
||||
const char *bdaddr;
|
||||
guint32 bt_type;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_bt_parent_class)->check_connection_compatible (device, connection))
|
||||
|
|
@ -178,10 +178,10 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
if (!(bt_type & priv->capabilities))
|
||||
return FALSE;
|
||||
|
||||
array = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (!array)
|
||||
bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (!bdaddr)
|
||||
return FALSE;
|
||||
if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, array->data, array->len))
|
||||
if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, bdaddr, -1))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -215,7 +215,7 @@ complete_connection (NMDevice *device,
|
|||
{
|
||||
NMDeviceBtPrivate *priv = NM_DEVICE_BT_GET_PRIVATE (device);
|
||||
NMSettingBluetooth *s_bt;
|
||||
const GByteArray *setting_bdaddr;
|
||||
const char *setting_bdaddr;
|
||||
const char *ctype;
|
||||
gboolean is_dun = FALSE, is_pan = FALSE;
|
||||
NMSettingGsm *s_gsm;
|
||||
|
|
@ -324,7 +324,7 @@ complete_connection (NMDevice *device,
|
|||
setting_bdaddr = nm_setting_bluetooth_get_bdaddr (s_bt);
|
||||
if (setting_bdaddr) {
|
||||
/* Make sure the setting BT Address (if any) matches the device's */
|
||||
if (!nm_utils_hwaddr_matches (setting_bdaddr->data, setting_bdaddr->len, priv->bdaddr, -1)) {
|
||||
if (!nm_utils_hwaddr_matches (setting_bdaddr, -1, priv->bdaddr, -1)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_BLUETOOTH_ERROR,
|
||||
NM_SETTING_BLUETOOTH_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -332,14 +332,9 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
GByteArray *bdaddr;
|
||||
|
||||
/* Lock the connection to this device by default */
|
||||
if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, NULL, ETH_ALEN)) {
|
||||
bdaddr = nm_utils_hwaddr_atoba (priv->bdaddr, ETH_ALEN);
|
||||
g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_BDADDR, bdaddr, NULL);
|
||||
g_byte_array_free (bdaddr, TRUE);
|
||||
}
|
||||
if (!nm_utils_hwaddr_matches (priv->bdaddr, -1, NULL, ETH_ALEN))
|
||||
g_object_set (G_OBJECT (s_bt), NM_SETTING_BLUETOOTH_BDADDR, priv->bdaddr, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
{
|
||||
const char *iface;
|
||||
NMSettingBridge *s_bridge;
|
||||
const GByteArray *mac_address;
|
||||
const char *mac_address;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_bridge_parent_class)->check_connection_compatible (device, connection))
|
||||
return FALSE;
|
||||
|
|
@ -120,8 +120,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
const char *hw_addr;
|
||||
|
||||
hw_addr = nm_device_get_hw_address (device);
|
||||
if ( !hw_addr
|
||||
|| !nm_utils_hwaddr_matches (hw_addr, -1, mac_address->data, mac_address->len))
|
||||
if (!hw_addr || !nm_utils_hwaddr_matches (hw_addr, -1, mac_address, -1))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -424,7 +423,8 @@ nm_device_bridge_new_for_connection (NMConnection *connection)
|
|||
{
|
||||
const char *iface;
|
||||
NMSettingBridge *s_bridge;
|
||||
const GByteArray *mac_address;
|
||||
const char *mac_address_str;
|
||||
guint8 mac_address[NM_UTILS_HWADDR_LEN_MAX];
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
|
|
@ -434,11 +434,15 @@ nm_device_bridge_new_for_connection (NMConnection *connection)
|
|||
s_bridge = nm_connection_get_setting_bridge (connection);
|
||||
g_return_val_if_fail (s_bridge, NULL);
|
||||
|
||||
mac_address = nm_setting_bridge_get_mac_address (s_bridge);
|
||||
mac_address_str = nm_setting_bridge_get_mac_address (s_bridge);
|
||||
if (mac_address_str) {
|
||||
if (!nm_utils_hwaddr_aton (mac_address_str, mac_address, ETH_ALEN))
|
||||
mac_address_str = NULL;
|
||||
}
|
||||
|
||||
if ( !nm_platform_bridge_add (iface,
|
||||
mac_address ? mac_address->data : NULL,
|
||||
mac_address ? mac_address->len : 0)
|
||||
mac_address_str ? mac_address : NULL,
|
||||
mac_address_str ? ETH_ALEN : 0)
|
||||
&& nm_platform_get_error () != NM_PLATFORM_ERROR_EXISTS) {
|
||||
nm_log_warn (LOGD_DEVICE | LOGD_BRIDGE, "(%s): failed to create bridge master interface for '%s': %s",
|
||||
iface, nm_connection_get_id (connection),
|
||||
|
|
|
|||
|
|
@ -101,8 +101,8 @@ typedef enum {
|
|||
} DcbWait;
|
||||
|
||||
typedef struct {
|
||||
char * perm_hw_addr; /* Permanent MAC address */
|
||||
guint8 initial_hw_addr[ETH_ALEN]; /* Initial MAC address (as seen when NM starts) */
|
||||
char * perm_hw_addr; /* Permanent MAC address */
|
||||
char * initial_hw_addr; /* Initial MAC address (as seen when NM starts) */
|
||||
|
||||
guint32 speed;
|
||||
|
||||
|
|
@ -361,7 +361,7 @@ update_permanent_hw_address (NMDevice *dev)
|
|||
errno = 0;
|
||||
ret = ioctl (fd, SIOCETHTOOL, &req);
|
||||
errsv = errno;
|
||||
if ((ret < 0) || !nm_ethernet_address_is_valid (epaddr->data)) {
|
||||
if ((ret < 0) || !nm_ethernet_address_is_valid (epaddr->data, ETH_ALEN)) {
|
||||
_LOGD (LOGD_HW | LOGD_ETHER, "unable to read permanent MAC address (error %d)", errsv);
|
||||
/* Fall back to current address */
|
||||
mac = nm_device_get_hw_address (dev);
|
||||
|
|
@ -382,16 +382,13 @@ update_initial_hw_address (NMDevice *dev)
|
|||
{
|
||||
NMDeviceEthernet *self = NM_DEVICE_ETHERNET (dev);
|
||||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||
const char *mac;
|
||||
|
||||
/* This sets initial MAC address from current MAC address. It should only
|
||||
* be called from NMDevice constructor() to really get the initial address.
|
||||
*/
|
||||
mac = nm_device_get_hw_address (dev);
|
||||
if (mac)
|
||||
nm_utils_hwaddr_aton (mac, priv->initial_hw_addr, ETH_ALEN);
|
||||
priv->initial_hw_addr = g_strdup (nm_device_get_hw_address (dev));
|
||||
|
||||
_LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", mac);
|
||||
_LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", priv->initial_hw_addr);
|
||||
}
|
||||
|
||||
static guint32
|
||||
|
|
@ -412,7 +409,7 @@ static gboolean
|
|||
match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_mac)
|
||||
{
|
||||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||
const GPtrArray *subchans;
|
||||
const char * const *subchans;
|
||||
int i;
|
||||
|
||||
*try_mac = TRUE;
|
||||
|
|
@ -426,8 +423,8 @@ match_subchans (NMDeviceEthernet *self, NMSettingWired *s_wired, gboolean *try_m
|
|||
return FALSE;
|
||||
|
||||
/* Make sure each subchannel in the connection is a subchannel of this device */
|
||||
for (i = 0; i < subchans->len; i++) {
|
||||
const char *candidate = g_ptr_array_index (subchans, i);
|
||||
for (i = 0; subchans[i]; i++) {
|
||||
const char *candidate = subchans[i];
|
||||
|
||||
if ( (priv->subchan1 && !strcmp (priv->subchan1, candidate))
|
||||
|| (priv->subchan2 && !strcmp (priv->subchan2, candidate))
|
||||
|
|
@ -462,7 +459,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
if (s_wired) {
|
||||
const GByteArray *mac;
|
||||
const char *mac;
|
||||
gboolean try_mac = TRUE;
|
||||
const GSList *mac_blacklist, *mac_blacklist_iter;
|
||||
|
||||
|
|
@ -470,21 +467,19 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (try_mac && mac && !nm_utils_hwaddr_matches (mac->data, mac->len, priv->perm_hw_addr, -1))
|
||||
if (try_mac && mac && !nm_utils_hwaddr_matches (mac, -1, priv->perm_hw_addr, -1))
|
||||
return FALSE;
|
||||
|
||||
/* Check for MAC address blacklist */
|
||||
mac_blacklist = nm_setting_wired_get_mac_address_blacklist (s_wired);
|
||||
for (mac_blacklist_iter = mac_blacklist; mac_blacklist_iter;
|
||||
mac_blacklist_iter = g_slist_next (mac_blacklist_iter)) {
|
||||
guint8 addr[ETH_ALEN];
|
||||
|
||||
if (!nm_utils_hwaddr_aton (mac_blacklist_iter->data, addr, ETH_ALEN)) {
|
||||
if (!nm_utils_hwaddr_valid (mac_blacklist_iter->data, ETH_ALEN)) {
|
||||
g_warn_if_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nm_utils_hwaddr_matches (addr, ETH_ALEN, priv->perm_hw_addr, -1))
|
||||
if (nm_utils_hwaddr_matches (mac_blacklist_iter->data, -1, priv->perm_hw_addr, -1))
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
@ -911,7 +906,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||
NMActRequest *req;
|
||||
NMSettingWired *s_wired;
|
||||
const GByteArray *cloned_mac;
|
||||
const char *cloned_mac;
|
||||
NMActStageReturn ret = NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
|
||||
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
|
@ -925,8 +920,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
if (s_wired) {
|
||||
/* Set device MAC address if the connection wants to change it */
|
||||
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
|
||||
if (cloned_mac && (cloned_mac->len == ETH_ALEN))
|
||||
nm_device_set_hw_addr (dev, cloned_mac->data, "set", LOGD_ETHER);
|
||||
if (cloned_mac)
|
||||
nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_ETHER);
|
||||
}
|
||||
|
||||
/* If we're re-activating a PPPoE connection a short while after
|
||||
|
|
@ -1430,7 +1425,7 @@ complete_connection (NMDevice *device,
|
|||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (device);
|
||||
NMSettingWired *s_wired;
|
||||
NMSettingPppoe *s_pppoe;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
|
||||
s_pppoe = nm_connection_get_setting_pppoe (connection);
|
||||
|
||||
|
|
@ -1460,7 +1455,7 @@ complete_connection (NMDevice *device,
|
|||
setting_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (setting_mac) {
|
||||
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
|
||||
if (!nm_utils_hwaddr_matches (setting_mac->data, setting_mac->len, priv->perm_hw_addr, -1)) {
|
||||
if (!nm_utils_hwaddr_matches (setting_mac, -1, priv->perm_hw_addr, -1)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRED_ERROR,
|
||||
NM_SETTING_WIRED_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1468,13 +1463,10 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
GByteArray *mac;
|
||||
|
||||
/* Lock the connection to this device by default */
|
||||
if (!nm_utils_hwaddr_matches (priv->perm_hw_addr, -1, NULL, ETH_ALEN)) {
|
||||
mac = nm_utils_hwaddr_atoba (priv->perm_hw_addr, ETH_ALEN);
|
||||
g_object_set (G_OBJECT (s_wired), NM_SETTING_WIRED_MAC_ADDRESS, mac, NULL);
|
||||
g_byte_array_free (mac, TRUE);
|
||||
g_object_set (G_OBJECT (s_wired),
|
||||
NM_SETTING_WIRED_MAC_ADDRESS, priv->perm_hw_addr,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1499,7 +1491,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
NMSettingWired *s_wired = nm_connection_get_setting_wired (connection);
|
||||
const char *mac = nm_device_get_hw_address (device);
|
||||
const char *mac_prop = NM_SETTING_WIRED_MAC_ADDRESS;
|
||||
GByteArray *array;
|
||||
GHashTableIter iter;
|
||||
gpointer key, value;
|
||||
|
||||
|
|
@ -1512,20 +1503,15 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
* and the current MAC, if different, is the cloned MAC.
|
||||
*/
|
||||
if (!nm_utils_hwaddr_matches (priv->perm_hw_addr, -1, NULL, ETH_ALEN)) {
|
||||
array = nm_utils_hwaddr_atoba (priv->perm_hw_addr, ETH_ALEN);
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, array, NULL);
|
||||
g_byte_array_unref (array);
|
||||
g_object_set (s_wired, NM_SETTING_WIRED_MAC_ADDRESS, priv->perm_hw_addr, NULL);
|
||||
|
||||
mac_prop = NULL;
|
||||
if (mac && !nm_utils_hwaddr_matches (priv->perm_hw_addr, -1, mac, -1))
|
||||
mac_prop = NM_SETTING_WIRED_CLONED_MAC_ADDRESS;
|
||||
}
|
||||
|
||||
if (mac_prop && mac && nm_utils_hwaddr_valid (mac, ETH_ALEN)) {
|
||||
array = nm_utils_hwaddr_atoba (mac, ETH_ALEN);
|
||||
g_object_set (s_wired, mac_prop, array, NULL);
|
||||
g_byte_array_unref (array);
|
||||
}
|
||||
if (mac_prop && mac && nm_utils_hwaddr_valid (mac, ETH_ALEN))
|
||||
g_object_set (s_wired, mac_prop, mac, NULL);
|
||||
|
||||
/* We don't set the MTU as we don't know whether it was set explicitly */
|
||||
|
||||
|
|
@ -1628,6 +1614,7 @@ finalize (GObject *object)
|
|||
NMDeviceEthernetPrivate *priv = NM_DEVICE_ETHERNET_GET_PRIVATE (self);
|
||||
|
||||
g_free (priv->perm_hw_addr);
|
||||
g_free (priv->initial_hw_addr);
|
||||
g_clear_object (&priv->supplicant.mgr);
|
||||
g_free (priv->subchan1);
|
||||
g_free (priv->subchan2);
|
||||
|
|
|
|||
|
|
@ -195,7 +195,6 @@ static gboolean
|
|||
check_connection_compatible (NMDevice *device, NMConnection *connection)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
const GByteArray *mac;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_infiniband_parent_class)->check_connection_compatible (device, connection))
|
||||
return FALSE;
|
||||
|
|
@ -208,9 +207,10 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
if (s_infiniband) {
|
||||
const char *mac;
|
||||
|
||||
mac = nm_setting_infiniband_get_mac_address (s_infiniband);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len,
|
||||
nm_device_get_hw_address (device), -1))
|
||||
if (mac && !nm_utils_hwaddr_matches (mac, -1, nm_device_get_hw_address (device), -1))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -225,7 +225,7 @@ complete_connection (NMDevice *device,
|
|||
GError **error)
|
||||
{
|
||||
NMSettingInfiniband *s_infiniband;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
const char *hw_address;
|
||||
|
||||
nm_utils_complete_generic (connection,
|
||||
|
|
@ -246,7 +246,7 @@ complete_connection (NMDevice *device,
|
|||
hw_address = nm_device_get_hw_address (device);
|
||||
if (setting_mac) {
|
||||
/* Make sure the setting MAC (if any) matches the device's MAC */
|
||||
if (!nm_utils_hwaddr_matches (setting_mac->data, setting_mac->len, hw_address, INFINIBAND_ALEN)) {
|
||||
if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_INFINIBAND_ERROR,
|
||||
NM_SETTING_INFINIBAND_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -254,12 +254,8 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
GByteArray *mac;
|
||||
|
||||
/* Lock the connection to this device by default */
|
||||
mac = nm_utils_hwaddr_atoba (hw_address, INFINIBAND_ALEN);
|
||||
g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NULL);
|
||||
g_byte_array_free (mac, TRUE);
|
||||
g_object_set (G_OBJECT (s_infiniband), NM_SETTING_INFINIBAND_MAC_ADDRESS, hw_address, NULL);
|
||||
}
|
||||
|
||||
if (!nm_setting_infiniband_get_transport_mode (s_infiniband))
|
||||
|
|
@ -273,7 +269,6 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
{
|
||||
NMSettingInfiniband *s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||
const char *mac = nm_device_get_hw_address (device);
|
||||
GByteArray *array;
|
||||
char *mode_path, *contents = NULL;
|
||||
const char *transport_mode = "datagram";
|
||||
|
||||
|
|
@ -282,11 +277,8 @@ update_connection (NMDevice *device, NMConnection *connection)
|
|||
nm_connection_add_setting (connection, (NMSetting *) s_infiniband);
|
||||
}
|
||||
|
||||
if (mac && !nm_utils_hwaddr_matches (mac, -1, NULL, INFINIBAND_ALEN)) {
|
||||
array = nm_utils_hwaddr_atoba (mac, INFINIBAND_ALEN);
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, array, NULL);
|
||||
g_byte_array_unref (array);
|
||||
}
|
||||
if (mac && !nm_utils_hwaddr_matches (mac, -1, NULL, INFINIBAND_ALEN))
|
||||
g_object_set (s_infiniband, NM_SETTING_INFINIBAND_MAC_ADDRESS, mac, NULL);
|
||||
|
||||
mode_path = g_strdup_printf ("/sys/class/net/%s/mode",
|
||||
ASSERT_VALID_PATH_COMPONENT (nm_device_get_iface (device)));
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ gboolean nm_device_bring_up (NMDevice *self, gboolean wait, gboolean *no_firmwar
|
|||
|
||||
void nm_device_take_down (NMDevice *self, gboolean block);
|
||||
|
||||
gboolean nm_device_set_hw_addr (NMDevice *device, const guint8 *addr,
|
||||
gboolean nm_device_set_hw_addr (NMDevice *device, const char *addr,
|
||||
const char *detail, guint64 hw_log_domain);
|
||||
|
||||
gboolean nm_device_ip_config_should_fail (NMDevice *self, gboolean ip6);
|
||||
|
|
@ -75,7 +75,7 @@ gboolean nm_device_activate_ip6_state_in_conf (NMDevice *device);
|
|||
gboolean nm_device_activate_ip6_state_in_wait (NMDevice *device);
|
||||
|
||||
void nm_device_set_dhcp_timeout (NMDevice *device, guint32 timeout);
|
||||
void nm_device_set_dhcp_anycast_address (NMDevice *device, guint8 *addr);
|
||||
void nm_device_set_dhcp_anycast_address (NMDevice *device, const char *addr);
|
||||
|
||||
gboolean nm_device_dhcp4_renew (NMDevice *device, gboolean release);
|
||||
gboolean nm_device_dhcp6_renew (NMDevice *device, gboolean release);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ G_DEFINE_TYPE (NMDeviceVlan, nm_device_vlan, NM_TYPE_DEVICE)
|
|||
#define NM_VLAN_ERROR (nm_vlan_error_quark ())
|
||||
|
||||
typedef struct {
|
||||
guint8 initial_hw_addr[ETH_ALEN];
|
||||
char *initial_hw_addr;
|
||||
|
||||
gboolean disposed;
|
||||
gboolean invalid;
|
||||
|
|
@ -88,12 +88,9 @@ update_initial_hw_address (NMDevice *dev)
|
|||
{
|
||||
NMDeviceVlan *self = NM_DEVICE_VLAN (dev);
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||
const char *mac_str;
|
||||
|
||||
mac_str = nm_device_get_hw_address (dev);
|
||||
nm_utils_hwaddr_aton (mac_str, priv->initial_hw_addr, ETH_ALEN);
|
||||
|
||||
_LOGD (LOGD_DEVICE | LOGD_VLAN, "read initial MAC address %s", mac_str);
|
||||
priv->initial_hw_addr = g_strdup (nm_device_get_hw_address (dev));
|
||||
_LOGD (LOGD_DEVICE | LOGD_VLAN, "read initial MAC address %s", priv->initial_hw_addr);
|
||||
}
|
||||
|
||||
static guint32
|
||||
|
|
@ -157,20 +154,20 @@ static gboolean
|
|||
match_hwaddr (NMDevice *device, NMConnection *connection, gboolean fail_if_no_hwaddr)
|
||||
{
|
||||
NMSettingWired *s_wired;
|
||||
const GByteArray *mac;
|
||||
const char *setting_mac;
|
||||
const char *device_mac;
|
||||
|
||||
s_wired = nm_connection_get_setting_wired (connection);
|
||||
if (!s_wired)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (!mac)
|
||||
setting_mac = nm_setting_wired_get_mac_address (s_wired);
|
||||
if (!setting_mac)
|
||||
return !fail_if_no_hwaddr;
|
||||
|
||||
device_mac = nm_device_get_hw_address (device);
|
||||
|
||||
return nm_utils_hwaddr_matches (mac->data, mac->len, device_mac, -1);
|
||||
return nm_utils_hwaddr_matches (setting_mac, -1, device_mac, -1);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
@ -333,7 +330,7 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
NMConnection *connection;
|
||||
NMSettingVlan *s_vlan;
|
||||
NMSettingWired *s_wired;
|
||||
const GByteArray *cloned_mac;
|
||||
const char *cloned_mac;
|
||||
NMActStageReturn ret;
|
||||
|
||||
g_return_val_if_fail (reason != NULL, NM_ACT_STAGE_RETURN_FAILURE);
|
||||
|
|
@ -352,8 +349,8 @@ act_stage1_prepare (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
if (s_wired) {
|
||||
/* Set device MAC address if the connection wants to change it */
|
||||
cloned_mac = nm_setting_wired_get_cloned_mac_address (s_wired);
|
||||
if (cloned_mac && (cloned_mac->len == ETH_ALEN))
|
||||
nm_device_set_hw_addr (dev, (const guint8 *) cloned_mac->data, "set", LOGD_VLAN);
|
||||
if (cloned_mac)
|
||||
nm_device_set_hw_addr (dev, cloned_mac, "set", LOGD_VLAN);
|
||||
}
|
||||
|
||||
s_vlan = nm_connection_get_setting_vlan (connection);
|
||||
|
|
@ -605,6 +602,17 @@ dispose (GObject *object)
|
|||
G_OBJECT_CLASS (nm_device_vlan_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMDeviceVlan *self = NM_DEVICE_VLAN (object);
|
||||
NMDeviceVlanPrivate *priv = NM_DEVICE_VLAN_GET_PRIVATE (self);
|
||||
|
||||
g_free (priv->initial_hw_addr);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_vlan_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
||||
{
|
||||
|
|
@ -620,6 +628,7 @@ nm_device_vlan_class_init (NMDeviceVlanClass *klass)
|
|||
object_class->get_property = get_property;
|
||||
object_class->set_property = set_property;
|
||||
object_class->dispose = dispose;
|
||||
object_class->finalize = finalize;
|
||||
|
||||
parent_class->update_initial_hw_address = update_initial_hw_address;
|
||||
parent_class->get_generic_capabilities = get_generic_capabilities;
|
||||
|
|
|
|||
|
|
@ -232,7 +232,7 @@ typedef struct {
|
|||
|
||||
/* Generic DHCP stuff */
|
||||
guint32 dhcp_timeout;
|
||||
GByteArray * dhcp_anycast_address;
|
||||
char * dhcp_anycast_address;
|
||||
|
||||
/* IP4 configuration info */
|
||||
NMIP4Config * ip4_config; /* Combined config from VPN, settings, and device */
|
||||
|
|
@ -6076,23 +6076,17 @@ nm_device_set_dhcp_timeout (NMDevice *self, guint32 timeout)
|
|||
}
|
||||
|
||||
void
|
||||
nm_device_set_dhcp_anycast_address (NMDevice *self, guint8 *addr)
|
||||
nm_device_set_dhcp_anycast_address (NMDevice *self, const char *addr)
|
||||
{
|
||||
NMDevicePrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_DEVICE (self));
|
||||
g_return_if_fail (!addr || nm_utils_hwaddr_valid (addr, ETH_ALEN));
|
||||
|
||||
priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
|
||||
if (priv->dhcp_anycast_address) {
|
||||
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
||||
priv->dhcp_anycast_address = NULL;
|
||||
}
|
||||
|
||||
if (addr) {
|
||||
priv->dhcp_anycast_address = g_byte_array_sized_new (ETH_ALEN);
|
||||
g_byte_array_append (priv->dhcp_anycast_address, addr, ETH_ALEN);
|
||||
}
|
||||
g_free (priv->dhcp_anycast_address);
|
||||
priv->dhcp_anycast_address = g_strdup (addr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -6984,46 +6978,47 @@ nm_device_update_hw_address (NMDevice *self)
|
|||
}
|
||||
|
||||
gboolean
|
||||
nm_device_set_hw_addr (NMDevice *self, const guint8 *addr,
|
||||
nm_device_set_hw_addr (NMDevice *self, const char *addr,
|
||||
const char *detail, guint64 hw_log_domain)
|
||||
{
|
||||
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||
char *mac_str = NULL;
|
||||
gboolean success = FALSE;
|
||||
const char *cur_addr = nm_device_get_hw_address (self);
|
||||
guint8 addr_bytes[NM_UTILS_HWADDR_LEN_MAX];
|
||||
|
||||
g_return_val_if_fail (addr != NULL, FALSE);
|
||||
|
||||
/* Do nothing if current MAC is same */
|
||||
if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, priv->hw_addr_len)) {
|
||||
if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) {
|
||||
_LOGD (LOGD_DEVICE | hw_log_domain, "no MAC address change needed");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
mac_str = nm_utils_hwaddr_ntoa (addr, priv->hw_addr_len);
|
||||
if (!nm_utils_hwaddr_aton (addr, addr_bytes, priv->hw_addr_len)) {
|
||||
_LOGW (LOGD_DEVICE | hw_log_domain, "invalid MAC address %s", addr);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Can't change MAC address while device is up */
|
||||
nm_device_take_down (self, FALSE);
|
||||
|
||||
success = nm_platform_link_set_address (nm_device_get_ip_ifindex (self), addr, priv->hw_addr_len);
|
||||
success = nm_platform_link_set_address (nm_device_get_ip_ifindex (self), addr_bytes, priv->hw_addr_len);
|
||||
if (success) {
|
||||
/* MAC address succesfully changed; update the current MAC to match */
|
||||
nm_device_update_hw_address (self);
|
||||
cur_addr = nm_device_get_hw_address (self);
|
||||
if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, priv->hw_addr_len)) {
|
||||
if (cur_addr && nm_utils_hwaddr_matches (cur_addr, -1, addr, -1)) {
|
||||
_LOGI (LOGD_DEVICE | hw_log_domain, "%s MAC address to %s",
|
||||
detail, mac_str);
|
||||
detail, addr);
|
||||
} else {
|
||||
_LOGW (LOGD_DEVICE | hw_log_domain,
|
||||
"new MAC address %s not successfully set", mac_str);
|
||||
"new MAC address %s not successfully set", addr);
|
||||
success = FALSE;
|
||||
}
|
||||
} else {
|
||||
_LOGW (LOGD_DEVICE | hw_log_domain, "failed to %s MAC address to %s",
|
||||
detail, mac_str);
|
||||
detail, addr);
|
||||
}
|
||||
nm_device_bring_up (self, TRUE, NULL);
|
||||
g_free (mac_str);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
|
@ -7316,8 +7311,7 @@ finalize (GObject *object)
|
|||
g_free (priv->driver_version);
|
||||
g_free (priv->firmware_version);
|
||||
g_free (priv->type_desc);
|
||||
if (priv->dhcp_anycast_address)
|
||||
g_byte_array_free (priv->dhcp_anycast_address, TRUE);
|
||||
g_free (priv->dhcp_anycast_address);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -150,12 +150,9 @@ complete_connection (NMDevice *device,
|
|||
}
|
||||
|
||||
if (!nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh)) {
|
||||
const guint8 anycast[ETH_ALEN] = { 0xC0, 0x27, 0xC0, 0x27, 0xC0, 0x27 };
|
||||
const char *anycast = "c0:27:c0:27:c0:27";
|
||||
|
||||
tmp = g_byte_array_sized_new (ETH_ALEN);
|
||||
g_byte_array_append (tmp, anycast, sizeof (anycast));
|
||||
g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, tmp, NULL);
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, anycast, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -225,8 +222,8 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
NMConnection *connection;
|
||||
NMSettingOlpcMesh *s_mesh;
|
||||
guint32 channel;
|
||||
const GByteArray *anycast_addr_array;
|
||||
guint8 *anycast_addr = NULL;
|
||||
GBytes *ssid;
|
||||
const char *anycast_addr;
|
||||
|
||||
connection = nm_device_get_connection (device);
|
||||
g_assert (connection);
|
||||
|
|
@ -237,14 +234,15 @@ act_stage2_config (NMDevice *device, NMDeviceStateReason *reason)
|
|||
channel = nm_setting_olpc_mesh_get_channel (s_mesh);
|
||||
if (channel != 0)
|
||||
_mesh_set_channel (self, channel);
|
||||
|
||||
ssid = nm_setting_olpc_mesh_get_ssid (s_mesh);
|
||||
nm_platform_mesh_set_ssid (nm_device_get_ifindex (device),
|
||||
nm_setting_olpc_mesh_get_ssid (s_mesh));
|
||||
|
||||
anycast_addr_array = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
|
||||
if (anycast_addr_array)
|
||||
anycast_addr = anycast_addr_array->data;
|
||||
g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
|
||||
anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh);
|
||||
nm_device_set_dhcp_anycast_address (device, anycast_addr);
|
||||
|
||||
return NM_ACT_STAGE_RETURN_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -116,8 +116,8 @@ static guint signals[LAST_SIGNAL] = { 0 };
|
|||
struct _NMDeviceWifiPrivate {
|
||||
gboolean disposed;
|
||||
|
||||
char * perm_hw_addr; /* Permanent MAC address */
|
||||
guint8 initial_hw_addr[ETH_ALEN]; /* Initial MAC address (as seen when NM starts) */
|
||||
char * perm_hw_addr; /* Permanent MAC address */
|
||||
char * initial_hw_addr; /* Initial MAC address (as seen when NM starts) */
|
||||
|
||||
gint8 invalid_strength_counter;
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ find_active_ap (NMDeviceWifi *self,
|
|||
_LOGD (LOGD_WIFI, "active BSSID: %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);
|
||||
|
||||
if (!nm_ethernet_address_is_valid (bssid))
|
||||
if (!nm_ethernet_address_is_valid (bssid, ETH_ALEN))
|
||||
return NULL;
|
||||
|
||||
ssid = nm_platform_wifi_get_ssid (ifindex);
|
||||
|
|
@ -399,31 +399,36 @@ find_active_ap (NMDeviceWifi *self,
|
|||
/* Find this SSID + BSSID in the device's AP list */
|
||||
for (iter = priv->ap_list; iter; iter = g_slist_next (iter)) {
|
||||
NMAccessPoint *ap = NM_AP (iter->data);
|
||||
const guint8 *ap_bssid = nm_ap_get_address (ap);
|
||||
const char *ap_bssid = nm_ap_get_address (ap);
|
||||
const GByteArray *ap_ssid = nm_ap_get_ssid (ap);
|
||||
NM80211Mode apmode;
|
||||
guint32 apfreq;
|
||||
|
||||
_LOGD (LOGD_WIFI, " AP: %s%s%s %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
_LOGD (LOGD_WIFI, " AP: %s%s%s %s",
|
||||
ap_ssid ? "'" : "",
|
||||
ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
|
||||
ap_ssid ? "'" : "",
|
||||
ap_bssid[0], ap_bssid[1], ap_bssid[2],
|
||||
ap_bssid[3], ap_bssid[4], ap_bssid[5]);
|
||||
ap_bssid);
|
||||
|
||||
if (ap == ignore_ap) {
|
||||
_LOGD (LOGD_WIFI, " ignored");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!nm_utils_hwaddr_matches (bssid, ETH_ALEN, ap_bssid, ETH_ALEN)) {
|
||||
if (!nm_utils_hwaddr_matches (bssid, ETH_ALEN, ap_bssid, -1)) {
|
||||
_LOGD (LOGD_WIFI, " BSSID mismatch");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((i == 0) && !nm_utils_same_ssid (ssid, ap_ssid, TRUE)) {
|
||||
_LOGD (LOGD_WIFI, " SSID mismatch");
|
||||
continue;
|
||||
if (i == 0) {
|
||||
if ( (ssid && !ap_ssid)
|
||||
|| (ap_ssid && !ssid)
|
||||
|| (ssid && ap_ssid && !nm_utils_same_ssid (ssid->data, ssid->len,
|
||||
ap_ssid->data, ap_ssid->len,
|
||||
TRUE))) {
|
||||
_LOGD (LOGD_WIFI, " SSID mismatch");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
apmode = nm_ap_get_mode (ap);
|
||||
|
|
@ -468,14 +473,14 @@ find_active_ap (NMDeviceWifi *self,
|
|||
* we can't match the AP based on frequency at all, just give up.
|
||||
*/
|
||||
if (match_nofreq && ((found_a_band != found_bg_band) || (devfreq == 0))) {
|
||||
const guint8 *ap_bssid = nm_ap_get_address (match_nofreq);
|
||||
const char *ap_bssid = nm_ap_get_address (match_nofreq);
|
||||
const GByteArray *ap_ssid = nm_ap_get_ssid (match_nofreq);
|
||||
|
||||
_LOGD (LOGD_WIFI, " matched %s%s%s %02x:%02x:%02x:%02x:%02x:%02x",
|
||||
_LOGD (LOGD_WIFI, " matched %s%s%s %s",
|
||||
ap_ssid ? "'" : "",
|
||||
ap_ssid ? nm_utils_escape_ssid (ap_ssid->data, ap_ssid->len) : "(none)",
|
||||
ap_ssid ? "'" : "",
|
||||
ap_bssid[0], ap_bssid[1], ap_bssid[2], ap_bssid[3], ap_bssid[4], ap_bssid[5]);
|
||||
ap_bssid);
|
||||
|
||||
active_ap = match_nofreq;
|
||||
goto done;
|
||||
|
|
@ -602,8 +607,11 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
|
|||
/* 0x02 means "locally administered" and should be OR-ed into
|
||||
* the first byte of IBSS BSSIDs.
|
||||
*/
|
||||
if ((bssid[0] & 0x02) && nm_ethernet_address_is_valid (bssid))
|
||||
nm_ap_set_address (priv->current_ap, bssid);
|
||||
if ((bssid[0] & 0x02) && nm_ethernet_address_is_valid (bssid, ETH_ALEN)) {
|
||||
char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
|
||||
nm_ap_set_address (priv->current_ap, bssid_str);
|
||||
g_free (bssid_str);
|
||||
}
|
||||
}
|
||||
|
||||
new_ap = find_active_ap (self, ignore_ap, FALSE);
|
||||
|
|
@ -619,31 +627,26 @@ periodic_update (NMDeviceWifi *self, NMAccessPoint *ignore_ap)
|
|||
}
|
||||
|
||||
if (new_ap != priv->current_ap) {
|
||||
const guint8 *new_bssid = NULL;
|
||||
const char *new_bssid = NULL;
|
||||
const GByteArray *new_ssid = NULL;
|
||||
const guint8 *old_bssid = NULL;
|
||||
const char *old_bssid = NULL;
|
||||
const GByteArray *old_ssid = NULL;
|
||||
char *old_addr = NULL, *new_addr = NULL;
|
||||
|
||||
if (new_ap) {
|
||||
new_bssid = nm_ap_get_address (new_ap);
|
||||
new_addr = nm_utils_hwaddr_ntoa (new_bssid, ETH_ALEN);
|
||||
new_ssid = nm_ap_get_ssid (new_ap);
|
||||
}
|
||||
|
||||
if (priv->current_ap) {
|
||||
old_bssid = nm_ap_get_address (priv->current_ap);
|
||||
old_addr = nm_utils_hwaddr_ntoa (old_bssid, ETH_ALEN);
|
||||
old_ssid = nm_ap_get_ssid (priv->current_ap);
|
||||
}
|
||||
|
||||
_LOGI (LOGD_WIFI, "roamed from BSSID %s (%s) to %s (%s)",
|
||||
old_addr ? old_addr : "(none)",
|
||||
old_bssid ? old_bssid : "(none)",
|
||||
old_ssid ? nm_utils_escape_ssid (old_ssid->data, old_ssid->len) : "(none)",
|
||||
new_addr ? new_addr : "(none)",
|
||||
new_bssid ? new_bssid : "(none)",
|
||||
new_ssid ? nm_utils_escape_ssid (new_ssid->data, new_ssid->len) : "(none)");
|
||||
g_free (old_addr);
|
||||
g_free (new_addr);
|
||||
|
||||
set_current_ap (self, new_ap, TRUE, FALSE);
|
||||
}
|
||||
|
|
@ -810,7 +813,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
const GByteArray *mac;
|
||||
const char *mac;
|
||||
const GSList *mac_blacklist, *mac_blacklist_iter;
|
||||
const char *mode;
|
||||
|
||||
|
|
@ -828,21 +831,19 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
mac = nm_setting_wireless_get_mac_address (s_wireless);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, priv->perm_hw_addr, -1))
|
||||
if (mac && !nm_utils_hwaddr_matches (mac, -1, priv->perm_hw_addr, -1))
|
||||
return FALSE;
|
||||
|
||||
/* Check for MAC address blacklist */
|
||||
mac_blacklist = nm_setting_wireless_get_mac_address_blacklist (s_wireless);
|
||||
for (mac_blacklist_iter = mac_blacklist; mac_blacklist_iter;
|
||||
mac_blacklist_iter = g_slist_next (mac_blacklist_iter)) {
|
||||
guint8 addr[ETH_ALEN];
|
||||
|
||||
if (!nm_utils_hwaddr_aton (mac_blacklist_iter->data, addr, ETH_ALEN)) {
|
||||
if (!nm_utils_hwaddr_valid (mac_blacklist_iter->data, ETH_ALEN)) {
|
||||
g_warn_if_reached ();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (nm_utils_hwaddr_matches (addr, ETH_ALEN, priv->perm_hw_addr, -1))
|
||||
if (nm_utils_hwaddr_matches (mac_blacklist_iter->data, -1, priv->perm_hw_addr, -1))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -980,10 +981,12 @@ complete_connection (NMDevice *device,
|
|||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
NMSetting8021x *s_8021x;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
char *str_ssid = NULL;
|
||||
NMAccessPoint *ap = NULL;
|
||||
const GByteArray *ssid = NULL;
|
||||
GByteArray *tmp_ssid = NULL;
|
||||
GBytes *setting_ssid = NULL;
|
||||
GSList *iter;
|
||||
gboolean hidden = FALSE;
|
||||
|
||||
|
|
@ -1001,8 +1004,8 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (!ssid || !ssid->len) {
|
||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (!setting_ssid || g_bytes_get_size (setting_ssid) == 0) {
|
||||
g_set_error_literal (error,
|
||||
NM_WIFI_ERROR,
|
||||
NM_WIFI_ERROR_CONNECTION_INVALID,
|
||||
|
|
@ -1065,7 +1068,13 @@ complete_connection (NMDevice *device,
|
|||
* for the SSID. The AP object will still be used for encryption
|
||||
* settings and such.
|
||||
*/
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
setting_ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (setting_ssid) {
|
||||
ssid = tmp_ssid = g_byte_array_new ();
|
||||
g_byte_array_append (tmp_ssid,
|
||||
g_bytes_get_data (setting_ssid, NULL),
|
||||
g_bytes_get_size (setting_ssid));
|
||||
}
|
||||
}
|
||||
|
||||
if (ssid == NULL) {
|
||||
|
|
@ -1085,8 +1094,11 @@ complete_connection (NMDevice *device,
|
|||
if (!nm_ap_complete_connection (ap,
|
||||
connection,
|
||||
is_manf_default_ssid (ssid),
|
||||
error))
|
||||
error)) {
|
||||
if (tmp_ssid)
|
||||
g_byte_array_unref (tmp_ssid);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* The kernel doesn't support Ad-Hoc WPA connections well at this time,
|
||||
|
|
@ -1098,11 +1110,13 @@ complete_connection (NMDevice *device,
|
|||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
"WPA Ad-Hoc disabled due to kernel bugs");
|
||||
if (tmp_ssid)
|
||||
g_byte_array_unref (tmp_ssid);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_assert (ssid);
|
||||
str_ssid = nm_utils_ssid_to_utf8 (ssid);
|
||||
str_ssid = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
|
||||
nm_utils_complete_generic (connection,
|
||||
NM_SETTING_WIRELESS_SETTING_NAME,
|
||||
|
|
@ -1112,6 +1126,8 @@ complete_connection (NMDevice *device,
|
|||
NULL,
|
||||
TRUE);
|
||||
g_free (str_ssid);
|
||||
if (tmp_ssid)
|
||||
g_byte_array_unref (tmp_ssid);
|
||||
|
||||
if (hidden)
|
||||
g_object_set (s_wifi, NM_SETTING_WIRELESS_HIDDEN, TRUE, NULL);
|
||||
|
|
@ -1119,7 +1135,7 @@ complete_connection (NMDevice *device,
|
|||
setting_mac = nm_setting_wireless_get_mac_address (s_wifi);
|
||||
if (setting_mac) {
|
||||
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
|
||||
if (!nm_utils_hwaddr_matches (setting_mac->data, setting_mac->len, priv->perm_hw_addr, -1)) {
|
||||
if (!nm_utils_hwaddr_matches (setting_mac, -1, priv->perm_hw_addr, -1)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -1127,7 +1143,6 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
GByteArray *mac;
|
||||
guint8 perm_hw_addr[ETH_ALEN];
|
||||
|
||||
/* Lock the connection to this device by default if it uses a
|
||||
|
|
@ -1136,9 +1151,9 @@ complete_connection (NMDevice *device,
|
|||
nm_utils_hwaddr_aton (priv->perm_hw_addr, perm_hw_addr, ETH_ALEN);
|
||||
if ( !(perm_hw_addr[0] & 0x02)
|
||||
&& !nm_utils_hwaddr_matches (perm_hw_addr, ETH_ALEN, NULL, ETH_ALEN)) {
|
||||
mac = nm_utils_hwaddr_atoba (priv->perm_hw_addr, ETH_ALEN);
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MAC_ADDRESS, mac, NULL);
|
||||
g_byte_array_free (mac, TRUE);
|
||||
g_object_set (G_OBJECT (s_wifi),
|
||||
NM_SETTING_WIRELESS_MAC_ADDRESS, priv->perm_hw_addr,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1389,7 +1404,6 @@ scanning_allowed (NMDeviceWifi *self)
|
|||
if (connection) {
|
||||
NMSettingWireless *s_wifi;
|
||||
const char *ip4_method = NULL;
|
||||
const GByteArray *bssid;
|
||||
|
||||
/* Don't scan when a shared connection is active; it makes drivers mad */
|
||||
ip4_method = nm_utils_get_ip_config_method (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
|
|
@ -1403,8 +1417,7 @@ scanning_allowed (NMDeviceWifi *self)
|
|||
*/
|
||||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wifi);
|
||||
bssid = nm_setting_wireless_get_bssid (s_wifi);
|
||||
if (bssid && bssid->len == ETH_ALEN)
|
||||
if (nm_setting_wireless_get_bssid (s_wifi))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
@ -1476,20 +1489,25 @@ build_hidden_probe_list (NMDeviceWifi *self)
|
|||
hidden_filter_func,
|
||||
NULL);
|
||||
if (connections && connections->data) {
|
||||
ssids = g_ptr_array_sized_new (max_scan_ssids - 1);
|
||||
g_ptr_array_add (ssids, nullssid); /* Add wildcard SSID */
|
||||
ssids = g_ptr_array_new_full (max_scan_ssids - 1, (GDestroyNotify) g_byte_array_unref);
|
||||
g_ptr_array_add (ssids, g_byte_array_ref (nullssid)); /* Add wildcard SSID */
|
||||
}
|
||||
|
||||
for (iter = connections; iter; iter = g_slist_next (iter)) {
|
||||
NMConnection *connection = iter->data;
|
||||
NMSettingWireless *s_wifi;
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
GByteArray *ssid_array;
|
||||
|
||||
s_wifi = (NMSettingWireless *) nm_connection_get_setting_wireless (connection);
|
||||
g_assert (s_wifi);
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
g_assert (ssid);
|
||||
g_ptr_array_add (ssids, (gpointer) ssid);
|
||||
ssid_array = g_byte_array_new ();
|
||||
g_byte_array_append (ssid_array,
|
||||
g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
g_ptr_array_add (ssids, ssid_array);
|
||||
}
|
||||
g_slist_free (connections);
|
||||
|
||||
|
|
@ -1516,11 +1534,13 @@ request_wireless_scan (gpointer user_data)
|
|||
|
||||
if (nm_logging_enabled (LOGL_DEBUG, LOGD_WIFI_SCAN)) {
|
||||
if (ssids) {
|
||||
const GByteArray *ssid;
|
||||
guint i;
|
||||
char *foo;
|
||||
|
||||
for (i = 0; i < ssids->len; i++) {
|
||||
foo = nm_utils_ssid_to_utf8 (g_ptr_array_index (ssids, i));
|
||||
ssid = g_ptr_array_index (ssids, i);
|
||||
foo = nm_utils_ssid_to_utf8 (ssid->data, ssid->len);
|
||||
_LOGD (LOGD_WIFI_SCAN, "(%d) probe scanning SSID '%s'",
|
||||
i, foo ? foo : "<hidden>");
|
||||
g_free (foo);
|
||||
|
|
@ -1536,10 +1556,8 @@ request_wireless_scan (gpointer user_data)
|
|||
nm_device_add_pending_action (NM_DEVICE (self), "scan", TRUE);
|
||||
}
|
||||
|
||||
if (ssids) {
|
||||
/* Elements owned by the connections, so we don't free them here */
|
||||
g_ptr_array_free (ssids, TRUE);
|
||||
}
|
||||
if (ssids)
|
||||
g_ptr_array_unref (ssids);
|
||||
} else
|
||||
_LOGD (LOGD_WIFI_SCAN, "scan requested but not allowed at this time");
|
||||
|
||||
|
|
@ -1639,7 +1657,7 @@ supplicant_iface_scan_done_cb (NMSupplicantInterface *iface,
|
|||
static void
|
||||
try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
|
||||
{
|
||||
const guint8 *bssid;
|
||||
const char *bssid;
|
||||
const GSList *connections, *iter;
|
||||
|
||||
g_return_if_fail (nm_ap_get_ssid (ap) == NULL);
|
||||
|
|
@ -1657,16 +1675,17 @@ try_fill_ssid_for_hidden_ap (NMAccessPoint *ap)
|
|||
s_wifi = nm_connection_get_setting_wireless (connection);
|
||||
if (s_wifi) {
|
||||
if (nm_settings_connection_has_seen_bssid (NM_SETTINGS_CONNECTION (connection), bssid)) {
|
||||
nm_ap_set_ssid (ap, nm_setting_wireless_get_ssid (s_wifi));
|
||||
GBytes *ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
|
||||
nm_ap_set_ssid (ap,
|
||||
g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
|
||||
|
||||
/*
|
||||
* merge_scanned_ap
|
||||
*
|
||||
|
|
@ -1686,7 +1705,7 @@ merge_scanned_ap (NMDeviceWifi *self,
|
|||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMAccessPoint *found_ap = NULL;
|
||||
const GByteArray *ssid;
|
||||
const guint8 *bssid;
|
||||
const char *bssid;
|
||||
gboolean strict_match = TRUE;
|
||||
|
||||
/* Let the manager try to fill in the SSID from seen-bssids lists */
|
||||
|
|
@ -1699,14 +1718,13 @@ merge_scanned_ap (NMDeviceWifi *self,
|
|||
ssid = nm_ap_get_ssid (merge_ap);
|
||||
if (ssid && (nm_utils_is_empty_ssid (ssid->data, ssid->len) == FALSE)) {
|
||||
/* Yay, matched it, no longer treat as hidden */
|
||||
_LOGD (LOGD_WIFI_SCAN, "matched hidden AP " MAC_FMT " => '%s'",
|
||||
MAC_ARG (bssid),
|
||||
nm_utils_escape_ssid (ssid->data, ssid->len));
|
||||
_LOGD (LOGD_WIFI_SCAN, "matched hidden AP %s => '%s'",
|
||||
bssid, nm_utils_escape_ssid (ssid->data, ssid->len));
|
||||
nm_ap_set_broadcast (merge_ap, FALSE);
|
||||
} else {
|
||||
/* Didn't have an entry for this AP in the database */
|
||||
_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP " MAC_FMT,
|
||||
MAC_ARG (bssid));
|
||||
_LOGD (LOGD_WIFI_SCAN, "failed to match hidden AP %s",
|
||||
bssid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1723,9 +1741,9 @@ merge_scanned_ap (NMDeviceWifi *self,
|
|||
if (!found_ap)
|
||||
found_ap = nm_ap_match_in_list (merge_ap, priv->ap_list, strict_match);
|
||||
if (found_ap) {
|
||||
_LOGD (LOGD_WIFI_SCAN, "merging AP '%s' " MAC_FMT " (%p) with existing (%p)",
|
||||
_LOGD (LOGD_WIFI_SCAN, "merging AP '%s' %s (%p) with existing (%p)",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
|
||||
MAC_ARG (bssid),
|
||||
bssid,
|
||||
merge_ap,
|
||||
found_ap);
|
||||
|
||||
|
|
@ -1745,10 +1763,9 @@ merge_scanned_ap (NMDeviceWifi *self,
|
|||
nm_ap_set_fake (found_ap, FALSE);
|
||||
} else {
|
||||
/* New entry in the list */
|
||||
_LOGD (LOGD_WIFI_SCAN, "adding new AP '%s' " MAC_FMT " (%p)",
|
||||
_LOGD (LOGD_WIFI_SCAN, "adding new AP '%s' %s (%p)",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
|
||||
MAC_ARG (bssid),
|
||||
merge_ap);
|
||||
bssid, merge_ap);
|
||||
|
||||
g_object_ref (merge_ap);
|
||||
priv->ap_list = g_slist_prepend (priv->ap_list, merge_ap);
|
||||
|
|
@ -1804,14 +1821,14 @@ cull_scan_list (NMDeviceWifi *self)
|
|||
/* Remove outdated APs */
|
||||
for (elt = outdated_list; elt; elt = g_slist_next (elt)) {
|
||||
NMAccessPoint *outdated_ap = NM_AP (elt->data);
|
||||
const guint8 *bssid;
|
||||
const char *bssid;
|
||||
const GByteArray *ssid;
|
||||
|
||||
bssid = nm_ap_get_address (outdated_ap);
|
||||
ssid = nm_ap_get_ssid (outdated_ap);
|
||||
_LOGD (LOGD_WIFI_SCAN,
|
||||
" removing %02x:%02x:%02x:%02x:%02x:%02x (%s%s%s)",
|
||||
bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5],
|
||||
" removing %s (%s%s%s)",
|
||||
bssid,
|
||||
ssid ? "'" : "",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)",
|
||||
ssid ? "'" : "");
|
||||
|
|
@ -2195,7 +2212,7 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||
if (devstate == NM_DEVICE_STATE_CONFIG) {
|
||||
NMConnection *connection;
|
||||
NMSettingWireless *s_wifi;
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
|
||||
connection = nm_device_get_connection (NM_DEVICE (self));
|
||||
g_return_if_fail (connection);
|
||||
|
|
@ -2210,7 +2227,8 @@ supplicant_iface_state_cb (NMSupplicantInterface *iface,
|
|||
"Activation: (wifi) Stage 2 of 5 (Device Configure) successful. %s '%s'.",
|
||||
priv->mode == NM_802_11_MODE_AP ? "Started Wi-Fi Hotspot" :
|
||||
"Connected to wireless network",
|
||||
ssid ? nm_utils_escape_ssid (ssid->data, ssid->len) : "(none)");
|
||||
ssid ? nm_utils_escape_ssid (g_bytes_get_data (ssid, NULL),
|
||||
g_bytes_get_size (ssid)) : "(none)");
|
||||
nm_device_activate_schedule_stage3_ip_config_start (device);
|
||||
} else if (devstate == NM_DEVICE_STATE_ACTIVATED)
|
||||
periodic_update (self, NULL);
|
||||
|
|
@ -2533,7 +2551,7 @@ update_permanent_hw_address (NMDevice *device)
|
|||
errno = 0;
|
||||
ret = ioctl (fd, SIOCETHTOOL, &req);
|
||||
errsv = errno;
|
||||
if ((ret < 0) || !nm_ethernet_address_is_valid (epaddr->data)) {
|
||||
if ((ret < 0) || !nm_ethernet_address_is_valid (epaddr->data, ETH_ALEN)) {
|
||||
_LOGD (LOGD_HW | LOGD_ETHER, "unable to read permanent MAC address (error %d)",
|
||||
errsv);
|
||||
/* Fall back to current address */
|
||||
|
|
@ -2551,15 +2569,13 @@ update_initial_hw_address (NMDevice *device)
|
|||
{
|
||||
NMDeviceWifi *self = NM_DEVICE_WIFI (device);
|
||||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
const char *mac_str;
|
||||
|
||||
/* This sets initial MAC address from current MAC address. It should only
|
||||
* be called from NMDevice constructor() to really get the initial address.
|
||||
*/
|
||||
mac_str = nm_device_get_hw_address (device);
|
||||
nm_utils_hwaddr_aton (mac_str, priv->initial_hw_addr, ETH_ALEN);
|
||||
priv->initial_hw_addr = g_strdup (nm_device_get_hw_address (device));
|
||||
|
||||
_LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", mac_str);
|
||||
_LOGD (LOGD_DEVICE | LOGD_ETHER, "read initial MAC address %s", priv->initial_hw_addr);
|
||||
}
|
||||
|
||||
static NMActStageReturn
|
||||
|
|
@ -2572,7 +2588,7 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||
NMActRequest *req;
|
||||
NMConnection *connection;
|
||||
NMSettingWireless *s_wireless;
|
||||
const GByteArray *cloned_mac;
|
||||
const char *cloned_mac;
|
||||
GSList *iter;
|
||||
const char *mode;
|
||||
const char *ap_path;
|
||||
|
|
@ -2615,8 +2631,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||
|
||||
/* Set spoof MAC to the interface */
|
||||
cloned_mac = nm_setting_wireless_get_cloned_mac_address (s_wireless);
|
||||
if (cloned_mac && (cloned_mac->len == ETH_ALEN))
|
||||
nm_device_set_hw_addr (device, (const guint8 *) cloned_mac->data, "set", LOGD_WIFI);
|
||||
if (cloned_mac)
|
||||
nm_device_set_hw_addr (device, cloned_mac, "set", LOGD_WIFI);
|
||||
|
||||
/* AP mode never uses a specific object or existing scanned AP */
|
||||
if (priv->mode != NM_802_11_MODE_AP) {
|
||||
|
|
@ -2653,12 +2669,8 @@ act_stage1_prepare (NMDevice *device, NMDeviceStateReason *reason)
|
|||
|
||||
if (nm_ap_get_mode (ap) == NM_802_11_MODE_INFRA)
|
||||
nm_ap_set_broadcast (ap, FALSE);
|
||||
else if (nm_ap_is_hotspot (ap)) {
|
||||
guint8 addr[ETH_ALEN];
|
||||
|
||||
nm_utils_hwaddr_aton (nm_device_get_hw_address (device), addr, ETH_ALEN);
|
||||
nm_ap_set_address (ap, addr);
|
||||
}
|
||||
else if (nm_ap_is_hotspot (ap))
|
||||
nm_ap_set_address (ap, nm_device_get_hw_address (device));
|
||||
|
||||
priv->ap_list = g_slist_prepend (priv->ap_list, ap);
|
||||
nm_ap_export_to_dbus (ap);
|
||||
|
|
@ -3021,8 +3033,11 @@ activation_success_handler (NMDevice *device)
|
|||
* the BSSID off the card and fill in the BSSID of the activation AP.
|
||||
*/
|
||||
nm_platform_wifi_get_bssid (ifindex, bssid);
|
||||
if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap)))
|
||||
nm_ap_set_address (ap, bssid);
|
||||
if (!nm_ethernet_address_is_valid (nm_ap_get_address (ap), -1)) {
|
||||
char *bssid_str = nm_utils_hwaddr_ntoa (bssid, ETH_ALEN);
|
||||
nm_ap_set_address (ap, bssid_str);
|
||||
g_free (bssid_str);
|
||||
}
|
||||
if (!nm_ap_get_freq (ap))
|
||||
nm_ap_set_freq (ap, nm_platform_wifi_get_frequency (ifindex));
|
||||
if (!nm_ap_get_max_bitrate (ap))
|
||||
|
|
@ -3036,9 +3051,11 @@ activation_success_handler (NMDevice *device)
|
|||
* instead.
|
||||
*/
|
||||
|
||||
/* If the better match was a hidden AP, update it's SSID */
|
||||
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len))
|
||||
nm_ap_set_ssid (tmp_ap, nm_ap_get_ssid (ap));
|
||||
/* If the better match was a hidden AP, update its SSID */
|
||||
if (!ssid || nm_utils_is_empty_ssid (ssid->data, ssid->len)) {
|
||||
ssid = nm_ap_get_ssid (ap);
|
||||
nm_ap_set_ssid (tmp_ap, ssid->data, ssid->len);
|
||||
}
|
||||
|
||||
nm_active_connection_set_specific_object (NM_ACTIVE_CONNECTION (req),
|
||||
nm_ap_get_dbus_path (tmp_ap));
|
||||
|
|
@ -3255,6 +3272,7 @@ finalize (GObject *object)
|
|||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
|
||||
g_free (priv->perm_hw_addr);
|
||||
g_free (priv->initial_hw_addr);
|
||||
|
||||
G_OBJECT_CLASS (nm_device_wifi_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ verify_adhoc (NMSettingWirelessSecurity *s_wsec,
|
|||
|
||||
gboolean
|
||||
nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
||||
const guint8 *ap_bssid,
|
||||
const char *bssid,
|
||||
NM80211Mode ap_mode,
|
||||
guint32 ap_flags,
|
||||
guint32 ap_wpa_flags,
|
||||
|
|
@ -478,7 +478,7 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||
NMSettingWireless *s_wifi;
|
||||
NMSettingWirelessSecurity *s_wsec;
|
||||
NMSetting8021x *s_8021x;
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid, *ap_ssid_bytes;
|
||||
const char *mode, *key_mgmt, *auth_alg, *leap_username;
|
||||
gboolean adhoc = FALSE;
|
||||
|
||||
|
|
@ -488,26 +488,22 @@ nm_ap_utils_complete_connection (const GByteArray *ap_ssid,
|
|||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
||||
/* Fill in missing SSID */
|
||||
ap_ssid_bytes = g_bytes_new (ap_ssid->data, ap_ssid->len);
|
||||
ssid = nm_setting_wireless_get_ssid (s_wifi);
|
||||
if (!ssid)
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid, NULL);
|
||||
else if ( ssid->len != ap_ssid->len
|
||||
|| memcmp (ssid->data, ap_ssid->data, ssid->len)) {
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, ap_ssid_bytes, NULL);
|
||||
else if (!g_bytes_equal (ssid, ap_ssid_bytes)) {
|
||||
g_set_error_literal (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
"Setting SSID did not match AP SSID");
|
||||
g_bytes_unref (ap_ssid_bytes);
|
||||
return FALSE;
|
||||
}
|
||||
g_bytes_unref (ap_ssid_bytes);
|
||||
|
||||
if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi)) {
|
||||
GByteArray *bssid;
|
||||
|
||||
bssid = g_byte_array_sized_new (ETH_ALEN);
|
||||
g_byte_array_append (bssid, ap_bssid, ETH_ALEN);
|
||||
if (lock_bssid && !nm_setting_wireless_get_bssid (s_wifi))
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
|
||||
g_byte_array_free (bssid, TRUE);
|
||||
}
|
||||
|
||||
/* And mode */
|
||||
mode = nm_setting_wireless_get_mode (s_wifi);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#include <nm-setting-8021x.h>
|
||||
|
||||
gboolean nm_ap_utils_complete_connection (const GByteArray *ssid,
|
||||
const guint8 *bssid,
|
||||
const char *bssid,
|
||||
NM80211Mode mode,
|
||||
guint32 flags,
|
||||
guint32 wpa_flags,
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef struct
|
|||
|
||||
/* Scanned or cached values */
|
||||
GByteArray * ssid;
|
||||
guint8 address[ETH_ALEN];
|
||||
char * address;
|
||||
NM80211Mode mode;
|
||||
gint8 strength;
|
||||
guint32 freq; /* Frequency in MHz; ie 2412 (== 2.412 GHz) */
|
||||
|
|
@ -101,6 +101,7 @@ finalize (GObject *object)
|
|||
g_free (priv->supplicant_path);
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
g_free (priv->address);
|
||||
|
||||
G_OBJECT_CLASS (nm_ap_parent_class)->finalize (object);
|
||||
}
|
||||
|
|
@ -110,6 +111,7 @@ set_property (GObject *object, guint prop_id,
|
|||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMAccessPoint *ap = NM_AP (object);
|
||||
GByteArray *ssid;
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_FLAGS:
|
||||
|
|
@ -122,7 +124,11 @@ set_property (GObject *object, guint prop_id,
|
|||
nm_ap_set_rsn_flags (ap, g_value_get_uint (value));
|
||||
break;
|
||||
case PROP_SSID:
|
||||
nm_ap_set_ssid (ap, (GByteArray *) g_value_get_boxed (value));
|
||||
ssid = g_value_get_boxed (value);
|
||||
if (ssid)
|
||||
nm_ap_set_ssid (ap, ssid->data, ssid->len);
|
||||
else
|
||||
nm_ap_set_ssid (ap, NULL, 0);
|
||||
break;
|
||||
case PROP_FREQUENCY:
|
||||
nm_ap_set_freq (ap, g_value_get_uint (value));
|
||||
|
|
@ -175,7 +181,7 @@ get_property (GObject *object, guint prop_id,
|
|||
g_value_set_uint (value, priv->freq);
|
||||
break;
|
||||
case PROP_HW_ADDRESS:
|
||||
g_value_take_string (value, nm_utils_hwaddr_ntoa (&priv->address, ETH_ALEN));
|
||||
g_value_set_string (value, priv->address);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_value_set_uint (value, priv->mode);
|
||||
|
|
@ -392,7 +398,6 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|||
|
||||
if (!strcmp (key, "SSID")) {
|
||||
guint32 len = MIN (32, array->len);
|
||||
GByteArray *ssid;
|
||||
|
||||
/* Stupid ieee80211 layer uses <hidden> */
|
||||
if (((len == 8) || (len == 9))
|
||||
|
|
@ -402,14 +407,15 @@ foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
|||
if (nm_utils_is_empty_ssid ((const guint8 *) array->data, len))
|
||||
return;
|
||||
|
||||
ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (ssid, (const guint8 *) array->data, len);
|
||||
nm_ap_set_ssid (ap, ssid);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
nm_ap_set_ssid (ap, (const guint8 *) array->data, len);
|
||||
} else if (!strcmp (key, "BSSID")) {
|
||||
char *addr;
|
||||
|
||||
if (array->len != ETH_ALEN)
|
||||
return;
|
||||
nm_ap_set_address (ap, (guint8 *) array->data);
|
||||
addr = nm_utils_hwaddr_ntoa (array->data, array->len);
|
||||
nm_ap_set_address (ap, addr);
|
||||
g_free (addr);
|
||||
} else if (!strcmp (key, "Rates")) {
|
||||
guint32 maxrate = 0;
|
||||
int i;
|
||||
|
|
@ -469,7 +475,7 @@ NMAccessPoint *
|
|||
nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
|
||||
{
|
||||
NMAccessPoint *ap;
|
||||
const guint8 *addr;
|
||||
const char *addr;
|
||||
const char bad_bssid1[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
const char bad_bssid2[ETH_ALEN] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
|
|
@ -484,8 +490,8 @@ nm_ap_new_from_properties (const char *supplicant_path, GHashTable *properties)
|
|||
|
||||
/* ignore APs with invalid BSSIDs */
|
||||
addr = nm_ap_get_address (ap);
|
||||
if ( !(memcmp (addr, bad_bssid1, ETH_ALEN))
|
||||
|| !(memcmp (addr, bad_bssid2, ETH_ALEN))) {
|
||||
if ( nm_utils_hwaddr_matches (addr, -1, bad_bssid1, ETH_ALEN)
|
||||
|| nm_utils_hwaddr_matches (addr, -1, bad_bssid2, ETH_ALEN)) {
|
||||
g_object_unref (ap);
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -583,7 +589,7 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||
NMAccessPoint *ap;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessSecurity *s_wireless_sec;
|
||||
const GByteArray *ssid;
|
||||
GBytes *ssid;
|
||||
const char *mode, *band, *key_mgmt;
|
||||
guint32 channel;
|
||||
NM80211ApSecurityFlags flags;
|
||||
|
|
@ -596,11 +602,11 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
g_return_val_if_fail (ssid != NULL, NULL);
|
||||
g_return_val_if_fail (ssid->len > 0, NULL);
|
||||
g_return_val_if_fail (g_bytes_get_size (ssid) > 0, NULL);
|
||||
|
||||
ap = nm_ap_new ();
|
||||
nm_ap_set_fake (ap, TRUE);
|
||||
nm_ap_set_ssid (ap, ssid);
|
||||
nm_ap_set_ssid (ap, g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
|
||||
|
||||
// FIXME: bssid too?
|
||||
|
||||
|
|
@ -706,10 +712,6 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define MAC_ARG(x) ((guint8*)(x))[0],((guint8*)(x))[1],((guint8*)(x))[2],((guint8*)(x))[3],((guint8*)(x))[4],((guint8*)(x))[5]
|
||||
|
||||
void
|
||||
nm_ap_dump (NMAccessPoint *ap, const char *prefix)
|
||||
{
|
||||
|
|
@ -723,7 +725,7 @@ nm_ap_dump (NMAccessPoint *ap, const char *prefix)
|
|||
prefix,
|
||||
priv->ssid ? nm_utils_escape_ssid (priv->ssid->data, priv->ssid->len) : "(none)",
|
||||
ap);
|
||||
nm_log_dbg (LOGD_WIFI_SCAN, " BSSID " MAC_FMT, MAC_ARG (priv->address));
|
||||
nm_log_dbg (LOGD_WIFI_SCAN, " BSSID %s", priv->address);
|
||||
nm_log_dbg (LOGD_WIFI_SCAN, " mode %d", priv->mode);
|
||||
nm_log_dbg (LOGD_WIFI_SCAN, " flags 0x%X", priv->flags);
|
||||
nm_log_dbg (LOGD_WIFI_SCAN, " wpa flags 0x%X", priv->wpa_flags);
|
||||
|
|
@ -772,20 +774,18 @@ const GByteArray * nm_ap_get_ssid (const NMAccessPoint *ap)
|
|||
}
|
||||
|
||||
void
|
||||
nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
|
||||
nm_ap_set_ssid (NMAccessPoint *ap, const guint8 *ssid, gsize len)
|
||||
{
|
||||
NMAccessPointPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_AP (ap));
|
||||
g_return_if_fail (ssid == NULL || len > 0);
|
||||
|
||||
priv = NM_AP_GET_PRIVATE (ap);
|
||||
|
||||
if (ssid == priv->ssid)
|
||||
return;
|
||||
|
||||
/* same SSID */
|
||||
if ((ssid && priv->ssid) && (ssid->len == priv->ssid->len)) {
|
||||
if (!memcmp (ssid->data, priv->ssid->data, ssid->len))
|
||||
if ((ssid && priv->ssid) && (len == priv->ssid->len)) {
|
||||
if (!memcmp (ssid, priv->ssid->data, len))
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -795,14 +795,8 @@ nm_ap_set_ssid (NMAccessPoint *ap, const GByteArray * ssid)
|
|||
}
|
||||
|
||||
if (ssid) {
|
||||
/* Should never get zero-length SSIDs */
|
||||
g_warn_if_fail (ssid->len > 0);
|
||||
|
||||
if (ssid->len) {
|
||||
priv->ssid = g_byte_array_sized_new (ssid->len);
|
||||
priv->ssid->len = ssid->len;
|
||||
memcpy (priv->ssid->data, ssid->data, ssid->len);
|
||||
}
|
||||
priv->ssid = g_byte_array_new ();
|
||||
g_byte_array_append (priv->ssid, ssid, len);
|
||||
}
|
||||
|
||||
g_object_notify (G_OBJECT (ap), NM_AP_SSID);
|
||||
|
|
@ -883,7 +877,7 @@ nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags)
|
|||
* Get/set functions for address
|
||||
*
|
||||
*/
|
||||
const guint8 *
|
||||
const char *
|
||||
nm_ap_get_address (const NMAccessPoint *ap)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||
|
|
@ -892,17 +886,19 @@ nm_ap_get_address (const NMAccessPoint *ap)
|
|||
}
|
||||
|
||||
void
|
||||
nm_ap_set_address (NMAccessPoint *ap, const guint8 *addr)
|
||||
nm_ap_set_address (NMAccessPoint *ap, const char *addr)
|
||||
{
|
||||
NMAccessPointPrivate *priv;
|
||||
|
||||
g_return_if_fail (NM_IS_AP (ap));
|
||||
g_return_if_fail (addr != NULL);
|
||||
g_return_if_fail (nm_utils_hwaddr_valid (addr, ETH_ALEN));
|
||||
|
||||
priv = NM_AP_GET_PRIVATE (ap);
|
||||
|
||||
if (!nm_utils_hwaddr_matches (addr, ETH_ALEN, priv->address, sizeof (priv->address))) {
|
||||
memcpy (NM_AP_GET_PRIVATE (ap)->address, addr, sizeof (priv->address));
|
||||
if (!priv->address || !nm_utils_hwaddr_matches (addr, -1, priv->address, -1)) {
|
||||
g_free (priv->address);
|
||||
priv->address = g_strdup (addr);
|
||||
g_object_notify (G_OBJECT (ap), NM_AP_HW_ADDRESS);
|
||||
}
|
||||
}
|
||||
|
|
@ -1106,9 +1102,10 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||
NMAccessPointPrivate *priv;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessSecurity *s_wireless_sec;
|
||||
GBytes *ssid;
|
||||
const char *mode;
|
||||
const char *band;
|
||||
const GByteArray *bssid;
|
||||
const char *bssid;
|
||||
guint32 channel;
|
||||
|
||||
g_return_val_if_fail (NM_IS_AP (self), FALSE);
|
||||
|
|
@ -1120,11 +1117,19 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||
if (s_wireless == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), priv->ssid, TRUE))
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
if ( (ssid && !priv->ssid)
|
||||
|| (priv->ssid && !ssid))
|
||||
return FALSE;
|
||||
|
||||
if ( ssid && priv->ssid &&
|
||||
!nm_utils_same_ssid (g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid),
|
||||
priv->ssid->data, priv->ssid->len,
|
||||
TRUE))
|
||||
return FALSE;
|
||||
|
||||
bssid = nm_setting_wireless_get_bssid (s_wireless);
|
||||
if (bssid && !nm_utils_hwaddr_matches (bssid->data, bssid->len, priv->address, ETH_ALEN))
|
||||
if (bssid && !nm_utils_hwaddr_matches (bssid, -1, priv->address, -1))
|
||||
return FALSE;
|
||||
|
||||
mode = nm_setting_wireless_get_mode (s_wireless);
|
||||
|
|
@ -1221,23 +1226,28 @@ nm_ap_match_in_list (NMAccessPoint *find_ap,
|
|||
for (iter = ap_list; iter; iter = g_slist_next (iter)) {
|
||||
NMAccessPoint * list_ap = NM_AP (iter->data);
|
||||
const GByteArray * list_ssid = nm_ap_get_ssid (list_ap);
|
||||
const guint8 * list_addr = nm_ap_get_address (list_ap);
|
||||
const char * list_addr = nm_ap_get_address (list_ap);
|
||||
|
||||
const GByteArray * find_ssid = nm_ap_get_ssid (find_ap);
|
||||
const guint8 * find_addr = nm_ap_get_address (find_ap);
|
||||
const char * find_addr = nm_ap_get_address (find_ap);
|
||||
|
||||
/* SSID match; if both APs are hiding their SSIDs,
|
||||
* let matching continue on BSSID and other properties
|
||||
*/
|
||||
if ( (!list_ssid && find_ssid)
|
||||
|| (list_ssid && !find_ssid)
|
||||
|| !nm_utils_same_ssid (list_ssid, find_ssid, TRUE))
|
||||
|| (list_ssid && !find_ssid))
|
||||
continue;
|
||||
if ( list_ssid
|
||||
&& find_ssid
|
||||
&& !nm_utils_same_ssid (list_ssid->data, list_ssid->len,
|
||||
find_ssid->data, find_ssid->len,
|
||||
TRUE))
|
||||
continue;
|
||||
|
||||
/* BSSID match */
|
||||
if ( (strict_match || nm_ethernet_address_is_valid (find_addr))
|
||||
&& nm_ethernet_address_is_valid (list_addr)
|
||||
&& !nm_utils_hwaddr_matches (list_addr, ETH_ALEN, find_addr, ETH_ALEN))
|
||||
if ( (strict_match || nm_ethernet_address_is_valid (find_addr, -1))
|
||||
&& nm_ethernet_address_is_valid (list_addr, -1)
|
||||
&& !nm_utils_hwaddr_matches (list_addr, -1, find_addr, -1))
|
||||
continue;
|
||||
|
||||
/* mode match */
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ void nm_ap_set_supplicant_path (NMAccessPoint *ap,
|
|||
const char *path);
|
||||
|
||||
const GByteArray *nm_ap_get_ssid (const NMAccessPoint * ap);
|
||||
void nm_ap_set_ssid (NMAccessPoint * ap, const GByteArray * ssid);
|
||||
void nm_ap_set_ssid (NMAccessPoint * ap, const guint8 * ssid, gsize len);
|
||||
|
||||
NM80211ApFlags nm_ap_get_flags (NMAccessPoint *ap);
|
||||
void nm_ap_set_flags (NMAccessPoint *ap, NM80211ApFlags flags);
|
||||
|
|
@ -78,8 +78,8 @@ void nm_ap_set_wpa_flags (NMAccessPoint *ap, NM80211ApSecurity
|
|||
NM80211ApSecurityFlags nm_ap_get_rsn_flags (NMAccessPoint *ap);
|
||||
void nm_ap_set_rsn_flags (NMAccessPoint *ap, NM80211ApSecurityFlags flags);
|
||||
|
||||
const guint8 *nm_ap_get_address (const NMAccessPoint *ap);
|
||||
void nm_ap_set_address (NMAccessPoint *ap, const guint8 *addr);
|
||||
const char *nm_ap_get_address (const NMAccessPoint *ap);
|
||||
void nm_ap_set_address (NMAccessPoint *ap, const char *addr);
|
||||
|
||||
NM80211Mode nm_ap_get_mode (NMAccessPoint *ap);
|
||||
void nm_ap_set_mode (NMAccessPoint *ap, const NM80211Mode mode);
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@
|
|||
|
||||
static gboolean
|
||||
complete_connection (const char *ssid,
|
||||
const guint8 bssid[ETH_ALEN],
|
||||
const char *bssid,
|
||||
NM80211Mode mode,
|
||||
guint32 flags,
|
||||
guint32 wpa_flags,
|
||||
|
|
@ -114,7 +114,7 @@ set_items (NMSetting *setting, const KeyData *items)
|
|||
{
|
||||
const KeyData *item;
|
||||
GParamSpec *pspec;
|
||||
GByteArray *tmp;
|
||||
GBytes *tmp;
|
||||
|
||||
for (item = items; item && item->key; item++) {
|
||||
g_assert (item->key);
|
||||
|
|
@ -138,12 +138,11 @@ set_items (NMSetting *setting, const KeyData *items)
|
|||
|
||||
g_assert (item->str == NULL);
|
||||
g_object_set (G_OBJECT (setting), item->key, foo, NULL);
|
||||
} else if (pspec->value_type == DBUS_TYPE_G_UCHAR_ARRAY) {
|
||||
} else if (pspec->value_type == G_TYPE_BYTES) {
|
||||
g_assert (item->str);
|
||||
tmp = g_byte_array_sized_new (strlen (item->str));
|
||||
g_byte_array_append (tmp, (const guint8 *) item->str, strlen (item->str));
|
||||
tmp = g_bytes_new (item->str, strlen (item->str));
|
||||
g_object_set (G_OBJECT (setting), item->key, tmp, NULL);
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
g_bytes_unref (tmp);
|
||||
} else {
|
||||
/* Special types, check based on property name */
|
||||
if (!strcmp (item->key, NM_SETTING_WIRELESS_SECURITY_PROTO))
|
||||
|
|
@ -218,12 +217,12 @@ fill_8021x (NMConnection *connection, const KeyData items[])
|
|||
|
||||
static NMConnection *
|
||||
create_basic (const char *ssid,
|
||||
const guint8 *bssid,
|
||||
const char *bssid,
|
||||
NM80211Mode mode)
|
||||
{
|
||||
NMConnection *connection;
|
||||
NMSettingWireless *s_wifi = NULL;
|
||||
GByteArray *tmp;
|
||||
GBytes *tmp;
|
||||
|
||||
connection = nm_simple_connection_new ();
|
||||
|
||||
|
|
@ -231,18 +230,13 @@ create_basic (const char *ssid,
|
|||
nm_connection_add_setting (connection, NM_SETTING (s_wifi));
|
||||
|
||||
/* SSID */
|
||||
tmp = g_byte_array_sized_new (strlen (ssid));
|
||||
g_byte_array_append (tmp, (const guint8 *) ssid, strlen (ssid));
|
||||
tmp = g_bytes_new (ssid, strlen (ssid));
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_SSID, tmp, NULL);
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
g_bytes_unref (tmp);
|
||||
|
||||
/* BSSID */
|
||||
if (bssid) {
|
||||
tmp = g_byte_array_sized_new (ETH_ALEN);
|
||||
g_byte_array_append (tmp, bssid, ETH_ALEN);
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, tmp, NULL);
|
||||
g_byte_array_free (tmp, TRUE);
|
||||
}
|
||||
if (bssid)
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_BSSID, bssid, NULL);
|
||||
|
||||
if (mode == NM_802_11_MODE_INFRA)
|
||||
g_object_set (G_OBJECT (s_wifi), NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
|
||||
|
|
@ -260,7 +254,7 @@ static void
|
|||
test_lock_bssid (void)
|
||||
{
|
||||
NMConnection *src, *expected;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *ssid = "blahblah";
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
|
@ -284,7 +278,7 @@ static void
|
|||
test_open_ap_empty_connection (void)
|
||||
{
|
||||
NMConnection *src, *expected;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *ssid = "blahblah";
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
|
@ -312,7 +306,7 @@ static void
|
|||
test_open_ap_leap_connection_1 (gconstpointer add_wifi)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, "Bill Smith", 0 }, { NULL } };
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
|
@ -344,7 +338,7 @@ static void
|
|||
test_open_ap_leap_connection_2 (void)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = { { NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 }, { NULL } };
|
||||
gboolean success;
|
||||
GError *error = NULL;
|
||||
|
|
@ -374,7 +368,7 @@ static void
|
|||
test_open_ap_wep_connection (gconstpointer add_wifi)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_WEP_KEY0, "11111111111111111111111111", 0 },
|
||||
{ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, NULL, 0 },
|
||||
|
|
@ -415,7 +409,7 @@ test_ap_wpa_psk_connection_base (const char *key_mgmt,
|
|||
{
|
||||
NMConnection *src;
|
||||
const char *ssid = "blahblah";
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData exp_wifi[] = {
|
||||
{ NM_SETTING_WIRELESS_SSID, ssid, 0 },
|
||||
{ NM_SETTING_WIRELESS_MODE, "infrastructure", 0 },
|
||||
|
|
@ -525,7 +519,7 @@ test_ap_wpa_eap_connection_base (const char *key_mgmt,
|
|||
guint error_code)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_empty[] = { { NULL } };
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, 0 },
|
||||
|
|
@ -731,7 +725,7 @@ static void
|
|||
test_priv_ap_empty_connection (void)
|
||||
{
|
||||
NMConnection *src, *expected;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *ssid = "blahblah";
|
||||
const KeyData exp_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", 0 },
|
||||
|
|
@ -766,7 +760,7 @@ test_priv_ap_leap_connection_1 (gconstpointer add_wifi)
|
|||
{
|
||||
NMConnection *src, *expected;
|
||||
const char *ssid = "blahblah";
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *leap_username = "Bill Smith";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
|
|
@ -811,7 +805,7 @@ static void
|
|||
test_priv_ap_leap_connection_2 (void)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
{ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 },
|
||||
|
|
@ -845,7 +839,7 @@ test_priv_ap_dynamic_wep_1 (void)
|
|||
{
|
||||
NMConnection *src, *expected;
|
||||
const char *ssid = "blahblah";
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
{ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
|
||||
|
|
@ -893,7 +887,7 @@ test_priv_ap_dynamic_wep_2 (void)
|
|||
{
|
||||
NMConnection *src, *expected;
|
||||
const char *ssid = "blahblah";
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", 0 },
|
||||
{ NULL } };
|
||||
|
|
@ -939,7 +933,7 @@ static void
|
|||
test_priv_ap_dynamic_wep_3 (void)
|
||||
{
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "shared", 0 },
|
||||
{ NULL } };
|
||||
|
|
@ -1052,7 +1046,7 @@ test_wpa_ap_empty_connection (gconstpointer data)
|
|||
{
|
||||
guint idx = GPOINTER_TO_UINT (data);
|
||||
NMConnection *src, *expected;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *ssid = "blahblah";
|
||||
const KeyData exp_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", 0 },
|
||||
|
|
@ -1090,7 +1084,7 @@ test_wpa_ap_leap_connection_1 (gconstpointer data)
|
|||
guint idx = GPOINTER_TO_UINT (data);
|
||||
NMConnection *src;
|
||||
const char *ssid = "blahblah";
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const char *leap_username = "Bill Smith";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
|
|
@ -1125,7 +1119,7 @@ test_wpa_ap_leap_connection_2 (gconstpointer data)
|
|||
{
|
||||
guint idx = GPOINTER_TO_UINT (data);
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
{ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", 0 },
|
||||
|
|
@ -1159,7 +1153,7 @@ test_wpa_ap_dynamic_wep_connection (gconstpointer data)
|
|||
{
|
||||
guint idx = GPOINTER_TO_UINT (data);
|
||||
NMConnection *src;
|
||||
const guint8 bssid[ETH_ALEN] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
|
||||
const char *bssid = "01:02:03:04:05:06";
|
||||
const KeyData src_wsec[] = {
|
||||
{ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", 0 },
|
||||
{ NULL } };
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
NMSettingConnection *s_con;
|
||||
NMSettingWimax *s_wimax;
|
||||
const char *connection_type;
|
||||
const GByteArray *mac;
|
||||
const char *mac;
|
||||
|
||||
if (!NM_DEVICE_CLASS (nm_device_wimax_parent_class)->check_connection_compatible (device, connection))
|
||||
return FALSE;
|
||||
|
|
@ -332,7 +332,7 @@ check_connection_compatible (NMDevice *device, NMConnection *connection)
|
|||
return FALSE;
|
||||
|
||||
mac = nm_setting_wimax_get_mac_address (s_wimax);
|
||||
if (mac && !nm_utils_hwaddr_matches (mac->data, mac->len, nm_device_get_hw_address (device), -1))
|
||||
if (mac && !nm_utils_hwaddr_matches (mac, -1, nm_device_get_hw_address (device), -1))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
|
|
@ -371,7 +371,7 @@ complete_connection (NMDevice *device,
|
|||
NMDeviceWimax *self = NM_DEVICE_WIMAX (device);
|
||||
NMDeviceWimaxPrivate *priv = NM_DEVICE_WIMAX_GET_PRIVATE (self);
|
||||
NMSettingWimax *s_wimax;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
const char *hw_address;
|
||||
const char *nsp_name = NULL;
|
||||
NMWimaxNsp *nsp = NULL;
|
||||
|
|
@ -450,7 +450,7 @@ complete_connection (NMDevice *device,
|
|||
hw_address = nm_device_get_hw_address (device);
|
||||
if (setting_mac) {
|
||||
/* Make sure the setting MAC (if any) matches the device's permanent MAC */
|
||||
if (!nm_utils_hwaddr_matches (setting_mac->data, setting_mac->len, hw_address, -1)) {
|
||||
if (!nm_utils_hwaddr_matches (setting_mac, -1, hw_address, -1)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIMAX_ERROR,
|
||||
NM_SETTING_WIMAX_ERROR_INVALID_PROPERTY,
|
||||
|
|
@ -458,14 +458,9 @@ complete_connection (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
GByteArray *mac;
|
||||
|
||||
/* Lock the connection to this device by default */
|
||||
if (!nm_utils_hwaddr_matches (hw_address, -1, NULL, ETH_ALEN)) {
|
||||
mac = nm_utils_hwaddr_atoba (hw_address, ETH_ALEN);
|
||||
g_object_set (G_OBJECT (s_wimax), NM_SETTING_WIMAX_MAC_ADDRESS, mac, NULL);
|
||||
g_byte_array_free (mac, TRUE);
|
||||
}
|
||||
if (!nm_utils_hwaddr_matches (hw_address, -1, NULL, ETH_ALEN))
|
||||
g_object_set (G_OBJECT (s_wimax), NM_SETTING_WIMAX_MAC_ADDRESS, hw_address, NULL);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ nm_dhcp_client_watch_child (NMDhcpClient *self, pid_t pid)
|
|||
gboolean
|
||||
nm_dhcp_client_start_ip4 (NMDhcpClient *self,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDhcpClientPrivate *priv;
|
||||
|
|
@ -480,7 +480,7 @@ get_duid (NMDhcpClient *self)
|
|||
|
||||
gboolean
|
||||
nm_dhcp_client_start_ip6 (NMDhcpClient *self,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy)
|
||||
|
|
|
|||
|
|
@ -65,11 +65,11 @@ typedef struct {
|
|||
|
||||
gboolean (*ip4_start) (NMDhcpClient *self,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *anycast_addr,
|
||||
const char *hostname);
|
||||
|
||||
gboolean (*ip6_start) (NMDhcpClient *self,
|
||||
GByteArray *anycast_addr,
|
||||
const char *anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
|
|
@ -117,11 +117,11 @@ guint32 nm_dhcp_client_get_priority (NMDhcpClient *self);
|
|||
|
||||
gboolean nm_dhcp_client_start_ip4 (NMDhcpClient *self,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname);
|
||||
|
||||
gboolean nm_dhcp_client_start_ip6 (NMDhcpClient *self,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy);
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ char *
|
|||
nm_dhcp_dhclient_create_config (const char *interface,
|
||||
gboolean is_ip6,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
const char *orig_contents)
|
||||
|
|
@ -138,6 +138,8 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
GPtrArray *alsoreq;
|
||||
int i;
|
||||
|
||||
g_return_val_if_fail (!anycast_addr || nm_utils_hwaddr_valid (anycast_addr, ETH_ALEN), NULL);
|
||||
|
||||
new_contents = g_string_new (_("# Created by NetworkManager\n"));
|
||||
alsoreq = g_ptr_array_sized_new (5);
|
||||
|
||||
|
|
@ -246,22 +248,14 @@ nm_dhcp_dhclient_create_config (const char *interface,
|
|||
|
||||
g_string_append_c (new_contents, '\n');
|
||||
|
||||
if (anycast_addr && anycast_addr->len == 6) {
|
||||
const guint8 *p_anycast_addr = anycast_addr->data;
|
||||
|
||||
if (anycast_addr) {
|
||||
g_string_append_printf (new_contents, "interface \"%s\" {\n"
|
||||
" initial-interval 1; \n"
|
||||
" anycast-mac ethernet %02x:%02x:%02x:%02x:%02x:%02x;\n"
|
||||
" anycast-mac ethernet %s;\n"
|
||||
"}\n",
|
||||
interface,
|
||||
p_anycast_addr[0], p_anycast_addr[1],
|
||||
p_anycast_addr[2], p_anycast_addr[3],
|
||||
p_anycast_addr[4], p_anycast_addr[5]);
|
||||
interface, anycast_addr);
|
||||
}
|
||||
|
||||
/* Finally, assert that anycast_addr was unset or a 48 bit mac address. */
|
||||
g_return_val_if_fail (!anycast_addr || anycast_addr->len == 6, g_string_free (new_contents, FALSE));
|
||||
|
||||
return g_string_free (new_contents, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
char *nm_dhcp_dhclient_create_config (const char *interface,
|
||||
gboolean is_ip6,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
const char *orig_contents);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ merge_dhclient_config (const char *iface,
|
|||
const char *conf_file,
|
||||
gboolean is_ip6,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *anycast_addr,
|
||||
const char *anycast_addr,
|
||||
const char *hostname,
|
||||
const char *orig_path,
|
||||
GError **error)
|
||||
|
|
@ -272,7 +272,7 @@ create_dhclient_config (const char *iface,
|
|||
gboolean is_ip6,
|
||||
const char *uuid,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
char *orig = NULL, *new = NULL;
|
||||
|
|
@ -482,7 +482,7 @@ dhclient_start (NMDhcpClient *client,
|
|||
static gboolean
|
||||
ip4_start (NMDhcpClient *client,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDhcpDhclientPrivate *priv = NM_DHCP_DHCLIENT_GET_PRIVATE (client);
|
||||
|
|
@ -502,7 +502,7 @@ ip4_start (NMDhcpClient *client,
|
|||
|
||||
static gboolean
|
||||
ip6_start (NMDhcpClient *client,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ dhcpcd_child_setup (gpointer user_data G_GNUC_UNUSED)
|
|||
static gboolean
|
||||
ip4_start (NMDhcpClient *client,
|
||||
const char *dhcp_client_id,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname)
|
||||
{
|
||||
NMDhcpDhcpcdPrivate *priv = NM_DHCP_DHCPCD_GET_PRIVATE (client);
|
||||
|
|
@ -171,7 +171,7 @@ ip4_start (NMDhcpClient *client,
|
|||
|
||||
static gboolean
|
||||
ip6_start (NMDhcpClient *client,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy,
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ client_start (NMDhcpManager *self,
|
|||
gboolean ipv6,
|
||||
const char *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
const char *hostname,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy)
|
||||
|
|
@ -452,7 +452,7 @@ nm_dhcp_manager_start_ip4 (NMDhcpManager *self,
|
|||
const char *dhcp_hostname,
|
||||
const char *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr)
|
||||
const char *dhcp_anycast_addr)
|
||||
{
|
||||
const char *hostname = NULL;
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ nm_dhcp_manager_start_ip6 (NMDhcpManager *self,
|
|||
guint priority,
|
||||
const char *dhcp_hostname,
|
||||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip4 (NMDhcpManager *manager,
|
|||
const char *dhcp_hostname,
|
||||
const char *dhcp_client_id,
|
||||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr);
|
||||
const char *dhcp_anycast_addr);
|
||||
|
||||
NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
||||
const char *iface,
|
||||
|
|
@ -81,7 +81,7 @@ NMDhcpClient * nm_dhcp_manager_start_ip6 (NMDhcpManager *manager,
|
|||
guint priority,
|
||||
const char *dhcp_hostname,
|
||||
guint32 timeout,
|
||||
GByteArray *dhcp_anycast_addr,
|
||||
const char *dhcp_anycast_addr,
|
||||
gboolean info_only,
|
||||
NMSettingIP6ConfigPrivacy privacy);
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ test_config (const char *orig,
|
|||
const char *hostname,
|
||||
const char *dhcp_client_id,
|
||||
const char *iface,
|
||||
GByteArray *anycast_addr)
|
||||
const char *anycast_addr)
|
||||
{
|
||||
char *new;
|
||||
|
||||
|
|
|
|||
|
|
@ -337,8 +337,7 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, i
|
|||
address.lifetime = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.preferred = NM_PLATFORM_LIFETIME_PERMANENT;
|
||||
address.source = NM_PLATFORM_SOURCE_USER;
|
||||
if (label)
|
||||
g_strlcpy (address.label, label, sizeof (address.label));
|
||||
g_strlcpy (address.label, label, sizeof (address.label));
|
||||
|
||||
nm_ip4_config_add_address (config, &address);
|
||||
}
|
||||
|
|
@ -368,8 +367,12 @@ nm_ip4_config_merge_setting (NMIP4Config *config, NMSettingIP4Config *setting, i
|
|||
nm_ip4_config_reset_domains (config);
|
||||
nm_ip4_config_reset_searches (config);
|
||||
}
|
||||
for (i = 0; i < nnameservers; i++)
|
||||
nm_ip4_config_add_nameserver (config, nm_setting_ip4_config_get_dns (setting, i));
|
||||
for (i = 0; i < nnameservers; i++) {
|
||||
guint32 ip;
|
||||
|
||||
if (inet_pton (AF_INET, nm_setting_ip4_config_get_dns (setting, i), &ip) == 1)
|
||||
nm_ip4_config_add_nameserver (config, ip);
|
||||
}
|
||||
for (i = 0; i < nsearches; i++)
|
||||
nm_ip4_config_add_search (config, nm_setting_ip4_config_get_dns_search (setting, i));
|
||||
|
||||
|
|
@ -425,10 +428,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||
if (same_prefix (address->address, gateway, address->plen))
|
||||
nm_ip4_address_set_gateway (s_addr, gateway);
|
||||
|
||||
if (*address->label)
|
||||
_nm_setting_ip4_config_add_address_with_label (s_ip4, s_addr, address->label);
|
||||
else
|
||||
nm_setting_ip4_config_add_address (s_ip4, s_addr);
|
||||
_nm_setting_ip4_config_add_address_with_label (s_ip4, s_addr, address->label);
|
||||
nm_ip4_address_unref (s_addr);
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ nm_ip4_config_create_setting (const NMIP4Config *config)
|
|||
for (i = 0; i < nnameservers; i++) {
|
||||
guint32 nameserver = nm_ip4_config_get_nameserver (config, i);
|
||||
|
||||
nm_setting_ip4_config_add_dns (s_ip4, nameserver);
|
||||
nm_setting_ip4_config_add_dns (s_ip4, nm_utils_inet4_ntop (nameserver, NULL));
|
||||
}
|
||||
for (i = 0; i < nsearches; i++) {
|
||||
const char *search = nm_ip4_config_get_search (config, i);
|
||||
|
|
|
|||
|
|
@ -470,8 +470,12 @@ nm_ip6_config_merge_setting (NMIP6Config *config, NMSettingIP6Config *setting, i
|
|||
nm_ip6_config_reset_domains (config);
|
||||
nm_ip6_config_reset_searches (config);
|
||||
}
|
||||
for (i = 0; i < nnameservers; i++)
|
||||
nm_ip6_config_add_nameserver (config, nm_setting_ip6_config_get_dns (setting, i));
|
||||
for (i = 0; i < nnameservers; i++) {
|
||||
struct in6_addr ip;
|
||||
|
||||
if (inet_pton (AF_INET6, nm_setting_ip6_config_get_dns (setting, i), &ip) == 1)
|
||||
nm_ip6_config_add_nameserver (config, &ip);
|
||||
}
|
||||
for (i = 0; i < nsearches; i++)
|
||||
nm_ip6_config_add_search (config, nm_setting_ip6_config_get_dns_search (setting, i));
|
||||
|
||||
|
|
@ -571,7 +575,7 @@ nm_ip6_config_create_setting (const NMIP6Config *config)
|
|||
for (i = 0; i < nnameservers; i++) {
|
||||
const struct in6_addr *nameserver = nm_ip6_config_get_nameserver (config, i);
|
||||
|
||||
nm_setting_ip6_config_add_dns (s_ip6, nameserver);
|
||||
nm_setting_ip6_config_add_dns (s_ip6, nm_utils_inet6_ntop (nameserver, NULL));
|
||||
}
|
||||
for (i = 0; i < nsearches; i++) {
|
||||
const char *search = nm_ip6_config_get_search (config, i);
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ nm_manager_get_state (NMManager *manager)
|
|||
/*******************************************************************/
|
||||
|
||||
static NMDevice *
|
||||
get_device_from_hwaddr (NMManager *self, const GByteArray *setting_mac)
|
||||
get_device_from_hwaddr (NMManager *self, const char *setting_mac)
|
||||
{
|
||||
NMManagerPrivate *priv = NM_MANAGER_GET_PRIVATE (self);
|
||||
const char *device_mac;
|
||||
|
|
@ -857,7 +857,7 @@ get_device_from_hwaddr (NMManager *self, const GByteArray *setting_mac)
|
|||
device_mac = nm_device_get_hw_address (iter->data);
|
||||
if (!device_mac)
|
||||
continue;
|
||||
if (nm_utils_hwaddr_matches (setting_mac->data, setting_mac->len, device_mac, -1))
|
||||
if (nm_utils_hwaddr_matches (setting_mac, -1, device_mac, -1))
|
||||
return device;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -873,7 +873,7 @@ find_vlan_parent (NMManager *self,
|
|||
NMConnection *parent_connection;
|
||||
const char *parent_iface;
|
||||
NMDevice *parent = NULL;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
GSList *iter;
|
||||
|
||||
/* The 'parent' property could be given by an interface name, a
|
||||
|
|
@ -926,7 +926,7 @@ find_infiniband_parent (NMManager *self,
|
|||
NMSettingInfiniband *s_infiniband;
|
||||
const char *parent_iface;
|
||||
NMDevice *parent = NULL;
|
||||
const GByteArray *setting_mac;
|
||||
const char *setting_mac;
|
||||
|
||||
s_infiniband = nm_connection_get_setting_infiniband (connection);
|
||||
g_return_val_if_fail (s_infiniband != NULL, NULL);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue