Commit 994948d7 authored by Dan Williams's avatar Dan Williams
Browse files

2005-10-15 Dan Williams <dcbw@redhat.com>

	Move scanning code into NetworkManager rather than use iwlib's
	iw_scan() function, so that we can figure out AP capabilities.

	* NetworkManager.h
		- Add AP capability bits

	* src/NetworkManagerAP.[ch]
		- Add capability field to NMAccessPoint structure
		- Add WPA & RSN Information Element fields and accessor
			functions to NMAccessPoint

	* src/NetworkManagerDevice.c
		- Remove usage of iw_scan
		- Add scanning code to NetworkManager rather than use
			iw_scan() from iwlib

	* src/NetworkManagerUtils.[ch]
		- (nm_dispose_scan_results): remove, unused


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1023 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
parent 150bf7ca
2005-10-15 Dan Williams <dcbw@redhat.com>
Move scanning code into NetworkManager rather than use iwlib's
iw_scan() function, so that we can figure out AP capabilities.
* NetworkManager.h
- Add AP capability bits
* src/NetworkManagerAP.[ch]
- Add capability field to NMAccessPoint structure
- Add WPA & RSN Information Element fields and accessor
functions to NMAccessPoint
* src/NetworkManagerDevice.c
- Remove usage of iw_scan
- Add scanning code to NetworkManager rather than use
iw_scan() from iwlib
* src/NetworkManagerUtils.[ch]
- (nm_dispose_scan_results): remove, unused
2005-10-14 Christopher Aillon <caillon@redhat.com>
* gnome/libnm_glib/libnm_glib.c:
......
......@@ -132,6 +132,16 @@ typedef enum NMEncKeyType
#define NM_DEVICE_CAP_WPA_PSK 0x0008
/*
* Access Point capability bits
*
*/
#define NM_AP_CAP_NONE 0x0000
#define NM_AP_CAP_WEP 0x0001
#define NM_AP_CAP_WPA1 0x0002
#define NM_AP_CAP_WPA2 0x0004
/*
* Wireless network modes
*/
......
......@@ -30,29 +30,36 @@
*/
struct NMAccessPoint
{
guint refcount;
char *essid;
struct ether_addr *address;
NMNetworkMode mode;
gint8 strength;
double freq;
guint16 rate;
gboolean encrypted;
guint refcount;
char * essid;
struct ether_addr * address;
NMNetworkMode mode;
gint8 strength;
double freq;
guint16 rate;
gboolean encrypted;
guint32 capabilities;
/* WPA auxiliary information */
guint8 * wpa_ie;
guint32 wpa_ie_len;
guint8 * rsn_ie;
guint32 rsn_ie_len;
/* Non-scanned attributes */
gboolean invalid;
gboolean matched; /* used in ap list diffing */
gboolean artificial; /* Whether or not the AP is from a scan */
gboolean user_created; /* Whether or not the AP was created by the user with "Create network..." */
GTimeVal last_seen; /* Last time the AP was seen in a scan */
gboolean invalid;
gboolean matched; /* used in ap list diffing */
gboolean artificial; /* Whether or not the AP is from a scan */
gboolean user_created; /* Whether or not the AP was created by the user with "Create network..." */
GTimeVal last_seen; /* Last time the AP was seen in a scan */
/* Things from user prefs/NetworkManagerInfo */
gboolean trusted;
char *enc_key;
NMEncKeyType enc_type;
NMDeviceAuthMethod auth_method;
GTimeVal timestamp;
GSList *user_addresses;
gboolean trusted;
char * enc_key;
NMEncKeyType enc_type;
NMDeviceAuthMethod auth_method;
GTimeVal timestamp;
GSList * user_addresses;
};
/* This is a controlled list. Want to add to it? Stop. Ask first. */
......@@ -639,3 +646,67 @@ gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap)
return FALSE;
}
const guint8 * nm_ap_get_wpa_ie (NMAccessPoint *ap, guint32 *length)
{
g_return_val_if_fail (ap != NULL, NULL);
g_return_val_if_fail (length != NULL, NULL);
*length = ap->wpa_ie_len;
return ap->wpa_ie;
}
void nm_ap_set_wpa_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length)
{
g_return_if_fail (ap != NULL);
if (wpa_ie)
g_return_if_fail ((length > 0) && (length <= AP_MAX_WPA_IE_LEN));
if (ap->wpa_ie)
{
g_free (ap->wpa_ie);
ap->wpa_ie = NULL;
ap->wpa_ie_len = 0;
}
if (wpa_ie)
{
ap->wpa_ie = g_malloc0 (length);
ap->wpa_ie_len = length;
memcpy (ap->wpa_ie, wpa_ie, length);
}
}
const guint8 * nm_ap_get_rsn_ie (NMAccessPoint *ap, guint32 *length)
{
g_return_val_if_fail (ap != NULL, NULL);
g_return_val_if_fail (length != NULL, NULL);
*length = ap->rsn_ie_len;
return ap->rsn_ie;
}
void nm_ap_set_rsn_ie (NMAccessPoint *ap, const guint8 *rsn_ie, guint32 length)
{
g_return_if_fail (ap != NULL);
if (rsn_ie)
g_return_if_fail ((length > 0) && (length <= AP_MAX_WPA_IE_LEN));
if (ap->rsn_ie)
{
g_free (ap->rsn_ie);
ap->rsn_ie = NULL;
ap->rsn_ie_len = 0;
}
if (rsn_ie)
{
ap->rsn_ie = g_malloc0 (length);
ap->rsn_ie_len = length;
memcpy (ap->rsn_ie, rsn_ie, length);
}
}
......@@ -28,6 +28,9 @@
typedef struct NMAccessPoint NMAccessPoint;
#define AP_MAX_WPA_IE_LEN 40
NMAccessPoint * nm_ap_new (void);
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap);
......@@ -43,7 +46,7 @@ void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
const char * nm_ap_get_enc_key_source (const NMAccessPoint *ap);
char * nm_ap_get_enc_key_hashed (const NMAccessPoint *ap);
void nm_ap_set_enc_key_source (NMAccessPoint *ap, const char *key, NMEncKeyType type);
NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap);
NMEncKeyType nm_ap_get_enc_type (const NMAccessPoint *ap);
NMDeviceAuthMethod nm_ap_get_auth_method (const NMAccessPoint *ap);
void nm_ap_set_auth_method (NMAccessPoint *ap, const NMDeviceAuthMethod auth_method);
......@@ -91,6 +94,12 @@ void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list);
gboolean nm_ap_is_enc_key_valid (NMAccessPoint *ap);
gboolean nm_is_enc_key_valid (const char *key, NMEncKeyType key_type);
const guint8 * nm_ap_get_wpa_ie (NMAccessPoint *ap, guint32 *length);
void nm_ap_set_wpa_ie (NMAccessPoint *ap, const guint8 *wpa_ie, guint32 length);
const guint8 * nm_ap_get_rsn_ie (NMAccessPoint *ap, guint32 *length);
void nm_ap_set_rsn_ie (NMAccessPoint *ap, const guint8 *rsn_ie, guint32 length);
/*
* NOTE:
* This is not intended to return true for all APs with manufacturer defaults. It is intended to return true for
......
This diff is collapsed.
......@@ -351,26 +351,6 @@ gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr)
}
/*
* nm_dispose_scan_results
*
* Free memory used by the wireless scan results structure
*
*/
void nm_dispose_scan_results (wireless_scan *result_list)
{
wireless_scan *tmp = result_list;
while (tmp)
{
wireless_scan *tmp2 = tmp;
tmp = tmp->next;
free (tmp2);
}
}
/*
* nm_spawn_process
*
......
......@@ -58,8 +58,6 @@ int nm_null_safe_strcmp (const char *s1, const char *s2);
gboolean nm_ethernet_address_is_valid (const struct ether_addr *test_addr);
void nm_dispose_scan_results (wireless_scan *result_list);
int nm_spawn_process (const char *args);
void nm_print_device_capabilities (NMDevice *dev);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment