mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-08 16:10:36 +01:00
* panel-applet/no-networkmanager.png panel-applet/Makefile.am panel-applet/NMWirelessApplet.c - Add a "NetworkManager not running" icon and use it - Use new consolidated GConf keys rather than Preferred/Trusted * TODO: update * info-daemon/NetworkManagerInfo.c info-daemon/NetworkManagerInfoDbus.[ch] info-daemon/NetworkManagerInfoPassphraseDialog.c - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted - Add a "getNetworkTrusted" dbus method - "WirelessNetworkUpdate" signal now sent rather than "PreferredNetworkUpdate/TrustedNetworkUpdate" signals - Start freeing some dbus errors (not completed yet) * info-daemon/passphrase.glade - Remove the "don't show" hints for pager and taskbar - Add a title since its going to be in the taskbar * src/NetworkManager.[ch] src/NetworkManagerAPList.[ch] - There are now no longer two separate lists of wireless networks, but one list where each network is "trusted" or not trusted * src/NetworkManagerAP.[ch] - Add get/set "trusted" accessors and data bit * src/NetworkManagerDbus.[ch] - Add function to get "trusted" status of a network from NetworkManagerInfo - Trap new WirelessNetworkUpdate signal rather than old separate signals * src/NetworkManagerDevice.[ch] - Add per-device config data (ip4 addr, gateway, netmask) and accessors - (nm_device_new): Get device config from backend when initializing devices - (nm_device_activation_worker): Split out device configuration on activation to deal with static/dynamic IP differences, and try encryption fallbacks on a device if the encryption method for the best AP is not good - (nm_device_update_best_ap): convert to new consolidated access point lists from NetworkManagerInfo, and copy over latest NMI info to best_ap when setting it * src/NetworkManagerWireless.c - libgcrypt code wasn't converting the MD5 digest to an ascii string, fix it * src/backends/NetworkManagerRedHat.c src/backends/NetworkManagerSystem.h - (nm_system_device_update_config_info): Add function to get device configuration from system data in ifcfg-* files * src/backends/NetworkManagerDebian.c src/backends/NetworkManagerGentoo.c src/backends/NetworkManagerSlackware.c - Add stub functions for getting device configuration git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@131 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
201 lines
4.2 KiB
C
201 lines
4.2 KiB
C
/* 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 <glib.h>
|
|
#include <stdio.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <linux/sockios.h>
|
|
#include <syslog.h>
|
|
|
|
#include "NetworkManager.h"
|
|
#include "NetworkManagerUtils.h"
|
|
|
|
|
|
/*#define LOCKING_DEBUG */
|
|
|
|
/*
|
|
* nm_try_acquire_mutex
|
|
*
|
|
* Tries to acquire a given mutex, sleeping a bit between tries.
|
|
*
|
|
* Returns: FALSE if mutex was not acquired
|
|
* TRUE if mutex was successfully acquired
|
|
*/
|
|
gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func)
|
|
{
|
|
gint i = 5;
|
|
|
|
g_return_val_if_fail (mutex != NULL, FALSE);
|
|
|
|
while (i > 0)
|
|
{
|
|
if (g_mutex_trylock (mutex))
|
|
{
|
|
#ifdef LOCKING_DEBUG
|
|
if (func) syslog (LOG_DEBUG, "MUTEX: %s got mutex 0x%X", func, mutex);
|
|
#endif
|
|
return (TRUE);
|
|
}
|
|
g_usleep (G_USEC_PER_SEC / 2);
|
|
i++;
|
|
}
|
|
|
|
return (FALSE);
|
|
}
|
|
|
|
|
|
/*
|
|
* nm_unlock_mutex
|
|
*
|
|
* Simply unlocks a mutex, balances nm_try_acquire_mutex()
|
|
*
|
|
*/
|
|
void nm_unlock_mutex (GMutex *mutex, const char *func)
|
|
{
|
|
g_return_if_fail (mutex != NULL);
|
|
|
|
#ifdef LOCKING_DEBUG
|
|
if (func) syslog (LOG_DEBUG, "MUTEX: %s released mutex 0x%X", func, mutex);
|
|
#endif
|
|
|
|
g_mutex_unlock (mutex);
|
|
}
|
|
|
|
|
|
/*
|
|
* nm_null_safe_strcmp
|
|
*
|
|
* Doesn't freaking segfault if s1/s2 are NULL
|
|
*
|
|
*/
|
|
int nm_null_safe_strcmp (const char *s1, const char *s2)
|
|
{
|
|
if (!s1 && !s2)
|
|
return 0;
|
|
if (!s1 && s2)
|
|
return -1;
|
|
if (s1 && !s2)
|
|
return 1;
|
|
|
|
return (strcmp (s1, s2));
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
* nm_get_network_control_socket
|
|
*
|
|
* Get a control socket for network operations.
|
|
*
|
|
*/
|
|
int nm_get_network_control_socket (void)
|
|
{
|
|
int fd;
|
|
|
|
/* Try to grab a control socket */
|
|
fd = socket(PF_INET, SOCK_DGRAM, 0);
|
|
if (fd >= 0)
|
|
return (fd);
|
|
fd = socket(PF_PACKET, SOCK_DGRAM, 0);
|
|
if (fd >= 0)
|
|
return (fd);
|
|
fd = socket(PF_INET6, SOCK_DGRAM, 0);
|
|
if (fd >= 0)
|
|
return (fd);
|
|
|
|
syslog (LOG_ERR, "nm_get_network_control_socket() could not get network control socket.");
|
|
return (-1);
|
|
}
|
|
|
|
|
|
/*
|
|
* nm_ethernet_address_is_valid
|
|
*
|
|
* Compares an ethernet address against known invalid addresses.
|
|
*
|
|
*/
|
|
gboolean nm_ethernet_address_is_valid (struct ether_addr *test_addr)
|
|
{
|
|
gboolean valid = FALSE;
|
|
struct ether_addr invalid_addr1 = { {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF} };
|
|
struct ether_addr invalid_addr2 = { {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
|
|
struct ether_addr invalid_addr3 = { {0x44, 0x44, 0x44, 0x44, 0x44, 0x44} };
|
|
|
|
g_return_val_if_fail (test_addr != NULL, FALSE);
|
|
|
|
/* Compare the AP address the card has with invalid ethernet MAC addresses. */
|
|
if ( (memcmp(test_addr, &invalid_addr1, sizeof(struct ether_addr)) != 0)
|
|
&& (memcmp(test_addr, &invalid_addr2, sizeof(struct ether_addr)) != 0)
|
|
&& (memcmp(test_addr, &invalid_addr3, sizeof(struct ether_addr)) != 0))
|
|
valid = TRUE;
|
|
|
|
return (valid);
|
|
}
|
|
|
|
|
|
/*
|
|
* 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
|
|
*
|
|
* Wrap g_spawn_sync in a usable manner
|
|
*
|
|
*/
|
|
int nm_spawn_process (char *args)
|
|
{
|
|
gint num_args;
|
|
char **argv;
|
|
int exit_status;
|
|
|
|
g_return_val_if_fail (args != NULL, -1);
|
|
|
|
if (g_shell_parse_argv (args, &num_args, &argv, NULL))
|
|
{
|
|
if (g_spawn_sync ("/", argv, NULL, 0, NULL, NULL, NULL, NULL, &exit_status, NULL))
|
|
{
|
|
g_strfreev (argv);
|
|
return (exit_status);
|
|
}
|
|
g_strfreev (argv);
|
|
}
|
|
|
|
return (-1);
|
|
}
|
|
|