NetworkManager/src/NetworkManagerAP.c

371 lines
6.9 KiB
C
Raw Normal View History

/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2004 Red Hat, Inc.
*/
#include "NetworkManagerAP.h"
#include "NetworkManagerUtils.h"
extern gboolean debug;
/*
* Encapsulates Access Point information
*/
struct NMAccessPoint
{
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
guint refcount;
gchar *essid;
struct ether_addr *address;
guint8 quality;
double freq;
guint16 rate;
gboolean encrypted;
gboolean invalid;
2004-08-02 Dan Williams <dcbw@redhat.com> * TODO - new task: proper logging support * info-daemon/NetworkManagerInfo.c - Correct spelling of "canceled" - Correct casting of objects for g_signal_connect() * info-daemon/NetworkManagerInfoDbus.c - Add defines for NetworkManager namespace and object path, and use them - Add filter function to trap new signals from NetworkManager: WirelessNetworkAppeared, WirelessNetworkDisappeared * info-daemon/passphrase.glade - Change name of "ok" button to "Login to Network..." - Mark invisible * src/NetworkManager.c - Code and debug message cleanups - Rename "nm_add_current_devices"->"nm_add_initial_devices" - (nm_add_initial_devices) Check returned string array of devices and don't try to add devices if array is NULL - (main) Initialize libhal a bit later, make code a bit clearer * src/NetworkManagerAP.[ch] - New accessor and data member "matched": used to speed up AP list diffing - New accessor and data member "enc_method": will be used during key fallback to cache which passphrase->key conversion actually works so we don't have to do it every time * src/NetworkManagerAPList.[ch] - (nm_ap_list_find_ap_in_list) New: find an AP by essid in an AP list - (nm_ap_list_diff) New: given two lists of access points, find the differences between them, and send WirelessNetworkAppeared/Disappeared signals over dbus in response to those differences * src/NetworkManagerDbus.[ch] - (nm_dbus_get_object_path_from_ap) New: given a device and an access point, make an object path for that access point (NOTE that we don't yet check to make sure that access point is actually in the device's AP list yet) - (nm_dbus_get_ap_from_object_path) Renamed from nm_dbus_get_network_from_object_path - (nm_dbus_signal_wireless_network_appeared, nm_dbus_signal_wireless_network_disappeared) New: signal appearance/disappearance of wireless networks - (nm_dbus_set_user_key_for_network) Mark the network/ap as invalid if the user cancelled key entry * src/NetworkManagerDevice.[ch] - (nm_device_ap_list_clear) Use nm_ap_list_free rather than doing it ourselves - (nm_device_ap_list_get) New: return the AP list (static function) - (nm_device_do_normal_scan) Destroy old AP list later, so that we can diff the new one resulting from the scan with the old one * src/NetworkManagerWireless.c - (nm_wireless_is_most_prefered_ap) "invalid" access points cannot be "best" access points * test/nminfotest.c - #define object paths and namespaces and use the #defines rather than static strings - Test out user-key functionality of NetworkManagerInfo too git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@33 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-02 21:12:40 +00:00
NMAPEncMethod enc_method;
gboolean matched; // used in ap list diffing
/* Things from user prefs */
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
gchar *wep_key;
guint priority;
};
/*
* nm_ap_new
*
* Create a new, blank user access point info structure
*
*/
NMAccessPoint * nm_ap_new (void)
{
NMAccessPoint *ap;
ap = g_new0 (NMAccessPoint, 1);
if (!ap)
syslog( LOG_ERR, "nm_ap_new() could not allocate a new user access point info structure. Not enough memory?" );
ap->priority = NM_AP_PRIORITY_WORST;
ap->refcount = 1;
return (ap);
}
/*
* nm_ap_new_from_ap
*
* Create a new user access point info structure, duplicating an existing one
*
*/
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
{
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
NMAccessPoint *new_ap;
struct ether_addr *new_addr;
g_return_val_if_fail (src_ap != NULL, NULL);
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
new_addr = g_new0 (struct ether_addr, 1);
g_return_val_if_fail (new_addr != NULL, NULL);
new_ap = nm_ap_new();
if (!new_ap)
syslog( LOG_ERR, "nm_ap_new_from_uap() could not allocate a new user access point info structure. Not enough memory?" );
new_ap->refcount = 1;
if (src_ap->essid && (strlen (src_ap->essid) > 0))
new_ap->essid = g_strdup (src_ap->essid);
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
if (src_ap->address)
{
memcpy (new_addr, src_ap->address, sizeof (struct ether_addr));
new_ap->address = new_addr;
}
new_ap->quality = src_ap->quality;
new_ap->freq = src_ap->freq;
new_ap->rate = src_ap->rate;
2004-07-19 Dan Williams <dcbw@redhat.com> * Makefile.am - Add info-daemon directory * configure.in - Check for glade libs and headers - Add info-daemon directory * src/NetworkManagerAP.c - nm_ap_new_from_ap(): Fix bug that resulted in an APs encryption status not getting copied over to the new AP. * src/NetworkManagerDbus.c src/NetworkManagerDbus.h - Deal with nm_device_ap_list_get_ap()->nm_device_ap_list_get_ap_by_index() change - Remove nm_dbus_signal_need_key_for_network() - Add disabled code for asynchronous user wep key callbacks - Add functions for getting, setting, and cancelling user key operations - Remove "setKeyForNetwork" device dbus method call, its on NetworkManager object instead - Add "setKeyForNetwork" dbus method call on NetworkManager object * src/NetworkManagerDevice.c src/NetworkManagerDevice.h - nm_device_update_link_active(): revert changes for wireless link detection, the WEP-key-is-wrong logic is in device activation now - nm_device_activate(): for wireless devices, if we can't associate with access point (perhaps key is wrong) trigger get-user-key pending action - Implement get-user-key pending action stuff, tie to dbus messages - Rename nm_device_ap_list_get_ap() -> nm_device_ap_list_get_ap_by_index() - Add nm_device_ap_list_get_ap_by_essid() - Instead of copying "best" access points, ref them instead so that the key we set sticks around * src/NetworkManagerPolicy.c - Deal with wrong WEP key, but right access point (and if so, return link_active = TRUE) - Don't cancel pending actions on a device if its the same device as last iteration - Only promote pending_device->active_device if activation was successfull * src/Makefile.am - Rename nmclienttest->nmtest * info-daemon/Makefile.am info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfo.h info-daemon/NetworkManagerInfoDbus.c info-daemon/NetworkManagerInfoDbus.h info-daemon/passphrase.glade info-daemon/NetworkManagerInfo.conf info-daemon/keyring.png - Import sources for info-daemon, which pops up dialog for passphrase/key when NetworkManager asks for it, and also will (soon) provide "allowed" access point lists to NetworkManager by proxying user's GConf git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@16 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-19 06:08:52 +00:00
new_ap->encrypted = src_ap->encrypted;
if (src_ap->wep_key && (strlen (src_ap->wep_key) > 0))
new_ap->wep_key = g_strdup (src_ap->wep_key);
new_ap->priority = src_ap->priority;
return (new_ap);
}
/*
* AP refcounting functions
*/
void nm_ap_ref (NMAccessPoint *ap)
{
g_return_if_fail (ap != NULL);
ap->refcount++;
}
void nm_ap_unref (NMAccessPoint *ap)
{
g_return_if_fail (ap != NULL);
ap->refcount--;
if (ap->refcount == 0)
{
g_free (ap->essid);
g_free (ap->address);
g_free (ap->wep_key);
ap->essid = NULL;
ap->wep_key = NULL;
g_free (ap);
}
}
/*
* Get/set functions for priority
*
*/
guint nm_ap_get_priority (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, 0);
return (ap->priority);
}
void nm_ap_set_priority (NMAccessPoint *ap, guint priority)
{
g_return_if_fail (ap != NULL);
ap->priority = priority;
}
/*
* Get/set functions for essid
*
*/
gchar * nm_ap_get_essid (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, NULL);
return (ap->essid);
}
void nm_ap_set_essid (NMAccessPoint *ap, gchar * essid)
{
g_return_if_fail (ap != NULL);
if (ap->essid)
g_free (ap->essid);
ap->essid = g_strdup (essid);
}
/*
* Get/set functions for WEP key
*
*/
gchar * nm_ap_get_wep_key (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, NULL);
return (ap->wep_key);
}
void nm_ap_set_wep_key (NMAccessPoint *ap, gchar * wep_key)
{
g_return_if_fail (ap != NULL);
if (ap->wep_key)
g_free (ap->wep_key);
ap->wep_key = g_strdup (wep_key);
}
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
/*
* Get/set functions for encrypted flag
*
*/
gboolean nm_ap_get_encrypted (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, FALSE);
return (ap->encrypted);
}
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted)
{
g_return_if_fail (ap != NULL);
ap->encrypted = encrypted;
}
/*
* Get/set functions for address
*
*/
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
struct ether_addr * nm_ap_get_address (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, NULL);
return (ap->address);
}
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr * addr)
{
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
struct ether_addr *new_addr;
g_return_if_fail (ap != NULL);
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
new_addr = g_new0 (struct ether_addr, 1);
g_return_if_fail (new_addr != NULL);
if (ap->address)
g_free (ap->address);
2004-07-15 Dan Williams <dcbw@redhat.com> * src/Makefile.am - Turn on warnings * src/NetworkManager.c - nm_create_device_and_add_to_list(): call nm_device_deactivate() rather that doing the deactivation ourselves - Cancel an pending actions on a device if its being removed - Break up link state checking a bit, make non-active wireless cards deactivated to save power - Remove unused variables * src/NetworkManager.h - Add support for "pending" device * src/NetworkManagerAP.h src/NetworkManagerAP.c - Add support for determining whether and AP has encryption enabled or not - AP address is now "struct ether_addr" rather than a string * src/NetworkManagerDbus.h src/NetworkManagerDbus.c - Add signal NeedKeyForNetwork, method SetKeyForNetwork (testing only) - Changes for AP address from struct ether_addr->string * src/NetworkManagerDevice.h src/NetworkManagerDevice.c - Remove unused variables, fix warnings - Add support for Pending Actions (things that block a device from being "active" until they are completed). - First pending action: Get a WEP key from the user - Add nm_device_is_wire[d|less](), rename nm_device_is_wireless() - Clean up explicit testing of dev->iface_type to use nm_device_is_wireless() - Update wireless link checking to try to determine if the AP we are associated with is correct, but the WEP key we are using is just wrong. If its wrong, trigger the GetUserKey pending action on the device - If dhclient can't get an IP address, it brings the device down. Bring it back up in that case, otherwise we can't scan or link-check on it - Add IP address change notifications at appropriate points (still needs some work) - Add nm_device_need_ap_switch(), checks whether we need to switch access points or not * src/NetworkManagerPolicy.h src/NetworkManagerPolicy.c - Split out "best" access point determiniation into separate function - Make device activation 2-stage: first the device is pending, then in the next iteration through it becomes "active" unless it has pending actions * src/NetworkManagerUtils.h src/NetworkManagerUtils.c - Clean up unused variables and warnings - Wrap our debug macros in {} to prevent possible confusion * src/NetworkManagerWireless.c - Forgot to return current best priority, which lead to last available AP always being chosen no matter what its priority was. Corrected. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@15 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-07-15 16:51:48 +00:00
memcpy (new_addr, addr, sizeof (struct ether_addr));
ap->address = new_addr;
}
/*
* Get/set functions for quality
*
*/
guint8 nm_ap_get_quality (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, 0);
return (ap->quality);
}
void nm_ap_set_quality (NMAccessPoint *ap, guint8 quality)
{
g_return_if_fail (ap != NULL);
ap->quality = quality;
}
/*
* Get/set functions for frequency
*
*/
double nm_ap_get_freq (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, 0);
return (ap->freq);
}
void nm_ap_set_freq (NMAccessPoint *ap, double freq)
{
g_return_if_fail (ap != NULL);
ap->freq = freq;
}
/*
* Get/set functions for rate
*
*/
guint16 nm_ap_get_rate (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, 0);
return (ap->rate);
}
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate)
{
g_return_if_fail (ap != NULL);
ap->rate = rate;
}
/*
* Get/set functions for "invalid" access points, ie ones
* for which a user explicitly does not wish to connect to
* (by cancelling requests for WEP key, for example)
*
*/
gboolean nm_ap_get_invalid (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, TRUE);
return (ap->invalid);
}
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
{
g_return_if_fail (ap != NULL);
ap->invalid = invalid;
}
2004-08-02 Dan Williams <dcbw@redhat.com> * TODO - new task: proper logging support * info-daemon/NetworkManagerInfo.c - Correct spelling of "canceled" - Correct casting of objects for g_signal_connect() * info-daemon/NetworkManagerInfoDbus.c - Add defines for NetworkManager namespace and object path, and use them - Add filter function to trap new signals from NetworkManager: WirelessNetworkAppeared, WirelessNetworkDisappeared * info-daemon/passphrase.glade - Change name of "ok" button to "Login to Network..." - Mark invisible * src/NetworkManager.c - Code and debug message cleanups - Rename "nm_add_current_devices"->"nm_add_initial_devices" - (nm_add_initial_devices) Check returned string array of devices and don't try to add devices if array is NULL - (main) Initialize libhal a bit later, make code a bit clearer * src/NetworkManagerAP.[ch] - New accessor and data member "matched": used to speed up AP list diffing - New accessor and data member "enc_method": will be used during key fallback to cache which passphrase->key conversion actually works so we don't have to do it every time * src/NetworkManagerAPList.[ch] - (nm_ap_list_find_ap_in_list) New: find an AP by essid in an AP list - (nm_ap_list_diff) New: given two lists of access points, find the differences between them, and send WirelessNetworkAppeared/Disappeared signals over dbus in response to those differences * src/NetworkManagerDbus.[ch] - (nm_dbus_get_object_path_from_ap) New: given a device and an access point, make an object path for that access point (NOTE that we don't yet check to make sure that access point is actually in the device's AP list yet) - (nm_dbus_get_ap_from_object_path) Renamed from nm_dbus_get_network_from_object_path - (nm_dbus_signal_wireless_network_appeared, nm_dbus_signal_wireless_network_disappeared) New: signal appearance/disappearance of wireless networks - (nm_dbus_set_user_key_for_network) Mark the network/ap as invalid if the user cancelled key entry * src/NetworkManagerDevice.[ch] - (nm_device_ap_list_clear) Use nm_ap_list_free rather than doing it ourselves - (nm_device_ap_list_get) New: return the AP list (static function) - (nm_device_do_normal_scan) Destroy old AP list later, so that we can diff the new one resulting from the scan with the old one * src/NetworkManagerWireless.c - (nm_wireless_is_most_prefered_ap) "invalid" access points cannot be "best" access points * test/nminfotest.c - #define object paths and namespaces and use the #defines rather than static strings - Test out user-key functionality of NetworkManagerInfo too git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@33 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2004-08-02 21:12:40 +00:00
/*
* Get/set functions for "matched", which is used by
* the ap list diffing functions to speed up the diff
*
*/
gboolean nm_ap_get_matched (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, TRUE);
return (ap->matched);
}
void nm_ap_set_matched (NMAccessPoint *ap, gboolean matched)
{
g_return_if_fail (ap != NULL);
ap->matched = matched;
}
/*
* Get/set functions for encryption method
* Given some sort of passphrase/wep key from the user, we try it first
* as a 104-bit passphrase->key conversion, and fall back from there. These
* functions are meant to cache which fallback succeeds so we don't have to
* do it every time.
*
*/
NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap)
{
g_return_val_if_fail (ap != NULL, TRUE);
return (ap->enc_method);
}
void nm_ap_set_enc_method (NMAccessPoint *ap, NMAPEncMethod enc_method)
{
g_return_if_fail (ap != NULL);
ap->enc_method = enc_method;
}