mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-07-09 04:05:56 +00:00
2008-10-28 Dan Williams <dcbw@redhat.com>
Patch from Tambet Ingo <tambet@gmail.com> * libnm-util/libnm-util.ver libnm-util/nm-setting-wireless.c libnm-util/nm-setting-wireless.h - Make properties private and add accessor functions * src/NetworkManagerAP.c src/nm-device-wifi.c src/nm-manager.c src/supplicant-manager/nm-supplicant-config.c system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c system-settings/plugins/ifcfg-fedora/reader.c system-settings/plugins/ifcfg-suse/parser.c system-settings/plugins/ifupdown/parser.c - Use wireless setting accessors git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4231 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
2161a7a043
commit
69713a8b93
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2008-10-28 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Tambet Ingo <tambet@gmail.com>
|
||||
|
||||
* libnm-util/libnm-util.ver
|
||||
libnm-util/nm-setting-wireless.c
|
||||
libnm-util/nm-setting-wireless.h
|
||||
- Make properties private and add accessor functions
|
||||
|
||||
* src/NetworkManagerAP.c
|
||||
src/nm-device-wifi.c
|
||||
src/nm-manager.c
|
||||
src/supplicant-manager/nm-supplicant-config.c
|
||||
system-settings/plugins/ifcfg-fedora/nm-ifcfg-connection.c
|
||||
system-settings/plugins/ifcfg-fedora/reader.c
|
||||
system-settings/plugins/ifcfg-suse/parser.c
|
||||
system-settings/plugins/ifupdown/parser.c
|
||||
- Use wireless setting accessors
|
||||
|
||||
2008-10-27 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
Patch from Tambet Ingo <tambet@gmail.com>
|
||||
|
|
|
@ -145,6 +145,19 @@ global:
|
|||
nm_setting_wireless_error_quark;
|
||||
nm_setting_wireless_get_type;
|
||||
nm_setting_wireless_new;
|
||||
nm_setting_wireless_get_ssid;
|
||||
nm_setting_wireless_get_mode;
|
||||
nm_setting_wireless_get_band;
|
||||
nm_setting_wireless_get_channel;
|
||||
nm_setting_wireless_get_bssid;
|
||||
nm_setting_wireless_get_rate;
|
||||
nm_setting_wireless_get_tx_power;
|
||||
nm_setting_wireless_get_mac_address;
|
||||
nm_setting_wireless_get_mtu;
|
||||
nm_setting_wireless_get_security;
|
||||
nm_setting_wireless_add_seen_bssid;
|
||||
nm_setting_wireless_get_num_seen_bssids;
|
||||
nm_setting_wireless_get_seen_bssid;
|
||||
nm_setting_wireless_security_error_get_type;
|
||||
nm_setting_wireless_security_error_quark;
|
||||
nm_setting_wireless_security_get_type;
|
||||
|
|
|
@ -75,6 +75,21 @@ nm_setting_wireless_error_get_type (void)
|
|||
|
||||
G_DEFINE_TYPE (NMSettingWireless, nm_setting_wireless, NM_TYPE_SETTING)
|
||||
|
||||
#define NM_SETTING_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_WIRELESS, NMSettingWirelessPrivate))
|
||||
|
||||
typedef struct {
|
||||
GByteArray *ssid;
|
||||
char *mode;
|
||||
char *band;
|
||||
guint32 channel;
|
||||
GByteArray *bssid;
|
||||
guint32 rate;
|
||||
guint32 tx_power;
|
||||
GByteArray *mac_address;
|
||||
guint32 mtu;
|
||||
GSList *seen_bssids;
|
||||
char *security;
|
||||
} NMSettingWirelessPrivate;
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SSID,
|
||||
|
@ -116,9 +131,13 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
|
|||
guint32 ap_rsn,
|
||||
guint32 ap_mode)
|
||||
{
|
||||
NMSettingWirelessPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (s_wireless), FALSE);
|
||||
|
||||
if (!s_wireless->security) {
|
||||
priv = NM_SETTING_WIRELESS_GET_PRIVATE (s_wireless);
|
||||
|
||||
if (!priv->security) {
|
||||
if ( (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)
|
||||
|| (ap_wpa != NM_802_11_AP_SEC_NONE)
|
||||
|| (ap_rsn != NM_802_11_AP_SEC_NONE))
|
||||
|
@ -126,7 +145,7 @@ nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
if (strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) != 0)
|
||||
if (strcmp (priv->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) != 0)
|
||||
return FALSE;
|
||||
|
||||
if (s_wireless_sec == NULL || !s_wireless_sec->key_mgmt)
|
||||
|
@ -272,6 +291,136 @@ nm_setting_wireless_new (void)
|
|||
return (NMSetting *) g_object_new (NM_TYPE_SETTING_WIRELESS, NULL);
|
||||
}
|
||||
|
||||
const GByteArray *
|
||||
nm_setting_wireless_get_ssid (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->ssid;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_wireless_get_mode (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mode;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_wireless_get_band (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->band;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_setting_wireless_get_channel (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->channel;
|
||||
}
|
||||
|
||||
const GByteArray *
|
||||
nm_setting_wireless_get_bssid (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->bssid;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_setting_wireless_get_rate (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->rate;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_setting_wireless_get_tx_power (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->tx_power;
|
||||
}
|
||||
|
||||
const GByteArray *
|
||||
nm_setting_wireless_get_mac_address (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mac_address;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_setting_wireless_get_mtu (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->mtu;
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_wireless_get_security (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return NM_SETTING_WIRELESS_GET_PRIVATE (setting)->security;
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
|
||||
const char *bssid)
|
||||
{
|
||||
NMSettingWirelessPrivate *priv;
|
||||
char *lower_bssid;
|
||||
GSList *iter;
|
||||
gboolean found = FALSE;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), FALSE);
|
||||
g_return_val_if_fail (bssid != NULL, FALSE);
|
||||
|
||||
lower_bssid = g_ascii_strdown (bssid, -1);
|
||||
if (!lower_bssid)
|
||||
return FALSE;
|
||||
|
||||
priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
|
||||
|
||||
for (iter = priv->seen_bssids; iter; iter = iter->next) {
|
||||
if (!strcmp ((char *) iter->data, lower_bssid)) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
priv->seen_bssids = g_slist_prepend (priv->seen_bssids, lower_bssid);
|
||||
else
|
||||
g_free (lower_bssid);
|
||||
|
||||
return !found;
|
||||
}
|
||||
|
||||
guint32
|
||||
nm_setting_wireless_get_num_seen_bssids (NMSettingWireless *setting)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), 0);
|
||||
|
||||
return g_slist_length (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
|
||||
}
|
||||
|
||||
const char *
|
||||
nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting,
|
||||
guint32 i)
|
||||
{
|
||||
g_return_val_if_fail (NM_IS_SETTING_WIRELESS (setting), NULL);
|
||||
|
||||
return (const char *) g_slist_nth (NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids, i);
|
||||
}
|
||||
|
||||
static gint
|
||||
find_setting_by_name (gconstpointer a, gconstpointer b)
|
||||
{
|
||||
|
@ -284,12 +433,12 @@ find_setting_by_name (gconstpointer a, gconstpointer b)
|
|||
static gboolean
|
||||
verify (NMSetting *setting, GSList *all_settings, GError **error)
|
||||
{
|
||||
NMSettingWireless *self = NM_SETTING_WIRELESS (setting);
|
||||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (setting);
|
||||
const char *valid_modes[] = { "infrastructure", "adhoc", NULL };
|
||||
const char *valid_bands[] = { "a", "bg", NULL };
|
||||
GSList *iter;
|
||||
|
||||
if (!self->ssid) {
|
||||
if (!priv->ssid) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_MISSING_PROPERTY,
|
||||
|
@ -297,7 +446,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (!self->ssid->len || self->ssid->len > 32) {
|
||||
if (!priv->ssid->len || priv->ssid->len > 32) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -305,7 +454,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->mode && !nm_utils_string_in_list (self->mode, valid_modes)) {
|
||||
if (priv->mode && !nm_utils_string_in_list (priv->mode, valid_modes)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -313,7 +462,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->band && !nm_utils_string_in_list (self->band, valid_bands)) {
|
||||
if (priv->band && !nm_utils_string_in_list (priv->band, valid_bands)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -321,7 +470,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->channel && !self->band) {
|
||||
if (priv->channel && !priv->band) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND,
|
||||
|
@ -329,8 +478,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->channel) {
|
||||
if (!strcmp (self->band, "a")) {
|
||||
if (priv->channel) {
|
||||
if (!strcmp (priv->band, "a")) {
|
||||
int i;
|
||||
int valid_channels[] = { 7, 8, 9, 11, 12, 16, 34, 36, 40, 44, 48,
|
||||
52, 56, 60, 64, 100, 104, 108, 112, 116,
|
||||
|
@ -339,7 +488,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
192, 196, 0 };
|
||||
|
||||
for (i = 0; valid_channels[i]; i++) {
|
||||
if (self->channel == valid_channels[i])
|
||||
if (priv->channel == valid_channels[i])
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -350,7 +499,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
NM_SETTING_WIRELESS_CHANNEL);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (!strcmp (self->band, "bg") && self->channel > 14) {
|
||||
} else if (!strcmp (priv->band, "bg") && priv->channel > 14) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -359,7 +508,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (self->bssid && self->bssid->len != ETH_ALEN) {
|
||||
if (priv->bssid && priv->bssid->len != ETH_ALEN) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -367,7 +516,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (self->mac_address && self->mac_address->len != ETH_ALEN) {
|
||||
if (priv->mac_address && priv->mac_address->len != ETH_ALEN) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_INVALID_PROPERTY,
|
||||
|
@ -375,7 +524,7 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
for (iter = self->seen_bssids; iter; iter = iter->next) {
|
||||
for (iter = priv->seen_bssids; iter; iter = iter->next) {
|
||||
struct ether_addr addr;
|
||||
|
||||
if (!ether_aton_r (iter->data, &addr)) {
|
||||
|
@ -387,8 +536,8 @@ verify (NMSetting *setting, GSList *all_settings, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if ( self->security
|
||||
&& !g_slist_find_custom (all_settings, self->security, find_setting_by_name)) {
|
||||
if ( priv->security
|
||||
&& !g_slist_find_custom (all_settings, priv->security, find_setting_by_name)) {
|
||||
g_set_error (error,
|
||||
NM_SETTING_WIRELESS_ERROR,
|
||||
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING,
|
||||
|
@ -408,20 +557,20 @@ nm_setting_wireless_init (NMSettingWireless *setting)
|
|||
static void
|
||||
finalize (GObject *object)
|
||||
{
|
||||
NMSettingWireless *self = NM_SETTING_WIRELESS (object);
|
||||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (object);
|
||||
|
||||
g_free (self->mode);
|
||||
g_free (self->band);
|
||||
g_free (self->security);
|
||||
g_free (priv->mode);
|
||||
g_free (priv->band);
|
||||
g_free (priv->security);
|
||||
|
||||
if (self->ssid)
|
||||
g_byte_array_free (self->ssid, TRUE);
|
||||
if (self->bssid)
|
||||
g_byte_array_free (self->bssid, TRUE);
|
||||
if (self->mac_address)
|
||||
g_byte_array_free (self->mac_address, TRUE);
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
if (priv->bssid)
|
||||
g_byte_array_free (priv->bssid, TRUE);
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
|
||||
nm_utils_slist_free (self->seen_bssids, g_free);
|
||||
nm_utils_slist_free (priv->seen_bssids, g_free);
|
||||
|
||||
G_OBJECT_CLASS (nm_setting_wireless_parent_class)->finalize (object);
|
||||
}
|
||||
|
@ -430,51 +579,51 @@ static void
|
|||
set_property (GObject *object, guint prop_id,
|
||||
const GValue *value, GParamSpec *pspec)
|
||||
{
|
||||
NMSettingWireless *setting = NM_SETTING_WIRELESS (object);
|
||||
NMSettingWirelessPrivate *priv = NM_SETTING_WIRELESS_GET_PRIVATE (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SSID:
|
||||
if (setting->ssid)
|
||||
g_byte_array_free (setting->ssid, TRUE);
|
||||
setting->ssid = g_value_dup_boxed (value);
|
||||
if (priv->ssid)
|
||||
g_byte_array_free (priv->ssid, TRUE);
|
||||
priv->ssid = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_free (setting->mode);
|
||||
setting->mode = g_value_dup_string (value);
|
||||
g_free (priv->mode);
|
||||
priv->mode = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_BAND:
|
||||
g_free (setting->band);
|
||||
setting->band = g_value_dup_string (value);
|
||||
g_free (priv->band);
|
||||
priv->band = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
setting->channel = g_value_get_uint (value);
|
||||
priv->channel = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_BSSID:
|
||||
if (setting->bssid)
|
||||
g_byte_array_free (setting->bssid, TRUE);
|
||||
setting->bssid = g_value_dup_boxed (value);
|
||||
if (priv->bssid)
|
||||
g_byte_array_free (priv->bssid, TRUE);
|
||||
priv->bssid = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_RATE:
|
||||
setting->rate = g_value_get_uint (value);
|
||||
priv->rate = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
setting->tx_power = g_value_get_uint (value);
|
||||
priv->tx_power = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
if (setting->mac_address)
|
||||
g_byte_array_free (setting->mac_address, TRUE);
|
||||
setting->mac_address = g_value_dup_boxed (value);
|
||||
if (priv->mac_address)
|
||||
g_byte_array_free (priv->mac_address, TRUE);
|
||||
priv->mac_address = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_MTU:
|
||||
setting->mtu = g_value_get_uint (value);
|
||||
priv->mtu = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
nm_utils_slist_free (setting->seen_bssids, g_free);
|
||||
setting->seen_bssids = g_value_dup_boxed (value);
|
||||
nm_utils_slist_free (priv->seen_bssids, g_free);
|
||||
priv->seen_bssids = g_value_dup_boxed (value);
|
||||
break;
|
||||
case PROP_SEC:
|
||||
g_free (setting->security);
|
||||
setting->security = g_value_dup_string (value);
|
||||
g_free (priv->security);
|
||||
priv->security = g_value_dup_string (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -490,37 +639,37 @@ get_property (GObject *object, guint prop_id,
|
|||
|
||||
switch (prop_id) {
|
||||
case PROP_SSID:
|
||||
g_value_set_boxed (value, setting->ssid);
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_ssid (setting));
|
||||
break;
|
||||
case PROP_MODE:
|
||||
g_value_set_string (value, setting->mode);
|
||||
g_value_set_string (value, nm_setting_wireless_get_mode (setting));
|
||||
break;
|
||||
case PROP_BAND:
|
||||
g_value_set_string (value, setting->band);
|
||||
g_value_set_string (value, nm_setting_wireless_get_band (setting));
|
||||
break;
|
||||
case PROP_CHANNEL:
|
||||
g_value_set_uint (value, setting->channel);
|
||||
g_value_set_uint (value, nm_setting_wireless_get_channel (setting));
|
||||
break;
|
||||
case PROP_BSSID:
|
||||
g_value_set_boxed (value, setting->bssid);
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_bssid (setting));
|
||||
break;
|
||||
case PROP_RATE:
|
||||
g_value_set_uint (value, setting->rate);
|
||||
g_value_set_uint (value, nm_setting_wireless_get_rate (setting));
|
||||
break;
|
||||
case PROP_TX_POWER:
|
||||
g_value_set_uint (value, setting->tx_power);
|
||||
g_value_set_uint (value, nm_setting_wireless_get_tx_power (setting));
|
||||
break;
|
||||
case PROP_MAC_ADDRESS:
|
||||
g_value_set_boxed (value, setting->mac_address);
|
||||
g_value_set_boxed (value, nm_setting_wireless_get_mac_address (setting));
|
||||
break;
|
||||
case PROP_MTU:
|
||||
g_value_set_uint (value, setting->mtu);
|
||||
g_value_set_uint (value, nm_setting_wireless_get_mtu (setting));
|
||||
break;
|
||||
case PROP_SEEN_BSSIDS:
|
||||
g_value_set_boxed (value, setting->seen_bssids);
|
||||
g_value_set_boxed (value, NM_SETTING_WIRELESS_GET_PRIVATE (setting)->seen_bssids);
|
||||
break;
|
||||
case PROP_SEC:
|
||||
g_value_set_string (value, setting->security);
|
||||
g_value_set_string (value, nm_setting_wireless_get_security (setting));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
|
@ -534,6 +683,8 @@ nm_setting_wireless_class_init (NMSettingWirelessClass *setting_class)
|
|||
GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
|
||||
NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
|
||||
|
||||
g_type_class_add_private (setting_class, sizeof (NMSettingWirelessPrivate));
|
||||
|
||||
/* virtual methods */
|
||||
object_class->set_property = set_property;
|
||||
object_class->get_property = get_property;
|
||||
|
|
|
@ -69,18 +69,6 @@ GQuark nm_setting_wireless_error_quark (void);
|
|||
|
||||
typedef struct {
|
||||
NMSetting parent;
|
||||
|
||||
GByteArray *ssid;
|
||||
char *mode;
|
||||
char *band;
|
||||
guint32 channel;
|
||||
GByteArray *bssid;
|
||||
guint32 rate;
|
||||
guint32 tx_power;
|
||||
GByteArray *mac_address;
|
||||
guint32 mtu;
|
||||
GSList *seen_bssids;
|
||||
char *security;
|
||||
} NMSettingWireless;
|
||||
|
||||
typedef struct {
|
||||
|
@ -91,12 +79,30 @@ GType nm_setting_wireless_get_type (void);
|
|||
|
||||
NMSetting *nm_setting_wireless_new (void);
|
||||
|
||||
gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
|
||||
NMSettingWirelessSecurity *s_wireless_sec,
|
||||
guint32 ap_flags,
|
||||
guint32 ap_wpa,
|
||||
guint32 ap_rsn,
|
||||
guint32 ap_mode);
|
||||
const GByteArray *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);
|
||||
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);
|
||||
guint32 nm_setting_wireless_get_mtu (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_security (NMSettingWireless *setting);
|
||||
|
||||
gboolean nm_setting_wireless_add_seen_bssid (NMSettingWireless *setting,
|
||||
const char *bssid);
|
||||
|
||||
guint32 nm_setting_wireless_get_num_seen_bssids (NMSettingWireless *setting);
|
||||
const char *nm_setting_wireless_get_seen_bssid (NMSettingWireless *setting,
|
||||
guint32 i);
|
||||
|
||||
gboolean nm_setting_wireless_ap_security_compatible (NMSettingWireless *s_wireless,
|
||||
NMSettingWirelessSecurity *s_wireless_sec,
|
||||
guint32 ap_flags,
|
||||
guint32 ap_wpa,
|
||||
guint32 ap_rsn,
|
||||
guint32 ap_mode);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -545,32 +545,32 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||
NMAccessPoint *ap;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessSecurity *s_wireless_sec;
|
||||
GByteArray *ssid;
|
||||
guint32 len;
|
||||
const GByteArray *ssid;
|
||||
const char *mode;
|
||||
const char *band;
|
||||
guint32 channel;
|
||||
guint32 flags;
|
||||
|
||||
g_return_val_if_fail (connection != NULL, NULL);
|
||||
|
||||
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
|
||||
g_return_val_if_fail (s_wireless != NULL, NULL);
|
||||
g_return_val_if_fail (s_wireless->ssid != NULL, NULL);
|
||||
g_return_val_if_fail (s_wireless->ssid->len > 0, NULL);
|
||||
|
||||
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);
|
||||
|
||||
ap = nm_ap_new ();
|
||||
nm_ap_set_fake (ap, TRUE);
|
||||
|
||||
len = s_wireless->ssid->len;
|
||||
ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (ssid, (const guint8 *) s_wireless->ssid->data, len);
|
||||
nm_ap_set_ssid (ap, ssid);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
|
||||
// FIXME: bssid too?
|
||||
|
||||
if (s_wireless->mode) {
|
||||
if (!strcmp (s_wireless->mode, "infrastructure"))
|
||||
mode = nm_setting_wireless_get_mode (s_wireless);
|
||||
if (mode) {
|
||||
if (!strcmp (mode, "infrastructure"))
|
||||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||
else if (!strcmp (s_wireless->mode, "adhoc"))
|
||||
else if (!strcmp (mode, "adhoc"))
|
||||
nm_ap_set_mode (ap, NM_802_11_MODE_ADHOC);
|
||||
else
|
||||
goto error;
|
||||
|
@ -578,8 +578,11 @@ nm_ap_new_fake_from_connection (NMConnection *connection)
|
|||
nm_ap_set_mode (ap, NM_802_11_MODE_INFRA);
|
||||
}
|
||||
|
||||
if (s_wireless->band && s_wireless->channel) {
|
||||
guint32 freq = channel_to_freq (s_wireless->channel, s_wireless->band);
|
||||
band = nm_setting_wireless_get_band (s_wireless);
|
||||
channel = nm_setting_wireless_get_channel (s_wireless);
|
||||
|
||||
if (band && channel) {
|
||||
guint32 freq = channel_to_freq (channel, band);
|
||||
|
||||
if (freq == 0)
|
||||
goto error;
|
||||
|
@ -1196,6 +1199,10 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||
NMAccessPointPrivate *priv;
|
||||
NMSettingWireless *s_wireless;
|
||||
NMSettingWirelessSecurity *s_wireless_sec;
|
||||
const char *mode;
|
||||
const char *band;
|
||||
const GByteArray *bssid;
|
||||
guint32 channel;
|
||||
|
||||
g_return_val_if_fail (NM_IS_AP (self), FALSE);
|
||||
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
|
||||
|
@ -1206,37 +1213,37 @@ nm_ap_check_compatible (NMAccessPoint *self,
|
|||
if (s_wireless == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (!nm_utils_same_ssid (s_wireless->ssid, priv->ssid, TRUE))
|
||||
if (!nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), priv->ssid, TRUE))
|
||||
return FALSE;
|
||||
|
||||
if (s_wireless->bssid) {
|
||||
if (memcmp (s_wireless->bssid->data, &priv->address, ETH_ALEN))
|
||||
bssid = nm_setting_wireless_get_bssid (s_wireless);
|
||||
if (bssid && memcmp (bssid->data, &priv->address, ETH_ALEN))
|
||||
return FALSE;
|
||||
|
||||
mode = nm_setting_wireless_get_mode (s_wireless);
|
||||
if (mode) {
|
||||
if (!strcmp (mode, "infrastructure") && (priv->mode != NM_802_11_MODE_INFRA))
|
||||
return FALSE;
|
||||
if (!strcmp (mode, "adhoc") && (priv->mode != NM_802_11_MODE_ADHOC))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s_wireless->mode) {
|
||||
if ( !strcmp (s_wireless->mode, "infrastructure")
|
||||
&& (priv->mode != NM_802_11_MODE_INFRA))
|
||||
return FALSE;
|
||||
if ( !strcmp (s_wireless->mode, "adhoc")
|
||||
&& (priv->mode != NM_802_11_MODE_ADHOC))
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (s_wireless->band) {
|
||||
if (!strcmp (s_wireless->band, "a")) {
|
||||
band = nm_setting_wireless_get_band (s_wireless);
|
||||
if (band) {
|
||||
if (!strcmp (band, "a")) {
|
||||
if (priv->freq < 4915 || priv->freq > 5825)
|
||||
return FALSE;
|
||||
} else if (!strcmp (s_wireless->band, "bg")) {
|
||||
} else if (!strcmp (band, "bg")) {
|
||||
if (priv->freq < 2412 || priv->freq > 2484)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_wireless->channel) {
|
||||
channel = nm_setting_wireless_get_channel (s_wireless);
|
||||
if (channel) {
|
||||
guint32 ap_chan = freq_to_channel (priv->freq);
|
||||
|
||||
if (s_wireless->channel != ap_chan)
|
||||
if (channel != ap_chan)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -986,6 +986,7 @@ real_check_connection_compatible (NMDevice *device,
|
|||
NMDeviceWifiPrivate *priv = NM_DEVICE_WIFI_GET_PRIVATE (self);
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
const GByteArray *mac;
|
||||
|
||||
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||
g_assert (s_con);
|
||||
|
@ -1005,8 +1006,8 @@ real_check_connection_compatible (NMDevice *device,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if ( s_wireless->mac_address
|
||||
&& memcmp (s_wireless->mac_address->data, &(priv->hw_addr.ether_addr_octet), ETH_ALEN)) {
|
||||
mac = nm_setting_wireless_get_mac_address (s_wireless);
|
||||
if (mac && memcmp (mac->data, &(priv->hw_addr.ether_addr_octet), ETH_ALEN)) {
|
||||
g_set_error (error,
|
||||
NM_WIFI_ERROR, NM_WIFI_ERROR_CONNECTION_INCOMPATIBLE,
|
||||
"The connection's MAC address did not match this device.");
|
||||
|
@ -1055,6 +1056,7 @@ real_get_best_auto_connection (NMDevice *dev,
|
|||
NMConnection *connection = NM_CONNECTION (iter->data);
|
||||
NMSettingConnection *s_con;
|
||||
NMSettingWireless *s_wireless;
|
||||
const GByteArray *mac;
|
||||
NMSettingIP4Config *s_ip4;
|
||||
|
||||
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
||||
|
@ -1069,10 +1071,9 @@ real_get_best_auto_connection (NMDevice *dev,
|
|||
if (!s_wireless)
|
||||
continue;
|
||||
|
||||
if (s_wireless->mac_address) {
|
||||
if (memcmp (s_wireless->mac_address->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
|
||||
mac = nm_setting_wireless_get_mac_address (s_wireless);
|
||||
if (mac && memcmp (mac->data, priv->hw_addr.ether_addr_octet, ETH_ALEN))
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Use the connection if it's a shared connection */
|
||||
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
|
||||
|
@ -2635,9 +2636,11 @@ build_supplicant_config (NMDeviceWifi *self,
|
|||
* nothing was specified then pick something usable.
|
||||
*/
|
||||
if ((nm_ap_get_mode (ap) == NM_802_11_MODE_ADHOC) && nm_ap_get_user_created (ap)) {
|
||||
const char *band = nm_setting_wireless_get_band (s_wireless);
|
||||
|
||||
adhoc_freq = nm_ap_get_freq (ap);
|
||||
if (!adhoc_freq) {
|
||||
if (s_wireless->band && !strcmp (s_wireless->band, "a")) {
|
||||
if (band && !strcmp (band, "a")) {
|
||||
guint32 a_freqs[] = {5180, 5200, 5220, 5745, 5765, 5785, 5805, 0};
|
||||
adhoc_freq = find_supported_frequency (self, a_freqs);
|
||||
} else {
|
||||
|
@ -2647,7 +2650,7 @@ build_supplicant_config (NMDeviceWifi *self,
|
|||
}
|
||||
|
||||
if (!adhoc_freq) {
|
||||
if (s_wireless->band && !strcmp (s_wireless->band, "a"))
|
||||
if (band && !strcmp (band, "a"))
|
||||
adhoc_freq = 5180;
|
||||
else
|
||||
adhoc_freq = 2462;
|
||||
|
@ -2878,7 +2881,7 @@ real_act_stage2_config (NMDevice *dev, NMDeviceStateReason *reason)
|
|||
}
|
||||
|
||||
/* have secrets, or no secrets required */
|
||||
if (s_wireless->security) {
|
||||
if (nm_setting_wireless_get_security (s_wireless)) {
|
||||
nm_info ("Activation (%s/wireless): connection '%s' has security"
|
||||
", and secrets exist. No new secrets needed.",
|
||||
iface, nm_setting_connection_get_id (s_connection));
|
||||
|
@ -2949,6 +2952,7 @@ real_act_stage4_get_ip4_config (NMDevice *dev,
|
|||
if ((ret == NM_ACT_STAGE_RETURN_SUCCESS) && *config) {
|
||||
NMConnection *connection;
|
||||
NMSettingWireless *s_wireless;
|
||||
guint32 mtu;
|
||||
|
||||
connection = nm_act_request_get_connection (nm_device_get_act_request (dev));
|
||||
g_assert (connection);
|
||||
|
@ -2956,8 +2960,9 @@ real_act_stage4_get_ip4_config (NMDevice *dev,
|
|||
g_assert (s_wireless);
|
||||
|
||||
/* MTU override */
|
||||
if (s_wireless->mtu)
|
||||
nm_ip4_config_set_mtu (*config, s_wireless->mtu);
|
||||
mtu = nm_setting_wireless_get_mtu (s_wireless);
|
||||
if (mtu)
|
||||
nm_ip4_config_set_mtu (*config, mtu);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1586,24 +1586,33 @@ manager_hidden_ap_found (NMDeviceInterface *device,
|
|||
for (iter = connections; iter && !done; iter = g_slist_next (iter)) {
|
||||
NMConnection *connection = NM_CONNECTION (iter->data);
|
||||
NMSettingWireless *s_wireless;
|
||||
GSList *seen_iter;
|
||||
|
||||
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
if (!s_wireless || !s_wireless->seen_bssids)
|
||||
goto next;
|
||||
g_assert (s_wireless->ssid);
|
||||
const GByteArray *ssid;
|
||||
guint32 num_bssids;
|
||||
guint32 i;
|
||||
|
||||
for (seen_iter = s_wireless->seen_bssids; seen_iter; seen_iter = g_slist_next (seen_iter)) {
|
||||
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
if (!s_wireless)
|
||||
goto next;
|
||||
|
||||
num_bssids = nm_setting_wireless_get_num_seen_bssids (s_wireless);
|
||||
if (num_bssids < 1)
|
||||
goto next;
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
g_assert (ssid);
|
||||
|
||||
for (i = 0; i < num_bssids; i++) {
|
||||
const char *seen_bssid = nm_setting_wireless_get_seen_bssid (s_wireless, i);
|
||||
struct ether_addr seen_addr;
|
||||
|
||||
if (!ether_aton_r ((char *) seen_iter->data, &seen_addr))
|
||||
if (!ether_aton_r (seen_bssid, &seen_addr))
|
||||
continue;
|
||||
|
||||
if (memcmp (ap_addr, &seen_addr, sizeof (struct ether_addr)))
|
||||
continue;
|
||||
|
||||
/* Copy the SSID from the connection to the AP */
|
||||
nm_ap_set_ssid (ap, s_wireless->ssid);
|
||||
nm_ap_set_ssid (ap, ssid);
|
||||
done = TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -336,13 +336,16 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||
{
|
||||
NMSupplicantConfigPrivate *priv;
|
||||
gboolean is_adhoc;
|
||||
const char *mode;
|
||||
const GByteArray *id;
|
||||
|
||||
g_return_val_if_fail (NM_IS_SUPPLICANT_CONFIG (self), FALSE);
|
||||
g_return_val_if_fail (setting != NULL, FALSE);
|
||||
|
||||
priv = NM_SUPPLICANT_CONFIG_GET_PRIVATE (self);
|
||||
|
||||
is_adhoc = (setting->mode && !strcmp (setting->mode, "adhoc")) ? TRUE : FALSE;
|
||||
|
||||
mode = nm_setting_wireless_get_mode (setting);
|
||||
is_adhoc = (mode && !strcmp (mode, "adhoc")) ? TRUE : FALSE;
|
||||
if (is_adhoc)
|
||||
priv->ap_scan = 2;
|
||||
else if (is_broadcast == FALSE) {
|
||||
|
@ -352,10 +355,8 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||
priv->ap_scan = has_scan_capa_ssid ? 1 : 2;
|
||||
}
|
||||
|
||||
if (!nm_supplicant_config_add_option (self, "ssid",
|
||||
(char *) setting->ssid->data,
|
||||
setting->ssid->len,
|
||||
FALSE)) {
|
||||
id = nm_setting_wireless_get_ssid (setting);
|
||||
if (!nm_supplicant_config_add_option (self, "ssid", (char *) id->data, id->len, FALSE)) {
|
||||
nm_warning ("Error adding SSID to supplicant config.");
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -387,10 +388,11 @@ nm_supplicant_config_add_setting_wireless (NMSupplicantConfig * self,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (setting->bssid && setting->bssid->len) {
|
||||
id = nm_setting_wireless_get_bssid (setting);
|
||||
if (id && id->len) {
|
||||
char *str_bssid;
|
||||
|
||||
str_bssid = g_strdup_printf (MAC_FMT, MAC_ARG (setting->bssid->data));
|
||||
str_bssid = g_strdup_printf (MAC_FMT, MAC_ARG (id->data));
|
||||
if (!nm_supplicant_config_add_option (self, "bssid",
|
||||
str_bssid, strlen (str_bssid),
|
||||
FALSE)) {
|
||||
|
|
|
@ -179,7 +179,7 @@ get_udi_for_connection (NMConnection *connection,
|
|||
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
|
||||
if (s_wireless) {
|
||||
devices = nm_system_config_hal_manager_get_devices_of_type (hal_mgr, NM_DEVICE_TYPE_WIFI);
|
||||
udi = get_ether_device_udi (g_connection, s_wireless->mac_address, devices);
|
||||
udi = get_ether_device_udi (g_connection, nm_setting_wireless_get_mac_address (s_wireless), devices);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -638,11 +638,15 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
GError **error)
|
||||
{
|
||||
NMSettingWireless *s_wireless;
|
||||
GByteArray *array;
|
||||
char *value;
|
||||
|
||||
s_wireless = NM_SETTING_WIRELESS (nm_setting_wireless_new ());
|
||||
|
||||
if (!read_mac_address (ifcfg, &s_wireless->mac_address, error)) {
|
||||
if (read_mac_address (ifcfg, &array, error)) {
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_MAC_ADDRESS, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
} else {
|
||||
g_object_unref (s_wireless);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -659,9 +663,11 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
goto error;
|
||||
}
|
||||
|
||||
s_wireless->ssid = g_byte_array_sized_new (strlen (value));
|
||||
g_byte_array_append (s_wireless->ssid, (const guint8 *) value, len);
|
||||
array = g_byte_array_sized_new (strlen (value));
|
||||
g_byte_array_append (array, (const guint8 *) value, len);
|
||||
g_free (value);
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, array, NULL);
|
||||
g_byte_array_free (array, TRUE);
|
||||
} else {
|
||||
/* Only fail on lack of SSID if device is managed */
|
||||
if (!unmanaged) {
|
||||
|
@ -674,14 +680,15 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
value = svGetValue (ifcfg, "MODE");
|
||||
if (value) {
|
||||
char *lcase;
|
||||
const char *mode = NULL;
|
||||
|
||||
lcase = g_ascii_strdown (value, -1);
|
||||
g_free (value);
|
||||
|
||||
if (!strcmp (lcase, "ad-hoc")) {
|
||||
s_wireless->mode = g_strdup ("adhoc");
|
||||
mode = "adhoc";
|
||||
} else if (!strcmp (lcase, "managed")) {
|
||||
s_wireless->mode = g_strdup ("infrastructure");
|
||||
mode = "infrastructure";
|
||||
} else {
|
||||
g_set_error (error, ifcfg_plugin_error_quark (), 0,
|
||||
"Invalid mode '%s' (not ad-hoc or managed)",
|
||||
|
@ -690,10 +697,13 @@ make_wireless_setting (shvarFile *ifcfg,
|
|||
goto error;
|
||||
}
|
||||
g_free (lcase);
|
||||
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, mode, NULL);
|
||||
}
|
||||
|
||||
if (security)
|
||||
s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC,
|
||||
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
|
||||
|
||||
// FIXME: channel/freq, other L2 parameters like RTS
|
||||
}
|
||||
|
@ -715,7 +725,7 @@ wireless_connection_from_ifcfg (const char *file,
|
|||
NMConnection *connection = NULL;
|
||||
NMSetting *con_setting = NULL;
|
||||
NMSetting *wireless_setting = NULL;
|
||||
NMSettingWireless *s_wireless;
|
||||
const GByteArray *ssid;
|
||||
NMSetting *security_setting = NULL;
|
||||
char *printable_ssid = NULL;
|
||||
|
||||
|
@ -748,11 +758,10 @@ wireless_connection_from_ifcfg (const char *file,
|
|||
}
|
||||
nm_connection_add_setting (connection, wireless_setting);
|
||||
|
||||
s_wireless = (NMSettingWireless *) wireless_setting;
|
||||
if (s_wireless && s_wireless->ssid) {
|
||||
printable_ssid = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data,
|
||||
(guint32) s_wireless->ssid->len);
|
||||
} else
|
||||
ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (wireless_setting));
|
||||
if (ssid)
|
||||
printable_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
|
||||
else
|
||||
printable_ssid = g_strdup_printf ("unmanaged");
|
||||
|
||||
con_setting = make_connection_setting (file, ifcfg,
|
||||
|
|
|
@ -426,8 +426,10 @@ read_wpa_psk_settings (shvarFile *ifcfg,
|
|||
security->psk = g_strdup (value);
|
||||
} else {
|
||||
/* passphrase */
|
||||
const GByteArray *ssid = nm_setting_wireless_get_mac_address (s_wireless);
|
||||
unsigned char *buf = g_malloc0 (WPA_PMK_LEN * 2);
|
||||
pbkdf2_sha1 (value, (char *) s_wireless->ssid->data, s_wireless->ssid->len, 4096, buf, WPA_PMK_LEN);
|
||||
|
||||
pbkdf2_sha1 (value, (char *) ssid->data, ssid->len, 4096, buf, WPA_PMK_LEN);
|
||||
security->psk = utils_bin2hexstr ((const char *) buf, WPA_PMK_LEN, WPA_PMK_LEN * 2);
|
||||
g_free (buf);
|
||||
}
|
||||
|
@ -558,8 +560,12 @@ make_wireless_setting (shvarFile *ifcfg)
|
|||
gsize len = strlen (str);
|
||||
|
||||
if (len > 0 && len <= 32) {
|
||||
s_wireless->ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (s_wireless->ssid, (const guint8 *) str, len);
|
||||
GByteArray *ssid;
|
||||
|
||||
ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (ssid, (const guint8 *) str, len);
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
} else
|
||||
g_warning ("Ignoring invalid ESSID '%s', (size %zu not between 1 and 32 inclusive)", str, len);
|
||||
|
||||
|
@ -568,10 +574,17 @@ make_wireless_setting (shvarFile *ifcfg)
|
|||
|
||||
str = svGetValue (ifcfg, "WIRLESS_MODE");
|
||||
if (str) {
|
||||
const char *mode;
|
||||
|
||||
if (!g_ascii_strcasecmp (str, "ad-hoc"))
|
||||
s_wireless->mode = g_strdup ("adhoc");
|
||||
mode = "adhoc";
|
||||
else if (!g_ascii_strcasecmp (str, "managed"))
|
||||
s_wireless->mode = g_strdup ("infrastructure");
|
||||
mode = "infrastructure";
|
||||
else
|
||||
mode = NULL;
|
||||
|
||||
if (mode)
|
||||
g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, mode, NULL);
|
||||
|
||||
g_free (str);
|
||||
}
|
||||
|
@ -584,12 +597,12 @@ make_wireless_setting (shvarFile *ifcfg)
|
|||
static char *
|
||||
get_printable_ssid (NMSetting *setting)
|
||||
{
|
||||
NMSettingWireless *s_wireless = NM_SETTING_WIRELESS (setting);
|
||||
const GByteArray *ssid;
|
||||
char *printable_ssid = NULL;
|
||||
|
||||
if (s_wireless->ssid)
|
||||
printable_ssid = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data,
|
||||
(guint32) s_wireless->ssid->len);
|
||||
ssid = nm_setting_wireless_get_ssid (NM_SETTING_WIRELESS (setting));
|
||||
if (ssid)
|
||||
printable_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
|
||||
|
||||
return printable_ssid;
|
||||
}
|
||||
|
|
|
@ -161,10 +161,14 @@ update_wireless_setting_from_if_block(NMConnection *connection,
|
|||
const gchar* newkey = map_by_mapping(mapping, curr->key+wpa_l);
|
||||
|
||||
if(newkey && !strcmp("ssid", newkey)) {
|
||||
GByteArray *ssid;
|
||||
gint len = strlen(curr->data);
|
||||
wireless_setting->ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (wireless_setting->ssid, (const guint8 *) curr->data, len);
|
||||
PLUGIN_PRINT("SCPlugin-Ifupdown", "setting wpa ssid = %d", wireless_setting->ssid->len);
|
||||
|
||||
ssid = g_byte_array_sized_new (len);
|
||||
g_byte_array_append (ssid, (const guint8 *) curr->data, len);
|
||||
g_object_set (wireless_setting, NM_SETTING_WIRELESS_SSID, ssid, NULL);
|
||||
g_byte_array_free (ssid, TRUE);
|
||||
PLUGIN_PRINT("SCPlugin-Ifupdown", "setting wpa ssid = %d", len);
|
||||
} else if(newkey) {
|
||||
|
||||
g_object_set(wireless_setting,
|
||||
|
@ -200,8 +204,11 @@ static char *normalize_psk (gpointer value, gpointer data) {
|
|||
normalized = g_strdup (value);
|
||||
} else {
|
||||
/* passphrase */
|
||||
const GByteArray *ssid;
|
||||
unsigned char *buf = g_malloc0 (WPA_PMK_LEN * 2);
|
||||
pbkdf2_sha1 (value, (char *) s_wireless->ssid->data, s_wireless->ssid->len, 4096, buf, WPA_PMK_LEN);
|
||||
|
||||
ssid = nm_setting_wireless_get_ssid (s_wireless);
|
||||
pbkdf2_sha1 (value, (char *) ssid->data, ssid->len, 4096, buf, WPA_PMK_LEN);
|
||||
normalized = utils_bin2hexstr ((const char *) buf, WPA_PMK_LEN, WPA_PMK_LEN * 2);
|
||||
g_free (buf);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user