mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-31 18:20:10 +01:00
2006-01-08 Dan Williams <dcbw@redhat.com>
* src/nm-ap-security.c src/nm-ap-security.h - Add a user_created argument to the write_supplicant_config functions * src/nm-ap-security-wep.c src/nm-ap-security-wpa-psk.c src/nm-device-802-11-wireless.c - Make Ad-Hoc mode somewhat work, at least write the correct options to wpa_supplicant git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1298 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
bb20df207b
commit
1754f71e7f
6 changed files with 89 additions and 49 deletions
13
ChangeLog
13
ChangeLog
|
|
@ -1,3 +1,16 @@
|
|||
2006-01-08 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/nm-ap-security.c
|
||||
src/nm-ap-security.h
|
||||
- Add a user_created argument to the write_supplicant_config
|
||||
functions
|
||||
|
||||
* src/nm-ap-security-wep.c
|
||||
src/nm-ap-security-wpa-psk.c
|
||||
src/nm-device-802-11-wireless.c
|
||||
- Make Ad-Hoc mode somewhat work, at least write the
|
||||
correct options to wpa_supplicant
|
||||
|
||||
2006-01-08 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* src/nm-device-802-11-wireless.c
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ real_serialize (NMAPSecurity *instance, DBusMessageIter *iter)
|
|||
static gboolean
|
||||
real_write_supplicant_config (NMAPSecurity *instance,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid)
|
||||
int nwid,
|
||||
gboolean user_created)
|
||||
{
|
||||
NMAPSecurityWEP * self = NM_AP_SECURITY_WEP (instance);
|
||||
gboolean success = FALSE;
|
||||
|
|
|
|||
|
|
@ -118,51 +118,20 @@ real_serialize (NMAPSecurity *instance, DBusMessageIter *iter)
|
|||
static gboolean
|
||||
real_write_supplicant_config (NMAPSecurity *instance,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid)
|
||||
int nwid,
|
||||
gboolean user_created)
|
||||
{
|
||||
NMAPSecurityWPA_PSK * self = NM_AP_SECURITY_WPA_PSK (instance);
|
||||
gboolean success = FALSE;
|
||||
char * msg = NULL;
|
||||
const char * key = nm_ap_security_get_key (instance);
|
||||
int cipher = nm_ap_security_get_we_cipher (instance);
|
||||
char * key_mgmt = "WPA-PSK";
|
||||
char * pairwise_cipher = NULL;
|
||||
char * group_cipher = NULL;
|
||||
|
||||
/* WPA-PSK network setup */
|
||||
|
||||
/* wpa_cli -ieth1 set_network 0 key_mgmt WPA-PSK */
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i key_mgmt WPA-PSK", nwid))
|
||||
goto out;
|
||||
|
||||
msg = g_strdup_printf ("SET_NETWORK %i psk <key>", nwid);
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, msg,
|
||||
"SET_NETWORK %i psk %s", nwid, key))
|
||||
{
|
||||
g_free (msg);
|
||||
goto out;
|
||||
}
|
||||
g_free (msg);
|
||||
|
||||
if (cipher == IW_AUTH_CIPHER_TKIP)
|
||||
{
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i pairwise TKIP", nwid))
|
||||
goto out;
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i group TKIP", nwid))
|
||||
goto out;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i pairwise CCMP", nwid))
|
||||
goto out;
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i group CCMP", nwid))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (self->priv->wpa_version == IW_AUTH_WPA_VERSION_WPA)
|
||||
{
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
|
|
@ -176,6 +145,40 @@ real_write_supplicant_config (NMAPSecurity *instance,
|
|||
goto out;
|
||||
}
|
||||
|
||||
/* Ad-Hoc has to be WPA-NONE */
|
||||
if (user_created)
|
||||
key_mgmt = "WPA-NONE";
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i key_mgmt %s", nwid, key_mgmt))
|
||||
goto out;
|
||||
|
||||
msg = g_strdup_printf ("SET_NETWORK %i psk <key>", nwid);
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, msg,
|
||||
"SET_NETWORK %i psk %s", nwid, key))
|
||||
{
|
||||
g_free (msg);
|
||||
goto out;
|
||||
}
|
||||
g_free (msg);
|
||||
|
||||
if (cipher == IW_AUTH_CIPHER_TKIP)
|
||||
pairwise_cipher = group_cipher = "TKIP";
|
||||
else
|
||||
pairwise_cipher = group_cipher = "CCMP";
|
||||
|
||||
/* Ad-Hoc requires pairwise cipher of NONE */
|
||||
if (user_created)
|
||||
pairwise_cipher = "NONE";
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i pairwise %s", nwid, pairwise_cipher))
|
||||
goto out;
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i group %s", nwid, group_cipher))
|
||||
goto out;
|
||||
|
||||
success = TRUE;
|
||||
|
||||
out:
|
||||
|
|
|
|||
|
|
@ -133,7 +133,8 @@ nm_ap_security_new_from_ap (NMAccessPoint *ap)
|
|||
gboolean
|
||||
nm_ap_security_write_supplicant_config (NMAPSecurity *self,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid)
|
||||
int nwid,
|
||||
gboolean user_created)
|
||||
{
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
g_return_val_if_fail (ctrl != NULL, FALSE);
|
||||
|
|
@ -142,7 +143,7 @@ nm_ap_security_write_supplicant_config (NMAPSecurity *self,
|
|||
if (self->priv->dispose_has_run)
|
||||
return FALSE;
|
||||
|
||||
return NM_AP_SECURITY_GET_CLASS (self)->write_supplicant_config_func (self, ctrl, nwid);
|
||||
return NM_AP_SECURITY_GET_CLASS (self)->write_supplicant_config_func (self, ctrl, nwid, user_created);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -193,7 +194,8 @@ real_serialize (NMAPSecurity *self, DBusMessageIter *iter)
|
|||
static gboolean
|
||||
real_write_supplicant_config (NMAPSecurity *self,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid)
|
||||
int nwid,
|
||||
gboolean user_created)
|
||||
{
|
||||
/* Unencrypted network setup */
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,10 @@ struct _NMAPSecurityClass
|
|||
|
||||
int (*serialize_func) (NMAPSecurity *self, DBusMessageIter *iter);
|
||||
|
||||
gboolean (*write_supplicant_config_func)(NMAPSecurity *self, struct wpa_ctrl *ctrl, int nwid);
|
||||
gboolean (*write_supplicant_config_func)(NMAPSecurity *self,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid,
|
||||
gboolean user_created);
|
||||
|
||||
int (*device_setup_func) (NMAPSecurity *self, NMDevice80211Wireless * dev);
|
||||
};
|
||||
|
|
@ -74,21 +77,26 @@ GType nm_ap_security_get_type (void);
|
|||
|
||||
NMAPSecurity * nm_ap_security_new_copy (NMAPSecurity *self);
|
||||
|
||||
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
||||
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
||||
|
||||
NMAPSecurity * nm_ap_security_new_from_ap (struct NMAccessPoint *ap);
|
||||
|
||||
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
||||
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
||||
|
||||
const char * nm_ap_security_get_key (NMAPSecurity *self);
|
||||
const char * nm_ap_security_get_key (NMAPSecurity *self);
|
||||
|
||||
int nm_ap_security_serialize (NMAPSecurity *self, DBusMessageIter *iter);
|
||||
int nm_ap_security_serialize (NMAPSecurity *self,
|
||||
DBusMessageIter *iter);
|
||||
|
||||
gboolean nm_ap_security_write_supplicant_config (NMAPSecurity *self, struct wpa_ctrl *ctrl, int nwid);
|
||||
gboolean nm_ap_security_write_supplicant_config (NMAPSecurity *self,
|
||||
struct wpa_ctrl *ctrl,
|
||||
int nwid,
|
||||
gboolean user_created);
|
||||
|
||||
int nm_ap_security_device_setup (NMAPSecurity *self, NMDevice80211Wireless *dev);
|
||||
int nm_ap_security_device_setup (NMAPSecurity *self,
|
||||
NMDevice80211Wireless *dev);
|
||||
|
||||
const char *nm_ap_security_get_description (NMAPSecurity *self);
|
||||
const char * nm_ap_security_get_description (NMAPSecurity *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -2421,6 +2421,7 @@ supplicant_send_network_config (NMDevice80211Wireless *self,
|
|||
int nwid;
|
||||
const char * essid;
|
||||
struct wpa_ctrl * ctrl;
|
||||
gboolean user_created;
|
||||
|
||||
g_return_val_if_fail (self != NULL, FALSE);
|
||||
g_return_val_if_fail (req != NULL, FALSE);
|
||||
|
|
@ -2453,10 +2454,22 @@ supplicant_send_network_config (NMDevice80211Wireless *self,
|
|||
"SET_NETWORK %i ssid \"%s\"", nwid, essid))
|
||||
goto out;
|
||||
|
||||
/* Ad-Hoc ? */
|
||||
user_created = nm_ap_get_user_created (ap);
|
||||
if (user_created)
|
||||
{
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
"SET_NETWORK %i mode 1", nwid))
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (nm_device_activation_should_cancel (NM_DEVICE (self)))
|
||||
goto out;
|
||||
|
||||
if (!nm_ap_security_write_supplicant_config (nm_ap_get_security (ap), ctrl, nwid))
|
||||
if (!nm_ap_security_write_supplicant_config (nm_ap_get_security (ap), ctrl, nwid, user_created))
|
||||
goto out;
|
||||
|
||||
if (nm_device_activation_should_cancel (NM_DEVICE (self)))
|
||||
goto out;
|
||||
|
||||
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue