2004-10-21 Dan Williams <dcbw@redhat.com>
* NetworkManager.h - New file, now contains commonly used structures and bits for the dbus API of NetworkManager * Makefile.am - Deliver NetworkManager.h to ${includedir}/NetworkManager * src/NetworkManager.h - Rename -> src/NetworkManagerMain.c * Various fixups all around to use NetworkManager.h and new src/NetworkManagerMain.h, remove redundant bits that got moved into NetworkManager.h * src/NetworkManagerDevice.[ch] src/NetworkManagerUtils.[ch] src/NetworkManagerPolicy.c src/NetworkManagerDbus.c - Whitelist wireless drivers, and blacklist some wired drivers. Also blacklist cipsec and ethernet-over-usb devices at this time (RH #135722, RH #135648) - Don't leak unsupported devices out over dbus, or allow them to be set as the active device. Skip over them during automatic device picking * test/nmclienttest.c - Clean up the dbus code a lot git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@261 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
30
ChangeLog
30
ChangeLog
@@ -1,3 +1,33 @@
|
|||||||
|
2004-10-21 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
* NetworkManager.h
|
||||||
|
- New file, now contains commonly used structures and bits
|
||||||
|
for the dbus API of NetworkManager
|
||||||
|
|
||||||
|
* Makefile.am
|
||||||
|
- Deliver NetworkManager.h to ${includedir}/NetworkManager
|
||||||
|
|
||||||
|
* src/NetworkManager.h
|
||||||
|
- Rename -> src/NetworkManagerMain.c
|
||||||
|
|
||||||
|
* Various fixups all around to use NetworkManager.h and new
|
||||||
|
src/NetworkManagerMain.h, remove redundant bits that got
|
||||||
|
moved into NetworkManager.h
|
||||||
|
|
||||||
|
* src/NetworkManagerDevice.[ch]
|
||||||
|
src/NetworkManagerUtils.[ch]
|
||||||
|
src/NetworkManagerPolicy.c
|
||||||
|
src/NetworkManagerDbus.c
|
||||||
|
- Whitelist wireless drivers, and blacklist some wired
|
||||||
|
drivers. Also blacklist cipsec and ethernet-over-usb
|
||||||
|
devices at this time (RH #135722, RH #135648)
|
||||||
|
- Don't leak unsupported devices out over dbus, or allow
|
||||||
|
them to be set as the active device. Skip over them
|
||||||
|
during automatic device picking
|
||||||
|
|
||||||
|
* test/nmclienttest.c
|
||||||
|
- Clean up the dbus code a lot
|
||||||
|
|
||||||
Tue Oct 19 14:20:29 2004 Jonathan Blandford <jrb@redhat.com>
|
Tue Oct 19 14:20:29 2004 Jonathan Blandford <jrb@redhat.com>
|
||||||
|
|
||||||
* configure.in: post release bump.
|
* configure.in: post release bump.
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
SUBDIRS = src dispatcher-daemon $(notification_icon_dir) info-daemon initscript test po
|
SUBDIRS = src dispatcher-daemon $(notification_icon_dir) info-daemon initscript test po
|
||||||
|
|
||||||
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in
|
EXTRA_DIST = CONTRIBUTING NetworkManager.pc.in NetworkManager.h
|
||||||
|
|
||||||
pkgconfigdir = $(libdir)/pkgconfig
|
pkgconfigdir = $(libdir)/pkgconfig
|
||||||
|
|
||||||
pkgconfig_DATA = NetworkManager.pc
|
pkgconfig_DATA = NetworkManager.pc
|
||||||
|
|
||||||
|
NetworkManagerincludedir=$(includedir)/NetworkManager
|
||||||
|
|
||||||
|
NetworkManagerinclude_HEADERS = NetworkManager.h
|
||||||
|
102
NetworkManager.h
Normal file
102
NetworkManager.h
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
/* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef NETWORK_MANAGER_H
|
||||||
|
#define NETWORK_MANAGER_H
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dbus services details
|
||||||
|
*/
|
||||||
|
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
||||||
|
|
||||||
|
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
||||||
|
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
||||||
|
#define NM_DBUS_PATH_DEVICES "/org/freedesktop/NetworkManager/Devices"
|
||||||
|
#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices"
|
||||||
|
|
||||||
|
#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo"
|
||||||
|
#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo"
|
||||||
|
#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Some common errors
|
||||||
|
*/
|
||||||
|
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
|
||||||
|
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
|
||||||
|
#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Types of NetworkManager devices
|
||||||
|
*/
|
||||||
|
typedef enum NMDeviceType
|
||||||
|
{
|
||||||
|
DEVICE_TYPE_DONT_KNOW = 0,
|
||||||
|
DEVICE_TYPE_WIRED_ETHERNET,
|
||||||
|
DEVICE_TYPE_WIRELESS_ETHERNET
|
||||||
|
} NMDeviceType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Wireless network types
|
||||||
|
*/
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
NETWORK_TYPE_UNKNOWN = 0,
|
||||||
|
NETWORK_TYPE_ALLOWED,
|
||||||
|
NETWORK_TYPE_INVALID,
|
||||||
|
NETWORK_TYPE_DEVICE
|
||||||
|
} NMNetworkType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Encryption key types
|
||||||
|
*/
|
||||||
|
typedef enum NMEncKeyType
|
||||||
|
{
|
||||||
|
NM_ENC_TYPE_UNKNOWN = 0,
|
||||||
|
NM_ENC_TYPE_NONE,
|
||||||
|
NM_ENC_TYPE_40_BIT_HEX_KEY,
|
||||||
|
NM_ENC_TYPE_40_BIT_PASSPHRASE,
|
||||||
|
NM_ENC_TYPE_128_BIT_HEX_KEY,
|
||||||
|
NM_ENC_TYPE_128_BIT_PASSPHRASE
|
||||||
|
/* FIXME: WPA and 802.1x support */
|
||||||
|
} NMEncKeyType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Driver support levels
|
||||||
|
*/
|
||||||
|
typedef enum NMDriverSupportLevel
|
||||||
|
{
|
||||||
|
NM_DRIVER_UNSUPPORTED = 0,
|
||||||
|
NM_DRIVER_SEMI_SUPPORTED,
|
||||||
|
NM_DRIVER_FULLY_SUPPORTED
|
||||||
|
} NMDriverSupportLevel;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Info-daemon specific preference locations
|
||||||
|
*/
|
||||||
|
#define NMI_GCONF_WIRELESS_NETWORKS_PATH "/system/networking/wireless/networks"
|
||||||
|
|
||||||
|
#endif
|
@@ -256,9 +256,9 @@ int main( int argc, char *argv[] )
|
|||||||
* get change notifications for our wireless networking data.
|
* get change notifications for our wireless networking data.
|
||||||
*/
|
*/
|
||||||
app_info->gconf_client = gconf_client_get_default ();
|
app_info->gconf_client = gconf_client_get_default ();
|
||||||
gconf_client_add_dir (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKING_PATH,
|
gconf_client_add_dir (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKS_PATH,
|
||||||
GCONF_CLIENT_PRELOAD_NONE, NULL);
|
GCONF_CLIENT_PRELOAD_NONE, NULL);
|
||||||
notify_id = gconf_client_notify_add (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKING_PATH,
|
notify_id = gconf_client_notify_add (app_info->gconf_client, NMI_GCONF_WIRELESS_NETWORKS_PATH,
|
||||||
nmi_gconf_notify_callback, app_info, NULL, NULL);
|
nmi_gconf_notify_callback, app_info, NULL, NULL);
|
||||||
|
|
||||||
/* Create our own dbus service */
|
/* Create our own dbus service */
|
||||||
|
@@ -56,7 +56,4 @@ struct NMIAppInfo
|
|||||||
};
|
};
|
||||||
typedef struct NMIAppInfo NMIAppInfo;
|
typedef struct NMIAppInfo NMIAppInfo;
|
||||||
|
|
||||||
#define NMI_GCONF_WIRELESS_NETWORKING_PATH "/system/networking/wireless"
|
|
||||||
#define NMI_GCONF_WIRELESS_NETWORKS_PATH "/system/networking/wireless/networks"
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -31,17 +31,6 @@
|
|||||||
#include "NetworkManagerInfoDbus.h"
|
#include "NetworkManagerInfoDbus.h"
|
||||||
#include "NetworkManagerInfoPassphraseDialog.h"
|
#include "NetworkManagerInfoPassphraseDialog.h"
|
||||||
|
|
||||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
|
||||||
|
|
||||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
|
||||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
|
||||||
#define NM_DBUS_PATH_DEVICES "/org/freedesktop/NetworkManager/Devices"
|
|
||||||
#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices"
|
|
||||||
|
|
||||||
#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmi_network_type_valid
|
* nmi_network_type_valid
|
||||||
@@ -49,7 +38,7 @@
|
|||||||
* Helper to validate network types NMI can deal with
|
* Helper to validate network types NMI can deal with
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
inline gboolean nmi_network_type_valid (NMINetworkType type)
|
inline gboolean nmi_network_type_valid (NMNetworkType type)
|
||||||
{
|
{
|
||||||
return ((type == NETWORK_TYPE_ALLOWED));
|
return ((type == NETWORK_TYPE_ALLOWED));
|
||||||
}
|
}
|
||||||
@@ -114,7 +103,7 @@ static void nmi_dbus_get_key_for_network (NMIAppInfo *info, DBusMessage *message
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
||||||
const char *network, const char *passphrase, const char *key_type_string)
|
const char *network, const char *passphrase, const int key_type)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
|
|
||||||
@@ -133,7 +122,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
|||||||
if (dbus_message_append_args (message, DBUS_TYPE_STRING, device,
|
if (dbus_message_append_args (message, DBUS_TYPE_STRING, device,
|
||||||
DBUS_TYPE_STRING, network,
|
DBUS_TYPE_STRING, network,
|
||||||
DBUS_TYPE_STRING, passphrase,
|
DBUS_TYPE_STRING, passphrase,
|
||||||
DBUS_TYPE_STRING, key_type_string,
|
DBUS_TYPE_INT32, key_type,
|
||||||
DBUS_TYPE_INVALID))
|
DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
if (!dbus_connection_send (connection, message, NULL))
|
if (!dbus_connection_send (connection, message, NULL))
|
||||||
@@ -151,7 +140,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
|||||||
* allowed/ignored network.
|
* allowed/ignored network.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMINetworkType type)
|
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMNetworkType type)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
|
|
||||||
@@ -191,7 +180,7 @@ static DBusMessage *nmi_dbus_get_networks (NMIAppInfo *info, DBusMessage *messag
|
|||||||
DBusMessage *reply_message = NULL;
|
DBusMessage *reply_message = NULL;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusMessageIter iter_array;
|
DBusMessageIter iter_array;
|
||||||
NMINetworkType type;
|
NMNetworkType type;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
g_return_val_if_fail (message != NULL, NULL);
|
g_return_val_if_fail (message != NULL, NULL);
|
||||||
@@ -275,7 +264,7 @@ static DBusMessage *nmi_dbus_get_network_timestamp (NMIAppInfo *info, DBusMessag
|
|||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
NMINetworkType type;
|
NMNetworkType type;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
@@ -329,7 +318,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m
|
|||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
NMINetworkType type;
|
NMNetworkType type;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
@@ -384,7 +373,7 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes
|
|||||||
GConfValue *key_value;
|
GConfValue *key_value;
|
||||||
GConfValue *key_type_value;
|
GConfValue *key_type_value;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
NMINetworkType type;
|
NMNetworkType type;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
@@ -416,10 +405,10 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes
|
|||||||
if (key_value && key_type_value)
|
if (key_value && key_type_value)
|
||||||
{
|
{
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (key_value),
|
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (key_value),
|
||||||
DBUS_TYPE_STRING, gconf_value_get_string (key_type_value), DBUS_TYPE_INVALID);
|
DBUS_TYPE_INT32, gconf_value_get_int (key_type_value), DBUS_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID);
|
dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_INT32, -1, DBUS_TYPE_INVALID);
|
||||||
|
|
||||||
if (key_value)
|
if (key_value)
|
||||||
gconf_value_free (key_value);
|
gconf_value_free (key_value);
|
||||||
@@ -444,7 +433,7 @@ static DBusMessage *nmi_dbus_get_network_trusted (NMIAppInfo *info, DBusMessage
|
|||||||
char *network = NULL;
|
char *network = NULL;
|
||||||
GConfValue *value;
|
GConfValue *value;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
NMINetworkType type;
|
NMNetworkType type;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
g_return_val_if_fail (info != NULL, NULL);
|
g_return_val_if_fail (info != NULL, NULL);
|
||||||
|
@@ -26,17 +26,9 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerInfo.h"
|
#include "NetworkManagerInfo.h"
|
||||||
|
|
||||||
/* MUST match MetworkManager NMNetworkType */
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
NETWORK_TYPE_UNKNOWN = 0,
|
|
||||||
NETWORK_TYPE_ALLOWED,
|
|
||||||
NETWORK_TYPE_INVALID,
|
|
||||||
NETWORK_TYPE_DEVICE
|
|
||||||
} NMINetworkType;
|
|
||||||
|
|
||||||
|
|
||||||
int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info);
|
int nmi_dbus_service_init (DBusConnection *dbus_connection, NMIAppInfo *info);
|
||||||
|
|
||||||
@@ -45,8 +37,8 @@ const char * nmi_dbus_nm_get_network_essid (DBusConnection *connection, const
|
|||||||
gboolean nmi_dbus_nm_get_network_encrypted (DBusConnection *connection, const char *ap_path);
|
gboolean nmi_dbus_nm_get_network_encrypted (DBusConnection *connection, const char *ap_path);
|
||||||
|
|
||||||
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
void nmi_dbus_return_user_key (DBusConnection *connection, const char *device,
|
||||||
const char *network, const char *passphrase, const char *key_type_string);
|
const char *network, const char *passphrase, const int key_type);
|
||||||
|
|
||||||
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMINetworkType type);
|
void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMNetworkType type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -132,25 +132,25 @@ void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
|
|||||||
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
||||||
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
char *key_type_string = NULL;
|
int key_type_return = NM_ENC_TYPE_UNKNOWN;
|
||||||
GConfEntry *gconf_entry;
|
GConfEntry *gconf_entry;
|
||||||
char *escaped_network;
|
char *escaped_network;
|
||||||
|
|
||||||
switch (key_type)
|
switch (key_type)
|
||||||
{
|
{
|
||||||
case KEY_TYPE_128_BIT_PASSPHRASE:
|
case KEY_TYPE_128_BIT_PASSPHRASE:
|
||||||
key_type_string = "128-bit-passphrase";
|
key_type_return = NM_ENC_TYPE_128_BIT_PASSPHRASE;
|
||||||
break;
|
break;
|
||||||
case KEY_TYPE_128_BIT_RAW_HEX_KEY:
|
case KEY_TYPE_128_BIT_RAW_HEX_KEY:
|
||||||
key_type_string = "128-bit-raw-hex-key";
|
key_type_return = NM_ENC_TYPE_128_BIT_HEX_KEY;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
key_type_string = "";
|
key_type_return = NM_ENC_TYPE_UNKNOWN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell NetworkManager about the key the user typed in */
|
/* Tell NetworkManager about the key the user typed in */
|
||||||
nmi_dbus_return_user_key (info->connection, device, network, passphrase, key_type_string);
|
nmi_dbus_return_user_key (info->connection, device, network, passphrase, key_type_return);
|
||||||
|
|
||||||
/* Update GConf with the new user key */
|
/* Update GConf with the new user key */
|
||||||
escaped_network = gnome_vfs_escape_string (network);
|
escaped_network = gnome_vfs_escape_string (network);
|
||||||
@@ -167,7 +167,7 @@ void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data)
|
|||||||
gconf_client_set_string (info->gconf_client, key, network, NULL);
|
gconf_client_set_string (info->gconf_client, key, network, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network);
|
||||||
gconf_client_set_string (info->gconf_client, key, key_type_string, NULL);
|
gconf_client_set_int (info->gconf_client, key, key_type_return, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
}
|
}
|
||||||
g_free (escaped_network);
|
g_free (escaped_network);
|
||||||
@@ -196,7 +196,7 @@ void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer us
|
|||||||
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
const char *device = g_object_get_data (G_OBJECT (dialog), "device");
|
||||||
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
const char *network = g_object_get_data (G_OBJECT (dialog), "network");
|
||||||
|
|
||||||
nmi_dbus_return_user_key (info->connection, device, network, "***canceled***", "");
|
nmi_dbus_return_user_key (info->connection, device, network, "***canceled***", NM_ENC_TYPE_UNKNOWN);
|
||||||
nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,6 @@
|
|||||||
#include "menu-info.h"
|
#include "menu-info.h"
|
||||||
|
|
||||||
#define CFG_UPDATE_INTERVAL 1
|
#define CFG_UPDATE_INTERVAL 1
|
||||||
#define NM_GCONF_WIRELESS_NETWORKS_PATH "/system/networking/wireless/networks"
|
|
||||||
|
|
||||||
static GtkWidget * nmwa_populate_menu (NMWirelessApplet *applet);
|
static GtkWidget * nmwa_populate_menu (NMWirelessApplet *applet);
|
||||||
static void nmwa_dispose_menu_items (NMWirelessApplet *applet);
|
static void nmwa_dispose_menu_items (NMWirelessApplet *applet);
|
||||||
@@ -426,12 +425,12 @@ static void nmwa_update_network_timestamp (NMWirelessApplet *applet, const Wirel
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Update timestamp on network */
|
/* Update timestamp on network */
|
||||||
key = g_strdup_printf ("%s/%s/timestamp", NM_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
|
key = g_strdup_printf ("%s/%s/timestamp", NMI_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
|
||||||
gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
|
gconf_client_set_int (applet->gconf_client, key, time (NULL), NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
|
|
||||||
/* Force-set the essid too so that we have a semi-complete network entry */
|
/* Force-set the essid too so that we have a semi-complete network entry */
|
||||||
key = g_strdup_printf ("%s/%s/essid", NM_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
|
key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, network->essid);
|
||||||
gconf_client_set_string (applet->gconf_client, key, network->essid, NULL);
|
gconf_client_set_string (applet->gconf_client, key, network->essid, NULL);
|
||||||
g_free (key);
|
g_free (key);
|
||||||
}
|
}
|
||||||
|
@@ -26,21 +26,7 @@
|
|||||||
#include "NMWirelessAppletDbus.h"
|
#include "NMWirelessAppletDbus.h"
|
||||||
#include "NMWirelessApplet.h"
|
#include "NMWirelessApplet.h"
|
||||||
|
|
||||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
|
||||||
|
|
||||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
|
||||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
|
||||||
#define NM_DBUS_PATH_DEVICES "/org/freedesktop/NetworkManager/Devices"
|
|
||||||
#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices"
|
|
||||||
|
|
||||||
#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
|
|
||||||
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
||||||
#define NM_DBUS_NO_ACTIVE_NET_ERROR "org.freedesktop.NetworkManager.NoActiveNetwork"
|
|
||||||
#define NM_DBUS_NO_ACTIVE_DEVICE_ERROR "org.freedesktop.NetworkManager.NoActiveDevice"
|
|
||||||
#define NM_DBUS_NO_NETWORKS_ERROR "org.freedesktop.NetworkManager.NoNetworks"
|
|
||||||
|
|
||||||
|
|
||||||
/* dbus doesn't define a DBUS_TYPE_STRING_ARRAY so we fake one here for consistency */
|
/* dbus doesn't define a DBUS_TYPE_STRING_ARRAY so we fake one here for consistency */
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
#include "NMWirelessApplet.h"
|
#include "NMWirelessApplet.h"
|
||||||
|
|
||||||
/* Return codes for functions that use dbus */
|
/* Return codes for functions that use dbus */
|
||||||
@@ -34,13 +35,6 @@ enum
|
|||||||
RETURN_NO_NM = -1
|
RETURN_NO_NM = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Must match NetworkManager device types */
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
DEVICE_TYPE_DONT_KNOW = 0,
|
|
||||||
DEVICE_TYPE_WIRED_ETHERNET,
|
|
||||||
DEVICE_TYPE_WIRELESS_ETHERNET
|
|
||||||
};
|
|
||||||
|
|
||||||
gpointer nmwa_dbus_worker (gpointer user_data);
|
gpointer nmwa_dbus_worker (gpointer user_data);
|
||||||
|
|
||||||
|
@@ -65,7 +65,7 @@ static char *nm_get_device_interface_from_hal (LibHalContext *ctx, const char *u
|
|||||||
|
|
||||||
if (hal_device_property_exists (ctx, udi, "net.interface"))
|
if (hal_device_property_exists (ctx, udi, "net.interface"))
|
||||||
{
|
{
|
||||||
/* Only use Ethernet and Wireless devices for now (ie not Sharp Zaurus IP-over-USB connections) */
|
/* Only use Ethernet and Wireless devices at the moment */
|
||||||
if (hal_device_property_exists (ctx, udi, "info.category"))
|
if (hal_device_property_exists (ctx, udi, "info.category"))
|
||||||
{
|
{
|
||||||
char *category = hal_device_get_property_string (ctx, udi, "info.category");
|
char *category = hal_device_get_property_string (ctx, udi, "info.category");
|
||||||
@@ -114,11 +114,8 @@ NMDevice * nm_create_device_and_add_to_list (NMData *data, const char *udi, cons
|
|||||||
if ((dev = nm_get_device_by_iface (data, iface)))
|
if ((dev = nm_get_device_by_iface (data, iface)))
|
||||||
return (NULL);
|
return (NULL);
|
||||||
|
|
||||||
if ((dev = nm_device_new (iface, test_device, test_device_type, data)))
|
if ((dev = nm_device_new (iface, udi, test_device, test_device_type, data)))
|
||||||
{
|
{
|
||||||
/* Build up the device structure */
|
|
||||||
nm_device_set_udi (dev, udi);
|
|
||||||
|
|
||||||
/* Attempt to acquire mutex for device list addition. If acquire fails,
|
/* Attempt to acquire mutex for device list addition. If acquire fails,
|
||||||
* just ignore the device addition entirely.
|
* just ignore the device addition entirely.
|
||||||
*/
|
*/
|
||||||
@@ -172,7 +169,6 @@ void nm_remove_device_from_list (NMData *data, const char *udi)
|
|||||||
/* Attempt to acquire mutex for device list deletion. If acquire fails,
|
/* Attempt to acquire mutex for device list deletion. If acquire fails,
|
||||||
* just ignore the device deletion entirely.
|
* just ignore the device deletion entirely.
|
||||||
*/
|
*/
|
||||||
fprintf (stderr, "Remove called fro device %s\n", udi);
|
|
||||||
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
|
if (nm_try_acquire_mutex (data->dev_list_mutex, __FUNCTION__))
|
||||||
{
|
{
|
||||||
element = data->dev_list;
|
element = data->dev_list;
|
||||||
|
@@ -43,7 +43,7 @@ struct NMAccessPoint
|
|||||||
|
|
||||||
/* Things from user prefs */
|
/* Things from user prefs */
|
||||||
char *enc_key;
|
char *enc_key;
|
||||||
NMAPEncMethod enc_method;
|
NMEncKeyType enc_method;
|
||||||
GTimeVal timestamp;
|
GTimeVal timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ char * nm_ap_get_essid (NMAccessPoint *ap)
|
|||||||
return (ap->essid);
|
return (ap->essid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_essid (NMAccessPoint *ap, char * essid)
|
void nm_ap_set_essid (NMAccessPoint *ap, const char * essid)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ char * nm_ap_get_enc_key_source (NMAccessPoint *ap)
|
|||||||
return (ap->enc_key);
|
return (ap->enc_key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_enc_key_source (NMAccessPoint *ap, char * key, NMAPEncMethod method)
|
void nm_ap_set_enc_key_source (NMAccessPoint *ap, char * key, NMEncKeyType method)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
@@ -221,14 +221,15 @@ char *nm_ap_get_enc_key_hashed (NMAccessPoint *ap)
|
|||||||
source_key = nm_ap_get_enc_key_source (ap);
|
source_key = nm_ap_get_enc_key_source (ap);
|
||||||
switch (ap->enc_method)
|
switch (ap->enc_method)
|
||||||
{
|
{
|
||||||
case (NM_AP_ENC_METHOD_128_BIT_PASSPHRASE):
|
case (NM_ENC_TYPE_128_BIT_PASSPHRASE):
|
||||||
if (source_key)
|
if (source_key)
|
||||||
hashed = nm_wireless_128bit_key_from_passphrase (source_key);
|
hashed = nm_wireless_128bit_key_from_passphrase (source_key);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (NM_AP_ENC_METHOD_40_BIT_PASSPHRASE):
|
case (NM_ENC_TYPE_128_BIT_HEX_KEY):
|
||||||
case (NM_AP_ENC_METHOD_128_BIT_HEX_KEY):
|
case (NM_ENC_TYPE_40_BIT_PASSPHRASE):
|
||||||
case (NM_AP_ENC_METHOD_UNKNOWN):
|
case (NM_ENC_TYPE_40_BIT_HEX_KEY):
|
||||||
|
case (NM_ENC_TYPE_UNKNOWN):
|
||||||
if (source_key)
|
if (source_key)
|
||||||
hashed = g_strdup (source_key);
|
hashed = g_strdup (source_key);
|
||||||
break;
|
break;
|
||||||
@@ -431,7 +432,7 @@ void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial)
|
|||||||
* Return the encryption method the user specified for this access point.
|
* Return the encryption method the user specified for this access point.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap)
|
const NMEncKeyType nm_ap_get_enc_method (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, TRUE);
|
g_return_val_if_fail (ap != NULL, TRUE);
|
||||||
|
|
||||||
|
@@ -24,19 +24,10 @@
|
|||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
typedef struct NMAccessPoint NMAccessPoint;
|
typedef struct NMAccessPoint NMAccessPoint;
|
||||||
|
|
||||||
typedef enum NMAPEncMethod
|
|
||||||
{
|
|
||||||
NM_AP_ENC_METHOD_UNKNOWN = 0,
|
|
||||||
NM_AP_ENC_METHOD_NONE,
|
|
||||||
NM_AP_ENC_METHOD_128_BIT_HEX_KEY,
|
|
||||||
NM_AP_ENC_METHOD_40_BIT_PASSPHRASE,
|
|
||||||
NM_AP_ENC_METHOD_128_BIT_PASSPHRASE /* Well, 104-bit really... */
|
|
||||||
} NMAPEncMethod;
|
|
||||||
|
|
||||||
|
|
||||||
NMAccessPoint * nm_ap_new (void);
|
NMAccessPoint * nm_ap_new (void);
|
||||||
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap);
|
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *ap);
|
||||||
|
|
||||||
@@ -47,11 +38,11 @@ const GTimeVal * nm_ap_get_timestamp (NMAccessPoint *ap);
|
|||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
||||||
|
|
||||||
char * nm_ap_get_essid (NMAccessPoint *ap);
|
char * nm_ap_get_essid (NMAccessPoint *ap);
|
||||||
void nm_ap_set_essid (NMAccessPoint *ap, char *essid);
|
void nm_ap_set_essid (NMAccessPoint *ap, const char *essid);
|
||||||
|
|
||||||
char * nm_ap_get_enc_key_source (NMAccessPoint *ap);
|
char * nm_ap_get_enc_key_source (NMAccessPoint *ap);
|
||||||
char * nm_ap_get_enc_key_hashed (NMAccessPoint *ap);
|
char * nm_ap_get_enc_key_hashed (NMAccessPoint *ap);
|
||||||
void nm_ap_set_enc_key_source (NMAccessPoint *ap, char *key, NMAPEncMethod method);
|
void nm_ap_set_enc_key_source (NMAccessPoint *ap, char *key, NMEncKeyType type);
|
||||||
|
|
||||||
gboolean nm_ap_get_encrypted (NMAccessPoint *ap);
|
gboolean nm_ap_get_encrypted (NMAccessPoint *ap);
|
||||||
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted);
|
void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted);
|
||||||
@@ -80,6 +71,6 @@ void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted);
|
|||||||
gboolean nm_ap_get_artificial (NMAccessPoint *ap);
|
gboolean nm_ap_get_artificial (NMAccessPoint *ap);
|
||||||
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
|
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
|
||||||
|
|
||||||
const NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap);
|
const NMEncKeyType nm_ap_get_enc_method (NMAccessPoint *ap);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -280,7 +280,7 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM
|
|||||||
/* Get the allowed access point's details from NetworkManagerInfo */
|
/* Get the allowed access point's details from NetworkManagerInfo */
|
||||||
if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network)))
|
if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network)))
|
||||||
{
|
{
|
||||||
NMAPEncMethod enc_method;
|
NMEncKeyType enc_method;
|
||||||
char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network, &enc_method);
|
char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network, &enc_method);
|
||||||
GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network);
|
GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network);
|
||||||
gboolean trusted = nm_dbus_get_network_trusted (data->dbus_connection, list->type, network);
|
gboolean trusted = nm_dbus_get_network_trusted (data->dbus_connection, list->type, network);
|
||||||
@@ -302,7 +302,7 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM
|
|||||||
if (key && strlen (key))
|
if (key && strlen (key))
|
||||||
nm_ap_set_enc_key_source (ap, key, enc_method);
|
nm_ap_set_enc_key_source (ap, key, enc_method);
|
||||||
else
|
else
|
||||||
nm_ap_set_enc_key_source (ap, NULL, NM_AP_ENC_METHOD_UNKNOWN);
|
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
||||||
|
|
||||||
if (new)
|
if (new)
|
||||||
{
|
{
|
||||||
|
@@ -26,13 +26,6 @@
|
|||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerDevice.h"
|
#include "NetworkManagerDevice.h"
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
NETWORK_TYPE_UNKNOWN = 0,
|
|
||||||
NETWORK_TYPE_ALLOWED,
|
|
||||||
NETWORK_TYPE_INVALID,
|
|
||||||
NETWORK_TYPE_DEVICE
|
|
||||||
} NMNetworkType;
|
|
||||||
|
|
||||||
typedef struct NMAccessPointList NMAccessPointList;
|
typedef struct NMAccessPointList NMAccessPointList;
|
||||||
typedef struct NMAPListIter NMAPListIter;
|
typedef struct NMAPListIter NMAPListIter;
|
||||||
|
@@ -63,25 +63,6 @@ static DBusMessage *nm_dbus_create_error_message (DBusMessage *message, const ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_dbus_get_enc_method_from_string
|
|
||||||
*
|
|
||||||
* Parse a string and return the encryption method it specifies.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
NMAPEncMethod nm_dbus_get_enc_method_from_string (const char *key_type)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (key_type != NULL, NM_AP_ENC_METHOD_UNKNOWN);
|
|
||||||
|
|
||||||
if (!strcmp (key_type, "128-bit-passphrase"))
|
|
||||||
return (NM_AP_ENC_METHOD_128_BIT_PASSPHRASE);
|
|
||||||
else if (!strcmp (key_type, "128-bit-raw-hex-key"))
|
|
||||||
return (NM_AP_ENC_METHOD_128_BIT_HEX_KEY);
|
|
||||||
|
|
||||||
return (NM_AP_ENC_METHOD_UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_dbus_get_object_path_from_device
|
* nm_dbus_get_object_path_from_device
|
||||||
*
|
*
|
||||||
@@ -290,7 +271,7 @@ static DBusMessage *nm_dbus_nm_set_active_device (DBusConnection *connection, DB
|
|||||||
|
|
||||||
dev = nm_dbus_get_device_from_object_path (data, dev_path);
|
dev = nm_dbus_get_device_from_object_path (data, dev_path);
|
||||||
dbus_free (dev_path);
|
dbus_free (dev_path);
|
||||||
if (!dev)
|
if (!dev || (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED))
|
||||||
{
|
{
|
||||||
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
|
reply_message = nm_dbus_create_error_message (message, NM_DBUS_INTERFACE, "DeviceNotFound",
|
||||||
"The requested network device does not exist.");
|
"The requested network device does not exist.");
|
||||||
@@ -376,7 +357,7 @@ static DBusMessage *nm_dbus_nm_get_devices (DBusConnection *connection, DBusMess
|
|||||||
{
|
{
|
||||||
NMDevice *dev = (NMDevice *)(element->data);
|
NMDevice *dev = (NMDevice *)(element->data);
|
||||||
|
|
||||||
if (dev)
|
if (dev && (nm_device_get_driver_support_level (dev) != NM_DRIVER_UNSUPPORTED))
|
||||||
{
|
{
|
||||||
char *object_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_DEVICES, nm_device_get_iface (dev));
|
char *object_path = g_strdup_printf ("%s/%s", NM_DBUS_PATH_DEVICES, nm_device_get_iface (dev));
|
||||||
dbus_message_iter_append_string (&iter_array, object_path);
|
dbus_message_iter_append_string (&iter_array, object_path);
|
||||||
@@ -658,7 +639,7 @@ static void nm_dbus_set_user_key_for_network (DBusConnection *connection, DBusMe
|
|||||||
char *device;
|
char *device;
|
||||||
char *network;
|
char *network;
|
||||||
char *passphrase;
|
char *passphrase;
|
||||||
char *key_type;
|
NMEncKeyType key_type;
|
||||||
|
|
||||||
g_return_if_fail (data != NULL);
|
g_return_if_fail (data != NULL);
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
@@ -669,21 +650,17 @@ static void nm_dbus_set_user_key_for_network (DBusConnection *connection, DBusMe
|
|||||||
DBUS_TYPE_STRING, &device,
|
DBUS_TYPE_STRING, &device,
|
||||||
DBUS_TYPE_STRING, &network,
|
DBUS_TYPE_STRING, &network,
|
||||||
DBUS_TYPE_STRING, &passphrase,
|
DBUS_TYPE_STRING, &passphrase,
|
||||||
DBUS_TYPE_STRING, &key_type,
|
DBUS_TYPE_INT32, &key_type,
|
||||||
DBUS_TYPE_INVALID))
|
DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
NMDevice *dev;
|
NMDevice *dev;
|
||||||
|
|
||||||
if ((dev = nm_get_device_by_iface (data, device)))
|
if ((dev = nm_get_device_by_iface (data, device)))
|
||||||
{
|
nm_device_set_user_key_for_network (dev, data->invalid_ap_list, network, passphrase, key_type);
|
||||||
NMAPEncMethod method = nm_dbus_get_enc_method_from_string (key_type);
|
|
||||||
nm_device_set_user_key_for_network (dev, data->invalid_ap_list, network, passphrase, method);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_free (device);
|
dbus_free (device);
|
||||||
dbus_free (network);
|
dbus_free (network);
|
||||||
dbus_free (passphrase);
|
dbus_free (passphrase);
|
||||||
dbus_free (key_type);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -780,7 +757,7 @@ char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type
|
|||||||
* NOTE: caller MUST free returned value
|
* NOTE: caller MUST free returned value
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMAPEncMethod *enc_method)
|
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMEncKeyType *enc_method)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
@@ -788,7 +765,7 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
|
|||||||
char *key = NULL;
|
char *key = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (enc_method != NULL, NULL);
|
g_return_val_if_fail (enc_method != NULL, NULL);
|
||||||
*enc_method = NM_AP_ENC_METHOD_UNKNOWN;
|
*enc_method = NM_ENC_TYPE_UNKNOWN;
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, NULL);
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
g_return_val_if_fail (network != NULL, NULL);
|
g_return_val_if_fail (network != NULL, NULL);
|
||||||
@@ -820,16 +797,15 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *dbus_key;
|
char *dbus_key;
|
||||||
char *dbus_key_type;
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_key, DBUS_TYPE_STRING, &dbus_key_type, DBUS_TYPE_INVALID))
|
if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_key, DBUS_TYPE_INT32, enc_method, DBUS_TYPE_INVALID))
|
||||||
{
|
{
|
||||||
key = (dbus_key == NULL ? NULL : strdup (dbus_key));
|
key = (dbus_key == NULL ? NULL : strdup (dbus_key));
|
||||||
dbus_free (dbus_key);
|
dbus_free (dbus_key);
|
||||||
*enc_method = nm_dbus_get_enc_method_from_string (dbus_key_type);
|
|
||||||
dbus_free (dbus_key_type);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
*enc_method = NM_ENC_TYPE_UNKNOWN;
|
||||||
if (dbus_error_is_set (&error))
|
if (dbus_error_is_set (&error))
|
||||||
dbus_error_free (&error);
|
dbus_error_free (&error);
|
||||||
|
|
||||||
|
@@ -25,19 +25,9 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerAPList.h"
|
#include "NetworkManagerAPList.h"
|
||||||
|
|
||||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
|
||||||
|
|
||||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
|
||||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
|
||||||
#define NM_DBUS_PATH_DEVICES "/org/freedesktop/NetworkManager/Devices"
|
|
||||||
#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices"
|
|
||||||
|
|
||||||
#define NMI_DBUS_SERVICE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_PATH "/org/freedesktop/NetworkManagerInfo"
|
|
||||||
#define NMI_DBUS_INTERFACE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
@@ -68,7 +58,7 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection);
|
|||||||
|
|
||||||
char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type, const char *network);
|
char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type, const char *network);
|
||||||
|
|
||||||
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMAPEncMethod *enc_method);
|
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMEncKeyType *enc_method);
|
||||||
|
|
||||||
GTimeVal * nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network);
|
GTimeVal * nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network);
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "NetworkManagerMain.h"
|
||||||
#include "NetworkManagerDevice.h"
|
#include "NetworkManagerDevice.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "NetworkManagerDbus.h"
|
#include "NetworkManagerDbus.h"
|
||||||
@@ -48,7 +49,7 @@ static gpointer nm_device_activation_worker (gpointer user_data);
|
|||||||
/* Wireless device specific options */
|
/* Wireless device specific options */
|
||||||
typedef struct NMDeviceWirelessOptions
|
typedef struct NMDeviceWirelessOptions
|
||||||
{
|
{
|
||||||
gchar *cur_essid;
|
char *cur_essid;
|
||||||
gboolean supports_wireless_scan;
|
gboolean supports_wireless_scan;
|
||||||
guint8 max_quality;
|
guint8 max_quality;
|
||||||
guint8 noise;
|
guint8 noise;
|
||||||
@@ -105,9 +106,11 @@ struct NMDevice
|
|||||||
{
|
{
|
||||||
guint refcount;
|
guint refcount;
|
||||||
|
|
||||||
gchar *udi;
|
char *udi;
|
||||||
gchar *iface;
|
char *iface;
|
||||||
NMDeviceType type;
|
NMDeviceType type;
|
||||||
|
NMDriverSupportLevel driver_support_level;
|
||||||
|
|
||||||
gboolean link_active;
|
gboolean link_active;
|
||||||
guint32 ip4_address;
|
guint32 ip4_address;
|
||||||
/* FIXME: ipv6 address too */
|
/* FIXME: ipv6 address too */
|
||||||
@@ -173,7 +176,7 @@ static gboolean nm_device_supports_wireless_scan (NMDevice *dev)
|
|||||||
return (TRUE);
|
return (TRUE);
|
||||||
|
|
||||||
iwlib_socket = iw_sockets_open ();
|
iwlib_socket = iw_sockets_open ();
|
||||||
error = iw_scan (iwlib_socket, nm_device_get_iface (dev), WIRELESS_EXT, &scan_data);
|
error = iw_scan (iwlib_socket, (char *)nm_device_get_iface (dev), WIRELESS_EXT, &scan_data);
|
||||||
nm_dispose_scan_results (scan_data.result);
|
nm_dispose_scan_results (scan_data.result);
|
||||||
if ((error == -1) && (errno == EOPNOTSUPP))
|
if ((error == -1) && (errno == EOPNOTSUPP))
|
||||||
can_scan = FALSE;
|
can_scan = FALSE;
|
||||||
@@ -266,12 +269,13 @@ NMDevice *nm_get_device_by_iface (NMData *data, const char *iface)
|
|||||||
* argument is ignored for real hardware devices since they are auto-probed.
|
* argument is ignored for real hardware devices since they are auto-probed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NMDevice *nm_device_new (const char *iface, gboolean test_dev, NMDeviceType test_dev_type, NMData *app_data)
|
NMDevice *nm_device_new (const char *iface, const char *udi, gboolean test_dev, NMDeviceType test_dev_type, NMData *app_data)
|
||||||
{
|
{
|
||||||
NMDevice *dev;
|
NMDevice *dev;
|
||||||
|
|
||||||
g_return_val_if_fail (iface != NULL, NULL);
|
g_return_val_if_fail (iface != NULL, NULL);
|
||||||
g_return_val_if_fail (strlen (iface) > 0, NULL);
|
g_return_val_if_fail (strlen (iface) > 0, NULL);
|
||||||
|
g_return_val_if_fail (app_data != NULL, NULL);
|
||||||
|
|
||||||
/* Test devices must have a valid type specified */
|
/* Test devices must have a valid type specified */
|
||||||
if (test_dev && !(test_dev_type != DEVICE_TYPE_DONT_KNOW))
|
if (test_dev && !(test_dev_type != DEVICE_TYPE_DONT_KNOW))
|
||||||
@@ -280,7 +284,7 @@ NMDevice *nm_device_new (const char *iface, gboolean test_dev, NMDeviceType test
|
|||||||
/* Another check to make sure we don't create a test device unless
|
/* Another check to make sure we don't create a test device unless
|
||||||
* test devices were enabled on the command line.
|
* test devices were enabled on the command line.
|
||||||
*/
|
*/
|
||||||
if (app_data && !app_data->enable_test_devices && test_dev)
|
if (!app_data->enable_test_devices && test_dev)
|
||||||
{
|
{
|
||||||
syslog (LOG_ERR, "nm_device_new(): attempt to create a test device, but test devices were not enabled"
|
syslog (LOG_ERR, "nm_device_new(): attempt to create a test device, but test devices were not enabled"
|
||||||
" on the command line. Will not create the device.\n");
|
" on the command line. Will not create the device.\n");
|
||||||
@@ -298,6 +302,7 @@ NMDevice *nm_device_new (const char *iface, gboolean test_dev, NMDeviceType test
|
|||||||
dev->app_data = app_data;
|
dev->app_data = app_data;
|
||||||
dev->iface = g_strdup (iface);
|
dev->iface = g_strdup (iface);
|
||||||
dev->test_device = test_dev;
|
dev->test_device = test_dev;
|
||||||
|
nm_device_set_udi (dev, udi);
|
||||||
|
|
||||||
/* Real hardware devices are probed for their type, test devices must have
|
/* Real hardware devices are probed for their type, test devices must have
|
||||||
* their type specified.
|
* their type specified.
|
||||||
@@ -341,6 +346,8 @@ NMDevice *nm_device_new (const char *iface, gboolean test_dev, NMDeviceType test
|
|||||||
nm_device_update_best_ap (dev);
|
nm_device_update_best_ap (dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->driver_support_level = nm_get_driver_support_level (dev->app_data->hal_ctx, dev);
|
||||||
|
|
||||||
/* Grab IP config data for this device from the system configuration files */
|
/* Grab IP config data for this device from the system configuration files */
|
||||||
nm_device_update_ip4_address (dev);
|
nm_device_update_ip4_address (dev);
|
||||||
nm_system_device_update_config_info (dev);
|
nm_system_device_update_config_info (dev);
|
||||||
@@ -424,7 +431,7 @@ void nm_device_set_udi (NMDevice *dev, const char *udi)
|
|||||||
/*
|
/*
|
||||||
* Get/set functions for iface
|
* Get/set functions for iface
|
||||||
*/
|
*/
|
||||||
char * nm_device_get_iface (NMDevice *dev)
|
const char * nm_device_get_iface (NMDevice *dev)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (dev != NULL, NULL);
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
@@ -457,6 +464,17 @@ gboolean nm_device_is_wired (NMDevice *dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Accessor for driver support level
|
||||||
|
*/
|
||||||
|
NMDriverSupportLevel nm_device_get_driver_support_level (NMDevice *dev)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (dev != NULL, NM_DRIVER_UNSUPPORTED);
|
||||||
|
|
||||||
|
return (dev->driver_support_level);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/set functions for link_active
|
* Get/set functions for link_active
|
||||||
*/
|
*/
|
||||||
@@ -1665,7 +1683,7 @@ gboolean nm_device_is_scanning (NMDevice *dev)
|
|||||||
*/
|
*/
|
||||||
void nm_device_set_user_key_for_network (NMDevice *dev, NMAccessPointList *invalid_list,
|
void nm_device_set_user_key_for_network (NMDevice *dev, NMAccessPointList *invalid_list,
|
||||||
unsigned char *network, unsigned char *key,
|
unsigned char *network, unsigned char *key,
|
||||||
NMAPEncMethod enc_method)
|
NMEncKeyType enc_method)
|
||||||
{
|
{
|
||||||
NMAccessPoint *best_ap;
|
NMAccessPoint *best_ap;
|
||||||
const char *cancel_message = "***canceled***";
|
const char *cancel_message = "***canceled***";
|
||||||
@@ -2195,7 +2213,7 @@ static void nm_device_do_normal_scan (NMDevice *dev)
|
|||||||
NMAPListIter *iter;
|
NMAPListIter *iter;
|
||||||
NMAccessPoint *artificial_ap;
|
NMAccessPoint *artificial_ap;
|
||||||
|
|
||||||
err = iw_scan (iwlib_socket, nm_device_get_iface (dev), WIRELESS_EXT, &scan_results);
|
err = iw_scan (iwlib_socket, (char *)nm_device_get_iface (dev), WIRELESS_EXT, &scan_results);
|
||||||
if ((err == -1) && (errno == ENODATA))
|
if ((err == -1) && (errno == ENODATA))
|
||||||
{
|
{
|
||||||
/* Card hasn't had time yet to compile full access point list.
|
/* Card hasn't had time yet to compile full access point list.
|
||||||
@@ -2203,7 +2221,7 @@ static void nm_device_do_normal_scan (NMDevice *dev)
|
|||||||
* give up.
|
* give up.
|
||||||
*/
|
*/
|
||||||
g_usleep (G_USEC_PER_SEC / 2);
|
g_usleep (G_USEC_PER_SEC / 2);
|
||||||
err = iw_scan (iwlib_socket, nm_device_get_iface (dev), WIRELESS_EXT, &scan_results);
|
err = iw_scan (iwlib_socket, (char *)nm_device_get_iface (dev), WIRELESS_EXT, &scan_results);
|
||||||
if (err == -1)
|
if (err == -1)
|
||||||
{
|
{
|
||||||
close (iwlib_socket);
|
close (iwlib_socket);
|
||||||
|
@@ -24,10 +24,11 @@
|
|||||||
|
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "NetworkManagerMain.h"
|
||||||
|
|
||||||
typedef struct NMDevice NMDevice;
|
typedef struct NMDevice NMDevice;
|
||||||
|
|
||||||
NMDevice * nm_device_new (const char *iface, gboolean test_device,
|
NMDevice * nm_device_new (const char *iface, const char *udi, gboolean test_device,
|
||||||
NMDeviceType test_dev_type, NMData *app_data);
|
NMDeviceType test_dev_type, NMData *app_data);
|
||||||
|
|
||||||
void nm_device_ref (NMDevice *dev);
|
void nm_device_ref (NMDevice *dev);
|
||||||
@@ -36,9 +37,11 @@ void nm_device_unref (NMDevice *dev);
|
|||||||
char * nm_device_get_udi (NMDevice *dev);
|
char * nm_device_get_udi (NMDevice *dev);
|
||||||
void nm_device_set_udi (NMDevice *dev, const char *udi);
|
void nm_device_set_udi (NMDevice *dev, const char *udi);
|
||||||
|
|
||||||
char * nm_device_get_iface (NMDevice *dev);
|
const char * nm_device_get_iface (NMDevice *dev);
|
||||||
|
|
||||||
NMDeviceType nm_device_get_type (NMDevice *dev);
|
NMDeviceType nm_device_get_type (NMDevice *dev);
|
||||||
|
NMDriverSupportLevel nm_device_get_driver_support_level (NMDevice *dev);
|
||||||
|
|
||||||
gboolean nm_device_is_wireless (NMDevice *dev);
|
gboolean nm_device_is_wireless (NMDevice *dev);
|
||||||
gboolean nm_device_is_wired (NMDevice *dev);
|
gboolean nm_device_is_wired (NMDevice *dev);
|
||||||
/* There is no nm_device_set_iface_type() because that's determined when you set the device's iface */
|
/* There is no nm_device_set_iface_type() because that's determined when you set the device's iface */
|
||||||
@@ -96,7 +99,7 @@ gboolean nm_device_find_and_use_essid (NMDevice *dev, const char *essid);
|
|||||||
|
|
||||||
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list,
|
||||||
unsigned char *network, unsigned char *key,
|
unsigned char *network, unsigned char *key,
|
||||||
NMAPEncMethod enc_method);
|
NMEncKeyType enc_method);
|
||||||
|
|
||||||
void nm_device_bring_up (NMDevice *dev);
|
void nm_device_bring_up (NMDevice *dev);
|
||||||
void nm_device_bring_down (NMDevice *dev);
|
void nm_device_bring_down (NMDevice *dev);
|
||||||
|
@@ -19,13 +19,14 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_H
|
#ifndef NETWORK_MANAGER_MAIN_H
|
||||||
#define NETWORK_MANAGER_H
|
#define NETWORK_MANAGER_MAIN_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <glib/gthread.h>
|
#include <glib/gthread.h>
|
||||||
#include <dbus/dbus.h>
|
#include <dbus/dbus.h>
|
||||||
#include <hal/libhal.h>
|
#include <hal/libhal.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerAP.h"
|
#include "NetworkManagerAP.h"
|
||||||
|
|
||||||
typedef struct NMData
|
typedef struct NMData
|
||||||
@@ -53,16 +54,6 @@ typedef struct NMData
|
|||||||
struct NMAccessPointList *invalid_ap_list;
|
struct NMAccessPointList *invalid_ap_list;
|
||||||
} NMData;
|
} NMData;
|
||||||
|
|
||||||
/*
|
|
||||||
* Types of NetworkManager devices
|
|
||||||
*/
|
|
||||||
typedef enum NMDeviceType
|
|
||||||
{
|
|
||||||
DEVICE_TYPE_DONT_KNOW = 0,
|
|
||||||
DEVICE_TYPE_WIRED_ETHERNET,
|
|
||||||
DEVICE_TYPE_WIRELESS_ETHERNET
|
|
||||||
} NMDeviceType;
|
|
||||||
|
|
||||||
|
|
||||||
struct NMDevice *nm_create_device_and_add_to_list (NMData *data, const char *udi, const char *iface,
|
struct NMDevice *nm_create_device_and_add_to_list (NMData *data, const char *udi, const char *iface,
|
||||||
gboolean test_device, NMDeviceType test_device_type);
|
gboolean test_device, NMDeviceType test_device_type);
|
@@ -66,6 +66,13 @@ static NMDevice * nm_policy_auto_get_best_device (NMData *data)
|
|||||||
|
|
||||||
dev = (NMDevice *)(element->data);
|
dev = (NMDevice *)(element->data);
|
||||||
|
|
||||||
|
/* Skip unsupported devices */
|
||||||
|
if (nm_device_get_driver_support_level (dev) == NM_DRIVER_UNSUPPORTED)
|
||||||
|
{
|
||||||
|
element = g_slist_next (element);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
dev_type = nm_device_get_type (dev);
|
dev_type = nm_device_get_type (dev);
|
||||||
link_active = nm_device_get_link_active (dev);
|
link_active = nm_device_get_link_active (dev);
|
||||||
|
|
||||||
@@ -211,6 +218,13 @@ static NMDevice * nm_policy_get_best_device (NMData *data, gboolean *should_lock
|
|||||||
best_dev = nm_policy_auto_get_best_device (data);
|
best_dev = nm_policy_auto_get_best_device (data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Ensure we support this driver */
|
||||||
|
if (best_dev && (nm_device_get_driver_support_level (best_dev) == NM_DRIVER_UNSUPPORTED))
|
||||||
|
{
|
||||||
|
syslog (LOG_ERR, "nm_policy_get_best_device(): tried to switch to unsupported device '%s'!\n", nm_device_get_iface (best_dev));
|
||||||
|
best_dev == NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return (best_dev);
|
return (best_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -210,3 +210,282 @@ int nm_spawn_process (char *args)
|
|||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct driver_support
|
||||||
|
{
|
||||||
|
char *name;
|
||||||
|
NMDriverSupportLevel level;
|
||||||
|
} driver_support;
|
||||||
|
|
||||||
|
/* The list of wireless drivers we support and how well we support each */
|
||||||
|
static driver_support wireless_driver_support_list[] =
|
||||||
|
{
|
||||||
|
/* Fully supported drivers */
|
||||||
|
{"airo_cs", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"airo", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"atmel_cs", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"atmel", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"atmel_pci", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"prism54", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"wl3501_cs", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"ipw2100", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"ipw2200", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"ath_pci", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
{"ath_cs", NM_DRIVER_FULLY_SUPPORTED},
|
||||||
|
/* Semi-supported drivers, for example ones that don't support
|
||||||
|
* wireless scanning yet in-kernel
|
||||||
|
*/
|
||||||
|
{"hermes", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"netwave_cs", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"orinoco_cs", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"orinoco", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"orinoco_pci", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"orinoco_plx", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"orinoco_tmd", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"wavelan_cs", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{"wavelan", NM_DRIVER_SEMI_SUPPORTED},
|
||||||
|
{NULL, NM_DRIVER_UNSUPPORTED}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* Blacklist of unsupported wired drivers */
|
||||||
|
static driver_support wired_driver_blacklist[] =
|
||||||
|
{
|
||||||
|
/* Completely unsupported drivers */
|
||||||
|
{NULL, NM_DRIVER_UNSUPPORTED}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_get_device_driver_name
|
||||||
|
*
|
||||||
|
* Checks either /proc/sys/bus/devices or /var/lib/pcmcia/stab to determine
|
||||||
|
* which driver is bound to the device.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
char *nm_get_device_driver_name (LibHalContext *ctx, NMDevice *dev)
|
||||||
|
{
|
||||||
|
FILE *f;
|
||||||
|
char *driver_name = NULL;
|
||||||
|
int vendor;
|
||||||
|
int product;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ctx != NULL, NULL);
|
||||||
|
g_return_val_if_fail (dev != NULL, NULL);
|
||||||
|
|
||||||
|
vendor = hal_device_get_property_int (ctx, nm_device_get_udi (dev), "pci.vendor_id");
|
||||||
|
product = hal_device_get_property_int (ctx, nm_device_get_udi (dev), "pci.product_id");
|
||||||
|
|
||||||
|
if (vendor && product)
|
||||||
|
{
|
||||||
|
if ((f = fopen ("/proc/bus/pci/devices", "r")))
|
||||||
|
{
|
||||||
|
char buf[200];
|
||||||
|
char id[9];
|
||||||
|
|
||||||
|
snprintf (&id[0], 9, "%4X%4X", vendor, product);
|
||||||
|
id[8] = '\0';
|
||||||
|
while (fgets (&buf[0], 200, f) && !feof (f))
|
||||||
|
{
|
||||||
|
char *p;
|
||||||
|
char s[9];
|
||||||
|
int len;
|
||||||
|
|
||||||
|
/* Whack newline */
|
||||||
|
buf[199] = '\0';
|
||||||
|
len = strlen (buf);
|
||||||
|
if ((buf[len-1] == '\n') || (buf[len-1] == '\r'))
|
||||||
|
{
|
||||||
|
buf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = strchr (buf, '\t');
|
||||||
|
s[8] = '\0';
|
||||||
|
strncpy (&s[0], p+1, 8);
|
||||||
|
|
||||||
|
if (!strcmp (&s[0], &id[0]))
|
||||||
|
{
|
||||||
|
/* Yay, we've got a match. Pull the driver name from the
|
||||||
|
* last word in the line.
|
||||||
|
*/
|
||||||
|
char *m = strrchr (&buf[0], '\t');
|
||||||
|
if (m && (m > &buf[0]) && (m < &buf[len]))
|
||||||
|
{
|
||||||
|
driver_name = strdup (m+1);
|
||||||
|
syslog (LOG_INFO, "PCI driver for '%s' is '%s'", nm_device_get_iface (dev), driver_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose (f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Might be a PCMCIA card, try /var/lib/pcmcia/stab and match the interface name.
|
||||||
|
*
|
||||||
|
* stab has a format like this:
|
||||||
|
* Socket 0: Belkin F5D6020 rev.2
|
||||||
|
* 0 network atmel_cs 0 eth2
|
||||||
|
* Socket 1: Belkin-5020
|
||||||
|
* 1 network pcnet_cs 0 eth1
|
||||||
|
*/
|
||||||
|
if (!driver_name && (f = fopen ("/var/lib/pcmcia/stab", "r")))
|
||||||
|
{
|
||||||
|
char buf[200];
|
||||||
|
|
||||||
|
while (fgets (&buf[0], 200, f) && !feof (f))
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
/* Whack newline */
|
||||||
|
buf[199] = '\0';
|
||||||
|
len = strlen (buf);
|
||||||
|
if ((buf[len-1] == '\n') || (buf[len-1] == '\r'))
|
||||||
|
{
|
||||||
|
buf[len-1] = '\0';
|
||||||
|
len--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Ignore lines that start with "Socket" */
|
||||||
|
if (strncmp (&buf[0], "Socket", 6) && (p = strrchr (&buf[0], '\t')))
|
||||||
|
{
|
||||||
|
/* See if this device's interface matches our device's interface */
|
||||||
|
if (!strcmp (++p, nm_device_get_iface (dev)))
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
/* Pull out driver name by seeking to _second_ tab */
|
||||||
|
if ((p = strchr (&buf[0], '\t')) && *(p++) && (p = strchr (p, '\t')))
|
||||||
|
{
|
||||||
|
p++;
|
||||||
|
end = strchr (p, '\t');
|
||||||
|
if (p && end)
|
||||||
|
{
|
||||||
|
*end = '\0';
|
||||||
|
driver_name = strdup (p);
|
||||||
|
syslog (LOG_INFO, "PCMCIA driver for '%s' is '%s'", nm_device_get_iface (dev), driver_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose (f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (driver_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_get_wireless_driver_support_level
|
||||||
|
*
|
||||||
|
* Checks either /proc/sys/bus/devices or /var/lib/pcmcia/stab to determine
|
||||||
|
* wether or not the card's driver is supported and how well, using a whitelist.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NMDriverSupportLevel nm_get_wireless_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
||||||
|
{
|
||||||
|
NMDriverSupportLevel level = NM_DRIVER_UNSUPPORTED;
|
||||||
|
char *driver_name = NULL;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ctx != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
|
|
||||||
|
if ((driver_name = nm_get_device_driver_name (ctx, dev)))
|
||||||
|
{
|
||||||
|
driver_support *driver = &wireless_driver_support_list[0];
|
||||||
|
while (driver->name != NULL)
|
||||||
|
{
|
||||||
|
if (!strcmp (driver->name, driver_name))
|
||||||
|
{
|
||||||
|
level = driver->level;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
driver++;
|
||||||
|
}
|
||||||
|
g_free (driver_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (level);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_get_wired_driver_support_level
|
||||||
|
*
|
||||||
|
* Blacklist certain devices.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NMDriverSupportLevel nm_get_wired_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
||||||
|
{
|
||||||
|
NMDriverSupportLevel level = NM_DRIVER_FULLY_SUPPORTED;
|
||||||
|
char *driver_name = NULL;
|
||||||
|
char *usb_test;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ctx != NULL, FALSE);
|
||||||
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
|
|
||||||
|
if ((driver_name = nm_get_device_driver_name (ctx, dev)))
|
||||||
|
{
|
||||||
|
driver_support *driver = &wired_driver_blacklist[0];
|
||||||
|
while (driver->name != NULL)
|
||||||
|
{
|
||||||
|
if (!strcmp (driver->name, driver_name))
|
||||||
|
{
|
||||||
|
level = driver->level;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
driver++;
|
||||||
|
}
|
||||||
|
g_free (driver_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cipsec devices are also explicitly unsupported at this time */
|
||||||
|
if (strstr (nm_device_get_iface (dev), "cipsec"))
|
||||||
|
level = NM_DRIVER_UNSUPPORTED;
|
||||||
|
|
||||||
|
/* Ignore Ethernet-over-USB devices too for the moment (Red Hat #135722) */
|
||||||
|
if ((usb_test = hal_device_get_property_string (ctx, nm_device_get_udi (dev), "usb.interface.class")))
|
||||||
|
{
|
||||||
|
hal_free_string (usb_test);
|
||||||
|
level = NM_DRIVER_UNSUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (level);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nm_get_driver_support_level
|
||||||
|
*
|
||||||
|
* Return the driver support level for a particular device.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
NMDriverSupportLevel nm_get_driver_support_level (LibHalContext *ctx, NMDevice *dev)
|
||||||
|
{
|
||||||
|
NMDriverSupportLevel level = NM_DRIVER_UNSUPPORTED;
|
||||||
|
|
||||||
|
g_return_val_if_fail (ctx != NULL, NM_DRIVER_UNSUPPORTED);
|
||||||
|
g_return_val_if_fail (dev != NULL, NM_DRIVER_UNSUPPORTED);
|
||||||
|
|
||||||
|
if (nm_device_is_wireless (dev))
|
||||||
|
level = nm_get_wireless_driver_support_level (ctx, dev);
|
||||||
|
else if (nm_device_is_wired (dev))
|
||||||
|
level = nm_get_wired_driver_support_level (ctx, dev);
|
||||||
|
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case NM_DRIVER_SEMI_SUPPORTED:
|
||||||
|
syslog (LOG_INFO, "%s: Driver support level is semi-supported", nm_device_get_iface (dev));
|
||||||
|
break;
|
||||||
|
case NM_DRIVER_FULLY_SUPPORTED:
|
||||||
|
syslog (LOG_INFO, "%s: Driver support level is fully-supported", nm_device_get_iface (dev));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
syslog (LOG_INFO, "%s: Driver support level is unsupported", nm_device_get_iface (dev));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (level);
|
||||||
|
}
|
||||||
|
@@ -29,8 +29,10 @@
|
|||||||
#include <iwlib.h>
|
#include <iwlib.h>
|
||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "NetworkManagerMain.h"
|
||||||
#include "NetworkManagerDevice.h"
|
#include "NetworkManagerDevice.h"
|
||||||
|
|
||||||
|
|
||||||
gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func);
|
gboolean nm_try_acquire_mutex (GMutex *mutex, const char *func);
|
||||||
void nm_unlock_mutex (GMutex *mutex, const char *func);
|
void nm_unlock_mutex (GMutex *mutex, const char *func);
|
||||||
|
|
||||||
@@ -44,4 +46,6 @@ void nm_dispose_scan_results (wireless_scan *result_list);
|
|||||||
|
|
||||||
int nm_spawn_process (char *args);
|
int nm_spawn_process (char *args);
|
||||||
|
|
||||||
|
NMDriverSupportLevel nm_get_driver_support_level (LibHalContext *ctx, NMDevice *dev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -58,7 +58,7 @@ void nm_system_init (void)
|
|||||||
gboolean nm_system_device_run_dhcp (NMDevice *dev)
|
gboolean nm_system_device_run_dhcp (NMDevice *dev)
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
char *iface;
|
const char *iface;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
g_return_val_if_fail (dev != NULL, FALSE);
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
@@ -204,7 +204,7 @@ gboolean nm_system_device_setup_static_ip4_config (NMDevice *dev)
|
|||||||
guint32 broadcast;
|
guint32 broadcast;
|
||||||
char *buf;
|
char *buf;
|
||||||
int err;
|
int err;
|
||||||
char *iface;
|
const char *iface;
|
||||||
|
|
||||||
g_return_val_if_fail (dev != NULL, FALSE);
|
g_return_val_if_fail (dev != NULL, FALSE);
|
||||||
g_return_val_if_fail (!nm_device_config_get_use_dhcp (dev), FALSE);
|
g_return_val_if_fail (!nm_device_config_get_use_dhcp (dev), FALSE);
|
||||||
|
@@ -24,438 +24,245 @@
|
|||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* Return codes for functions that use dbus */
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
RETURN_SUCCESS = 1,
|
||||||
|
RETURN_FAILURE = 0,
|
||||||
|
RETURN_NO_NM = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
/* dbus doesn't define a DBUS_TYPE_STRING_ARRAY so we fake one here for consistency */
|
||||||
|
#define DBUS_TYPE_STRING_ARRAY ((int) '$')
|
||||||
|
|
||||||
|
#define DBUS_NO_SERVICE_ERROR "org.freedesktop.DBus.Error.ServiceDoesNotExist"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* nmwa_dbus_call_nm_method
|
||||||
|
*
|
||||||
|
* Do a method call on NetworkManager.
|
||||||
|
*
|
||||||
|
* Returns: RETURN_SUCCESS on success
|
||||||
|
* RETURN_FAILURE on failure
|
||||||
|
* RETURN_NO_NM if NetworkManager service no longer exists
|
||||||
|
*/
|
||||||
|
static int nmwa_dbus_call_nm_method (DBusConnection *con, const char *path, const char *method, int arg_type, void **arg, int *item_count)
|
||||||
|
{
|
||||||
|
DBusMessage *message;
|
||||||
|
DBusMessage *reply;
|
||||||
|
DBusError error;
|
||||||
|
char *dbus_string = NULL;
|
||||||
|
int dbus_int = 0;
|
||||||
|
gboolean dbus_bool = FALSE;
|
||||||
|
char **dbus_string_array = NULL;
|
||||||
|
int num_items = 0;
|
||||||
|
dbus_bool_t ret = TRUE;
|
||||||
|
DBusMessageIter iter;
|
||||||
|
|
||||||
|
g_return_val_if_fail (con != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (path != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (method != NULL, RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (((arg_type == DBUS_TYPE_STRING) || (arg_type == DBUS_TYPE_INT32) || (arg_type == DBUS_TYPE_BOOLEAN) || (arg_type == DBUS_TYPE_STRING_ARRAY)), RETURN_FAILURE);
|
||||||
|
g_return_val_if_fail (arg != NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if ((arg_type == DBUS_TYPE_STRING) || (arg_type == DBUS_TYPE_STRING_ARRAY))
|
||||||
|
g_return_val_if_fail (*arg == NULL, RETURN_FAILURE);
|
||||||
|
|
||||||
|
if (arg_type == DBUS_TYPE_STRING_ARRAY)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (item_count != NULL, RETURN_FAILURE);
|
||||||
|
*item_count = 0;
|
||||||
|
*((char **)arg) = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, method)))
|
||||||
|
{
|
||||||
|
fprintf (stderr, "nmwa_dbus_call_nm_method(): Couldn't allocate the dbus message\n");
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
reply = dbus_connection_send_with_reply_and_block (con, message, -1, &error);
|
||||||
|
dbus_message_unref (message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
{
|
||||||
|
int ret = RETURN_FAILURE;
|
||||||
|
|
||||||
|
if (!strcmp (error.name, DBUS_NO_SERVICE_ERROR))
|
||||||
|
ret = RETURN_NO_NM;
|
||||||
|
else if (!strcmp (error.name, NM_DBUS_NO_ACTIVE_NET_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error.name, NM_DBUS_NO_ACTIVE_DEVICE_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
else if (!strcmp (error.name, NM_DBUS_NO_NETWORKS_ERROR))
|
||||||
|
ret = RETURN_SUCCESS;
|
||||||
|
|
||||||
|
if (ret != RETURN_SUCCESS)
|
||||||
|
fprintf (stderr, "nmwa_dbus_call_nm_method(): %s raised:\n %s\n\n", error.name, error.message);
|
||||||
|
|
||||||
|
dbus_error_free (&error);
|
||||||
|
return (ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reply == NULL)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "nmwa_dbus_call_nm_method(): dbus reply message was NULL\n" );
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_error_init (&error);
|
||||||
|
switch (arg_type)
|
||||||
|
{
|
||||||
|
case DBUS_TYPE_STRING:
|
||||||
|
ret = dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID);
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_STRING_ARRAY:
|
||||||
|
dbus_message_iter_init (reply, &iter);
|
||||||
|
ret = dbus_message_iter_get_string_array (&iter, &dbus_string_array, &num_items);
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_INT32:
|
||||||
|
ret = dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &dbus_int, DBUS_TYPE_INVALID);
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_BOOLEAN:
|
||||||
|
ret = dbus_message_get_args (reply, &error, DBUS_TYPE_BOOLEAN, &dbus_bool, DBUS_TYPE_INVALID);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
fprintf (stderr, "nmwa_dbus_call_nm_method(): Unknown argument type!\n");
|
||||||
|
ret = FALSE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "nmwa_dbus_call_nm_method(): error while getting args: name='%s' message='%s'\n", error.name, error.message);
|
||||||
|
if (dbus_error_is_set (&error))
|
||||||
|
dbus_error_free (&error);
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
return (RETURN_FAILURE);
|
||||||
|
}
|
||||||
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
|
switch (arg_type)
|
||||||
|
{
|
||||||
|
case DBUS_TYPE_STRING:
|
||||||
|
*((char **)(arg)) = dbus_string;
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_STRING_ARRAY:
|
||||||
|
*((char ***)(arg)) = dbus_string_array;
|
||||||
|
*item_count = num_items;
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_INT32:
|
||||||
|
*((int *)(arg)) = dbus_int;
|
||||||
|
break;
|
||||||
|
case DBUS_TYPE_BOOLEAN:
|
||||||
|
*((gboolean *)(arg)) = dbus_bool;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (RETURN_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
char * get_active_device (DBusConnection *connection)
|
char * get_active_device (DBusConnection *connection)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
char *active_device = NULL;
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
char *device_path;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
ret = nmwa_dbus_call_nm_method (connection, NM_DBUS_PATH, "getActiveDevice", DBUS_TYPE_STRING, (void *)(&active_device), NULL);
|
||||||
"/org/freedesktop/NetworkManager",
|
if (ret == RETURN_SUCCESS)
|
||||||
"org.freedesktop.NetworkManager",
|
return (active_device);
|
||||||
"getActiveDevice");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
return (NULL);
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char *string;
|
|
||||||
string = dbus_message_iter_get_string (&iter);
|
|
||||||
if (!string)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL active device object path" );
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (stderr, "Active device: '%s'\n", string );
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
|
|
||||||
device_path = g_strdup (string);
|
|
||||||
return (device_path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_device_name (DBusConnection *connection, char *path)
|
char * get_object_name (DBusConnection *connection, char *path)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
char *name = NULL;
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
ret = nmwa_dbus_call_nm_method (connection, path, "getName", DBUS_TYPE_STRING, (void *)(&name), NULL);
|
||||||
path,
|
if (ret == RETURN_SUCCESS)
|
||||||
"org.freedesktop.NetworkManager",
|
return (name);
|
||||||
"getName");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
return (NULL);
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char *string;
|
|
||||||
string = dbus_message_iter_get_string (&iter);
|
|
||||||
if (!string)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL active device object path" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (stderr, "Active device name: '%s'\n", string );
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_object_signal_strength (DBusConnection *connection, char *path)
|
int get_object_signal_strength (DBusConnection *connection, char *path)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
int strength = -1;
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
ret = nmwa_dbus_call_nm_method (connection, path, "getStrength", DBUS_TYPE_INT32, (void *)(&strength), NULL);
|
||||||
path,
|
if (ret == RETURN_SUCCESS)
|
||||||
"org.freedesktop.NetworkManager.Devices",
|
return (strength);
|
||||||
"getStrength");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
return (-1);
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
int qual = dbus_message_iter_get_int32 (&iter);
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
|
|
||||||
return (qual);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_nm_status (DBusConnection *connection)
|
char * get_nm_status (DBusConnection *connection)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
char *status = NULL;
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
ret = nmwa_dbus_call_nm_method (connection, NM_DBUS_PATH, "status", DBUS_TYPE_STRING, (void *)(&status), NULL);
|
||||||
"/org/freedesktop/NetworkManager",
|
if (ret == RETURN_SUCCESS)
|
||||||
"org.freedesktop.NetworkManager",
|
return (status);
|
||||||
"status");
|
|
||||||
if (message == NULL)
|
return (NULL);
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
char * get_device_active_network (DBusConnection *connection, char *path)
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
{
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
int ret;
|
||||||
dbus_message_unref (message);
|
char *net = NULL;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
ret = nmwa_dbus_call_nm_method (connection, path, "getActiveNetwork", DBUS_TYPE_STRING, (void *)(&net), NULL);
|
||||||
{
|
if (ret == RETURN_SUCCESS)
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
return (net);
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
return (NULL);
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char *string;
|
|
||||||
string = dbus_message_iter_get_string (&iter);
|
|
||||||
if (!string)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL status" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (stderr, "NM Status: '%s'\n", string );
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
}
|
|
||||||
|
|
||||||
void get_device_active_network (DBusConnection *connection, char *path)
|
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusMessage *reply;
|
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getActiveNetwork");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
if (strstr (error.name, "NoActiveNetwork"))
|
|
||||||
fprintf (stderr, " This device is not associated with a wireless network\n");
|
|
||||||
else
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char *string;
|
|
||||||
string = dbus_message_iter_get_string (&iter);
|
|
||||||
if (!string)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL active device object path" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (stderr, "Active device's Network: '%s' ", string );
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
string,
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getName");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
string = dbus_message_iter_get_string (&iter);
|
|
||||||
if (!string)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL active device object path" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (stderr, " (%s)\n", string );
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int get_device_type (DBusConnection *connection, char *path)
|
int get_device_type (DBusConnection *connection, char *path)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
int type = -1;
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getType");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
int type = dbus_message_iter_get_int32 (&iter);
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
|
|
||||||
|
ret = nmwa_dbus_call_nm_method (connection, path, "getType", DBUS_TYPE_INT32, (void *)(&type), NULL);
|
||||||
|
if (ret == RETURN_SUCCESS)
|
||||||
return (type);
|
return (type);
|
||||||
|
|
||||||
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * get_network_name (DBusConnection *connection, const char *path)
|
void print_device_networks (DBusConnection *connection, const char *path)
|
||||||
{
|
{
|
||||||
DBusMessage *message2;
|
int ret;
|
||||||
DBusMessage *reply2;
|
char **networks = NULL;
|
||||||
DBusMessageIter iter2;
|
int num_networks = 0;
|
||||||
DBusError error2;
|
|
||||||
|
|
||||||
message2 = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getName");
|
|
||||||
if (message2 == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error2);
|
|
||||||
reply2 = dbus_connection_send_with_reply_and_block (connection, message2, -1, &error2);
|
|
||||||
dbus_message_unref (message2);
|
|
||||||
if (dbus_error_is_set (&error2))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error2.name, error2.message);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply2 == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply2, &iter2);
|
|
||||||
const char *string2 = dbus_message_iter_get_string (&iter2);
|
|
||||||
if (!string2)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned a NULL network name" );
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (reply2);
|
|
||||||
|
|
||||||
return (string2);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void get_device_networks (DBusConnection *connection, const char *path)
|
|
||||||
{
|
|
||||||
DBusMessage *message;
|
|
||||||
DBusMessage *reply;
|
|
||||||
DBusMessageIter iter;
|
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
path,
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getNetworks");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char **networks;
|
|
||||||
int num_networks;
|
|
||||||
|
|
||||||
if (!dbus_message_iter_get_string_array (&iter, &networks, &num_networks))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned no device list" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
ret = nmwa_dbus_call_nm_method (connection, path, "getNetworks", DBUS_TYPE_STRING_ARRAY, (void **)(&networks), &num_networks);
|
||||||
|
if (ret != RETURN_SUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
fprintf( stderr, " Networks:\n" );
|
fprintf( stderr, " Networks:\n" );
|
||||||
for (i = 0; i < num_networks; i++)
|
for (i = 0; i < num_networks; i++)
|
||||||
{
|
{
|
||||||
const char *name = get_network_name (connection, networks[i]);
|
char *name = get_object_name (connection, networks[i]);
|
||||||
|
|
||||||
fprintf( stderr, " %s (%s) Strength: %d%%\n", networks[i], name,
|
fprintf( stderr, " %s (%s) Strength: %d%%\n", networks[i], name,
|
||||||
get_object_signal_strength (connection, networks[i]) );
|
get_object_signal_strength (connection, networks[i]) );
|
||||||
@@ -466,75 +273,41 @@ void get_device_networks (DBusConnection *connection, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_devices (DBusConnection *connection)
|
void print_devices (DBusConnection *connection)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
int ret;
|
||||||
DBusMessage *reply;
|
char **devices = NULL;
|
||||||
DBusMessageIter iter;
|
int num_devices = 0;
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
message = dbus_message_new_method_call ("org.freedesktop.NetworkManager",
|
|
||||||
"/org/freedesktop/NetworkManager",
|
|
||||||
"org.freedesktop.NetworkManager",
|
|
||||||
"getDevices");
|
|
||||||
if (message == NULL)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "%s raised:\n %s\n\n", error.name, error.message);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply == NULL)
|
|
||||||
{
|
|
||||||
fprintf( stderr, "dbus reply message was NULL\n" );
|
|
||||||
dbus_message_unref (message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
dbus_message_iter_init (reply, &iter);
|
|
||||||
char **devices;
|
|
||||||
int num_devices;
|
|
||||||
|
|
||||||
if (!dbus_message_iter_get_string_array (&iter, &devices, &num_devices))
|
|
||||||
{
|
|
||||||
fprintf (stderr, "NetworkManager returned no device list" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
ret = nmwa_dbus_call_nm_method (connection, NM_DBUS_PATH, "getDevices", DBUS_TYPE_STRING_ARRAY, (void **)(&devices), &num_devices);
|
||||||
|
if (ret != RETURN_SUCCESS)
|
||||||
|
return;
|
||||||
|
|
||||||
fprintf( stderr, "Devices:\n" );
|
fprintf( stderr, "Devices:\n" );
|
||||||
for (i = 0; i < num_devices; i++)
|
for (i = 0; i < num_devices; i++)
|
||||||
{
|
{
|
||||||
int type;
|
int type = get_device_type (connection, devices[i]);
|
||||||
|
|
||||||
fprintf (stderr, " %s", devices[i]);
|
fprintf (stderr, " %s\n", devices[i]);
|
||||||
if ((type = get_device_type (connection, devices[i])) == 2)
|
if (type == DEVICE_TYPE_WIRELESS_ETHERNET)
|
||||||
{
|
{
|
||||||
|
char *active_network = get_device_active_network (connection, devices[i]);
|
||||||
|
|
||||||
|
fprintf (stderr, " Device type: wireless\n");
|
||||||
fprintf (stderr, " Strength: %d%%\n", get_object_signal_strength (connection, devices[i]));
|
fprintf (stderr, " Strength: %d%%\n", get_object_signal_strength (connection, devices[i]));
|
||||||
fprintf (stderr, " Device type: '%d'\n", type );
|
fprintf (stderr, " Active Network: '%s'\n", active_network);
|
||||||
get_device_active_network (connection, devices[i]);
|
dbus_free (active_network);
|
||||||
get_device_networks (connection, devices[i]);
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n Device type: '%d'\n", type );
|
|
||||||
fprintf (stderr, "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
print_device_networks (connection, devices[i]);
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
|
else if (type == DEVICE_TYPE_WIRED_ETHERNET)
|
||||||
|
fprintf (stderr, " Device type: wired\n");
|
||||||
|
else
|
||||||
|
fprintf (stderr, " Device type: unknown\n");
|
||||||
|
fprintf (stderr, "\n");
|
||||||
|
}
|
||||||
dbus_free_string_array (devices);
|
dbus_free_string_array (devices);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -590,18 +363,35 @@ int main( int argc, char *argv[] )
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *path;
|
char *path;
|
||||||
|
char *status;
|
||||||
|
|
||||||
|
status = get_nm_status (connection);
|
||||||
|
if (!status)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "NetworkManager appears not to be running (could not get its status). Will exit.\n");
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
fprintf (stderr, "NM Status: '%s'\n", status);
|
||||||
|
dbus_free (status);
|
||||||
|
|
||||||
get_nm_status (connection);
|
|
||||||
path = get_active_device (connection);
|
path = get_active_device (connection);
|
||||||
get_device_name (connection, path);
|
fprintf (stderr, "Active device: '%s'\n", path ? path : "(none)");
|
||||||
get_devices (connection);
|
if (path)
|
||||||
if ((argc == 2) && (get_device_type (connection, path) == 2))
|
{
|
||||||
|
char *name = get_object_name (connection, path);
|
||||||
|
fprintf (stderr, "Active device name: '%s'\n", name ? name : "(none)");
|
||||||
|
dbus_free (name);
|
||||||
|
}
|
||||||
|
|
||||||
|
print_devices (connection);
|
||||||
|
|
||||||
|
if (path && (argc == 2) && (get_device_type (connection, path) == DEVICE_TYPE_WIRELESS_ETHERNET))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Attempting to force AP '%s' for device '%s'\n", argv[1], path);
|
fprintf (stderr, "Attempting to force AP '%s' for device '%s'\n", argv[1], path);
|
||||||
set_device_network (connection, path, argv[1]);
|
set_device_network (connection, path, argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (path);
|
dbus_free (path);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -27,32 +27,17 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#define NMI_DBUS_NMI_OBJECT_PATH_PREFIX "/org/freedesktop/NetworkManagerInfo"
|
#include "NetworkManager.h"
|
||||||
#define NMI_DBUS_NMI_NAMESPACE "org.freedesktop.NetworkManagerInfo"
|
|
||||||
#define NM_DBUS_NM_OBJECT_PATH_PREFIX "/org/freedesktop/NetworkManager"
|
|
||||||
#define NM_DBUS_NM_NAMESPACE "org.freedesktop.NetworkManager"
|
|
||||||
|
|
||||||
|
|
||||||
/* MUST match MetworkManager NMNetworkType */
|
char * get_network_string_property (DBusConnection *connection, char *network, char *method, NMNetworkType type)
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
NETWORK_TYPE_UNKNOWN = 0,
|
|
||||||
NETWORK_TYPE_ALLOWED,
|
|
||||||
NETWORK_TYPE_INVALID,
|
|
||||||
NETWORK_TYPE_DEVICE
|
|
||||||
} NMINetworkType;
|
|
||||||
|
|
||||||
char * get_network_string_property (DBusConnection *connection, char *network, char *method, NMINetworkType type)
|
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, method);
|
||||||
NMI_DBUS_NMI_OBJECT_PATH_PREFIX,
|
|
||||||
NMI_DBUS_NMI_NAMESPACE,
|
|
||||||
method);
|
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
||||||
@@ -94,7 +79,7 @@ char * get_network_string_property (DBusConnection *connection, char *network, c
|
|||||||
return (ret_string);
|
return (ret_string);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean get_network_trusted (DBusConnection *connection, char *network, NMINetworkType type)
|
gboolean get_network_trusted (DBusConnection *connection, char *network, NMNetworkType type)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
@@ -104,10 +89,7 @@ gboolean get_network_trusted (DBusConnection *connection, char *network, NMINetw
|
|||||||
g_return_val_if_fail (connection != NULL, -1);
|
g_return_val_if_fail (connection != NULL, -1);
|
||||||
g_return_val_if_fail (network != NULL, -1);
|
g_return_val_if_fail (network != NULL, -1);
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworkTrusted");
|
||||||
NMI_DBUS_NMI_OBJECT_PATH_PREFIX,
|
|
||||||
NMI_DBUS_NMI_NAMESPACE,
|
|
||||||
"getNetworkTrusted");
|
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
||||||
@@ -146,17 +128,14 @@ gboolean get_network_trusted (DBusConnection *connection, char *network, NMINetw
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void get_networks_of_type (DBusConnection *connection, NMINetworkType type)
|
void get_networks_of_type (DBusConnection *connection, NMNetworkType type)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
DBusMessageIter iter;
|
DBusMessageIter iter;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getNetworks");
|
||||||
NMI_DBUS_NMI_OBJECT_PATH_PREFIX,
|
|
||||||
NMI_DBUS_NMI_NAMESPACE,
|
|
||||||
"getNetworks");
|
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
fprintf (stderr, "Couldn't allocate the dbus message\n");
|
||||||
@@ -224,8 +203,7 @@ void get_user_key_for_network (DBusConnection *connection)
|
|||||||
|
|
||||||
g_return_if_fail (connection != NULL);
|
g_return_if_fail (connection != NULL);
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_NMI_NAMESPACE, NMI_DBUS_NMI_OBJECT_PATH_PREFIX,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getKeyForNetwork");
|
||||||
NMI_DBUS_NMI_NAMESPACE, "getKeyForNetwork");
|
|
||||||
if (message == NULL)
|
if (message == NULL)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "get_user_key_for_network(): Couldn't allocate the dbus message\n");
|
fprintf (stderr, "get_user_key_for_network(): Couldn't allocate the dbus message\n");
|
||||||
@@ -336,14 +314,14 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
dbus_connection_setup_with_g_main (connection, NULL);
|
dbus_connection_setup_with_g_main (connection, NULL);
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
dbus_bus_acquire_service (connection, NM_DBUS_NM_NAMESPACE, 0, &error);
|
dbus_bus_acquire_service (connection, NM_DBUS_SERVICE, 0, &error);
|
||||||
if (dbus_error_is_set (&error))
|
if (dbus_error_is_set (&error))
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not acquire its service. dbus_bus_acquire_service() says: '%s'\n", error.message);
|
fprintf (stderr, "Could not acquire its service. dbus_bus_acquire_service() says: '%s'\n", error.message);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
success = dbus_connection_register_object_path (connection, NM_DBUS_NM_OBJECT_PATH_PREFIX, &vtable, loop);
|
success = dbus_connection_register_object_path (connection, NM_DBUS_INTERFACE, &vtable, loop);
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "Could not register a handler for NetworkManager. Not enough memory?\n");
|
fprintf (stderr, "Could not register a handler for NetworkManager. Not enough memory?\n");
|
||||||
|
@@ -27,20 +27,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
/* These MUST correspond to NetworkManager device types */
|
#include "NetworkManager.h"
|
||||||
typedef enum NMDeviceType
|
|
||||||
{
|
|
||||||
DEVICE_TYPE_DONT_KNOW = 0,
|
|
||||||
DEVICE_TYPE_WIRED_ETHERNET,
|
|
||||||
DEVICE_TYPE_WIRELESS_ETHERNET
|
|
||||||
} NMDeviceType;
|
|
||||||
|
|
||||||
|
|
||||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
|
||||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
|
||||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
|
||||||
#define NM_DBUS_INTERFACE_DEVICES "org.freedesktop.NetworkManager.Devices"
|
|
||||||
|
|
||||||
|
|
||||||
void create_device (DBusConnection *connection, NMDeviceType type)
|
void create_device (DBusConnection *connection, NMDeviceType type)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user