2007-02-16 Tambet Ingo <tambet@ximian.com>
* introspection/nm-ip4-config.xml: Implement. * libnm-glib/libnm-glib-test.c: Use new DBUS API in tests. * libnm-glib/nm-ip4-config.c: * libnm-glib/nm-ip4-config.c: Implement. * src/nm-ap-security[-*]: Remove circular dependencies between APs and AP securities. APs reference security. * src/nm-device-802-11-wireless.c: Implement missing properties that need to be exported over DBUS. * src/nm-device-802-3-ethernet.c: Ditto. * src/NetworkManagerAP.c: * src/NetworkManagerAP.h: - Convert to GObject, export over DBUS. * src/nm-ip4-config.h: * src/nm-ip4-config.h: - Convert to GObject, export over DBUS. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2322 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
25
ChangeLog
25
ChangeLog
@@ -1,3 +1,28 @@
|
|||||||
|
2007-02-16 Tambet Ingo <tambet@ximian.com>
|
||||||
|
|
||||||
|
* introspection/nm-ip4-config.xml: Implement.
|
||||||
|
|
||||||
|
* libnm-glib/libnm-glib-test.c: Use new DBUS API in tests.
|
||||||
|
|
||||||
|
* libnm-glib/nm-ip4-config.c:
|
||||||
|
* libnm-glib/nm-ip4-config.c: Implement.
|
||||||
|
|
||||||
|
* src/nm-ap-security[-*]: Remove circular dependencies between APs and AP
|
||||||
|
securities. APs reference security.
|
||||||
|
|
||||||
|
* src/nm-device-802-11-wireless.c: Implement missing properties that need to
|
||||||
|
be exported over DBUS.
|
||||||
|
|
||||||
|
* src/nm-device-802-3-ethernet.c: Ditto.
|
||||||
|
|
||||||
|
* src/NetworkManagerAP.c:
|
||||||
|
* src/NetworkManagerAP.h:
|
||||||
|
- Convert to GObject, export over DBUS.
|
||||||
|
|
||||||
|
* src/nm-ip4-config.h:
|
||||||
|
* src/nm-ip4-config.h:
|
||||||
|
- Convert to GObject, export over DBUS.
|
||||||
|
|
||||||
2007-02-12 Dan Williams <dcbw@redhat.com>
|
2007-02-12 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
Patch from Helmut Schaa <hschaa@suse.de>
|
Patch from Helmut Schaa <hschaa@suse.de>
|
||||||
|
@@ -7,6 +7,7 @@ sbin_PROGRAMS = NetworkManagerDispatcher
|
|||||||
NetworkManagerDispatcher_CPPFLAGS = \
|
NetworkManagerDispatcher_CPPFLAGS = \
|
||||||
$(DBUS_CFLAGS) \
|
$(DBUS_CFLAGS) \
|
||||||
$(GTHREAD_CFLAGS) \
|
$(GTHREAD_CFLAGS) \
|
||||||
|
-I$(top_builddir)/libnm-glib \
|
||||||
-Wall \
|
-Wall \
|
||||||
-DDBUS_API_SUBJECT_TO_CHANGE \
|
-DDBUS_API_SUBJECT_TO_CHANGE \
|
||||||
-DBINDIR=\"$(bindir)\" \
|
-DBINDIR=\"$(bindir)\" \
|
||||||
@@ -18,7 +19,8 @@ NetworkManagerDispatcher_CPPFLAGS = \
|
|||||||
NetworkManagerDispatcher_SOURCES = NetworkManagerDispatcher.c
|
NetworkManagerDispatcher_SOURCES = NetworkManagerDispatcher.c
|
||||||
|
|
||||||
NetworkManagerDispatcher_LDADD = \
|
NetworkManagerDispatcher_LDADD = \
|
||||||
$(DBUS_LIBS) \
|
$(DBUS_LIBS) \
|
||||||
$(GTHREAD_LIBS) \
|
$(GTHREAD_LIBS) \
|
||||||
$(top_builddir)/utils/libnmutils.la
|
$(top_builddir)/utils/libnmutils.la \
|
||||||
|
$(top_builddir)/libnm-glib/libnm-glib.la
|
||||||
|
|
||||||
|
@@ -37,22 +37,14 @@
|
|||||||
|
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
|
#include "nm-client.h"
|
||||||
|
|
||||||
enum NMDAction
|
|
||||||
{
|
|
||||||
NMD_DEVICE_DONT_KNOW,
|
|
||||||
NMD_DEVICE_NOW_INACTIVE,
|
|
||||||
NMD_DEVICE_NOW_ACTIVE,
|
|
||||||
};
|
|
||||||
typedef enum NMDAction NMDAction;
|
|
||||||
|
|
||||||
|
|
||||||
#define NM_SCRIPT_DIR SYSCONFDIR"/NetworkManager/dispatcher.d"
|
#define NM_SCRIPT_DIR SYSCONFDIR"/NetworkManager/dispatcher.d"
|
||||||
|
|
||||||
#define NMD_DEFAULT_PID_FILE LOCALSTATEDIR"/run/NetworkManagerDispatcher.pid"
|
#define NMD_DEFAULT_PID_FILE LOCALSTATEDIR"/run/NetworkManagerDispatcher.pid"
|
||||||
|
|
||||||
static DBusConnection *nmd_dbus_init (void);
|
GHashTable *device_signals_hash;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nmd_permission_check
|
* nmd_permission_check
|
||||||
@@ -66,7 +58,8 @@ static DBusConnection *nmd_dbus_init (void);
|
|||||||
* - Executable by the owner.
|
* - Executable by the owner.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static inline gboolean nmd_permission_check (struct stat *s)
|
static inline gboolean
|
||||||
|
nmd_permission_check (struct stat *s)
|
||||||
{
|
{
|
||||||
if (!S_ISREG (s->st_mode))
|
if (!S_ISREG (s->st_mode))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -86,19 +79,22 @@ static inline gboolean nmd_permission_check (struct stat *s)
|
|||||||
* Call scripts in /etc/NetworkManager.d when devices go down or up
|
* Call scripts in /etc/NetworkManager.d when devices go down or up
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static void nmd_execute_scripts (NMDAction action, char *iface_name)
|
static void
|
||||||
|
nmd_execute_scripts (NMDeviceState state, char *iface_name)
|
||||||
{
|
{
|
||||||
GDir * dir;
|
GDir * dir;
|
||||||
const char * file_name;
|
const char * file_name;
|
||||||
const char * char_act;
|
const char * char_act;
|
||||||
|
|
||||||
if (action == NMD_DEVICE_NOW_ACTIVE)
|
if (state == NM_DEVICE_STATE_ACTIVATED)
|
||||||
char_act = "up";
|
char_act = "up";
|
||||||
else if (action == NMD_DEVICE_NOW_INACTIVE)
|
else if (state == NM_DEVICE_STATE_DISCONNECTED)
|
||||||
char_act = "down";
|
char_act = "down";
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
nm_info ("Device %s is now %s.", iface_name, char_act);
|
||||||
|
|
||||||
if (!(dir = g_dir_open (NM_SCRIPT_DIR, 0, NULL)))
|
if (!(dir = g_dir_open (NM_SCRIPT_DIR, 0, NULL)))
|
||||||
{
|
{
|
||||||
nm_warning ("nmd_execute_scripts(): opendir() could not open '" NM_SCRIPT_DIR "'. errno = %d", errno);
|
nm_warning ("nmd_execute_scripts(): opendir() could not open '" NM_SCRIPT_DIR "'. errno = %d", errno);
|
||||||
@@ -107,7 +103,7 @@ static void nmd_execute_scripts (NMDAction action, char *iface_name)
|
|||||||
|
|
||||||
while ((file_name = g_dir_read_name (dir)))
|
while ((file_name = g_dir_read_name (dir)))
|
||||||
{
|
{
|
||||||
char * file_path = g_strdup_printf (NM_SCRIPT_DIR"/%s", file_name);
|
char *file_path = g_build_filename (NM_SCRIPT_DIR, file_name, NULL);
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
||||||
if ((file_name[0] != '.') && (stat (file_path, &s) == 0))
|
if ((file_name[0] != '.') && (stat (file_path, &s) == 0))
|
||||||
@@ -131,183 +127,57 @@ static void nmd_execute_scripts (NMDAction action, char *iface_name)
|
|||||||
g_dir_close (dir);
|
g_dir_close (dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
/*
|
device_state_changed (NMDevice *device, NMDeviceState state, gpointer user_data)
|
||||||
* nmd_get_device_name
|
|
||||||
*
|
|
||||||
* Queries NetworkManager for the name of a device, specified by a device path
|
|
||||||
*/
|
|
||||||
static char * nmd_get_device_name (DBusConnection *connection, char *path)
|
|
||||||
{
|
{
|
||||||
DBusMessage * message;
|
if (state == NM_DEVICE_STATE_ACTIVATED || state == NM_DEVICE_STATE_DISCONNECTED) {
|
||||||
DBusMessage * reply;
|
char *iface;
|
||||||
DBusError error;
|
|
||||||
char * dbus_dev_name = NULL;
|
|
||||||
char * dev_name = NULL;
|
|
||||||
|
|
||||||
if (!(message = dbus_message_new_method_call (NM_DBUS_SERVICE, path, NM_DBUS_INTERFACE, "getName")))
|
iface = nm_device_get_iface (device);
|
||||||
{
|
nmd_execute_scripts (state, iface);
|
||||||
nm_warning ("Couldn't allocate the dbus message");
|
g_free (iface);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_error_init (&error);
|
|
||||||
reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error);
|
|
||||||
dbus_message_unref (message);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
{
|
|
||||||
nm_warning ("%s raised: %s", error.name, error.message);
|
|
||||||
dbus_error_free (&error);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now analyze reply */
|
|
||||||
if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &dbus_dev_name, DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
nm_warning ("There was an error getting the device name from NetworkManager." );
|
|
||||||
dev_name = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
dev_name = g_strdup (dbus_dev_name);
|
|
||||||
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
|
|
||||||
return dev_name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* nmd reinit_dbus
|
device_add_listener (NMClient *client, NMDevice *device, gpointer user_data)
|
||||||
*
|
|
||||||
* Reconnect to the system message bus if the connection was dropped.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static gboolean nmd_reinit_dbus (gpointer user_data)
|
|
||||||
{
|
{
|
||||||
if (nmd_dbus_init ())
|
guint id;
|
||||||
{
|
|
||||||
nm_info ("Successfully reconnected to the system bus.");
|
if (!g_hash_table_lookup (device_signals_hash, device)) {
|
||||||
return FALSE;
|
id = g_signal_connect (device, "state-changed",
|
||||||
|
G_CALLBACK (device_state_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
g_hash_table_insert (device_signals_hash, g_object_ref (device), GUINT_TO_POINTER (id));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* nmd_dbus_filter
|
device_remove_listener (NMClient *client, NMDevice *device, gpointer user_data)
|
||||||
*
|
|
||||||
* Handles dbus messages from NetworkManager, dispatches device active/not-active messages
|
|
||||||
*/
|
|
||||||
static DBusHandlerResult nmd_dbus_filter (DBusConnection *connection, DBusMessage *message, void *user_data)
|
|
||||||
{
|
{
|
||||||
const char *object_path;
|
guint id;
|
||||||
DBusError error;
|
|
||||||
char *dev_object_path = NULL;
|
|
||||||
gboolean handled = FALSE;
|
|
||||||
NMDAction action = NMD_DEVICE_DONT_KNOW;
|
|
||||||
|
|
||||||
dbus_error_init (&error);
|
id = GPOINTER_TO_UINT (g_hash_table_lookup (device_signals_hash, device));
|
||||||
object_path = dbus_message_get_path (message);
|
if (id) {
|
||||||
|
g_signal_handler_disconnect (device, id);
|
||||||
if (dbus_message_is_signal (message, DBUS_INTERFACE_LOCAL, "Disconnected"))
|
g_hash_table_remove (device_signals_hash, device);
|
||||||
{
|
|
||||||
dbus_connection_unref (connection);
|
|
||||||
connection = NULL;
|
|
||||||
g_timeout_add (3000, nmd_reinit_dbus, NULL);
|
|
||||||
handled = TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNoLongerActive"))
|
|
||||||
action = NMD_DEVICE_NOW_INACTIVE;
|
|
||||||
else if (dbus_message_is_signal (message, NM_DBUS_INTERFACE, "DeviceNowActive"))
|
|
||||||
action = NMD_DEVICE_NOW_ACTIVE;
|
|
||||||
|
|
||||||
if (action != NMD_DEVICE_DONT_KNOW)
|
|
||||||
{
|
|
||||||
if (dbus_message_get_args (message, &error, DBUS_TYPE_OBJECT_PATH, &dev_object_path, DBUS_TYPE_INVALID))
|
|
||||||
{
|
|
||||||
char * dev_iface_name = NULL;
|
|
||||||
|
|
||||||
dev_object_path = nm_dbus_unescape_object_path (dev_object_path);
|
|
||||||
if (dev_object_path)
|
|
||||||
dev_iface_name = nmd_get_device_name (connection, dev_object_path);
|
|
||||||
|
|
||||||
if (dev_object_path && dev_iface_name)
|
|
||||||
{
|
|
||||||
nm_info ("Device %s (%s) is now %s.", dev_object_path, dev_iface_name,
|
|
||||||
(action == NMD_DEVICE_NOW_INACTIVE ? "down" :
|
|
||||||
(action == NMD_DEVICE_NOW_ACTIVE ? "up" : "error")));
|
|
||||||
|
|
||||||
nmd_execute_scripts (action, dev_iface_name);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (dev_object_path);
|
|
||||||
g_free (dev_iface_name);
|
|
||||||
|
|
||||||
handled = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (handled ? DBUS_HANDLER_RESULT_HANDLED : DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
static void
|
||||||
* nmd_dbus_init
|
add_existing_device_listeners (NMClient *client)
|
||||||
*
|
|
||||||
* Initialize a connection to NetworkManager
|
|
||||||
*/
|
|
||||||
static DBusConnection *nmd_dbus_init (void)
|
|
||||||
{
|
{
|
||||||
DBusConnection *connection = NULL;
|
GSList *list, *iter;
|
||||||
DBusError error;
|
|
||||||
|
|
||||||
/* connect to NetworkManager service on the system bus */
|
list = nm_client_get_devices (client);
|
||||||
dbus_error_init (&error);
|
for (iter = list; iter; iter = iter->next)
|
||||||
connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error);
|
device_add_listener (client, NM_DEVICE (iter->data), NULL);
|
||||||
if (connection == NULL)
|
|
||||||
{
|
|
||||||
nm_warning ("nmd_dbus_init(): could not connect to the message bus. dbus says: '%s'", error.message);
|
|
||||||
dbus_error_free (&error);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
dbus_connection_set_exit_on_disconnect (connection, FALSE);
|
g_slist_foreach (list, (GFunc) g_object_unref, NULL);
|
||||||
dbus_connection_setup_with_g_main (connection, NULL);
|
g_slist_free (list);
|
||||||
|
|
||||||
if (!dbus_connection_add_filter (connection, nmd_dbus_filter, NULL, NULL))
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
dbus_bus_add_match (connection,
|
|
||||||
"type='signal',"
|
|
||||||
"interface='" NM_DBUS_INTERFACE "',"
|
|
||||||
"sender='" NM_DBUS_SERVICE "',"
|
|
||||||
"path='" NM_DBUS_PATH "'", &error);
|
|
||||||
if (dbus_error_is_set (&error))
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
return (connection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* nmd_print_usage
|
|
||||||
*
|
|
||||||
* Prints program usage.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nmd_print_usage (void)
|
|
||||||
{
|
|
||||||
fprintf (stderr, "\n" "usage : NetworkManagerDispatcher [--no-daemon] [--pid-file=<file>] [--help]\n");
|
|
||||||
fprintf (stderr,
|
|
||||||
"\n"
|
|
||||||
" --no-daemon Do not daemonize\n"
|
|
||||||
" --pid-file=<path> Specify the location of a PID file\n"
|
|
||||||
" --help Show this information and exit\n"
|
|
||||||
"\n"
|
|
||||||
"NetworkManagerDispatcher listens for device messages from NetworkManager\n"
|
|
||||||
"and runs scripts in " NM_SCRIPT_DIR "\n"
|
|
||||||
"\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
write_pidfile (const char *pidfile)
|
write_pidfile (const char *pidfile)
|
||||||
{
|
{
|
||||||
@@ -331,88 +201,75 @@ write_pidfile (const char *pidfile)
|
|||||||
* main
|
* main
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int main (int argc, char *argv[])
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
gboolean become_daemon = TRUE;
|
GError *err = NULL;
|
||||||
GMainLoop * loop = NULL;
|
GOptionContext *opt_ctx;
|
||||||
DBusConnection *connection = NULL;
|
GMainLoop *loop;
|
||||||
char * pidfile = NULL;
|
int ret = EXIT_FAILURE;
|
||||||
char * user_pidfile = NULL;
|
NMClient *client;
|
||||||
|
gboolean no_daemon = FALSE;
|
||||||
|
char *pidfile = NMD_DEFAULT_PID_FILE;
|
||||||
|
|
||||||
/* Parse options */
|
GOptionEntry entries[] = {
|
||||||
while (1)
|
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &no_daemon, "Do not daemonize", NULL },
|
||||||
{
|
{ "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, "Specify the location of a PID file", "filename" },
|
||||||
int c;
|
{ NULL }
|
||||||
int option_index = 0;
|
};
|
||||||
const char *opt;
|
|
||||||
|
|
||||||
static struct option options[] = {
|
opt_ctx = g_option_context_new (NULL);
|
||||||
{"no-daemon", 0, NULL, 0},
|
g_option_context_set_summary (opt_ctx,
|
||||||
{"pid-file", 1, NULL, 0},
|
"NetworkManagerDispatcher listens for device messages from NetworkManager\n"
|
||||||
{"help", 0, NULL, 0},
|
"and runs scripts in " NM_SCRIPT_DIR);
|
||||||
{NULL, 0, NULL, 0}
|
g_option_context_add_main_entries (opt_ctx, entries, NULL);
|
||||||
};
|
|
||||||
|
|
||||||
c = getopt_long (argc, argv, "", options, &option_index);
|
if (!g_option_context_parse (opt_ctx, &argc, &argv, &err)) {
|
||||||
if (c == -1)
|
g_print ("%s\n", err->message);
|
||||||
break;
|
g_error_free (err);
|
||||||
|
goto out;
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
opt = options[option_index].name;
|
|
||||||
if (strcmp (opt, "help") == 0)
|
|
||||||
{
|
|
||||||
nmd_print_usage ();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else if (strcmp (opt, "no-daemon") == 0)
|
|
||||||
become_daemon = FALSE;
|
|
||||||
else if (strcmp (opt, "pid-file") == 0)
|
|
||||||
user_pidfile = g_strdup (optarg);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nmd_print_usage ();
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
nmd_print_usage ();
|
|
||||||
return 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
openlog("NetworkManagerDispatcher", (become_daemon) ? LOG_CONS : LOG_CONS | LOG_PERROR, (become_daemon) ? LOG_DAEMON : LOG_USER);
|
openlog ("NetworkManagerDispatcher",
|
||||||
|
(no_daemon) ? LOG_CONS | LOG_PERROR : LOG_CONS,
|
||||||
|
(no_daemon) ? LOG_USER : LOG_DAEMON);
|
||||||
|
|
||||||
if (become_daemon)
|
if (!no_daemon) {
|
||||||
{
|
if (daemon (FALSE, FALSE) < 0) {
|
||||||
if (daemon (FALSE, FALSE) < 0)
|
nm_warning ("NetworkManagerDispatcher could not daemonize: %s", strerror (errno));
|
||||||
{
|
goto out;
|
||||||
nm_warning ("NetworkManagerDispatcher could not daemonize: %s", strerror (errno));
|
|
||||||
exit (1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pidfile = user_pidfile ? user_pidfile : NMD_DEFAULT_PID_FILE;
|
|
||||||
write_pidfile (pidfile);
|
write_pidfile (pidfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_type_init ();
|
g_type_init ();
|
||||||
if (!g_thread_supported ())
|
|
||||||
g_thread_init (NULL);
|
|
||||||
|
|
||||||
/* Connect to the NetworkManager dbus service and run the main loop */
|
client = nm_client_new ();
|
||||||
if ((connection = nmd_dbus_init ()))
|
if (!client)
|
||||||
{
|
goto out;
|
||||||
loop = g_main_loop_new (NULL, FALSE);
|
|
||||||
g_main_loop_run (loop);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean up pidfile */
|
device_signals_hash = g_hash_table_new_full (NULL, NULL, (GDestroyNotify) g_object_unref, NULL);
|
||||||
if (pidfile)
|
|
||||||
unlink (pidfile);
|
|
||||||
g_free (user_pidfile);
|
|
||||||
|
|
||||||
return 0;
|
g_signal_connect (client, "device-added",
|
||||||
|
G_CALLBACK (device_add_listener), NULL);
|
||||||
|
g_signal_connect (client, "device-removed",
|
||||||
|
G_CALLBACK (device_remove_listener), NULL);
|
||||||
|
|
||||||
|
add_existing_device_listeners (client);
|
||||||
|
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
g_main_loop_unref (loop);
|
||||||
|
g_object_unref (client);
|
||||||
|
g_hash_table_destroy (device_signals_hash);
|
||||||
|
|
||||||
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
out:
|
||||||
|
g_option_context_free (opt_ctx);
|
||||||
|
closelog ();
|
||||||
|
unlink (pidfile);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
@@ -3,13 +3,13 @@
|
|||||||
<node name="/">
|
<node name="/">
|
||||||
<interface name="org.freedesktop.NetworkManager.AccessPoint">
|
<interface name="org.freedesktop.NetworkManager.AccessPoint">
|
||||||
<property name="Address" type="s" access="read"/>
|
<property name="Address" type="s" access="read"/>
|
||||||
<property name="Capabilities" type="i" access="read"/>
|
<property name="Capabilities" type="u" access="read"/>
|
||||||
<property name="Encrypted" type="b" access="read"/>
|
<property name="Encrypted" type="b" access="read"/>
|
||||||
<property name="Essid" type="s" access="read"/>
|
<property name="Essid" type="s" access="read"/>
|
||||||
<property name="Frequency" type="d" access="read"/>
|
<property name="Frequency" type="d" access="read"/>
|
||||||
<property name="HWAddress" type="s" access="read"/>
|
<property name="HWAddress" type="s" access="read"/>
|
||||||
<property name="Mode" type="i" access="read"/>
|
<property name="Mode" type="i" access="read"/>
|
||||||
<property name="Rate" type="i" access="read"/>
|
<property name="Rate" type="u" access="read"/>
|
||||||
<property name="Strength" type="i" access="read"/>
|
<property name="Strength" type="i" access="read"/>
|
||||||
|
|
||||||
<signal name="StrengthChanged">
|
<signal name="StrengthChanged">
|
||||||
|
@@ -14,8 +14,9 @@
|
|||||||
<arg name="networks" type="ao" direction="out"/>
|
<arg name="networks" type="ao" direction="out"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<property name="Address" type="s" access="read"/>
|
<property name="HwAddress" type="s" access="read"/>
|
||||||
<property name="Mode" type="i" access="read"/>
|
<property name="Mode" type="i" access="read"/>
|
||||||
|
<property name="Bitrate" type="i" access="read"/>
|
||||||
<property name="ActiveNetwork" type="o" access="read"/>
|
<property name="ActiveNetwork" type="o" access="read"/>
|
||||||
|
|
||||||
<signal name="NetworkAdded">
|
<signal name="NetworkAdded">
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
<interface name="org.freedesktop.NetworkManager.Device.Wired">
|
<interface name="org.freedesktop.NetworkManager.Device.Wired">
|
||||||
<method name="Activate">
|
<method name="Activate">
|
||||||
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_802_3_ethernet_activate"/>
|
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="impl_device_802_3_ethernet_activate"/>
|
||||||
<arg name="user_requested" type="b"/>
|
<arg name="user_requested" type="b" direction="in"/>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<property name="HwAddress" type="s" access="read"/>
|
<property name="HwAddress" type="s" access="read"/>
|
||||||
|
@@ -12,6 +12,7 @@
|
|||||||
<property name="Capabilities" type="i" access="read"/>
|
<property name="Capabilities" type="i" access="read"/>
|
||||||
<property name="Ip4Address" type="i" access="read"/>
|
<property name="Ip4Address" type="i" access="read"/>
|
||||||
<property name="State" type="u" access="read"/>
|
<property name="State" type="u" access="read"/>
|
||||||
|
<property name="Ip4Config" type="o" access="read"/>
|
||||||
|
|
||||||
<!-- Ugh, but I see no other way of getting the type on the caller
|
<!-- Ugh, but I see no other way of getting the type on the caller
|
||||||
based on dbus object path only -->
|
based on dbus object path only -->
|
||||||
|
16
introspection/nm-ip4-config.xml
Normal file
16
introspection/nm-ip4-config.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
|
||||||
|
<node name="/">
|
||||||
|
<interface name="org.freedesktop.NetworkManager.IP4Config">
|
||||||
|
<property name="Address" type="u" access="read"/>
|
||||||
|
<property name="Gateway" type="u" access="read"/>
|
||||||
|
<property name="Netmask" type="u" access="read"/>
|
||||||
|
<property name="Broadcast" type="u" access="read"/>
|
||||||
|
<property name="Hostname" type="s" access="read"/>
|
||||||
|
<property name="Nameservers" type="au" access="read"/>
|
||||||
|
<property name="Domains" type="as" access="read"/>
|
||||||
|
<property name="NisDomain" type="s" access="read"/>
|
||||||
|
<property name="NisServers" type="au" access="read"/>
|
||||||
|
</interface>
|
||||||
|
</node>
|
||||||
|
|
@@ -20,7 +20,8 @@ libnminclude_HEADERS = \
|
|||||||
nm-device.h \
|
nm-device.h \
|
||||||
nm-device-802-3-ethernet.h \
|
nm-device-802-3-ethernet.h \
|
||||||
nm-device-802-11-wireless.h \
|
nm-device-802-11-wireless.h \
|
||||||
nm-access-point.h
|
nm-access-point.h \
|
||||||
|
nm-ip4-config.h
|
||||||
|
|
||||||
libnm_glib_la_SOURCES = \
|
libnm_glib_la_SOURCES = \
|
||||||
nm-client.c \
|
nm-client.c \
|
||||||
@@ -29,6 +30,7 @@ libnm_glib_la_SOURCES = \
|
|||||||
nm-device-802-3-ethernet.c \
|
nm-device-802-3-ethernet.c \
|
||||||
nm-device-802-11-wireless.c \
|
nm-device-802-11-wireless.c \
|
||||||
nm-access-point.c \
|
nm-access-point.c \
|
||||||
|
nm-ip4-config.c \
|
||||||
nm-utils.c \
|
nm-utils.c \
|
||||||
nm-utils.h \
|
nm-utils.h \
|
||||||
$(BUILT_SOURCES)
|
$(BUILT_SOURCES)
|
||||||
|
@@ -1,4 +1,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <sys/socket.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include "nm-client.h"
|
#include "nm-client.h"
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
#include "nm-device-802-3-ethernet.h"
|
#include "nm-device-802-3-ethernet.h"
|
||||||
@@ -33,12 +38,150 @@ test_get_state (NMClient *client)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
ip4_address_as_string (guint32 ip)
|
||||||
|
{
|
||||||
|
struct in_addr tmp_addr;
|
||||||
|
gchar *ip_string;
|
||||||
|
|
||||||
|
tmp_addr.s_addr = ip;
|
||||||
|
ip_string = inet_ntoa (tmp_addr);
|
||||||
|
|
||||||
|
return g_strdup (ip_string);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_ip4_config (NMIP4Config *cfg)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
GArray *array;
|
||||||
|
char **ptr_array;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
tmp = ip4_address_as_string (nm_ip4_config_get_address (cfg));
|
||||||
|
g_print ("IP4 address: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
tmp = ip4_address_as_string (nm_ip4_config_get_gateway (cfg));
|
||||||
|
g_print ("IP4 gateway: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
tmp = ip4_address_as_string (nm_ip4_config_get_netmask (cfg));
|
||||||
|
g_print ("IP4 netmask: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
tmp = ip4_address_as_string (nm_ip4_config_get_broadcast (cfg));
|
||||||
|
g_print ("IP4 broadcast: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
tmp = nm_ip4_config_get_hostname (cfg);
|
||||||
|
g_print ("IP4 hostname: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
array = nm_ip4_config_get_nameservers (cfg);
|
||||||
|
if (array) {
|
||||||
|
g_print ("IP4 DNS:\n");
|
||||||
|
for (i = 0; i < array->len; i++) {
|
||||||
|
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
|
||||||
|
g_print ("\t%s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_array_free (array, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
ptr_array = nm_ip4_config_get_domains (cfg);
|
||||||
|
if (ptr_array) {
|
||||||
|
g_print ("IP4 domains:\n");
|
||||||
|
for (i = 0; ptr_array[i]; i++) {
|
||||||
|
g_print ("\t%s\n", ptr_array[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_strfreev (ptr_array);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = nm_ip4_config_get_nis_domain (cfg);
|
||||||
|
g_print ("IP4 NIS domain: %s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
|
||||||
|
array = nm_ip4_config_get_nis_servers (cfg);
|
||||||
|
if (array) {
|
||||||
|
g_print ("IP4 NIS servers:\n");
|
||||||
|
for (i = 0; i < array->len; i++) {
|
||||||
|
tmp = ip4_address_as_string (g_array_index (array, guint32, i));
|
||||||
|
g_print ("\t%s\n", tmp);
|
||||||
|
g_free (tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_array_free (array, TRUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_wireless (NMDevice80211Wireless *device)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
GSList *iter;
|
||||||
|
GSList *networks;
|
||||||
|
|
||||||
|
g_print ("Mode: %d\n", nm_device_802_11_wireless_get_mode (device));
|
||||||
|
g_print ("Bitrate: %d\n", nm_device_802_11_wireless_get_bitrate (device));
|
||||||
|
|
||||||
|
str = nm_device_802_11_wireless_get_hw_address (device);
|
||||||
|
g_print ("MAC: %s\n", str);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
g_print ("Networks:\n");
|
||||||
|
networks = nm_device_802_11_wireless_get_networks (device);
|
||||||
|
for (iter = networks; iter; iter = iter->next) {
|
||||||
|
NMAccessPoint *ap = NM_ACCESS_POINT (iter->data);
|
||||||
|
|
||||||
|
str = nm_access_point_get_essid (ap);
|
||||||
|
g_print ("\tEssid: %s\n", str);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
/* This is not provided by NM yet */
|
||||||
|
#if 0
|
||||||
|
str = nm_access_point_get_address (ap);
|
||||||
|
g_print ("\tAddress: %s\n", str);
|
||||||
|
g_free (str);
|
||||||
|
|
||||||
|
str = nm_access_point_get_hw_address (ap);
|
||||||
|
g_print ("\tMAC Address: %s\n", str);
|
||||||
|
g_free (str);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_print ("\tCapabilities: %d\n", nm_access_point_get_capabilities (ap));
|
||||||
|
g_print ("\tEncrypted: %d\n", nm_access_point_is_encrypted (ap));
|
||||||
|
g_print ("\tFrequency: %f\n", nm_access_point_get_frequency (ap));
|
||||||
|
|
||||||
|
g_print ("\tMode: %d\n", nm_access_point_get_mode (ap));
|
||||||
|
g_print ("\tRate: %d\n", nm_access_point_get_rate (ap));
|
||||||
|
g_print ("\tStrength: %d\n", nm_access_point_get_strength (ap));
|
||||||
|
|
||||||
|
g_print ("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
g_slist_foreach (networks, (GFunc) g_object_unref, NULL);
|
||||||
|
g_slist_free (networks);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
dump_wired (NMDevice8023Ethernet *device)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
g_print ("Speed: %d\n", nm_device_802_3_ethernet_get_speed (device));
|
||||||
|
|
||||||
|
str = nm_device_802_3_ethernet_get_hw_address (device);
|
||||||
|
g_print ("MAC: %s\n", str);
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dump_device (NMDevice *device)
|
dump_device (NMDevice *device)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
gboolean b;
|
|
||||||
guint32 u;
|
guint32 u;
|
||||||
NMDeviceState state;
|
NMDeviceState state;
|
||||||
|
|
||||||
@@ -60,24 +203,16 @@ dump_device (NMDevice *device)
|
|||||||
state = nm_device_get_state (device);
|
state = nm_device_get_state (device);
|
||||||
g_print ("State: %d\n", state);
|
g_print ("State: %d\n", state);
|
||||||
|
|
||||||
if (NM_IS_DEVICE_802_3_ETHERNET (device)) {
|
if (state == NM_DEVICE_STATE_ACTIVATED) {
|
||||||
int speed = nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (device));
|
NMIP4Config *cfg = nm_device_get_ip4_config (device);
|
||||||
g_print ("Speed: %d\n", speed);
|
dump_ip4_config (cfg);
|
||||||
} else if (NM_IS_DEVICE_802_11_WIRELESS (device)) {
|
g_object_unref (cfg);
|
||||||
GSList *iter;
|
|
||||||
GSList *networks = nm_device_802_11_wireless_get_networks (NM_DEVICE_802_11_WIRELESS (device));
|
|
||||||
|
|
||||||
g_print ("Networks:\n");
|
|
||||||
for (iter = networks; iter; iter = iter->next) {
|
|
||||||
NMAccessPoint *ap = NM_ACCESS_POINT (iter->data);
|
|
||||||
|
|
||||||
str = nm_access_point_get_essid (ap);
|
|
||||||
g_print ("\tEssid: %s\n", str);
|
|
||||||
g_free (str);
|
|
||||||
}
|
|
||||||
g_slist_foreach (networks, (GFunc) g_object_unref, NULL);
|
|
||||||
g_slist_free (networks);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (NM_IS_DEVICE_802_3_ETHERNET (device))
|
||||||
|
dump_wired (NM_DEVICE_802_3_ETHERNET (device));
|
||||||
|
else if (NM_IS_DEVICE_802_11_WIRELESS (device))
|
||||||
|
dump_wireless (NM_DEVICE_802_11_WIRELESS (device));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@@ -181,7 +316,7 @@ main (int argc, char *argv[])
|
|||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_wireless_enabled (client);
|
/* test_wireless_enabled (client); */
|
||||||
test_get_state (client);
|
test_get_state (client);
|
||||||
test_devices (client);
|
test_devices (client);
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "nm-access-point.h"
|
#include "nm-access-point.h"
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
#include "nm-access-point-bindings.h"
|
#include "nm-access-point-bindings.h"
|
||||||
|
|
||||||
@@ -43,11 +44,11 @@ nm_access_point_get_address (NMAccessPoint *ap)
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
guint32
|
||||||
nm_access_point_get_capabilities (NMAccessPoint *ap)
|
nm_access_point_get_capabilities (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
GValue value = {0,};
|
GValue value = {0,};
|
||||||
int caps = 0;
|
guint32 caps = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ nm_access_point_get_capabilities (NMAccessPoint *ap)
|
|||||||
NM_DBUS_INTERFACE_ACCESS_POINT,
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
||||||
"Capabilities",
|
"Capabilities",
|
||||||
&value))
|
&value))
|
||||||
caps = g_value_get_int (&value);
|
caps = g_value_get_uint (&value);
|
||||||
|
|
||||||
return caps;
|
return caps;
|
||||||
}
|
}
|
||||||
@@ -94,9 +95,22 @@ nm_access_point_get_essid (NMAccessPoint *ap)
|
|||||||
return essid;
|
return essid;
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
gdouble
|
||||||
nm_access_point_get_frequency (NMAccessPoint *ap)
|
nm_access_point_get_frequency (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
|
GValue value = {0,};
|
||||||
|
double freq = 0.0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), freq);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (ap),
|
||||||
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
||||||
|
"Frequency",
|
||||||
|
&value))
|
||||||
|
freq = g_value_get_double (&value);
|
||||||
|
|
||||||
|
return freq;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@@ -133,11 +147,11 @@ nm_access_point_get_mode (NMAccessPoint *ap)
|
|||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
guint32
|
||||||
nm_access_point_get_rate (NMAccessPoint *ap)
|
nm_access_point_get_rate (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
GValue value = {0,};
|
GValue value = {0,};
|
||||||
int rate = 0;
|
guint32 rate = 0;
|
||||||
|
|
||||||
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), 0);
|
||||||
|
|
||||||
@@ -145,7 +159,7 @@ nm_access_point_get_rate (NMAccessPoint *ap)
|
|||||||
NM_DBUS_INTERFACE_ACCESS_POINT,
|
NM_DBUS_INTERFACE_ACCESS_POINT,
|
||||||
"Rate",
|
"Rate",
|
||||||
&value))
|
&value))
|
||||||
rate = g_value_get_int (&value);
|
rate = g_value_get_uint (&value);
|
||||||
|
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
|
@@ -25,13 +25,13 @@ GType nm_access_point_get_type (void);
|
|||||||
NMAccessPoint *nm_access_point_new (DBusGConnection *connection, const char *path);
|
NMAccessPoint *nm_access_point_new (DBusGConnection *connection, const char *path);
|
||||||
|
|
||||||
char *nm_access_point_get_address (NMAccessPoint *ap);
|
char *nm_access_point_get_address (NMAccessPoint *ap);
|
||||||
int nm_access_point_get_capabilities (NMAccessPoint *ap);
|
guint32 nm_access_point_get_capabilities (NMAccessPoint *ap);
|
||||||
gboolean nm_access_point_is_encrypted (NMAccessPoint *ap);
|
gboolean nm_access_point_is_encrypted (NMAccessPoint *ap);
|
||||||
char *nm_access_point_get_essid (NMAccessPoint *ap);
|
char *nm_access_point_get_essid (NMAccessPoint *ap);
|
||||||
double nm_access_point_get_frequency (NMAccessPoint *ap);
|
gdouble nm_access_point_get_frequency (NMAccessPoint *ap);
|
||||||
char *nm_access_point_get_hw_address (NMAccessPoint *ap);
|
char *nm_access_point_get_hw_address (NMAccessPoint *ap);
|
||||||
int nm_access_point_get_mode (NMAccessPoint *ap);
|
int nm_access_point_get_mode (NMAccessPoint *ap);
|
||||||
int nm_access_point_get_rate (NMAccessPoint *ap);
|
guint32 nm_access_point_get_rate (NMAccessPoint *ap);
|
||||||
int nm_access_point_get_strength (NMAccessPoint *ap);
|
int nm_access_point_get_strength (NMAccessPoint *ap);
|
||||||
|
|
||||||
#endif /* NM_ACCESS_POINT_H */
|
#endif /* NM_ACCESS_POINT_H */
|
||||||
|
@@ -75,7 +75,7 @@ nm_client_new (void)
|
|||||||
|
|
||||||
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
|
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &err);
|
||||||
if (!connection) {
|
if (!connection) {
|
||||||
g_warning ("Couldn't connect to system bus: %d", err->message);
|
g_warning ("Couldn't connect to system bus: %s", err->message);
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "nm-device-802-11-wireless.h"
|
#include "nm-device-802-11-wireless.h"
|
||||||
#include "nm-device-private.h"
|
#include "nm-device-private.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
#include "nm-device-802-11-wireless-bindings.h"
|
#include "nm-device-802-11-wireless-bindings.h"
|
||||||
|
|
||||||
@@ -30,7 +31,7 @@ nm_device_802_11_wireless_new (DBusGConnection *connection, const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device)
|
nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device)
|
||||||
{
|
{
|
||||||
GValue value = {0,};
|
GValue value = {0,};
|
||||||
char *address = NULL;
|
char *address = NULL;
|
||||||
@@ -39,7 +40,7 @@ nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device)
|
|||||||
|
|
||||||
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
||||||
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
||||||
"Address",
|
"HwAddress",
|
||||||
&value))
|
&value))
|
||||||
address = g_strdup (g_value_get_string (&value));
|
address = g_strdup (g_value_get_string (&value));
|
||||||
|
|
||||||
@@ -56,13 +57,30 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device)
|
|||||||
|
|
||||||
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
||||||
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
||||||
"Node",
|
"Mode",
|
||||||
&value))
|
&value))
|
||||||
mode = g_value_get_int (&value);
|
mode = g_value_get_int (&value);
|
||||||
|
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device)
|
||||||
|
{
|
||||||
|
GValue value = {0,};
|
||||||
|
int bitrate = 0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE_802_11_WIRELESS (device), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
||||||
|
NM_DBUS_INTERFACE_DEVICE_WIRELESS,
|
||||||
|
"Bitrate",
|
||||||
|
&value))
|
||||||
|
bitrate = g_value_get_int (&value);
|
||||||
|
|
||||||
|
return bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
NMAccessPoint *
|
NMAccessPoint *
|
||||||
nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
|
nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device)
|
||||||
{
|
{
|
||||||
|
@@ -23,10 +23,10 @@ GType nm_device_802_11_wireless_get_type (void);
|
|||||||
|
|
||||||
NMDevice80211Wireless *nm_device_802_11_wireless_new (DBusGConnection *connection,
|
NMDevice80211Wireless *nm_device_802_11_wireless_new (DBusGConnection *connection,
|
||||||
const char *path);
|
const char *path);
|
||||||
int nm_device_802_11_wireless_get_speed (NMDevice80211Wireless *device);
|
|
||||||
char *nm_device_802_11_wireless_get_address (NMDevice80211Wireless *device);
|
|
||||||
|
|
||||||
|
char *nm_device_802_11_wireless_get_hw_address (NMDevice80211Wireless *device);
|
||||||
int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device);
|
int nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *device);
|
||||||
|
int nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *device);
|
||||||
NMAccessPoint *nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device);
|
NMAccessPoint *nm_device_802_11_wireless_get_active_network (NMDevice80211Wireless *device);
|
||||||
|
|
||||||
GSList *nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device);
|
GSList *nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "nm-device-802-3-ethernet.h"
|
#include "nm-device-802-3-ethernet.h"
|
||||||
#include "nm-device-private.h"
|
#include "nm-device-private.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
#include "nm-device-802-3-ethernet-bindings.h"
|
#include "nm-device-802-3-ethernet-bindings.h"
|
||||||
|
|
||||||
@@ -47,7 +48,7 @@ nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device)
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device)
|
nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device)
|
||||||
{
|
{
|
||||||
char *address = NULL;
|
char *address = NULL;
|
||||||
GValue value = {0,};
|
GValue value = {0,};
|
||||||
@@ -56,7 +57,7 @@ nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device)
|
|||||||
|
|
||||||
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
||||||
NM_DBUS_INTERFACE_DEVICE_WIRED,
|
NM_DBUS_INTERFACE_DEVICE_WIRED,
|
||||||
"Address",
|
"HwAddress",
|
||||||
&value))
|
&value))
|
||||||
address = g_strdup (g_value_get_string (&value));
|
address = g_strdup (g_value_get_string (&value));
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ GType nm_device_802_3_ethernet_get_type (void);
|
|||||||
NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *connection,
|
NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *connection,
|
||||||
const char *path);
|
const char *path);
|
||||||
int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
|
int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device);
|
||||||
char *nm_device_802_3_ethernet_get_address (NMDevice8023Ethernet *device);
|
char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device);
|
||||||
void nm_device_802_3_ethernet_activate (NMDevice8023Ethernet *device,
|
void nm_device_802_3_ethernet_activate (NMDevice8023Ethernet *device,
|
||||||
gboolean user_requested);
|
gboolean user_requested);
|
||||||
|
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
#include "nm-device-private.h"
|
#include "nm-device-private.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
#include "nm-device-bindings.h"
|
#include "nm-device-bindings.h"
|
||||||
|
|
||||||
@@ -164,6 +165,30 @@ nm_device_get_ip4_address (NMDevice *device)
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NMIP4Config *
|
||||||
|
nm_device_get_ip4_config (NMDevice *device)
|
||||||
|
{
|
||||||
|
NMIP4Config *config = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_DEVICE (device), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (device),
|
||||||
|
NM_DBUS_INTERFACE_DEVICE,
|
||||||
|
"Ip4Config",
|
||||||
|
&value)) {
|
||||||
|
DBusGConnection *connection = NULL;
|
||||||
|
|
||||||
|
g_assert (G_VALUE_TYPE (&value) == DBUS_TYPE_G_OBJECT_PATH);
|
||||||
|
|
||||||
|
g_object_get (device, "connection", &connection, NULL);
|
||||||
|
|
||||||
|
config = nm_ip4_config_new (connection, (const char *) g_value_get_boxed (&value));
|
||||||
|
}
|
||||||
|
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
NMDeviceState
|
NMDeviceState
|
||||||
nm_device_get_state (NMDevice *device)
|
nm_device_get_state (NMDevice *device)
|
||||||
{
|
{
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <dbus/dbus-glib.h>
|
#include <dbus/dbus-glib.h>
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
|
#include "nm-ip4-config.h"
|
||||||
|
|
||||||
#define NM_TYPE_DEVICE (nm_device_get_type ())
|
#define NM_TYPE_DEVICE (nm_device_get_type ())
|
||||||
#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
|
#define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice))
|
||||||
@@ -34,6 +35,10 @@ char *nm_device_get_iface (NMDevice *device);
|
|||||||
char *nm_device_get_udi (NMDevice *device);
|
char *nm_device_get_udi (NMDevice *device);
|
||||||
char *nm_device_get_driver (NMDevice *device);
|
char *nm_device_get_driver (NMDevice *device);
|
||||||
guint32 nm_device_get_ip4_address (NMDevice *device);
|
guint32 nm_device_get_ip4_address (NMDevice *device);
|
||||||
|
NMIP4Config *nm_device_get_ip4_config (NMDevice *device);
|
||||||
NMDeviceState nm_device_get_state (NMDevice *device);
|
NMDeviceState nm_device_get_state (NMDevice *device);
|
||||||
|
|
||||||
|
NMDeviceType nm_device_type_for_path (DBusGConnection *connection,
|
||||||
|
const char *path);
|
||||||
|
|
||||||
#endif /* NM_DEVICE_H */
|
#endif /* NM_DEVICE_H */
|
||||||
|
183
libnm-glib/nm-ip4-config.c
Normal file
183
libnm-glib/nm-ip4-config.c
Normal file
@@ -0,0 +1,183 @@
|
|||||||
|
#include "nm-ip4-config.h"
|
||||||
|
#include "nm-device-private.h"
|
||||||
|
#include "nm-utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, DBUS_TYPE_G_PROXY)
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ip4_config_init (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
#define INTERFACE NM_DBUS_INTERFACE ".IP4Config"
|
||||||
|
|
||||||
|
NMIP4Config *
|
||||||
|
nm_ip4_config_new (DBusGConnection *connection, const char *object_path)
|
||||||
|
{
|
||||||
|
return (NMIP4Config *) g_object_new (NM_TYPE_IP4_CONFIG,
|
||||||
|
"name", NM_DBUS_SERVICE,
|
||||||
|
"path", object_path,
|
||||||
|
"interface", INTERFACE,
|
||||||
|
"connection", connection,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
guint32
|
||||||
|
nm_ip4_config_get_address (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
guint32 address = 0;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Address",
|
||||||
|
&value))
|
||||||
|
address = g_value_get_uint (&value);
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint32
|
||||||
|
nm_ip4_config_get_gateway (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
guint32 gateway = 0;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Gateway",
|
||||||
|
&value))
|
||||||
|
gateway = g_value_get_uint (&value);
|
||||||
|
|
||||||
|
return gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint32
|
||||||
|
nm_ip4_config_get_netmask (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
guint32 netmask = 0;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Netmask",
|
||||||
|
&value))
|
||||||
|
netmask = g_value_get_uint (&value);
|
||||||
|
|
||||||
|
return netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
guint32
|
||||||
|
nm_ip4_config_get_broadcast (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
guint32 broadcast = 0;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Broadcast",
|
||||||
|
&value))
|
||||||
|
broadcast = g_value_get_uint (&value);
|
||||||
|
|
||||||
|
return broadcast;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
nm_ip4_config_get_hostname (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
char *address = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Hostname",
|
||||||
|
&value))
|
||||||
|
address = g_strdup (g_value_get_string (&value));
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
GArray *
|
||||||
|
nm_ip4_config_get_nameservers (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
GArray *array = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Nameservers",
|
||||||
|
&value))
|
||||||
|
array = (GArray *) g_value_get_boxed (&value);
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
nm_ip4_config_get_domains (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
char **array = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"Domains",
|
||||||
|
&value))
|
||||||
|
array = (char **) g_value_get_boxed (&value);
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
nm_ip4_config_get_nis_domain (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
char *address = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"NisDomain",
|
||||||
|
&value))
|
||||||
|
address = g_strdup (g_value_get_string (&value));
|
||||||
|
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
GArray *
|
||||||
|
nm_ip4_config_get_nis_servers (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
GArray *array = NULL;
|
||||||
|
GValue value = {0,};
|
||||||
|
|
||||||
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
|
if (nm_dbus_get_property (DBUS_G_PROXY (config),
|
||||||
|
INTERFACE,
|
||||||
|
"NisServers",
|
||||||
|
&value))
|
||||||
|
array = (GArray *) g_value_get_boxed (&value);
|
||||||
|
|
||||||
|
return array;
|
||||||
|
}
|
40
libnm-glib/nm-ip4-config.h
Normal file
40
libnm-glib/nm-ip4-config.h
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#ifndef NM_IP4_CONFIG_H
|
||||||
|
#define NM_IP4_CONFIG_H
|
||||||
|
|
||||||
|
#include <glib/gtypes.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
#include <dbus/dbus-glib.h>
|
||||||
|
#include "NetworkManager.h"
|
||||||
|
|
||||||
|
#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
|
||||||
|
#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
|
||||||
|
#define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
|
||||||
|
#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
|
||||||
|
#define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_IP4_CONFIG))
|
||||||
|
#define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DBusGProxy parent;
|
||||||
|
} NMIP4Config;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DBusGProxyClass parent;
|
||||||
|
} NMIP4ConfigClass;
|
||||||
|
|
||||||
|
GType nm_ip4_config_get_type (void);
|
||||||
|
|
||||||
|
NMIP4Config *nm_ip4_config_new (DBusGConnection *connection,
|
||||||
|
const char *object_path);
|
||||||
|
|
||||||
|
guint32 nm_ip4_config_get_address (NMIP4Config *config);
|
||||||
|
guint32 nm_ip4_config_get_gateway (NMIP4Config *config);
|
||||||
|
guint32 nm_ip4_config_get_netmask (NMIP4Config *config);
|
||||||
|
guint32 nm_ip4_config_get_broadcast (NMIP4Config *config);
|
||||||
|
char *nm_ip4_config_get_hostname (NMIP4Config *config);
|
||||||
|
GArray *nm_ip4_config_get_nameservers (NMIP4Config *config);
|
||||||
|
char **nm_ip4_config_get_domains (NMIP4Config *config);
|
||||||
|
char *nm_ip4_config_get_nis_domain (NMIP4Config *config);
|
||||||
|
GArray *nm_ip4_config_get_nis_servers (NMIP4Config *config);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* NM_IP4_CONFIG_H */
|
@@ -103,6 +103,9 @@ nm-device-802-3-ethernet-glue.h: $(top_srcdir)/introspection/nm-device-802-3-eth
|
|||||||
nm-device-802-11-wireless-glue.h: $(top_srcdir)/introspection/nm-device-802-11-wireless.xml
|
nm-device-802-11-wireless-glue.h: $(top_srcdir)/introspection/nm-device-802-11-wireless.xml
|
||||||
dbus-binding-tool --prefix=nm_device_802_11_wireless --mode=glib-server --output=nm-device-802-11-wireless-glue.h $(top_srcdir)/introspection/nm-device-802-11-wireless.xml
|
dbus-binding-tool --prefix=nm_device_802_11_wireless --mode=glib-server --output=nm-device-802-11-wireless-glue.h $(top_srcdir)/introspection/nm-device-802-11-wireless.xml
|
||||||
|
|
||||||
|
nm-ip4-config-glue.h: $(top_srcdir)/introspection/nm-ip4-config.xml
|
||||||
|
dbus-binding-tool --prefix=nm_ip4_config --mode=glib-server --output=nm-ip4-config-glue.h $(top_srcdir)/introspection/nm-ip4-config.xml
|
||||||
|
|
||||||
|
|
||||||
built_sources = \
|
built_sources = \
|
||||||
nm-marshal.h \
|
nm-marshal.h \
|
||||||
@@ -112,6 +115,7 @@ built_sources = \
|
|||||||
nm-device-interface-glue.h \
|
nm-device-interface-glue.h \
|
||||||
nm-device-802-3-ethernet-glue.h \
|
nm-device-802-3-ethernet-glue.h \
|
||||||
nm-device-802-11-wireless-glue.h \
|
nm-device-802-11-wireless-glue.h \
|
||||||
|
nm-ip4-config-glue.h \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
$(NetworkManager_OBJECTS): $(built_sources)
|
$(NetworkManager_OBJECTS): $(built_sources)
|
||||||
|
@@ -154,7 +154,7 @@ nm_monitor_setup (NMData *data)
|
|||||||
* Create data structure used in callbacks from libhal.
|
* Create data structure used in callbacks from libhal.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
static NMData *nm_data_new (gboolean enable_test_devices)
|
static NMData *nm_data_new (void)
|
||||||
{
|
{
|
||||||
NMData * data;
|
NMData * data;
|
||||||
guint id;
|
guint id;
|
||||||
@@ -195,7 +195,6 @@ static NMData *nm_data_new (gboolean enable_test_devices)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->enable_test_devices = enable_test_devices;
|
|
||||||
data->wireless_enabled = TRUE;
|
data->wireless_enabled = TRUE;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -317,7 +316,6 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
GOptionContext *opt_ctx = NULL;
|
GOptionContext *opt_ctx = NULL;
|
||||||
gboolean become_daemon = FALSE;
|
gboolean become_daemon = FALSE;
|
||||||
gboolean enable_test_devices = FALSE;
|
|
||||||
gboolean show_usage = FALSE;
|
gboolean show_usage = FALSE;
|
||||||
char * pidfile = NULL;
|
char * pidfile = NULL;
|
||||||
char * user_pidfile = NULL;
|
char * user_pidfile = NULL;
|
||||||
@@ -331,8 +329,7 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
GOptionEntry options[] = {
|
GOptionEntry options[] = {
|
||||||
{"no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL},
|
{"no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL},
|
||||||
{"pid-file", 0, 0, G_OPTION_ARG_STRING, &user_pidfile, "Specify the location of a PID file", NULL},
|
{"pid-file", 0, 0, G_OPTION_ARG_FILENAME, &user_pidfile, "Specify the location of a PID file", "filename"},
|
||||||
{"enable-test-devices", 0, 0, G_OPTION_ARG_NONE, &enable_test_devices, "Allow dummy devices to be created via DBUS methods [DEBUG]", NULL},
|
|
||||||
{"info", 0, 0, G_OPTION_ARG_NONE, &show_usage, "Show application information", NULL},
|
{"info", 0, 0, G_OPTION_ARG_NONE, &show_usage, "Show application information", NULL},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
@@ -395,7 +392,7 @@ main (int argc, char *argv[])
|
|||||||
nm_system_init();
|
nm_system_init();
|
||||||
|
|
||||||
/* Initialize our instance data */
|
/* Initialize our instance data */
|
||||||
nm_data = nm_data_new (enable_test_devices);
|
nm_data = nm_data_new ();
|
||||||
if (!nm_data) {
|
if (!nm_data) {
|
||||||
nm_error ("Failed to initialize.");
|
nm_error ("Failed to initialize.");
|
||||||
goto pidfile;
|
goto pidfile;
|
||||||
|
@@ -23,16 +23,29 @@
|
|||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-ap-security.h"
|
#include "nm-ap-security.h"
|
||||||
|
#include "nm-dbus-manager.h"
|
||||||
#include <wireless.h>
|
#include <wireless.h>
|
||||||
|
#include "wpa.h"
|
||||||
|
|
||||||
|
#include "nm-access-point-glue.h"
|
||||||
|
|
||||||
|
/* This is a controlled list. Want to add to it? Stop. Ask first. */
|
||||||
|
static const char * default_essid_list[] =
|
||||||
|
{
|
||||||
|
"linksys",
|
||||||
|
"linksys-a",
|
||||||
|
"linksys-g",
|
||||||
|
"default",
|
||||||
|
"belkin54g",
|
||||||
|
"NETGEAR",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encapsulates Access Point information
|
* Encapsulates Access Point information
|
||||||
*/
|
*/
|
||||||
struct NMAccessPoint
|
typedef struct
|
||||||
{
|
{
|
||||||
guint refcount;
|
|
||||||
|
|
||||||
/* Scanned or cached values */
|
/* Scanned or cached values */
|
||||||
char * essid;
|
char * essid;
|
||||||
char * orig_essid;
|
char * orig_essid;
|
||||||
@@ -60,37 +73,253 @@ struct NMAccessPoint
|
|||||||
NMAPSecurity * security;
|
NMAPSecurity * security;
|
||||||
GTimeVal timestamp;
|
GTimeVal timestamp;
|
||||||
GSList * user_addresses;
|
GSList * user_addresses;
|
||||||
|
} NMAccessPointPrivate;
|
||||||
|
|
||||||
|
#define NM_AP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP, NMAccessPointPrivate))
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (NMAccessPoint, nm_ap, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
enum {
|
||||||
|
STRENGTH_CHANGED,
|
||||||
|
|
||||||
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This is a controlled list. Want to add to it? Stop. Ask first. */
|
static guint signals[LAST_SIGNAL] = { 0 };
|
||||||
static const char * default_essid_list[] =
|
|
||||||
{
|
enum {
|
||||||
"linksys",
|
PROP_0,
|
||||||
"linksys-a",
|
PROP_ADDRESS,
|
||||||
"linksys-g",
|
PROP_CAPABILITIES,
|
||||||
"default",
|
PROP_ENCRYPTED,
|
||||||
"belkin54g",
|
PROP_ESSID,
|
||||||
"NETGEAR",
|
PROP_FREQUENCY,
|
||||||
NULL
|
PROP_HWADDRESS,
|
||||||
|
PROP_MODE,
|
||||||
|
PROP_RATE,
|
||||||
|
PROP_STRENGTH,
|
||||||
|
|
||||||
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ap_init (NMAccessPoint *ap)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finalize (GObject *object)
|
||||||
|
{
|
||||||
|
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_free (priv->essid);
|
||||||
|
g_free (priv->orig_essid);
|
||||||
|
g_slist_foreach (priv->user_addresses, (GFunc)g_free, NULL);
|
||||||
|
g_slist_free (priv->user_addresses);
|
||||||
|
|
||||||
|
if (priv->security)
|
||||||
|
g_object_unref (G_OBJECT (priv->security));
|
||||||
|
|
||||||
|
G_OBJECT_CLASS (nm_ap_parent_class)->finalize (object);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_property (GObject *object, guint prop_id,
|
||||||
|
const GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
||||||
|
const char *essid;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_CAPABILITIES:
|
||||||
|
priv->capabilities = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
|
case PROP_ESSID:
|
||||||
|
essid = g_value_get_string (value);
|
||||||
|
|
||||||
|
if (priv->essid) {
|
||||||
|
g_free (priv->essid);
|
||||||
|
g_free (priv->orig_essid);
|
||||||
|
priv->essid = NULL;
|
||||||
|
priv->orig_essid = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (essid) {
|
||||||
|
priv->orig_essid = g_strdup (essid);
|
||||||
|
priv->essid = nm_utils_essid_to_utf8 (essid);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case PROP_FREQUENCY:
|
||||||
|
priv->freq = g_value_get_double (value);
|
||||||
|
break;
|
||||||
|
case PROP_MODE:
|
||||||
|
mode = g_value_get_int (value);
|
||||||
|
|
||||||
|
if (mode == IW_MODE_ADHOC || mode == IW_MODE_INFRA)
|
||||||
|
priv->mode = mode;
|
||||||
|
else
|
||||||
|
g_warning ("Invalid mode");
|
||||||
|
break;
|
||||||
|
case PROP_RATE:
|
||||||
|
priv->rate = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
|
case PROP_STRENGTH:
|
||||||
|
nm_ap_set_strength (NM_AP (object), g_value_get_int (value));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object, guint prop_id,
|
||||||
|
GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_CAPABILITIES:
|
||||||
|
g_value_set_uint (value, priv->capabilities);
|
||||||
|
break;
|
||||||
|
case PROP_ENCRYPTED:
|
||||||
|
g_value_set_boolean (value, priv->capabilities & NM_802_11_CAP_PROTO_NONE);
|
||||||
|
break;
|
||||||
|
case PROP_ESSID:
|
||||||
|
g_value_set_string (value, priv->essid);
|
||||||
|
break;
|
||||||
|
case PROP_FREQUENCY:
|
||||||
|
g_value_set_double (value, priv->freq);
|
||||||
|
break;
|
||||||
|
case PROP_MODE:
|
||||||
|
g_value_set_int (value, priv->mode);
|
||||||
|
break;
|
||||||
|
case PROP_RATE:
|
||||||
|
g_value_set_uint (value, priv->rate);
|
||||||
|
break;
|
||||||
|
case PROP_STRENGTH:
|
||||||
|
g_value_set_int (value, priv->strength);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ap_class_init (NMAccessPointClass *ap_class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (ap_class);
|
||||||
|
|
||||||
|
g_type_class_add_private (ap_class, sizeof (NMAccessPointPrivate));
|
||||||
|
|
||||||
|
/* virtual methods */
|
||||||
|
object_class->set_property = set_property;
|
||||||
|
object_class->get_property = get_property;
|
||||||
|
object_class->finalize = finalize;
|
||||||
|
|
||||||
|
/* properties */
|
||||||
|
|
||||||
|
/* FIXME: address */
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_CAPABILITIES,
|
||||||
|
g_param_spec_uint (NM_AP_CAPABILITIES,
|
||||||
|
"Capabilities",
|
||||||
|
"Capabilities",
|
||||||
|
NM_802_11_CAP_NONE, NM_802_11_CAP_CIPHER_CCMP, NM_802_11_CAP_PROTO_NONE,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_ENCRYPTED,
|
||||||
|
g_param_spec_boolean (NM_AP_ENCRYPTED,
|
||||||
|
"Encrypted",
|
||||||
|
"Is encrypted",
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_ESSID,
|
||||||
|
g_param_spec_string (NM_AP_ESSID,
|
||||||
|
"ESSID",
|
||||||
|
"ESSID",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_FREQUENCY,
|
||||||
|
g_param_spec_double (NM_AP_FREQUENCY,
|
||||||
|
"Frequency",
|
||||||
|
"Frequency",
|
||||||
|
0.0, 10000.0, 0.0, /* FIXME */
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/* FIXME: HWAddress */
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_MODE,
|
||||||
|
g_param_spec_int (NM_AP_MODE,
|
||||||
|
"Mode",
|
||||||
|
"Mode",
|
||||||
|
IW_MODE_ADHOC, IW_MODE_INFRA, IW_MODE_INFRA,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_RATE,
|
||||||
|
g_param_spec_uint (NM_AP_RATE,
|
||||||
|
"Rate",
|
||||||
|
"Rate",
|
||||||
|
0, G_MAXUINT16, 0,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_STRENGTH,
|
||||||
|
g_param_spec_int (NM_AP_STRENGTH,
|
||||||
|
"Strength",
|
||||||
|
"Strength",
|
||||||
|
G_MININT8, G_MAXINT8, 0,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/* Signals */
|
||||||
|
signals[STRENGTH_CHANGED] =
|
||||||
|
g_signal_new ("strength_changed",
|
||||||
|
G_OBJECT_CLASS_TYPE (object_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (NMAccessPointClass, strength_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__CHAR,
|
||||||
|
G_TYPE_NONE, 1,
|
||||||
|
G_TYPE_CHAR);
|
||||||
|
|
||||||
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (ap_class),
|
||||||
|
&dbus_glib_nm_access_point_object_info);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_ap_new
|
* nm_ap_new
|
||||||
*
|
*
|
||||||
* Create a new, blank user access point info structure
|
* Create a new, blank user access point info structure
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NMAccessPoint * nm_ap_new (void)
|
NMAccessPoint *nm_ap_new (void)
|
||||||
{
|
{
|
||||||
NMAccessPoint *ap;
|
NMDBusManager *manager;
|
||||||
|
GObject *object;
|
||||||
ap = g_slice_new0 (NMAccessPoint);
|
char *path;
|
||||||
ap->mode = IW_MODE_INFRA;
|
static guint32 counter = 0;
|
||||||
ap->refcount = 1;
|
|
||||||
ap->capabilities = NM_802_11_CAP_PROTO_NONE;
|
|
||||||
ap->broadcast = TRUE;
|
|
||||||
|
|
||||||
return ap;
|
object = g_object_new (NM_TYPE_AP, NULL);
|
||||||
|
|
||||||
|
manager = nm_dbus_manager_get ();
|
||||||
|
|
||||||
|
path = g_strdup_printf (NM_DBUS_PATH_ACCESS_POINT "/%d", counter++);
|
||||||
|
dbus_g_connection_register_g_object (nm_dbus_manager_get_connection (manager),
|
||||||
|
path, object);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
|
return (NMAccessPoint *) object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -100,34 +329,40 @@ NMAccessPoint * nm_ap_new (void)
|
|||||||
* Create a new user access point info structure, duplicating an existing one
|
* Create a new user access point info structure, duplicating an existing one
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
|
NMAccessPoint *
|
||||||
|
nm_ap_new_from_ap (NMAccessPoint *src_ap)
|
||||||
{
|
{
|
||||||
NMAccessPoint * new_ap;
|
NMAccessPoint * new_ap;
|
||||||
|
NMAccessPointPrivate *src_priv;
|
||||||
|
NMAccessPointPrivate *new_priv;
|
||||||
|
|
||||||
g_return_val_if_fail (src_ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (src_ap), NULL);
|
||||||
|
|
||||||
if (!(new_ap = nm_ap_new()))
|
if (!(new_ap = nm_ap_new ()))
|
||||||
{
|
{
|
||||||
nm_warning ("nm_ap_new_from_uap() could not allocate a new user access point structure. Not enough memory?");
|
nm_warning ("nm_ap_new_from_uap() could not allocate a new user access point structure. Not enough memory?");
|
||||||
return (NULL);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_ap->essid && (strlen (src_ap->essid) > 0))
|
src_priv = NM_AP_GET_PRIVATE (src_ap);
|
||||||
|
new_priv = NM_AP_GET_PRIVATE (new_ap);
|
||||||
|
|
||||||
|
if (src_priv->essid && (strlen (src_priv->essid) > 0))
|
||||||
{
|
{
|
||||||
new_ap->essid = g_strdup (src_ap->essid);
|
new_priv->essid = g_strdup (src_priv->essid);
|
||||||
new_ap->orig_essid = g_strdup (src_ap->orig_essid);
|
new_priv->orig_essid = g_strdup (src_priv->orig_essid);
|
||||||
}
|
}
|
||||||
memcpy (&new_ap->address, &src_ap->address, sizeof (struct ether_addr));
|
memcpy (&new_priv->address, &src_priv->address, sizeof (struct ether_addr));
|
||||||
new_ap->mode = src_ap->mode;
|
new_priv->mode = src_priv->mode;
|
||||||
new_ap->strength = src_ap->strength;
|
new_priv->strength = src_priv->strength;
|
||||||
new_ap->freq = src_ap->freq;
|
new_priv->freq = src_priv->freq;
|
||||||
new_ap->rate = src_ap->rate;
|
new_priv->rate = src_priv->rate;
|
||||||
new_ap->capabilities = src_ap->capabilities;
|
new_priv->capabilities = src_priv->capabilities;
|
||||||
new_ap->artificial = src_ap->artificial;
|
new_priv->artificial = src_priv->artificial;
|
||||||
new_ap->broadcast = src_ap->broadcast;
|
new_priv->broadcast = src_priv->broadcast;
|
||||||
|
|
||||||
if (src_ap->security)
|
if (src_priv->security)
|
||||||
new_ap->security = nm_ap_security_new_copy (src_ap->security);
|
new_priv->security = nm_ap_security_new_copy (src_priv->security);
|
||||||
|
|
||||||
return new_ap;
|
return new_ap;
|
||||||
}
|
}
|
||||||
@@ -137,7 +372,6 @@ NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
|
|||||||
#define IEEE80211_CAP_IBSS 0x0002
|
#define IEEE80211_CAP_IBSS 0x0002
|
||||||
#define IEEE80211_CAP_PRIVACY 0x0010
|
#define IEEE80211_CAP_PRIVACY 0x0010
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
foreach_property_cb (gpointer key, gpointer value, gpointer user_data)
|
||||||
{
|
{
|
||||||
@@ -232,62 +466,34 @@ nm_ap_new_from_properties (GHashTable *properties)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* AP refcounting functions
|
|
||||||
*/
|
|
||||||
void nm_ap_ref (NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
g_return_if_fail (ap != NULL);
|
|
||||||
|
|
||||||
ap->refcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nm_ap_unref (NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
g_return_if_fail (ap != NULL);
|
|
||||||
g_return_if_fail (ap->refcount > 0);
|
|
||||||
|
|
||||||
ap->refcount--;
|
|
||||||
if (ap->refcount == 0)
|
|
||||||
{
|
|
||||||
g_free (ap->essid);
|
|
||||||
g_free (ap->orig_essid);
|
|
||||||
g_slist_foreach (ap->user_addresses, (GFunc)g_free, NULL);
|
|
||||||
g_slist_free (ap->user_addresses);
|
|
||||||
|
|
||||||
if (ap->security)
|
|
||||||
g_object_unref (G_OBJECT (ap->security));
|
|
||||||
|
|
||||||
memset (ap, 0, sizeof (NMAccessPoint));
|
|
||||||
g_slice_free (NMAccessPoint, ap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get/set functions for timestamp
|
* Get/set functions for timestamp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const GTimeVal *nm_ap_get_timestamp (const NMAccessPoint *ap)
|
const GTimeVal *nm_ap_get_timestamp (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, 0);
|
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
||||||
|
|
||||||
return (&ap->timestamp);
|
return (&NM_AP_GET_PRIVATE (ap)->timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec)
|
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
NMAccessPointPrivate *priv;
|
||||||
|
|
||||||
ap->timestamp.tv_sec = sec;
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
ap->timestamp.tv_usec = usec;
|
|
||||||
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
|
priv->timestamp.tv_sec = sec;
|
||||||
|
priv->timestamp.tv_usec = usec;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp)
|
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->timestamp = *timestamp;
|
NM_AP_GET_PRIVATE (ap)->timestamp = *timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -296,51 +502,43 @@ void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *times
|
|||||||
*/
|
*/
|
||||||
const char * nm_ap_get_essid (const NMAccessPoint *ap)
|
const char * nm_ap_get_essid (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
return ap->essid;
|
return NM_AP_GET_PRIVATE (ap)->essid;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * nm_ap_get_orig_essid (const NMAccessPoint *ap)
|
const char * nm_ap_get_orig_essid (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
return ap->orig_essid;
|
return NM_AP_GET_PRIVATE (ap)->orig_essid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_essid (NMAccessPoint *ap, const char * essid)
|
void nm_ap_set_essid (NMAccessPoint *ap, const char * essid)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
if (ap->essid)
|
g_object_set (ap, NM_AP_ESSID, essid, NULL);
|
||||||
{
|
|
||||||
g_free (ap->essid);
|
|
||||||
g_free (ap->orig_essid);
|
|
||||||
ap->essid = NULL;
|
|
||||||
ap->orig_essid = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (essid)
|
|
||||||
{
|
|
||||||
ap->orig_essid = g_strdup (essid);
|
|
||||||
ap->essid = nm_utils_essid_to_utf8 (essid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
guint32 nm_ap_get_capabilities (NMAccessPoint *ap)
|
guint32 nm_ap_get_capabilities (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, NM_802_11_CAP_NONE);
|
guint32 caps;
|
||||||
|
|
||||||
return ap->capabilities;
|
g_return_val_if_fail (NM_IS_AP (ap), NM_802_11_CAP_NONE);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_CAPABILITIES, &caps, NULL);
|
||||||
|
|
||||||
|
return caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities)
|
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->capabilities = capabilities;
|
g_object_set (ap, NM_AP_CAPABILITIES, capabilities, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -348,11 +546,15 @@ void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities)
|
|||||||
* Accessor function for encrypted flag
|
* Accessor function for encrypted flag
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap)
|
gboolean nm_ap_get_encrypted (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
gboolean encrypted;
|
||||||
|
|
||||||
return (!(ap->capabilities & NM_802_11_CAP_PROTO_NONE));
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_ENCRYPTED, &encrypted, NULL);
|
||||||
|
|
||||||
|
return encrypted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -362,23 +564,27 @@ gboolean nm_ap_get_encrypted (const NMAccessPoint *ap)
|
|||||||
*/
|
*/
|
||||||
NMAPSecurity * nm_ap_get_security (const NMAccessPoint *ap)
|
NMAPSecurity * nm_ap_get_security (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
return ap->security;
|
return NM_AP_GET_PRIVATE (ap)->security;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security)
|
void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
NMAccessPointPrivate *priv;
|
||||||
|
|
||||||
if (ap->security)
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
|
if (priv->security)
|
||||||
{
|
{
|
||||||
g_object_unref (G_OBJECT (ap->security));
|
g_object_unref (G_OBJECT (priv->security));
|
||||||
ap->security = NULL;
|
priv->security = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (security)
|
if (security)
|
||||||
ap->security = nm_ap_security_new_copy (security);
|
priv->security = nm_ap_security_new_copy (security);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -388,17 +594,17 @@ void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security)
|
|||||||
*/
|
*/
|
||||||
const struct ether_addr * nm_ap_get_address (const NMAccessPoint *ap)
|
const struct ether_addr * nm_ap_get_address (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
return &ap->address;
|
return &NM_AP_GET_PRIVATE (ap)->address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr * addr)
|
void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr * addr)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
g_return_if_fail (addr != NULL);
|
g_return_if_fail (addr != NULL);
|
||||||
|
|
||||||
memcpy (&ap->address, addr, sizeof (struct ether_addr));
|
memcpy (&NM_AP_GET_PRIVATE (ap)->address, addr, sizeof (struct ether_addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -406,19 +612,22 @@ void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr * addr)
|
|||||||
* Get/set functions for mode (ie Ad-Hoc, Infrastructure, etc)
|
* Get/set functions for mode (ie Ad-Hoc, Infrastructure, etc)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int nm_ap_get_mode (const NMAccessPoint *ap)
|
int nm_ap_get_mode (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, -1);
|
int mode;
|
||||||
|
|
||||||
return ap->mode;
|
g_return_val_if_fail (NM_IS_AP (ap), -1);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_MODE, &mode, NULL);
|
||||||
|
|
||||||
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_mode (NMAccessPoint *ap, const int mode)
|
void nm_ap_set_mode (NMAccessPoint *ap, const int mode)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
g_return_if_fail ((mode == IW_MODE_ADHOC) || (mode == IW_MODE_INFRA));
|
|
||||||
|
|
||||||
ap->mode = mode;
|
g_object_set (ap, NM_AP_MODE, mode, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -426,18 +635,29 @@ void nm_ap_set_mode (NMAccessPoint *ap, const int mode)
|
|||||||
* Get/set functions for strength
|
* Get/set functions for strength
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
gint8 nm_ap_get_strength (const NMAccessPoint *ap)
|
gint8 nm_ap_get_strength (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, 0);
|
gint8 strength;
|
||||||
|
|
||||||
return (ap->strength);
|
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_STRENGTH, &strength, NULL);
|
||||||
|
|
||||||
|
return strength;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
|
void nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
NMAccessPointPrivate *priv;
|
||||||
|
|
||||||
ap->strength = strength;
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
|
if (priv->strength != strength) {
|
||||||
|
priv->strength = strength;
|
||||||
|
g_signal_emit (ap, signals[STRENGTH_CHANGED], 0, strength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -445,18 +665,22 @@ void nm_ap_set_strength (NMAccessPoint *ap, const gint8 strength)
|
|||||||
* Get/set functions for frequency
|
* Get/set functions for frequency
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
double nm_ap_get_freq (const NMAccessPoint *ap)
|
double nm_ap_get_freq (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, 0);
|
double freq;
|
||||||
|
|
||||||
return (ap->freq);
|
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_FREQUENCY, &freq, NULL);
|
||||||
|
|
||||||
|
return freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_freq (NMAccessPoint *ap, const double freq)
|
void nm_ap_set_freq (NMAccessPoint *ap, const double freq)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->freq = freq;
|
g_object_set (ap, NM_AP_FREQUENCY, freq, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -464,18 +688,22 @@ void nm_ap_set_freq (NMAccessPoint *ap, const double freq)
|
|||||||
* Get/set functions for rate
|
* Get/set functions for rate
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
guint16 nm_ap_get_rate (const NMAccessPoint *ap)
|
guint16 nm_ap_get_rate (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, 0);
|
guint16 rate;
|
||||||
|
|
||||||
return (ap->rate);
|
g_return_val_if_fail (NM_IS_AP (ap), 0);
|
||||||
|
|
||||||
|
g_object_get (ap, NM_AP_RATE, &rate, NULL);
|
||||||
|
|
||||||
|
return rate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate)
|
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->rate = rate;
|
g_object_set (ap, NM_AP_RATE, rate, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -487,16 +715,16 @@ void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate)
|
|||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_invalid (const NMAccessPoint *ap)
|
gboolean nm_ap_get_invalid (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, TRUE);
|
g_return_val_if_fail (NM_IS_AP (ap), TRUE);
|
||||||
|
|
||||||
return (ap->invalid);
|
return NM_AP_GET_PRIVATE (ap)->invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
|
void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->invalid = invalid;
|
NM_AP_GET_PRIVATE (ap)->invalid = invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -507,16 +735,16 @@ void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid)
|
|||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_fallback (const NMAccessPoint *ap)
|
gboolean nm_ap_get_fallback (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
|
|
||||||
return (ap->fallback);
|
return NM_AP_GET_PRIVATE (ap)->fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback)
|
void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->fallback = fallback;
|
NM_AP_GET_PRIVATE (ap)->fallback = fallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -528,16 +756,16 @@ void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback)
|
|||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_artificial (const NMAccessPoint *ap)
|
gboolean nm_ap_get_artificial (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
|
|
||||||
return (ap->artificial);
|
return NM_AP_GET_PRIVATE (ap)->artificial;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial)
|
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->artificial = artificial;
|
NM_AP_GET_PRIVATE (ap)->artificial = artificial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -545,17 +773,19 @@ void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial)
|
|||||||
* Get/Set functions to indicate whether an access point is broadcasting
|
* Get/Set functions to indicate whether an access point is broadcasting
|
||||||
* (hidden). This is a superset of artificial.
|
* (hidden). This is a superset of artificial.
|
||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_broadcast (const NMAccessPoint *ap)
|
gboolean nm_ap_get_broadcast (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, TRUE);
|
g_return_val_if_fail (NM_IS_AP (ap), TRUE);
|
||||||
return ap->broadcast;
|
|
||||||
|
return NM_AP_GET_PRIVATE (ap)->broadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast)
|
void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
ap->broadcast = broadcast;
|
|
||||||
|
NM_AP_GET_PRIVATE (ap)->broadcast = broadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -566,16 +796,16 @@ void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast)
|
|||||||
*/
|
*/
|
||||||
const GTimeVal *nm_ap_get_last_seen (const NMAccessPoint *ap)
|
const GTimeVal *nm_ap_get_last_seen (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
|
|
||||||
return (&ap->last_seen);
|
return &NM_AP_GET_PRIVATE (ap)->last_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_last_seen (NMAccessPoint *ap, const GTimeVal *last_seen)
|
void nm_ap_set_last_seen (NMAccessPoint *ap, const GTimeVal *last_seen)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->last_seen = *last_seen;
|
NM_AP_GET_PRIVATE (ap)->last_seen = *last_seen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -588,16 +818,16 @@ void nm_ap_set_last_seen (NMAccessPoint *ap, const GTimeVal *last_seen)
|
|||||||
*/
|
*/
|
||||||
gboolean nm_ap_get_user_created (const NMAccessPoint *ap)
|
gboolean nm_ap_get_user_created (const NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
|
|
||||||
return (ap->user_created);
|
return NM_AP_GET_PRIVATE (ap)->user_created;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created)
|
void nm_ap_set_user_created (NMAccessPoint *ap, gboolean user_created)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
ap->user_created = user_created;
|
NM_AP_GET_PRIVATE (ap)->user_created = user_created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -615,27 +845,30 @@ GSList *nm_ap_get_user_addresses (const NMAccessPoint *ap)
|
|||||||
GSList *new = NULL;
|
GSList *new = NULL;
|
||||||
GSList *elt = NULL;
|
GSList *elt = NULL;
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
g_return_val_if_fail (NM_IS_AP (ap), NULL);
|
||||||
|
|
||||||
for (elt = ap->user_addresses; elt; elt = g_slist_next (elt))
|
for (elt = NM_AP_GET_PRIVATE (ap)->user_addresses; elt; elt = g_slist_next (elt))
|
||||||
{
|
{
|
||||||
if (elt->data)
|
if (elt->data)
|
||||||
new = g_slist_append (new, g_strdup (elt->data));
|
new = g_slist_append (new, g_strdup (elt->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a _deep__copy_ of the address list */
|
/* Return a _deep__copy_ of the address list */
|
||||||
return (new);
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list)
|
void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list)
|
||||||
{
|
{
|
||||||
|
NMAccessPointPrivate *priv;
|
||||||
GSList *elt = NULL;
|
GSList *elt = NULL;
|
||||||
GSList *new = NULL;
|
GSList *new = NULL;
|
||||||
|
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
/* Free existing list */
|
/* Free existing list */
|
||||||
g_slist_foreach (ap->user_addresses, (GFunc) g_free, NULL);
|
g_slist_foreach (priv->user_addresses, (GFunc) g_free, NULL);
|
||||||
|
|
||||||
/* Copy new list and set as our own */
|
/* Copy new list and set as our own */
|
||||||
for (elt = list; elt; elt = g_slist_next (elt))
|
for (elt = list; elt; elt = g_slist_next (elt))
|
||||||
@@ -644,7 +877,7 @@ void nm_ap_set_user_addresses (NMAccessPoint *ap, GSList *list)
|
|||||||
new = g_slist_append (new, g_strdup (elt->data));
|
new = g_slist_append (new, g_strdup (elt->data));
|
||||||
}
|
}
|
||||||
|
|
||||||
ap->user_addresses = new;
|
priv->user_addresses = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -653,8 +886,8 @@ gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap)
|
|||||||
const char **default_essid = default_essid_list;
|
const char **default_essid = default_essid_list;
|
||||||
const char *this_essid;
|
const char *this_essid;
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_AP (ap), FALSE);
|
||||||
this_essid = ap->essid;
|
this_essid = NM_AP_GET_PRIVATE (ap)->essid;
|
||||||
|
|
||||||
while (*default_essid)
|
while (*default_essid)
|
||||||
{
|
{
|
||||||
@@ -717,7 +950,7 @@ void nm_ap_add_capabilities_from_security (NMAccessPoint *ap, NMAPSecurity *secu
|
|||||||
guint32 caps;
|
guint32 caps;
|
||||||
int cipher;
|
int cipher;
|
||||||
|
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
g_return_if_fail (security != NULL);
|
g_return_if_fail (security != NULL);
|
||||||
|
|
||||||
cipher = nm_ap_security_get_we_cipher (security);
|
cipher = nm_ap_security_get_we_cipher (security);
|
||||||
@@ -731,7 +964,7 @@ void nm_ap_add_capabilities_from_ie (NMAccessPoint *ap, const guint8 *wpa_ie, gu
|
|||||||
wpa_ie_data * cap_data;
|
wpa_ie_data * cap_data;
|
||||||
guint32 caps;
|
guint32 caps;
|
||||||
|
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
|
|
||||||
if (!(cap_data = wpa_parse_wpa_ie (wpa_ie, length)))
|
if (!(cap_data = wpa_parse_wpa_ie (wpa_ie, length)))
|
||||||
return;
|
return;
|
||||||
@@ -768,8 +1001,12 @@ void nm_ap_add_capabilities_from_ie (NMAccessPoint *ap, const guint8 *wpa_ie, gu
|
|||||||
|
|
||||||
void nm_ap_add_capabilities_for_wep (NMAccessPoint *ap)
|
void nm_ap_add_capabilities_for_wep (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
NMAccessPointPrivate *priv;
|
||||||
|
|
||||||
ap->capabilities |= (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40 | NM_802_11_CAP_CIPHER_WEP104);
|
g_return_if_fail (NM_IS_AP (ap));
|
||||||
ap->capabilities &= ~NM_802_11_CAP_PROTO_NONE;
|
|
||||||
|
priv = NM_AP_GET_PRIVATE (ap);
|
||||||
|
|
||||||
|
priv->capabilities |= (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40 | NM_802_11_CAP_CIPHER_WEP104);
|
||||||
|
priv->capabilities &= ~NM_802_11_CAP_PROTO_NONE;
|
||||||
}
|
}
|
||||||
|
@@ -19,25 +19,50 @@
|
|||||||
* (C) Copyright 2004 Red Hat, Inc.
|
* (C) Copyright 2004 Red Hat, Inc.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NETWORK_MANAGER_AP_H
|
#ifndef NM_ACCESS_POINT_H
|
||||||
#define NETWORK_MANAGER_AP_H
|
#define NM_ACCESS_POINT_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib/gtypes.h>
|
||||||
|
#include <glib-object.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "wpa.h"
|
|
||||||
#include "nm-ap-security.h"
|
#include "nm-ap-security.h"
|
||||||
|
|
||||||
typedef struct NMAccessPoint NMAccessPoint;
|
#define NM_TYPE_AP (nm_ap_get_type ())
|
||||||
|
#define NM_AP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AP, NMAccessPoint))
|
||||||
|
#define NM_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AP, NMAccessPointClass))
|
||||||
|
#define NM_IS_AP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AP))
|
||||||
|
#define NM_IS_AP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_AP))
|
||||||
|
#define NM_AP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AP, NMAccessPointClass))
|
||||||
|
|
||||||
|
#define NM_AP_ADDRESS "address"
|
||||||
|
#define NM_AP_CAPABILITIES "capabilities"
|
||||||
|
#define NM_AP_ENCRYPTED "encrypted"
|
||||||
|
#define NM_AP_ESSID "essid"
|
||||||
|
#define NM_AP_FREQUENCY "frequency"
|
||||||
|
#define NM_AP_HWADDRESS "hwaddress"
|
||||||
|
#define NM_AP_MODE "mode"
|
||||||
|
#define NM_AP_RATE "rate"
|
||||||
|
#define NM_AP_STRENGTH "strength"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObject parent;
|
||||||
|
} NMAccessPoint;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObjectClass parent;
|
||||||
|
|
||||||
|
/* Signals */
|
||||||
|
void (*strength_changed) (NMAccessPoint *ap, gint8 strength);
|
||||||
|
} NMAccessPointClass;
|
||||||
|
|
||||||
|
GType nm_ap_get_type (void);
|
||||||
|
|
||||||
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);
|
||||||
NMAccessPoint * nm_ap_new_from_properties (GHashTable *properties);
|
NMAccessPoint * nm_ap_new_from_properties (GHashTable *properties);
|
||||||
|
|
||||||
void nm_ap_unref (NMAccessPoint *ap);
|
|
||||||
void nm_ap_ref (NMAccessPoint *ap);
|
|
||||||
|
|
||||||
const GTimeVal * nm_ap_get_timestamp (const NMAccessPoint *ap);
|
const GTimeVal * nm_ap_get_timestamp (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec);
|
void nm_ap_set_timestamp (NMAccessPoint *ap, glong sec, glong usec);
|
||||||
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
void nm_ap_set_timestamp_via_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
||||||
@@ -50,7 +75,7 @@ const char * nm_ap_get_orig_essid (const NMAccessPoint *ap);
|
|||||||
guint32 nm_ap_get_capabilities (NMAccessPoint *ap);
|
guint32 nm_ap_get_capabilities (NMAccessPoint *ap);
|
||||||
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities);
|
void nm_ap_set_capabilities (NMAccessPoint *ap, guint32 capabilities);
|
||||||
|
|
||||||
gboolean nm_ap_get_encrypted (const NMAccessPoint *ap);
|
gboolean nm_ap_get_encrypted (NMAccessPoint *ap);
|
||||||
|
|
||||||
NMAPSecurity * nm_ap_get_security (const NMAccessPoint *ap);
|
NMAPSecurity * nm_ap_get_security (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security);
|
void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security);
|
||||||
@@ -58,16 +83,16 @@ void nm_ap_set_security (NMAccessPoint *ap, NMAPSecurity *security);
|
|||||||
const struct ether_addr * nm_ap_get_address (const NMAccessPoint *ap);
|
const struct ether_addr * nm_ap_get_address (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr *addr);
|
void nm_ap_set_address (NMAccessPoint *ap, const struct ether_addr *addr);
|
||||||
|
|
||||||
int nm_ap_get_mode (const NMAccessPoint *ap);
|
int nm_ap_get_mode (NMAccessPoint *ap);
|
||||||
void nm_ap_set_mode (NMAccessPoint *ap, const int mode);
|
void nm_ap_set_mode (NMAccessPoint *ap, const int mode);
|
||||||
|
|
||||||
gint8 nm_ap_get_strength (const NMAccessPoint *ap);
|
gint8 nm_ap_get_strength (NMAccessPoint *ap);
|
||||||
void nm_ap_set_strength (NMAccessPoint *ap, gint8 strength);
|
void nm_ap_set_strength (NMAccessPoint *ap, gint8 strength);
|
||||||
|
|
||||||
double nm_ap_get_freq (const NMAccessPoint *ap);
|
double nm_ap_get_freq (NMAccessPoint *ap);
|
||||||
void nm_ap_set_freq (NMAccessPoint *ap, double freq);
|
void nm_ap_set_freq (NMAccessPoint *ap, double freq);
|
||||||
|
|
||||||
guint16 nm_ap_get_rate (const NMAccessPoint *ap);
|
guint16 nm_ap_get_rate (NMAccessPoint *ap);
|
||||||
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate);
|
void nm_ap_set_rate (NMAccessPoint *ap, guint16 rate);
|
||||||
|
|
||||||
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
|
gboolean nm_ap_get_invalid (const NMAccessPoint *ap);
|
||||||
@@ -79,7 +104,7 @@ void nm_ap_set_fallback (NMAccessPoint *ap, gboolean fallback);
|
|||||||
gboolean nm_ap_get_artificial (const NMAccessPoint *ap);
|
gboolean nm_ap_get_artificial (const NMAccessPoint *ap);
|
||||||
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
|
void nm_ap_set_artificial (NMAccessPoint *ap, gboolean artificial);
|
||||||
|
|
||||||
gboolean nm_ap_get_broadcast (const NMAccessPoint *ap);
|
gboolean nm_ap_get_broadcast (NMAccessPoint *ap);
|
||||||
void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast);
|
void nm_ap_set_broadcast (NMAccessPoint *ap, gboolean broadcast);
|
||||||
|
|
||||||
const GTimeVal * nm_ap_get_last_seen (const NMAccessPoint *ap);
|
const GTimeVal * nm_ap_get_last_seen (const NMAccessPoint *ap);
|
||||||
@@ -102,4 +127,4 @@ void nm_ap_add_capabilities_for_wep (NMAccessPoint *ap);
|
|||||||
*/
|
*/
|
||||||
gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap);
|
gboolean nm_ap_has_manufacturer_default_essid (NMAccessPoint *ap);
|
||||||
|
|
||||||
#endif
|
#endif /* NM_ACCESS_POINT_H */
|
||||||
|
@@ -68,19 +68,6 @@ void nm_ap_list_ref (NMAccessPointList *list)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* nm_ap_list_element_free
|
|
||||||
*
|
|
||||||
* Frees each member of an access point list before the list is
|
|
||||||
* disposed of.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
static void nm_ap_list_element_free (void *element, void *user_data)
|
|
||||||
{
|
|
||||||
nm_ap_unref (element);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nm_ap_list_unref
|
* nm_ap_list_unref
|
||||||
*
|
*
|
||||||
@@ -95,7 +82,7 @@ void nm_ap_list_unref (NMAccessPointList *list)
|
|||||||
|
|
||||||
list->refcount--;
|
list->refcount--;
|
||||||
if (list->refcount <= 0) {
|
if (list->refcount <= 0) {
|
||||||
g_slist_foreach (list->ap_list, nm_ap_list_element_free, NULL);
|
g_slist_foreach (list->ap_list, (GFunc) g_object_unref, NULL);
|
||||||
g_slist_free (list->ap_list);
|
g_slist_free (list->ap_list);
|
||||||
g_slice_free (NMAccessPointList, list);
|
g_slice_free (NMAccessPointList, list);
|
||||||
}
|
}
|
||||||
@@ -140,8 +127,7 @@ void nm_ap_list_append_ap (NMAccessPointList *list, NMAccessPoint *ap)
|
|||||||
g_return_if_fail (list != NULL);
|
g_return_if_fail (list != NULL);
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
nm_ap_ref (ap);
|
list->ap_list = g_slist_append (list->ap_list, g_object_ref (ap));
|
||||||
list->ap_list = g_slist_append (list->ap_list, ap);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -163,7 +149,7 @@ void nm_ap_list_remove_ap (NMAccessPointList *list, NMAccessPoint *ap)
|
|||||||
|
|
||||||
if (list_ap == ap) {
|
if (list_ap == ap) {
|
||||||
list->ap_list = g_slist_remove_link (list->ap_list, elt);
|
list->ap_list = g_slist_remove_link (list->ap_list, elt);
|
||||||
nm_ap_unref (list_ap);
|
g_object_unref (list_ap);
|
||||||
g_slist_free (elt);
|
g_slist_free (elt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -189,7 +175,7 @@ void nm_ap_list_remove_ap_by_essid (NMAccessPointList *list, const char *network
|
|||||||
|
|
||||||
if (nm_null_safe_strcmp (nm_ap_get_essid (list_ap), network) == 0) {
|
if (nm_null_safe_strcmp (nm_ap_get_essid (list_ap), network) == 0) {
|
||||||
list->ap_list = g_slist_remove_link (list->ap_list, elt);
|
list->ap_list = g_slist_remove_link (list->ap_list, elt);
|
||||||
nm_ap_unref (list_ap);
|
g_object_unref (list_ap);
|
||||||
g_slist_free (elt);
|
g_slist_free (elt);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -259,7 +259,7 @@ nm_dbus_signal_device_status_change (gpointer user_data)
|
|||||||
const char *essid = nm_ap_get_essid (cb_data->ap);
|
const char *essid = nm_ap_get_essid (cb_data->ap);
|
||||||
if (essid)
|
if (essid)
|
||||||
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &essid, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_STRING, &essid, DBUS_TYPE_INVALID);
|
||||||
nm_ap_unref (cb_data->ap);
|
g_object_unref (cb_data->ap);
|
||||||
} else {
|
} else {
|
||||||
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID);
|
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path, DBUS_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
@@ -290,10 +290,9 @@ void nm_dbus_schedule_device_status_change_signal (NMData *data, NMDevice *dev,
|
|||||||
g_object_ref (G_OBJECT (dev));
|
g_object_ref (G_OBJECT (dev));
|
||||||
cb_data->data = data;
|
cb_data->data = data;
|
||||||
cb_data->dev = dev;
|
cb_data->dev = dev;
|
||||||
if (ap) {
|
if (ap)
|
||||||
nm_ap_ref (ap);
|
cb_data->ap = g_object_ref (ap);
|
||||||
cb_data->ap = ap;
|
|
||||||
}
|
|
||||||
cb_data->status = status;
|
cb_data->status = status;
|
||||||
|
|
||||||
id = g_idle_add (nm_dbus_signal_device_status_change, cb_data);
|
id = g_idle_add (nm_dbus_signal_device_status_change, cb_data);
|
||||||
|
@@ -49,7 +49,6 @@ typedef struct NMData
|
|||||||
guint32 nmi_sig_handler_id;
|
guint32 nmi_sig_handler_id;
|
||||||
|
|
||||||
GMainLoop * main_loop;
|
GMainLoop * main_loop;
|
||||||
gboolean enable_test_devices;
|
|
||||||
|
|
||||||
guint dev_change_check_idle_id;
|
guint dev_change_check_idle_id;
|
||||||
|
|
||||||
|
@@ -425,7 +425,7 @@ nm_policy_device_change_check (gpointer user_data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ap)
|
if (ap)
|
||||||
nm_ap_unref (ap);
|
g_object_unref (ap);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@@ -629,7 +629,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -327,7 +327,7 @@ out:
|
|||||||
{
|
{
|
||||||
sys_data->use_dhcp = TRUE;
|
sys_data->use_dhcp = TRUE;
|
||||||
/* Clear out the config */
|
/* Clear out the config */
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
sys_data->config = NULL;
|
sys_data->config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -350,7 +350,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -576,7 +576,7 @@ out:
|
|||||||
{
|
{
|
||||||
sys_data->use_dhcp = TRUE;
|
sys_data->use_dhcp = TRUE;
|
||||||
/* Clear out the config */
|
/* Clear out the config */
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
sys_data->config = NULL;
|
sys_data->config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -425,7 +425,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
g_return_if_fail(sys_data != NULL);
|
g_return_if_fail(sys_data != NULL);
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
|
|
||||||
g_free (sys_data);
|
g_free (sys_data);
|
||||||
}
|
}
|
||||||
|
@@ -356,7 +356,7 @@ static NMIP4Config *netdevice_file_get_ip4_config (GKeyFile *file)
|
|||||||
|
|
||||||
if (ipaddress == NULL)
|
if (ipaddress == NULL)
|
||||||
{
|
{
|
||||||
nm_ip4_config_unref (ip4_config);
|
g_object_unref (ip4_config);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -463,7 +463,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -461,7 +461,7 @@ out:
|
|||||||
{
|
{
|
||||||
sys_data->use_dhcp = TRUE;
|
sys_data->use_dhcp = TRUE;
|
||||||
/* Clear out the config */
|
/* Clear out the config */
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
sys_data->config = NULL;
|
sys_data->config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -409,7 +409,8 @@ found:
|
|||||||
|
|
||||||
cipher = cipher_wpa_psk_passphrase_new ();
|
cipher = cipher_wpa_psk_passphrase_new ();
|
||||||
nm_ap_set_capabilities (ap, NM_802_11_CAP_PROTO_WPA);
|
nm_ap_set_capabilities (ap, NM_802_11_CAP_PROTO_WPA);
|
||||||
security = nm_ap_security_wpa_psk_new_from_ap (ap, NM_AUTH_TYPE_WPA_PSK_AUTO);
|
security = nm_ap_security_wpa_psk_new (NM_802_11_CAP_PROTO_WPA,
|
||||||
|
NM_AUTH_TYPE_WPA_PSK_AUTO);
|
||||||
hash = ieee_802_11_cipher_hash (cipher, buf, key);
|
hash = ieee_802_11_cipher_hash (cipher, buf, key);
|
||||||
if (hash)
|
if (hash)
|
||||||
{
|
{
|
||||||
@@ -447,7 +448,7 @@ found:
|
|||||||
cipher = cipher_wep64_hex_new ();
|
cipher = cipher_wep64_hex_new ();
|
||||||
real_key = key;
|
real_key = key;
|
||||||
}
|
}
|
||||||
security = nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP40);
|
security = nm_ap_security_wep_new (IW_AUTH_CIPHER_WEP40);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -471,7 +472,7 @@ found:
|
|||||||
real_key = g_strjoinv (NULL, keyv);
|
real_key = g_strjoinv (NULL, keyv);
|
||||||
g_strfreev (keyv);
|
g_strfreev (keyv);
|
||||||
}
|
}
|
||||||
security = nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP104);
|
security = nm_ap_security_wep_new (IW_AUTH_CIPHER_WEP104);
|
||||||
}
|
}
|
||||||
hash = ieee_802_11_cipher_hash (cipher, buf, real_key);
|
hash = ieee_802_11_cipher_hash (cipher, buf, real_key);
|
||||||
if (hash)
|
if (hash)
|
||||||
@@ -489,7 +490,7 @@ found:
|
|||||||
{
|
{
|
||||||
NMAPSecurity * security;
|
NMAPSecurity * security;
|
||||||
|
|
||||||
security = nm_ap_security_new (IW_AUTH_CIPHER_NONE);
|
security = nm_ap_security_new (NM_DEVICE_CAP_NONE, FALSE);
|
||||||
nm_ap_set_security (ap, security);
|
nm_ap_set_security (ap, security);
|
||||||
g_object_unref (G_OBJECT (security));
|
g_object_unref (G_OBJECT (security));
|
||||||
}
|
}
|
||||||
@@ -506,7 +507,7 @@ found:
|
|||||||
/* New AP, just add it to the list */
|
/* New AP, just add it to the list */
|
||||||
nm_ap_list_append_ap (app_data->allowed_ap_list, ap);
|
nm_ap_list_append_ap (app_data->allowed_ap_list, ap);
|
||||||
}
|
}
|
||||||
nm_ap_unref (ap);
|
g_object_unref (ap);
|
||||||
|
|
||||||
nm_debug ("Adding '%s' to the list of trusted networks", buf);
|
nm_debug ("Adding '%s' to the list of trusted networks", buf);
|
||||||
|
|
||||||
@@ -608,7 +609,7 @@ out:
|
|||||||
nm_debug ("error, enable dhcp");
|
nm_debug ("error, enable dhcp");
|
||||||
sys_data->use_dhcp = TRUE;
|
sys_data->use_dhcp = TRUE;
|
||||||
/* Clear out the config */
|
/* Clear out the config */
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
sys_data->config = NULL;
|
sys_data->config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -665,7 +666,7 @@ void nm_system_device_free_system_config (NMDevice *dev, void *system_config_dat
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (sys_data->config)
|
if (sys_data->config)
|
||||||
nm_ip4_config_unref (sys_data->config);
|
g_object_unref (sys_data->config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -622,8 +622,7 @@ nm_named_manager_add_ip4_config (NMNamedManager *mgr, NMIP4Config *config)
|
|||||||
add_all_ip4_configs_to_named (mgr);
|
add_all_ip4_configs_to_named (mgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
nm_ip4_config_ref (config);
|
mgr->priv->configs = g_slist_append (mgr->priv->configs, g_object_ref (config));
|
||||||
mgr->priv->configs = g_slist_append (mgr->priv->configs, config);
|
|
||||||
|
|
||||||
/* Activate the zone config */
|
/* Activate the zone config */
|
||||||
if (mgr->priv->use_named)
|
if (mgr->priv->use_named)
|
||||||
@@ -678,7 +677,7 @@ nm_named_manager_remove_ip4_config (NMNamedManager *mgr, NMIP4Config *config)
|
|||||||
remove_ip4_config_from_named (mgr, config);
|
remove_ip4_config_from_named (mgr, config);
|
||||||
|
|
||||||
mgr->priv->configs = g_slist_remove (mgr->priv->configs, config);
|
mgr->priv->configs = g_slist_remove (mgr->priv->configs, config);
|
||||||
nm_ip4_config_unref (config);
|
g_object_unref (config);
|
||||||
|
|
||||||
/* Clear out and reload configs since we may need a new
|
/* Clear out and reload configs since we may need a new
|
||||||
* default zone if the one we are removing was the old
|
* default zone if the one we are removing was the old
|
||||||
@@ -738,7 +737,7 @@ nm_named_manager_finalize (GObject *object)
|
|||||||
|
|
||||||
g_return_if_fail (mgr->priv != NULL);
|
g_return_if_fail (mgr->priv != NULL);
|
||||||
|
|
||||||
g_slist_foreach (mgr->priv->configs, (GFunc) nm_ip4_config_unref, NULL);
|
g_slist_foreach (mgr->priv->configs, (GFunc) g_object_unref, NULL);
|
||||||
g_slist_free (mgr->priv->configs);
|
g_slist_free (mgr->priv->configs);
|
||||||
|
|
||||||
g_object_unref (mgr->priv->dbus_mgr);
|
g_object_unref (mgr->priv->dbus_mgr);
|
||||||
|
@@ -61,11 +61,7 @@ NMActRequest * nm_act_request_new (NMData *data, NMDevice *dev, NMAccessPoint *a
|
|||||||
|
|
||||||
g_object_ref (G_OBJECT (dev));
|
g_object_ref (G_OBJECT (dev));
|
||||||
req->dev = dev;
|
req->dev = dev;
|
||||||
|
req->ap = ap ? g_object_ref (ap) : NULL;
|
||||||
if (ap)
|
|
||||||
nm_ap_ref (ap);
|
|
||||||
req->ap = ap;
|
|
||||||
|
|
||||||
req->user_requested = user_requested;
|
req->user_requested = user_requested;
|
||||||
|
|
||||||
return req;
|
return req;
|
||||||
@@ -87,7 +83,7 @@ void nm_act_request_unref (NMActRequest *req)
|
|||||||
if (req->refcount <= 0) {
|
if (req->refcount <= 0) {
|
||||||
g_object_unref (G_OBJECT (req->dev));
|
g_object_unref (G_OBJECT (req->dev));
|
||||||
if (req->ap)
|
if (req->ap)
|
||||||
nm_ap_unref (req->ap);
|
g_object_unref (req->ap);
|
||||||
|
|
||||||
memset (req, 0, sizeof (NMActRequest));
|
memset (req, 0, sizeof (NMActRequest));
|
||||||
g_free (req);
|
g_free (req);
|
||||||
@@ -139,14 +135,12 @@ void nm_act_request_set_ip4_config (NMActRequest *req, NMIP4Config *ip4_config)
|
|||||||
|
|
||||||
if (req->ip4_config)
|
if (req->ip4_config)
|
||||||
{
|
{
|
||||||
nm_ip4_config_unref (req->ip4_config);
|
g_object_unref (req->ip4_config);
|
||||||
req->ip4_config = NULL;
|
req->ip4_config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip4_config)
|
if (ip4_config)
|
||||||
{
|
req->ip4_config = g_object_ref (ip4_config);
|
||||||
nm_ip4_config_ref (ip4_config);
|
|
||||||
req->ip4_config = ip4_config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NMActStage nm_act_request_get_stage (NMActRequest *req)
|
NMActStage nm_act_request_get_stage (NMActRequest *req)
|
||||||
|
@@ -71,11 +71,9 @@ out:
|
|||||||
|
|
||||||
|
|
||||||
NMAPSecurityLEAP *
|
NMAPSecurityLEAP *
|
||||||
nm_ap_security_leap_new_from_ap (NMAccessPoint *ap)
|
nm_ap_security_leap_new (void)
|
||||||
{
|
{
|
||||||
NMAPSecurityLEAP * security = NULL;
|
NMAPSecurityLEAP *security;
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
|
||||||
|
|
||||||
security = g_object_new (NM_TYPE_AP_SECURITY_LEAP, NULL);
|
security = g_object_new (NM_TYPE_AP_SECURITY_LEAP, NULL);
|
||||||
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_LEAP);
|
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_LEAP);
|
||||||
|
@@ -54,8 +54,6 @@ struct _NMAPSecurityLEAPClass
|
|||||||
GType nm_ap_security_leap_get_type (void);
|
GType nm_ap_security_leap_get_type (void);
|
||||||
|
|
||||||
NMAPSecurityLEAP * nm_ap_security_leap_new_deserialize (DBusMessageIter *iter);
|
NMAPSecurityLEAP * nm_ap_security_leap_new_deserialize (DBusMessageIter *iter);
|
||||||
|
NMAPSecurityLEAP * nm_ap_security_leap_new (void);
|
||||||
struct NMAccessPoint;
|
|
||||||
NMAPSecurityLEAP * nm_ap_security_leap_new_from_ap (struct NMAccessPoint *ap);
|
|
||||||
|
|
||||||
#endif /* NM_AP_SECURITY_LEAP_H */
|
#endif /* NM_AP_SECURITY_LEAP_H */
|
||||||
|
@@ -83,11 +83,10 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMAPSecurityWEP *
|
NMAPSecurityWEP *
|
||||||
nm_ap_security_wep_new_from_ap (NMAccessPoint *ap, int we_cipher)
|
nm_ap_security_wep_new (int we_cipher)
|
||||||
{
|
{
|
||||||
NMAPSecurityWEP * security = NULL;
|
NMAPSecurityWEP *security;
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
|
||||||
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_WEP40) || (we_cipher == IW_AUTH_CIPHER_WEP104), NULL);
|
g_return_val_if_fail ((we_cipher == IW_AUTH_CIPHER_WEP40) || (we_cipher == IW_AUTH_CIPHER_WEP104), NULL);
|
||||||
|
|
||||||
security = g_object_new (NM_TYPE_AP_SECURITY_WEP, NULL);
|
security = g_object_new (NM_TYPE_AP_SECURITY_WEP, NULL);
|
||||||
|
@@ -54,8 +54,6 @@ struct _NMAPSecurityWEPClass
|
|||||||
GType nm_ap_security_wep_get_type (void);
|
GType nm_ap_security_wep_get_type (void);
|
||||||
|
|
||||||
NMAPSecurityWEP * nm_ap_security_wep_new_deserialize (DBusMessageIter *iter, int we_cipher);
|
NMAPSecurityWEP * nm_ap_security_wep_new_deserialize (DBusMessageIter *iter, int we_cipher);
|
||||||
|
NMAPSecurityWEP * nm_ap_security_wep_new (int we_cipher);
|
||||||
struct NMAccessPoint;
|
|
||||||
NMAPSecurityWEP * nm_ap_security_wep_new_from_ap (struct NMAccessPoint *ap, int we_cipher);
|
|
||||||
|
|
||||||
#endif /* NM_AP_SECURITY_WEP_H */
|
#endif /* NM_AP_SECURITY_WEP_H */
|
||||||
|
@@ -100,24 +100,17 @@ out:
|
|||||||
|
|
||||||
|
|
||||||
NMAPSecurityWPA_EAP *
|
NMAPSecurityWPA_EAP *
|
||||||
nm_ap_security_wpa_eap_new_from_ap (NMAccessPoint *ap)
|
nm_ap_security_wpa_eap_new (guint32 capabilities)
|
||||||
{
|
{
|
||||||
NMAPSecurityWPA_EAP * security = NULL;
|
NMAPSecurityWPA_EAP *security;
|
||||||
guint32 caps;
|
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
|
||||||
|
|
||||||
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_EAP, NULL);
|
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_EAP, NULL);
|
||||||
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_WPA_EAP);
|
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_WPA_EAP);
|
||||||
|
|
||||||
caps = nm_ap_get_capabilities (ap);
|
if (capabilities & NM_802_11_CAP_PROTO_WPA2) {
|
||||||
if (caps & NM_802_11_CAP_PROTO_WPA2)
|
|
||||||
{
|
|
||||||
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA2;
|
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA2;
|
||||||
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA2 Enterprise"));
|
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA2 Enterprise"));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
|
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
|
||||||
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA Enterprise"));
|
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA Enterprise"));
|
||||||
}
|
}
|
||||||
|
@@ -55,8 +55,6 @@ struct _NMAPSecurityWPA_EAPClass
|
|||||||
GType nm_ap_security_wpa_eap_get_type (void);
|
GType nm_ap_security_wpa_eap_get_type (void);
|
||||||
|
|
||||||
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new_deserialize (DBusMessageIter *iter);
|
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new_deserialize (DBusMessageIter *iter);
|
||||||
|
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new (guint32 capabilities);
|
||||||
struct NMAccessPoint;
|
|
||||||
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new_from_ap (struct NMAccessPoint *ap);
|
|
||||||
|
|
||||||
#endif /* NM_AP_SECURITY_WPA_EAP_H */
|
#endif /* NM_AP_SECURITY_WPA_EAP_H */
|
||||||
|
@@ -95,21 +95,18 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
NMAPSecurityWPA_PSK *
|
NMAPSecurityWPA_PSK *
|
||||||
nm_ap_security_wpa_psk_new_from_ap (NMAccessPoint *ap, int we_cipher)
|
nm_ap_security_wpa_psk_new (guint32 capabilities, int we_cipher)
|
||||||
{
|
{
|
||||||
NMAPSecurityWPA_PSK * security = NULL;
|
NMAPSecurityWPA_PSK *security;
|
||||||
guint32 caps;
|
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
|
||||||
g_return_val_if_fail (we_cipher == NM_AUTH_TYPE_WPA_PSK_AUTO || we_cipher == IW_AUTH_CIPHER_TKIP || (we_cipher == IW_AUTH_CIPHER_CCMP), NULL);
|
g_return_val_if_fail (we_cipher == NM_AUTH_TYPE_WPA_PSK_AUTO || we_cipher == IW_AUTH_CIPHER_TKIP || (we_cipher == IW_AUTH_CIPHER_CCMP), NULL);
|
||||||
|
|
||||||
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_PSK, NULL);
|
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_PSK, NULL);
|
||||||
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), we_cipher);
|
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), we_cipher);
|
||||||
|
|
||||||
caps = nm_ap_get_capabilities (ap);
|
if (capabilities & NM_802_11_CAP_PROTO_WPA2)
|
||||||
if (caps & NM_802_11_CAP_PROTO_WPA2)
|
|
||||||
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA2;
|
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA2;
|
||||||
else if (caps & NM_802_11_CAP_PROTO_WPA)
|
else if (capabilities & NM_802_11_CAP_PROTO_WPA)
|
||||||
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
|
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
|
||||||
security->priv->key_mgt = IW_AUTH_KEY_MGMT_PSK;
|
security->priv->key_mgt = IW_AUTH_KEY_MGMT_PSK;
|
||||||
|
|
||||||
|
@@ -54,8 +54,6 @@ struct _NMAPSecurityWPA_PSKClass
|
|||||||
GType nm_ap_security_wpa_psk_get_type (void);
|
GType nm_ap_security_wpa_psk_get_type (void);
|
||||||
|
|
||||||
NMAPSecurityWPA_PSK * nm_ap_security_wpa_psk_new_deserialize (DBusMessageIter *iter, int we_cipher);
|
NMAPSecurityWPA_PSK * nm_ap_security_wpa_psk_new_deserialize (DBusMessageIter *iter, int we_cipher);
|
||||||
|
NMAPSecurityWPA_PSK * nm_ap_security_wpa_psk_new (guint32 capabilities, int we_cipher);
|
||||||
struct NMAccessPoint;
|
|
||||||
NMAPSecurityWPA_PSK * nm_ap_security_wpa_psk_new_from_ap (struct NMAccessPoint *ap, int we_cipher);
|
|
||||||
|
|
||||||
#endif /* NM_AP_SECURITY_WPA_PSK_H */
|
#endif /* NM_AP_SECURITY_WPA_PSK_H */
|
||||||
|
@@ -45,14 +45,40 @@ struct _NMAPSecurityPrivate
|
|||||||
gboolean dispose_has_run;
|
gboolean dispose_has_run;
|
||||||
};
|
};
|
||||||
|
|
||||||
NMAPSecurity *
|
#define WPA2_CCMP_PSK (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_CIPHER_CCMP | NM_802_11_CAP_KEY_MGMT_PSK)
|
||||||
nm_ap_security_new (int we_cipher)
|
#define WPA2_TKIP_PSK (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_CIPHER_TKIP | NM_802_11_CAP_KEY_MGMT_PSK)
|
||||||
{
|
#define WPA2_EAP (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_KEY_MGMT_802_1X)
|
||||||
NMAPSecurity * security;
|
#define WPA_CCMP_PSK (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_CIPHER_CCMP | NM_802_11_CAP_KEY_MGMT_PSK)
|
||||||
|
#define WPA_TKIP_PSK (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_CIPHER_TKIP | NM_802_11_CAP_KEY_MGMT_PSK)
|
||||||
|
#define WPA_EAP (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_KEY_MGMT_802_1X)
|
||||||
|
#define WEP_WEP104 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP104)
|
||||||
|
#define WEP_WEP40 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40)
|
||||||
|
#define LEAP (NM_802_11_CAP_KEY_MGMT_802_1X)
|
||||||
|
|
||||||
|
NMAPSecurity *
|
||||||
|
nm_ap_security_new (guint32 capabilities, gboolean encrypted)
|
||||||
|
{
|
||||||
|
NMAPSecurity *security;
|
||||||
|
|
||||||
|
/* Deteremine best encryption algorithm to use */
|
||||||
|
if (((capabilities & WPA_CCMP_PSK) == WPA_CCMP_PSK) || ((capabilities & WPA2_CCMP_PSK) == WPA2_CCMP_PSK))
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_wpa_psk_new (capabilities, IW_AUTH_CIPHER_CCMP));
|
||||||
|
else if (((capabilities & WPA_TKIP_PSK) == WPA_TKIP_PSK) || ((capabilities & WPA2_TKIP_PSK) == WPA2_TKIP_PSK))
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_wpa_psk_new (capabilities, IW_AUTH_CIPHER_TKIP));
|
||||||
|
else if (((capabilities & WPA_EAP) == WPA_EAP) || ((capabilities & WPA2_EAP) == WPA2_EAP))
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_wpa_eap_new (capabilities));
|
||||||
|
else if ((capabilities & WEP_WEP104) == WEP_WEP104)
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_wep_new (IW_AUTH_CIPHER_WEP104));
|
||||||
|
else if ((capabilities & WEP_WEP40) == WEP_WEP40)
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_wep_new (IW_AUTH_CIPHER_WEP40));
|
||||||
|
else if ((capabilities & LEAP) == LEAP)
|
||||||
|
security = NM_AP_SECURITY (nm_ap_security_leap_new ());
|
||||||
|
else if (!encrypted) {
|
||||||
|
security = g_object_new (NM_TYPE_AP_SECURITY, NULL);
|
||||||
|
security->priv->we_cipher = IW_AUTH_CIPHER_NONE;
|
||||||
|
security->priv->key = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
security = g_object_new (NM_TYPE_AP_SECURITY, NULL);
|
|
||||||
security->priv->we_cipher = we_cipher;
|
|
||||||
security->priv->key = NULL;
|
|
||||||
return security;
|
return security;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +98,7 @@ nm_ap_security_new_deserialize (DBusMessageIter *iter)
|
|||||||
dbus_message_iter_get_basic (iter, &we_cipher);
|
dbus_message_iter_get_basic (iter, &we_cipher);
|
||||||
|
|
||||||
if (we_cipher == IW_AUTH_CIPHER_NONE)
|
if (we_cipher == IW_AUTH_CIPHER_NONE)
|
||||||
security = nm_ap_security_new (we_cipher);
|
security = nm_ap_security_new (NM_DEVICE_CAP_NONE, FALSE);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Advance to start of cipher-dependent options */
|
/* Advance to start of cipher-dependent options */
|
||||||
@@ -111,44 +137,6 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define WPA2_CCMP_PSK (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_CIPHER_CCMP | NM_802_11_CAP_KEY_MGMT_PSK)
|
|
||||||
#define WPA2_TKIP_PSK (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_CIPHER_TKIP | NM_802_11_CAP_KEY_MGMT_PSK)
|
|
||||||
#define WPA2_EAP (NM_802_11_CAP_PROTO_WPA2 | NM_802_11_CAP_KEY_MGMT_802_1X)
|
|
||||||
#define WPA_CCMP_PSK (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_CIPHER_CCMP | NM_802_11_CAP_KEY_MGMT_PSK)
|
|
||||||
#define WPA_TKIP_PSK (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_CIPHER_TKIP | NM_802_11_CAP_KEY_MGMT_PSK)
|
|
||||||
#define WPA_EAP (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_KEY_MGMT_802_1X)
|
|
||||||
#define WEP_WEP104 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP104)
|
|
||||||
#define WEP_WEP40 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40)
|
|
||||||
#define LEAP (NM_802_11_CAP_KEY_MGMT_802_1X)
|
|
||||||
NMAPSecurity *
|
|
||||||
nm_ap_security_new_from_ap (NMAccessPoint *ap)
|
|
||||||
{
|
|
||||||
NMAPSecurity * security = NULL;
|
|
||||||
guint32 caps;
|
|
||||||
|
|
||||||
g_return_val_if_fail (ap != NULL, NULL);
|
|
||||||
|
|
||||||
/* Deteremine best encryption algorithm to use */
|
|
||||||
caps = nm_ap_get_capabilities (ap);
|
|
||||||
if (((caps & WPA_CCMP_PSK) == WPA_CCMP_PSK) || ((caps & WPA2_CCMP_PSK) == WPA2_CCMP_PSK))
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_wpa_psk_new_from_ap (ap, IW_AUTH_CIPHER_CCMP));
|
|
||||||
else if (((caps & WPA_TKIP_PSK) == WPA_TKIP_PSK) || ((caps & WPA2_TKIP_PSK) == WPA2_TKIP_PSK))
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_wpa_psk_new_from_ap (ap, IW_AUTH_CIPHER_TKIP));
|
|
||||||
else if (((caps & WPA_EAP) == WPA_EAP) || ((caps & WPA2_EAP) == WPA2_EAP))
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_wpa_eap_new_from_ap (ap));
|
|
||||||
else if ((caps & WEP_WEP104) == WEP_WEP104)
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP104));
|
|
||||||
else if ((caps & WEP_WEP40) == WEP_WEP40)
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP40));
|
|
||||||
else if ((caps & LEAP) == LEAP)
|
|
||||||
security = NM_AP_SECURITY (nm_ap_security_leap_new_from_ap (ap));
|
|
||||||
else if (!nm_ap_get_encrypted (ap))
|
|
||||||
security = nm_ap_security_new (IW_AUTH_CIPHER_NONE);
|
|
||||||
|
|
||||||
return security;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
guint32
|
guint32
|
||||||
nm_ap_security_get_default_capabilities (NMAPSecurity *self)
|
nm_ap_security_get_default_capabilities (NMAPSecurity *self)
|
||||||
{
|
{
|
||||||
@@ -221,7 +209,11 @@ nm_ap_security_set_key (NMAPSecurity *self, const char *key, int key_len)
|
|||||||
static NMAPSecurity *
|
static NMAPSecurity *
|
||||||
real_copy_constructor (NMAPSecurity *self)
|
real_copy_constructor (NMAPSecurity *self)
|
||||||
{
|
{
|
||||||
NMAPSecurity * dst = nm_ap_security_new (self->priv->we_cipher);
|
NMAPSecurity *dst;
|
||||||
|
|
||||||
|
dst = g_object_new (NM_TYPE_AP_SECURITY, NULL);
|
||||||
|
dst->priv->we_cipher = self->priv->we_cipher;
|
||||||
|
dst->priv->key = NULL;
|
||||||
|
|
||||||
nm_ap_security_copy_properties (self, dst);
|
nm_ap_security_copy_properties (self, dst);
|
||||||
return dst;
|
return dst;
|
||||||
|
@@ -54,8 +54,6 @@ struct _NMAPSecurity
|
|||||||
NMAPSecurityPrivate *priv;
|
NMAPSecurityPrivate *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct NMAccessPoint;
|
|
||||||
|
|
||||||
struct _NMAPSecurityClass
|
struct _NMAPSecurityClass
|
||||||
{
|
{
|
||||||
GObjectClass parent;
|
GObjectClass parent;
|
||||||
@@ -79,12 +77,10 @@ GType nm_ap_security_get_type (void);
|
|||||||
|
|
||||||
NMAPSecurity * nm_ap_security_new_copy (NMAPSecurity *self);
|
NMAPSecurity * nm_ap_security_new_copy (NMAPSecurity *self);
|
||||||
|
|
||||||
NMAPSecurity * nm_ap_security_new (int we_cipher);
|
NMAPSecurity * nm_ap_security_new (guint32 capabilities, gboolean encrypted);
|
||||||
|
|
||||||
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
NMAPSecurity * nm_ap_security_new_deserialize (DBusMessageIter *iter);
|
||||||
|
|
||||||
NMAPSecurity * nm_ap_security_new_from_ap (struct NMAccessPoint *ap);
|
|
||||||
|
|
||||||
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
int nm_ap_security_get_we_cipher (NMAPSecurity *self);
|
||||||
|
|
||||||
const char * nm_ap_security_get_key (NMAPSecurity *self);
|
const char * nm_ap_security_get_key (NMAPSecurity *self);
|
||||||
|
@@ -108,16 +108,6 @@ nm_dbus_manager_init (NMDBusManager *self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
cleanup_handler_data (gpointer item, gpointer user_data)
|
|
||||||
{
|
|
||||||
MethodHandlerData * data = (MethodHandlerData *) item;
|
|
||||||
|
|
||||||
nm_dbus_method_list_unref (data->list);
|
|
||||||
memset (data, 0, sizeof (MethodHandlerData));
|
|
||||||
g_slice_free (MethodHandlerData, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_signal_handler_helper (gpointer item,
|
free_signal_handler_helper (gpointer item,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
@@ -529,42 +519,6 @@ nm_dbus_manager_name_has_owner (NMDBusManager *self,
|
|||||||
return has_owner;
|
return has_owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DBusHandlerResult
|
|
||||||
nm_dbus_manager_message_handler (DBusConnection *connection,
|
|
||||||
DBusMessage *message,
|
|
||||||
void *user_data)
|
|
||||||
{
|
|
||||||
MethodHandlerData * data = (MethodHandlerData *) user_data;
|
|
||||||
NMDBusManager * self = data->self;
|
|
||||||
NMDbusMethodList * list = data->list;
|
|
||||||
DBusObjectPathMessageFunction custom_handler_func;
|
|
||||||
gboolean handled = FALSE;
|
|
||||||
DBusMessage * reply = NULL;
|
|
||||||
void * hdlr_user_data;
|
|
||||||
|
|
||||||
g_return_val_if_fail (self != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
||||||
g_return_val_if_fail (list != NULL, DBUS_HANDLER_RESULT_NOT_YET_HANDLED);
|
|
||||||
|
|
||||||
hdlr_user_data = nm_dbus_method_list_get_user_data (list);
|
|
||||||
|
|
||||||
/* Try the method lists' custom handler first */
|
|
||||||
custom_handler_func = nm_dbus_method_list_get_custom_handler_func (list);
|
|
||||||
if (custom_handler_func) {
|
|
||||||
handled = (*custom_handler_func) (connection, message, hdlr_user_data);
|
|
||||||
} else {
|
|
||||||
/* Generic handler for lists that don't specify a custom handler */
|
|
||||||
handled = nm_dbus_method_list_dispatch (list, connection, message,
|
|
||||||
hdlr_user_data, &reply);
|
|
||||||
if (reply) {
|
|
||||||
dbus_connection_send (connection, reply, NULL);
|
|
||||||
dbus_message_unref (reply);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return handled ? DBUS_HANDLER_RESULT_HANDLED
|
|
||||||
: DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
proxy_name_owner_changed (DBusGProxy *proxy,
|
proxy_name_owner_changed (DBusGProxy *proxy,
|
||||||
const char *name,
|
const char *name,
|
||||||
|
@@ -508,7 +508,7 @@ static void nm_dbus_get_network_data_cb (DBusPendingCall *pcall, void *user_data
|
|||||||
/* New AP, just add it to the list */
|
/* New AP, just add it to the list */
|
||||||
nm_ap_list_append_ap (cb_data->list, ap);
|
nm_ap_list_append_ap (cb_data->list, ap);
|
||||||
}
|
}
|
||||||
nm_ap_unref (ap);
|
g_object_unref (ap);
|
||||||
|
|
||||||
/* Ensure all devices get new information copied into their device lists */
|
/* Ensure all devices get new information copied into their device lists */
|
||||||
nm_policy_schedule_device_ap_lists_update_from_allowed (cb_data->data);
|
nm_policy_schedule_device_ap_lists_update_from_allowed (cb_data->data);
|
||||||
|
@@ -66,6 +66,17 @@ G_DEFINE_TYPE (NMDevice80211Wireless, nm_device_802_11_wireless, NM_TYPE_DEVICE)
|
|||||||
|
|
||||||
#define NM_DEVICE_802_11_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessPrivate))
|
#define NM_DEVICE_802_11_WIRELESS_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessPrivate))
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_HW_ADDRESS,
|
||||||
|
PROP_MODE,
|
||||||
|
PROP_BITRATE,
|
||||||
|
PROP_ACTIVE_NETWORK,
|
||||||
|
|
||||||
|
LAST_PROP
|
||||||
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
NETWORK_ADDED,
|
NETWORK_ADDED,
|
||||||
NETWORK_REMOVED,
|
NETWORK_REMOVED,
|
||||||
@@ -707,7 +718,7 @@ nm_device_802_11_wireless_copy_allowed_to_dev_list (NMDevice80211Wireless *self,
|
|||||||
NMAccessPoint * dst_ap = nm_ap_new_from_ap (src_ap);
|
NMAccessPoint * dst_ap = nm_ap_new_from_ap (src_ap);
|
||||||
|
|
||||||
nm_ap_list_append_ap (dev_list, dst_ap);
|
nm_ap_list_append_ap (dev_list, dst_ap);
|
||||||
nm_ap_unref (dst_ap);
|
g_object_unref (dst_ap);
|
||||||
}
|
}
|
||||||
nm_ap_list_iter_free (iter);
|
nm_ap_list_iter_free (iter);
|
||||||
}
|
}
|
||||||
@@ -918,8 +929,7 @@ nm_device_802_11_wireless_get_best_ap (NMDevice80211Wireless *self)
|
|||||||
&& !nm_ap_list_get_ap_by_essid (app_data->invalid_ap_list, essid)
|
&& !nm_ap_list_get_ap_by_essid (app_data->invalid_ap_list, essid)
|
||||||
&& nm_device_802_11_wireless_ap_list_get_ap_by_essid (self, essid))
|
&& nm_device_802_11_wireless_ap_list_get_ap_by_essid (self, essid))
|
||||||
{
|
{
|
||||||
nm_ap_ref (cur_ap);
|
return (NMAccessPoint *) g_object_ref (cur_ap);
|
||||||
return cur_ap;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -961,7 +971,7 @@ nm_device_802_11_wireless_get_best_ap (NMDevice80211Wireless *self)
|
|||||||
best_ap = get_best_fallback_ap (self);
|
best_ap = get_best_fallback_ap (self);
|
||||||
|
|
||||||
if (best_ap)
|
if (best_ap)
|
||||||
nm_ap_ref (best_ap);
|
g_object_ref (best_ap);
|
||||||
|
|
||||||
return best_ap;
|
return best_ap;
|
||||||
}
|
}
|
||||||
@@ -1019,7 +1029,7 @@ nm_device_802_11_wireless_get_activation_ap (NMDevice80211Wireless *self,
|
|||||||
*/
|
*/
|
||||||
nm_ap_set_capabilities (ap, nm_ap_security_get_default_capabilities (security));
|
nm_ap_set_capabilities (ap, nm_ap_security_get_default_capabilities (security));
|
||||||
nm_ap_list_append_ap (dev_ap_list, ap);
|
nm_ap_list_append_ap (dev_ap_list, ap);
|
||||||
nm_ap_unref (ap);
|
g_object_unref (ap);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1030,7 +1040,8 @@ nm_device_802_11_wireless_get_activation_ap (NMDevice80211Wireless *self,
|
|||||||
|
|
||||||
/* If we didn't get any security info, make some up. */
|
/* If we didn't get any security info, make some up. */
|
||||||
if (!security)
|
if (!security)
|
||||||
security = nm_ap_security_new_from_ap (ap);
|
security = nm_ap_security_new (nm_ap_get_capabilities (ap),
|
||||||
|
nm_ap_get_encrypted (ap));
|
||||||
}
|
}
|
||||||
g_assert (security);
|
g_assert (security);
|
||||||
nm_ap_set_security (ap, security);
|
nm_ap_set_security (ap, security);
|
||||||
@@ -1171,8 +1182,11 @@ impl_device_get_active_networks (NMDevice80211Wireless *device,
|
|||||||
|
|
||||||
while ((ap = nm_ap_list_iter_next (list_iter))) {
|
while ((ap = nm_ap_list_iter_next (list_iter))) {
|
||||||
if (nm_ap_get_essid (ap)) {
|
if (nm_ap_get_essid (ap)) {
|
||||||
g_ptr_array_add (*networks,
|
/* FIXME: In theory, it should be possible to use something like:
|
||||||
nm_dbus_get_object_path_for_network (NM_DEVICE (device), ap));
|
g_ptr_array_add (*networks, ap);
|
||||||
|
and let dbus-glib get the already registered object path, but it crashes
|
||||||
|
NM currently. Figure it out. */
|
||||||
|
g_ptr_array_add (*networks, g_strdup (g_object_get_data (ap, "dbus_glib_object_path")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nm_ap_list_iter_free (list_iter);
|
nm_ap_list_iter_free (list_iter);
|
||||||
@@ -2042,7 +2056,8 @@ ap_need_key (NMDevice80211Wireless *self,
|
|||||||
* settings were changed.
|
* settings were changed.
|
||||||
*/
|
*/
|
||||||
if (we_cipher != IW_AUTH_CIPHER_NONE)
|
if (we_cipher != IW_AUTH_CIPHER_NONE)
|
||||||
nm_ap_set_security (ap, nm_ap_security_new_from_ap (ap));
|
nm_ap_set_security (ap, nm_ap_security_new (nm_ap_get_capabilities (ap),
|
||||||
|
nm_ap_get_encrypted (ap)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2380,7 +2395,7 @@ supplicant_iface_scanned_ap_cb (NMSupplicantInterface * iface,
|
|||||||
/* Remove outdated access points */
|
/* Remove outdated access points */
|
||||||
cull_scan_list (self);
|
cull_scan_list (self);
|
||||||
|
|
||||||
nm_ap_unref (ap);
|
g_object_unref (ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3345,6 +3360,44 @@ nm_device_802_11_wireless_finalize (GObject *object)
|
|||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object, guint prop_id,
|
||||||
|
GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
NMDevice80211Wireless *device = NM_DEVICE_802_11_WIRELESS (object);
|
||||||
|
struct ether_addr hw_addr;
|
||||||
|
char hw_addr_buf[20];
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_HW_ADDRESS:
|
||||||
|
memset (hw_addr_buf, 0, 20);
|
||||||
|
nm_device_802_11_wireless_get_address (device, &hw_addr);
|
||||||
|
iw_ether_ntop (&hw_addr, hw_addr_buf);
|
||||||
|
g_value_set_string (value, &hw_addr_buf[0]);
|
||||||
|
break;
|
||||||
|
case PROP_MODE:
|
||||||
|
g_value_set_int (value, nm_device_802_11_wireless_get_mode (device));
|
||||||
|
break;
|
||||||
|
case PROP_BITRATE:
|
||||||
|
g_value_set_int (value, nm_device_802_11_wireless_get_bitrate (device));
|
||||||
|
break;
|
||||||
|
case PROP_ACTIVE_NETWORK:
|
||||||
|
/* FIXME: */
|
||||||
|
#if 0
|
||||||
|
req = nm_device_get_act_request (NM_DEVICE (device));
|
||||||
|
if (req && ap = nm_act_request_get_ap (req)) {
|
||||||
|
NMAccessPoint *tmp_ap;
|
||||||
|
|
||||||
|
if ((tmp_ap = nm_device_802_11_wireless_ap_list_get_ap_by_essid (device, nm_ap_get_essid (ap))))
|
||||||
|
g_value_set_object (value, tmp_ap);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
||||||
@@ -3354,6 +3407,7 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
|||||||
|
|
||||||
g_type_class_add_private (object_class, sizeof (NMDevice80211WirelessPrivate));
|
g_type_class_add_private (object_class, sizeof (NMDevice80211WirelessPrivate));
|
||||||
|
|
||||||
|
object_class->get_property = get_property;
|
||||||
object_class->dispose = nm_device_802_11_wireless_dispose;
|
object_class->dispose = nm_device_802_11_wireless_dispose;
|
||||||
object_class->finalize = nm_device_802_11_wireless_finalize;
|
object_class->finalize = nm_device_802_11_wireless_finalize;
|
||||||
|
|
||||||
@@ -3374,6 +3428,36 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
|||||||
|
|
||||||
parent_class->activation_cancel_handler = real_activation_cancel_handler;
|
parent_class->activation_cancel_handler = real_activation_cancel_handler;
|
||||||
|
|
||||||
|
/* Properties */
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_HW_ADDRESS,
|
||||||
|
g_param_spec_string (NM_DEVICE_802_11_WIRELESS_HW_ADDRESS,
|
||||||
|
"MAC Address",
|
||||||
|
"Hardware MAC address",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_MODE,
|
||||||
|
g_param_spec_int (NM_DEVICE_802_11_WIRELESS_MODE,
|
||||||
|
"Mode",
|
||||||
|
"Mode",
|
||||||
|
0, G_MAXINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_BITRATE,
|
||||||
|
g_param_spec_int (NM_DEVICE_802_11_WIRELESS_BITRATE,
|
||||||
|
"Bitrate",
|
||||||
|
"Bitrate",
|
||||||
|
0, G_MAXINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_ACTIVE_NETWORK,
|
||||||
|
g_param_spec_object (NM_DEVICE_802_11_WIRELESS_ACTIVE_NETWORK,
|
||||||
|
"Active network",
|
||||||
|
"Currently active network",
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
/* Signals */
|
/* Signals */
|
||||||
signals[NETWORK_ADDED] =
|
signals[NETWORK_ADDED] =
|
||||||
g_signal_new ("network-added",
|
g_signal_new ("network-added",
|
||||||
@@ -3381,9 +3465,9 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
|||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_added),
|
G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_added),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__POINTER,
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
G_TYPE_POINTER);
|
G_TYPE_OBJECT);
|
||||||
|
|
||||||
signals[NETWORK_REMOVED] =
|
signals[NETWORK_REMOVED] =
|
||||||
g_signal_new ("network-removed",
|
g_signal_new ("network-removed",
|
||||||
@@ -3391,9 +3475,9 @@ nm_device_802_11_wireless_class_init (NMDevice80211WirelessClass *klass)
|
|||||||
G_SIGNAL_RUN_FIRST,
|
G_SIGNAL_RUN_FIRST,
|
||||||
G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_removed),
|
G_STRUCT_OFFSET (NMDevice80211WirelessClass, network_removed),
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
g_cclosure_marshal_VOID__POINTER,
|
g_cclosure_marshal_VOID__OBJECT,
|
||||||
G_TYPE_NONE, 1,
|
G_TYPE_NONE, 1,
|
||||||
G_TYPE_POINTER);
|
G_TYPE_OBJECT);
|
||||||
|
|
||||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
||||||
&dbus_glib_nm_device_802_11_wireless_object_info);
|
&dbus_glib_nm_device_802_11_wireless_object_info);
|
||||||
|
@@ -42,6 +42,12 @@ G_BEGIN_DECLS
|
|||||||
#define NM_IS_DEVICE_802_11_WIRELESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_802_11_WIRELESS))
|
#define NM_IS_DEVICE_802_11_WIRELESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_DEVICE_802_11_WIRELESS))
|
||||||
#define NM_DEVICE_802_11_WIRELESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessClass))
|
#define NM_DEVICE_802_11_WIRELESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessClass))
|
||||||
|
|
||||||
|
|
||||||
|
#define NM_DEVICE_802_11_WIRELESS_HW_ADDRESS "hw-address"
|
||||||
|
#define NM_DEVICE_802_11_WIRELESS_MODE "mode"
|
||||||
|
#define NM_DEVICE_802_11_WIRELESS_BITRATE "bitrate"
|
||||||
|
#define NM_DEVICE_802_11_WIRELESS_ACTIVE_NETWORK "active-network"
|
||||||
|
|
||||||
typedef enum NMWirelessScanInterval
|
typedef enum NMWirelessScanInterval
|
||||||
{
|
{
|
||||||
NM_WIRELESS_SCAN_INTERVAL_INIT = 0,
|
NM_WIRELESS_SCAN_INTERVAL_INIT = 0,
|
||||||
|
@@ -413,15 +413,19 @@ static void
|
|||||||
get_property (GObject *object, guint prop_id,
|
get_property (GObject *object, guint prop_id,
|
||||||
GValue *value, GParamSpec *pspec)
|
GValue *value, GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
/* FIXME: */
|
NMDevice8023Ethernet *device = NM_DEVICE_802_3_ETHERNET (object);
|
||||||
/* NMDevice8023EthernetPrivate *priv = NM_DEVICE_802_3_ETHERNET_GET_PRIVATE (object); */
|
struct ether_addr hw_addr;
|
||||||
|
char hw_addr_buf[20];
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
/* case PROP_HW_ADDRESS: */
|
case PROP_HW_ADDRESS:
|
||||||
/* g_value_set_int (value, ); */
|
memset (hw_addr_buf, 0, 20);
|
||||||
/* break; */
|
nm_device_802_3_ethernet_get_address (device, &hw_addr);
|
||||||
|
iw_ether_ntop (&hw_addr, hw_addr_buf);
|
||||||
|
g_value_set_string (value, &hw_addr_buf[0]);
|
||||||
|
break;
|
||||||
case PROP_SPEED:
|
case PROP_SPEED:
|
||||||
g_value_set_int (value, nm_device_802_3_ethernet_get_speed (NM_DEVICE_802_3_ETHERNET (object)));
|
g_value_set_int (value, nm_device_802_3_ethernet_get_speed (device));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
@@ -453,19 +457,19 @@ nm_device_802_3_ethernet_class_init (NMDevice8023EthernetClass *klass)
|
|||||||
/* properties */
|
/* properties */
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_HW_ADDRESS,
|
(object_class, PROP_HW_ADDRESS,
|
||||||
g_param_spec_int (NM_DEVICE_802_3_ETHERNET_HW_ADDRESS,
|
g_param_spec_string (NM_DEVICE_802_3_ETHERNET_HW_ADDRESS,
|
||||||
"MAC Address",
|
"MAC Address",
|
||||||
"Hardware MAC address",
|
"Hardware MAC address",
|
||||||
0, G_MAXINT32, 0,
|
NULL,
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class, PROP_SPEED,
|
(object_class, PROP_SPEED,
|
||||||
g_param_spec_int (NM_DEVICE_802_3_ETHERNET_SPEED,
|
g_param_spec_int (NM_DEVICE_802_3_ETHERNET_SPEED,
|
||||||
"Speed",
|
"Speed",
|
||||||
"Speed",
|
"Speed",
|
||||||
0, G_MAXINT32, 0,
|
0, G_MAXINT32, 0,
|
||||||
G_PARAM_READABLE));
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (klass),
|
||||||
&dbus_glib_nm_device_802_3_ethernet_object_info);
|
&dbus_glib_nm_device_802_3_ethernet_object_info);
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include "nm-device-interface.h"
|
#include "nm-device-interface.h"
|
||||||
|
#include "nm-ip4-config.h"
|
||||||
|
|
||||||
static gboolean impl_device_deactivate (NMDeviceInterface *device, GError **err);
|
static gboolean impl_device_deactivate (NMDeviceInterface *device, GError **err);
|
||||||
|
|
||||||
@@ -62,6 +63,14 @@ nm_device_interface_init (gpointer g_iface)
|
|||||||
0, G_MAXUINT32, 0, /* FIXME */
|
0, G_MAXUINT32, 0, /* FIXME */
|
||||||
G_PARAM_READWRITE));
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
|
g_object_interface_install_property
|
||||||
|
(g_iface,
|
||||||
|
g_param_spec_object (NM_DEVICE_INTERFACE_IP4_CONFIG,
|
||||||
|
"IP4 Config",
|
||||||
|
"IP4 Config",
|
||||||
|
G_TYPE_OBJECT,
|
||||||
|
G_PARAM_READWRITE));
|
||||||
|
|
||||||
g_object_interface_install_property
|
g_object_interface_install_property
|
||||||
(g_iface,
|
(g_iface,
|
||||||
g_param_spec_uint (NM_DEVICE_INTERFACE_STATE,
|
g_param_spec_uint (NM_DEVICE_INTERFACE_STATE,
|
||||||
|
@@ -16,6 +16,7 @@
|
|||||||
#define NM_DEVICE_INTERFACE_DRIVER "driver"
|
#define NM_DEVICE_INTERFACE_DRIVER "driver"
|
||||||
#define NM_DEVICE_INTERFACE_CAPABILITIES "capabilities"
|
#define NM_DEVICE_INTERFACE_CAPABILITIES "capabilities"
|
||||||
#define NM_DEVICE_INTERFACE_IP4_ADDRESS "ip4_address"
|
#define NM_DEVICE_INTERFACE_IP4_ADDRESS "ip4_address"
|
||||||
|
#define NM_DEVICE_INTERFACE_IP4_CONFIG "ip4_config"
|
||||||
#define NM_DEVICE_INTERFACE_STATE "state"
|
#define NM_DEVICE_INTERFACE_STATE "state"
|
||||||
#define NM_DEVICE_INTERFACE_APP_DATA "app_data" /* Ugh */
|
#define NM_DEVICE_INTERFACE_APP_DATA "app_data" /* Ugh */
|
||||||
#define NM_DEVICE_INTERFACE_DEVICE_TYPE "device_type" /* ugh */
|
#define NM_DEVICE_INTERFACE_DEVICE_TYPE "device_type" /* ugh */
|
||||||
@@ -28,6 +29,7 @@ typedef enum {
|
|||||||
NM_DEVICE_INTERFACE_PROP_DRIVER,
|
NM_DEVICE_INTERFACE_PROP_DRIVER,
|
||||||
NM_DEVICE_INTERFACE_PROP_CAPABILITIES,
|
NM_DEVICE_INTERFACE_PROP_CAPABILITIES,
|
||||||
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
||||||
|
NM_DEVICE_INTERFACE_PROP_IP4_CONFIG,
|
||||||
NM_DEVICE_INTERFACE_PROP_STATE,
|
NM_DEVICE_INTERFACE_PROP_STATE,
|
||||||
NM_DEVICE_INTERFACE_PROP_APP_DATA,
|
NM_DEVICE_INTERFACE_PROP_APP_DATA,
|
||||||
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE
|
NM_DEVICE_INTERFACE_PROP_DEVICE_TYPE
|
||||||
|
@@ -1396,16 +1396,17 @@ nm_device_get_ip4_config (NMDevice *self)
|
|||||||
void
|
void
|
||||||
nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config)
|
nm_device_set_ip4_config (NMDevice *self, NMIP4Config *config)
|
||||||
{
|
{
|
||||||
NMIP4Config *old_config;
|
NMDevicePrivate *priv = NM_DEVICE_GET_PRIVATE (self);
|
||||||
|
|
||||||
g_return_if_fail (self != NULL);
|
g_return_if_fail (NM_IS_DEVICE (self));
|
||||||
|
|
||||||
|
if (priv->ip4_config) {
|
||||||
|
g_object_unref (priv->ip4_config);
|
||||||
|
priv->ip4_config = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
old_config = self->priv->ip4_config;
|
|
||||||
if (config)
|
if (config)
|
||||||
nm_ip4_config_ref (config);
|
priv->ip4_config = g_object_ref (config);
|
||||||
self->priv->ip4_config = config;
|
|
||||||
if (old_config)
|
|
||||||
nm_ip4_config_unref (old_config);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1611,11 +1612,7 @@ nm_device_dispose (GObject *object)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
nm_system_device_free_system_config (self, self->priv->system_config_data);
|
nm_system_device_free_system_config (self, self->priv->system_config_data);
|
||||||
if (self->priv->ip4_config)
|
nm_device_set_ip4_config (self, NULL);
|
||||||
{
|
|
||||||
nm_ip4_config_unref (self->priv->ip4_config);
|
|
||||||
self->priv->ip4_config = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (self->priv->act_request)
|
if (self->priv->act_request)
|
||||||
{
|
{
|
||||||
@@ -1703,6 +1700,9 @@ get_property (GObject *object, guint prop_id,
|
|||||||
case NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS:
|
case NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS:
|
||||||
g_value_set_uint (value, priv->ip4_address);
|
g_value_set_uint (value, priv->ip4_address);
|
||||||
break;
|
break;
|
||||||
|
case NM_DEVICE_INTERFACE_PROP_IP4_CONFIG:
|
||||||
|
g_value_set_object (value, priv->ip4_config);
|
||||||
|
break;
|
||||||
case NM_DEVICE_INTERFACE_PROP_STATE:
|
case NM_DEVICE_INTERFACE_PROP_STATE:
|
||||||
g_value_set_uint (value, priv->state);
|
g_value_set_uint (value, priv->state);
|
||||||
break;
|
break;
|
||||||
@@ -1763,6 +1763,10 @@ nm_device_class_init (NMDeviceClass *klass)
|
|||||||
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
NM_DEVICE_INTERFACE_PROP_IP4_ADDRESS,
|
||||||
NM_DEVICE_INTERFACE_IP4_ADDRESS);
|
NM_DEVICE_INTERFACE_IP4_ADDRESS);
|
||||||
|
|
||||||
|
g_object_class_override_property (object_class,
|
||||||
|
NM_DEVICE_INTERFACE_PROP_IP4_CONFIG,
|
||||||
|
NM_DEVICE_INTERFACE_IP4_CONFIG);
|
||||||
|
|
||||||
g_object_class_override_property (object_class,
|
g_object_class_override_property (object_class,
|
||||||
NM_DEVICE_INTERFACE_PROP_STATE,
|
NM_DEVICE_INTERFACE_PROP_STATE,
|
||||||
NM_DEVICE_INTERFACE_STATE);
|
NM_DEVICE_INTERFACE_STATE);
|
||||||
|
@@ -23,18 +23,23 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "nm-ip4-config.h"
|
||||||
|
#include "nm-dbus-manager.h"
|
||||||
#include "NetworkManager.h"
|
#include "NetworkManager.h"
|
||||||
#include "NetworkManagerUtils.h"
|
#include "NetworkManagerUtils.h"
|
||||||
#include "nm-ip4-config.h"
|
|
||||||
|
|
||||||
#include <netlink/route/addr.h>
|
#include <netlink/route/addr.h>
|
||||||
#include <netlink/utils.h>
|
#include <netlink/utils.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
|
||||||
struct NMIP4Config
|
#include "nm-ip4-config-glue.h"
|
||||||
{
|
|
||||||
guint refcount;
|
|
||||||
|
|
||||||
|
|
||||||
|
G_DEFINE_TYPE (NMIP4Config, nm_ip4_config, G_TYPE_OBJECT)
|
||||||
|
|
||||||
|
#define NM_IP4_CONFIG_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_IP4_CONFIG, NMIP4ConfigPrivate))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
guint32 ip4_address;
|
guint32 ip4_address;
|
||||||
guint32 ip4_ptp_address;
|
guint32 ip4_ptp_address;
|
||||||
guint32 ip4_gateway;
|
guint32 ip4_gateway;
|
||||||
@@ -44,48 +49,75 @@ struct NMIP4Config
|
|||||||
guint32 mtu; /* Maximum Transmission Unit of the interface */
|
guint32 mtu; /* Maximum Transmission Unit of the interface */
|
||||||
guint32 mss; /* Maximum Segment Size of the route */
|
guint32 mss; /* Maximum Segment Size of the route */
|
||||||
|
|
||||||
GSList * nameservers;
|
GArray *nameservers;
|
||||||
GSList * domains;
|
GPtrArray *domains;
|
||||||
|
|
||||||
gchar * hostname;
|
gchar * hostname;
|
||||||
gchar * nis_domain;
|
gchar * nis_domain;
|
||||||
GSList * nis_servers;
|
GArray *nis_servers;
|
||||||
|
|
||||||
/* If this is a VPN/etc config that requires
|
/* If this is a VPN/etc config that requires
|
||||||
* another device (like Ethernet) to already have
|
* another device (like Ethernet) to already have
|
||||||
* an IP4Config before it can be used.
|
* an IP4Config before it can be used.
|
||||||
*/
|
*/
|
||||||
gboolean secondary;
|
gboolean secondary;
|
||||||
|
} NMIP4ConfigPrivate;
|
||||||
|
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PROP_0,
|
||||||
|
PROP_ADDRESS,
|
||||||
|
PROP_GATEWAY,
|
||||||
|
PROP_NETMASK,
|
||||||
|
PROP_BROADCAST,
|
||||||
|
PROP_HOSTNAME,
|
||||||
|
PROP_NAMESERVERS,
|
||||||
|
PROP_DOMAINS,
|
||||||
|
PROP_NIS_DOMAIN,
|
||||||
|
PROP_NIS_SERVERS,
|
||||||
|
|
||||||
|
LAST_PROP
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
NMIP4Config *nm_ip4_config_new (void)
|
NMIP4Config *
|
||||||
|
nm_ip4_config_new (void)
|
||||||
{
|
{
|
||||||
NMIP4Config *config = g_slice_new0 (NMIP4Config);
|
GObject *object;
|
||||||
|
DBusGConnection *connection;
|
||||||
|
char *path;
|
||||||
|
static guint32 counter = 0;
|
||||||
|
|
||||||
config->refcount = 1;
|
object = g_object_new (NM_TYPE_IP4_CONFIG, NULL);
|
||||||
|
|
||||||
return config;
|
connection = nm_dbus_manager_get_connection (nm_dbus_manager_get ());
|
||||||
|
path = g_strdup_printf (NM_DBUS_PATH "/IP4Config/%d", counter++);
|
||||||
|
|
||||||
|
dbus_g_connection_register_g_object (connection, path, object);
|
||||||
|
g_free (path);
|
||||||
|
|
||||||
|
return (NMIP4Config *) object;
|
||||||
}
|
}
|
||||||
|
|
||||||
NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
|
NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
|
||||||
{
|
{
|
||||||
NMIP4Config * dst_config;
|
NMIP4Config *dst_config;
|
||||||
int i, len;
|
NMIP4ConfigPrivate *priv;
|
||||||
|
int i;
|
||||||
|
int len;
|
||||||
|
|
||||||
g_return_val_if_fail (src_config != NULL, NULL);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (src_config), NULL);
|
||||||
|
|
||||||
dst_config = g_slice_new0 (NMIP4Config);
|
dst_config = nm_ip4_config_new ();
|
||||||
dst_config->refcount = 1;
|
priv = NM_IP4_CONFIG_GET_PRIVATE (dst_config);
|
||||||
|
|
||||||
dst_config->ip4_address = nm_ip4_config_get_address (src_config);
|
nm_ip4_config_set_address (dst_config, nm_ip4_config_get_address (src_config));
|
||||||
dst_config->ip4_ptp_address = nm_ip4_config_get_ptp_address (src_config);
|
nm_ip4_config_set_ptp_address (dst_config, nm_ip4_config_get_ptp_address (src_config));
|
||||||
dst_config->ip4_gateway = nm_ip4_config_get_gateway (src_config);
|
nm_ip4_config_set_gateway (dst_config, nm_ip4_config_get_gateway (src_config));
|
||||||
dst_config->ip4_netmask = nm_ip4_config_get_netmask (src_config);
|
nm_ip4_config_set_netmask (dst_config, nm_ip4_config_get_netmask (src_config));
|
||||||
dst_config->ip4_broadcast = nm_ip4_config_get_broadcast (src_config);
|
nm_ip4_config_set_broadcast (dst_config, nm_ip4_config_get_broadcast (src_config));
|
||||||
|
nm_ip4_config_set_hostname (dst_config, nm_ip4_config_get_hostname (src_config));
|
||||||
dst_config->hostname = g_strdup (nm_ip4_config_get_hostname (src_config));
|
nm_ip4_config_set_nis_domain (dst_config, nm_ip4_config_get_nis_domain (src_config));
|
||||||
dst_config->nis_domain = g_strdup (nm_ip4_config_get_nis_domain (src_config));
|
|
||||||
|
|
||||||
len = nm_ip4_config_get_num_nameservers (src_config);
|
len = nm_ip4_config_get_num_nameservers (src_config);
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
@@ -102,260 +134,219 @@ NMIP4Config *nm_ip4_config_copy (NMIP4Config *src_config)
|
|||||||
return dst_config;
|
return dst_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_ref (NMIP4Config *config)
|
|
||||||
{
|
|
||||||
g_return_if_fail (config != NULL);
|
|
||||||
|
|
||||||
config->refcount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
void nm_ip4_config_unref (NMIP4Config *config)
|
|
||||||
{
|
|
||||||
g_return_if_fail (config != NULL);
|
|
||||||
|
|
||||||
config->refcount--;
|
|
||||||
if (config->refcount <= 0)
|
|
||||||
{
|
|
||||||
g_free (config->hostname);
|
|
||||||
g_free (config->nis_domain);
|
|
||||||
g_slist_free (config->nameservers);
|
|
||||||
g_slist_foreach (config->domains, (GFunc) g_free, NULL);
|
|
||||||
g_slist_free (config->domains);
|
|
||||||
g_slist_free (config->nis_servers);
|
|
||||||
|
|
||||||
memset (config, 0, sizeof (NMIP4Config));
|
|
||||||
g_slice_free (NMIP4Config, config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gboolean nm_ip4_config_get_secondary (NMIP4Config *config)
|
gboolean nm_ip4_config_get_secondary (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, FALSE);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), FALSE);
|
||||||
|
|
||||||
return config->secondary;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_secondary (NMIP4Config *config, gboolean secondary)
|
void nm_ip4_config_set_secondary (NMIP4Config *config, gboolean secondary)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->secondary = secondary;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->secondary = secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_address (NMIP4Config *config)
|
guint32 nm_ip4_config_get_address (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->ip4_address;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_address (NMIP4Config *config, guint32 addr)
|
void nm_ip4_config_set_address (NMIP4Config *config, guint32 addr)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->ip4_address = addr;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_address = addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_ptp_address (NMIP4Config *config)
|
guint32 nm_ip4_config_get_ptp_address (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->ip4_ptp_address;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_ptp_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_ptp_address (NMIP4Config *config, guint32 ptp_addr)
|
void nm_ip4_config_set_ptp_address (NMIP4Config *config, guint32 ptp_addr)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->ip4_ptp_address = ptp_addr;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_ptp_address = ptp_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_gateway (NMIP4Config *config)
|
guint32 nm_ip4_config_get_gateway (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->ip4_gateway;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway)
|
void nm_ip4_config_set_gateway (NMIP4Config *config, guint32 gateway)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->ip4_gateway = gateway;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_gateway = gateway;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_netmask (NMIP4Config *config)
|
guint32 nm_ip4_config_get_netmask (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->ip4_netmask;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_netmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_netmask (NMIP4Config *config, guint32 netmask)
|
void nm_ip4_config_set_netmask (NMIP4Config *config, guint32 netmask)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->ip4_netmask = netmask;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_netmask = netmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_broadcast (NMIP4Config *config)
|
guint32 nm_ip4_config_get_broadcast (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->ip4_broadcast;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_broadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_broadcast (NMIP4Config *config, guint32 broadcast)
|
void nm_ip4_config_set_broadcast (NMIP4Config *config, guint32 broadcast)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->ip4_broadcast = broadcast;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->ip4_broadcast = broadcast;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver)
|
void nm_ip4_config_add_nameserver (NMIP4Config *config, guint32 nameserver)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
if (nameserver != 0)
|
if (nameserver != 0)
|
||||||
config->nameservers = g_slist_append (config->nameservers, GINT_TO_POINTER (nameserver));
|
g_array_append_val (NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers, nameserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_nameserver (NMIP4Config *config, guint i)
|
guint32 nm_ip4_config_get_nameserver (NMIP4Config *config, guint i)
|
||||||
{
|
{
|
||||||
guint nameserver;
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
return g_array_index (NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers, guint32, i);
|
||||||
g_return_val_if_fail (i < g_slist_length (config->nameservers), 0);
|
|
||||||
|
|
||||||
if ((nameserver = GPOINTER_TO_UINT (g_slist_nth_data (config->nameservers, i))))
|
|
||||||
return nameserver;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config)
|
guint32 nm_ip4_config_get_num_nameservers (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return (g_slist_length (config->nameservers));
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->nameservers->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server)
|
void nm_ip4_config_add_nis_server (NMIP4Config *config, guint32 nis_server)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->nis_servers = g_slist_append (config->nis_servers, GINT_TO_POINTER (nis_server));
|
g_array_append_val (NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers, nis_server);
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i)
|
guint32 nm_ip4_config_get_nis_server (NMIP4Config *config, guint i)
|
||||||
{
|
{
|
||||||
guint nis_server;
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
return g_array_index (NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers, guint32, i);
|
||||||
g_return_val_if_fail (i < g_slist_length (config->nis_servers), 0);
|
|
||||||
|
|
||||||
if ((nis_server = GPOINTER_TO_UINT (g_slist_nth_data (config->nis_servers, i))))
|
|
||||||
return nis_server;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config)
|
guint32 nm_ip4_config_get_num_nis_servers (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return (g_slist_length (config->nis_servers));
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->nis_servers->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
|
void nm_ip4_config_add_domain (NMIP4Config *config, const char *domain)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
g_return_if_fail (domain != NULL);
|
g_return_if_fail (domain != NULL);
|
||||||
|
|
||||||
if (!strlen (domain))
|
if (!strlen (domain))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config->domains = g_slist_append (config->domains, g_strdup (domain));
|
g_ptr_array_add (NM_IP4_CONFIG_GET_PRIVATE (config)->domains, g_strdup (domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname)
|
void nm_ip4_config_set_hostname (NMIP4Config *config, const char *hostname)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
g_return_if_fail (hostname != NULL);
|
g_return_if_fail (hostname != NULL);
|
||||||
|
|
||||||
if (!strlen (hostname))
|
if (!strlen (hostname))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config->hostname = g_strdup (hostname);
|
NM_IP4_CONFIG_GET_PRIVATE (config)->hostname = g_strdup (hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *nm_ip4_config_get_hostname (NMIP4Config *config)
|
const char *nm_ip4_config_get_hostname (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, NULL);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
return config->hostname;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
|
void nm_ip4_config_set_nis_domain (NMIP4Config *config, const char *domain)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
g_return_if_fail (domain != NULL);
|
g_return_if_fail (domain != NULL);
|
||||||
|
|
||||||
if (!strlen (domain))
|
if (!strlen (domain))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
config->nis_domain = g_strdup (domain);
|
NM_IP4_CONFIG_GET_PRIVATE (config)->nis_domain = g_strdup (domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *nm_ip4_config_get_nis_domain (NMIP4Config *config)
|
const char *nm_ip4_config_get_nis_domain (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail( config != NULL, NULL);
|
g_return_val_if_fail( NM_IS_IP4_CONFIG (config), NULL);
|
||||||
return config->nis_domain;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->nis_domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *nm_ip4_config_get_domain (NMIP4Config *config, guint i)
|
const char *nm_ip4_config_get_domain (NMIP4Config *config, guint i)
|
||||||
{
|
{
|
||||||
const char *domain;
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
g_return_val_if_fail (config != NULL, NULL);
|
return (const char *) g_ptr_array_index (NM_IP4_CONFIG_GET_PRIVATE (config)->domains, i);
|
||||||
g_return_val_if_fail (i < g_slist_length (config->domains), NULL);
|
|
||||||
|
|
||||||
if ((domain = (const char *) g_slist_nth_data (config->domains, i)))
|
|
||||||
return domain;
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_num_domains (NMIP4Config *config)
|
guint32 nm_ip4_config_get_num_domains (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return (g_slist_length (config->domains));
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->domains->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_mtu (NMIP4Config *config)
|
guint32 nm_ip4_config_get_mtu (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->mtu;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu)
|
void nm_ip4_config_set_mtu (NMIP4Config *config, guint32 mtu)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->mtu = mtu;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->mtu = mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint32 nm_ip4_config_get_mss (NMIP4Config *config)
|
guint32 nm_ip4_config_get_mss (NMIP4Config *config)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (config != NULL, 0);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), 0);
|
||||||
|
|
||||||
return config->mss;
|
return NM_IP4_CONFIG_GET_PRIVATE (config)->mss;
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
|
void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss)
|
||||||
{
|
{
|
||||||
g_return_if_fail (config != NULL);
|
g_return_if_fail (NM_IS_IP4_CONFIG (config));
|
||||||
|
|
||||||
config->mss = mss;
|
NM_IP4_CONFIG_GET_PRIVATE (config)->mss = mss;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libnl convenience/conversion functions */
|
/* libnl convenience/conversion functions */
|
||||||
@@ -412,25 +403,26 @@ static int ip4_addr_to_rtnl_broadcast (guint32 ip4_broadcast, struct rtnl_addr *
|
|||||||
|
|
||||||
struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flags)
|
struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flags)
|
||||||
{
|
{
|
||||||
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||||
struct rtnl_addr * addr = NULL;
|
struct rtnl_addr * addr = NULL;
|
||||||
gboolean success = TRUE;
|
gboolean success = TRUE;
|
||||||
|
|
||||||
g_return_val_if_fail (config != NULL, NULL);
|
g_return_val_if_fail (NM_IS_IP4_CONFIG (config), NULL);
|
||||||
|
|
||||||
if (!(addr = rtnl_addr_alloc()))
|
if (!(addr = rtnl_addr_alloc()))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (flags & NM_RTNL_ADDR_ADDR)
|
if (flags & NM_RTNL_ADDR_ADDR)
|
||||||
success = (ip4_addr_to_rtnl_local (config->ip4_address, addr) >= 0);
|
success = (ip4_addr_to_rtnl_local (priv->ip4_address, addr) >= 0);
|
||||||
|
|
||||||
if (flags & NM_RTNL_ADDR_PTP_ADDR)
|
if (flags & NM_RTNL_ADDR_PTP_ADDR)
|
||||||
success = (ip4_addr_to_rtnl_peer (config->ip4_ptp_address, addr) >= 0);
|
success = (ip4_addr_to_rtnl_peer (priv->ip4_ptp_address, addr) >= 0);
|
||||||
|
|
||||||
if (flags & NM_RTNL_ADDR_NETMASK)
|
if (flags & NM_RTNL_ADDR_NETMASK)
|
||||||
ip4_addr_to_rtnl_prefixlen (config->ip4_netmask, addr);
|
ip4_addr_to_rtnl_prefixlen (priv->ip4_netmask, addr);
|
||||||
|
|
||||||
if (flags & NM_RTNL_ADDR_BROADCAST)
|
if (flags & NM_RTNL_ADDR_BROADCAST)
|
||||||
success = (ip4_addr_to_rtnl_broadcast (config->ip4_broadcast, addr) >= 0);
|
success = (ip4_addr_to_rtnl_broadcast (priv->ip4_broadcast, addr) >= 0);
|
||||||
|
|
||||||
if (!success)
|
if (!success)
|
||||||
{
|
{
|
||||||
@@ -440,3 +432,145 @@ struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flag
|
|||||||
|
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ip4_config_init (NMIP4Config *config)
|
||||||
|
{
|
||||||
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (config);
|
||||||
|
|
||||||
|
priv->nameservers = g_array_new (FALSE, TRUE, sizeof (guint32));
|
||||||
|
priv->nis_servers = g_array_new (FALSE, TRUE, sizeof (guint32));
|
||||||
|
priv->domains = g_ptr_array_new ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
finalize (GObject *object)
|
||||||
|
{
|
||||||
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
g_free (priv->hostname);
|
||||||
|
g_free (priv->nis_domain);
|
||||||
|
g_array_free (priv->nameservers, TRUE);
|
||||||
|
g_ptr_array_free (priv->domains, TRUE);
|
||||||
|
g_array_free (priv->nis_servers, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
get_property (GObject *object, guint prop_id,
|
||||||
|
GValue *value, GParamSpec *pspec)
|
||||||
|
{
|
||||||
|
NMIP4ConfigPrivate *priv = NM_IP4_CONFIG_GET_PRIVATE (object);
|
||||||
|
|
||||||
|
switch (prop_id) {
|
||||||
|
case PROP_ADDRESS:
|
||||||
|
g_value_set_uint (value, priv->ip4_address);
|
||||||
|
break;
|
||||||
|
case PROP_GATEWAY:
|
||||||
|
g_value_set_uint (value, priv->ip4_gateway);
|
||||||
|
break;
|
||||||
|
case PROP_NETMASK:
|
||||||
|
g_value_set_uint (value, priv->ip4_netmask);
|
||||||
|
break;
|
||||||
|
case PROP_BROADCAST:
|
||||||
|
g_value_set_uint (value, priv->ip4_broadcast);
|
||||||
|
break;
|
||||||
|
case PROP_HOSTNAME:
|
||||||
|
g_value_set_string (value, priv->hostname);
|
||||||
|
break;
|
||||||
|
case PROP_NAMESERVERS:
|
||||||
|
g_value_set_boxed (value, priv->nameservers);
|
||||||
|
break;
|
||||||
|
case PROP_DOMAINS:
|
||||||
|
g_value_set_boxed (value, priv->domains);
|
||||||
|
break;
|
||||||
|
case PROP_NIS_DOMAIN:
|
||||||
|
g_value_set_string (value, priv->nis_domain);
|
||||||
|
break;
|
||||||
|
case PROP_NIS_SERVERS:
|
||||||
|
g_value_set_boxed (value, priv->nis_servers);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_ip4_config_class_init (NMIP4ConfigClass *config_class)
|
||||||
|
{
|
||||||
|
GObjectClass *object_class = G_OBJECT_CLASS (config_class);
|
||||||
|
|
||||||
|
g_type_class_add_private (config_class, sizeof (NMIP4ConfigPrivate));
|
||||||
|
|
||||||
|
/* virtual methods */
|
||||||
|
object_class->get_property = get_property;
|
||||||
|
object_class->finalize = finalize;
|
||||||
|
|
||||||
|
/* properties */
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_ADDRESS,
|
||||||
|
g_param_spec_uint (NM_IP4_CONFIG_ADDRESS,
|
||||||
|
"Address",
|
||||||
|
"IP4 address",
|
||||||
|
0, G_MAXUINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_GATEWAY,
|
||||||
|
g_param_spec_uint (NM_IP4_CONFIG_GATEWAY,
|
||||||
|
"Gateway",
|
||||||
|
"Gateway address",
|
||||||
|
0, G_MAXUINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_NETMASK,
|
||||||
|
g_param_spec_uint (NM_IP4_CONFIG_NETMASK,
|
||||||
|
"Netmask",
|
||||||
|
"Netmask address",
|
||||||
|
0, G_MAXUINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_BROADCAST,
|
||||||
|
g_param_spec_uint (NM_IP4_CONFIG_BROADCAST,
|
||||||
|
"Broadcast",
|
||||||
|
"Broadcast address",
|
||||||
|
0, G_MAXUINT32, 0,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_HOSTNAME,
|
||||||
|
g_param_spec_string (NM_IP4_CONFIG_HOSTNAME,
|
||||||
|
"Hostname",
|
||||||
|
"Hostname",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_NAMESERVERS,
|
||||||
|
g_param_spec_boxed (NM_IP4_CONFIG_NAMESERVERS,
|
||||||
|
"Nameservers",
|
||||||
|
"DNS list",
|
||||||
|
DBUS_TYPE_G_UINT_ARRAY,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_DOMAINS,
|
||||||
|
g_param_spec_boxed (NM_IP4_CONFIG_DOMAINS,
|
||||||
|
"Domains",
|
||||||
|
"Domains",
|
||||||
|
dbus_g_type_get_collection ("GPtrArray", G_TYPE_STRING),
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_NIS_DOMAIN,
|
||||||
|
g_param_spec_string (NM_IP4_CONFIG_NIS_DOMAIN,
|
||||||
|
"NIS domain",
|
||||||
|
"NIS domain name",
|
||||||
|
NULL,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
g_object_class_install_property
|
||||||
|
(object_class, PROP_NIS_SERVERS,
|
||||||
|
g_param_spec_boxed (NM_IP4_CONFIG_NIS_SERVERS,
|
||||||
|
"NIS servers",
|
||||||
|
"NIS servers",
|
||||||
|
DBUS_TYPE_G_UINT_ARRAY,
|
||||||
|
G_PARAM_READABLE));
|
||||||
|
|
||||||
|
dbus_g_object_type_install_info (G_TYPE_FROM_CLASS (config_class),
|
||||||
|
&dbus_glib_nm_ip4_config_object_info);
|
||||||
|
}
|
||||||
|
@@ -22,15 +22,39 @@
|
|||||||
#ifndef NM_IP4_CONFIG_H
|
#ifndef NM_IP4_CONFIG_H
|
||||||
#define NM_IP4_CONFIG_H
|
#define NM_IP4_CONFIG_H
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib/gtypes.h>
|
||||||
|
#include <glib-object.h>
|
||||||
|
|
||||||
typedef struct NMIP4Config NMIP4Config;
|
#define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ())
|
||||||
|
#define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config))
|
||||||
|
#define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
|
||||||
|
#define NM_IS_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_IP4_CONFIG))
|
||||||
|
#define NM_IS_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_IP4_CONFIG))
|
||||||
|
#define NM_IP4_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass))
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObject parent;
|
||||||
|
} NMIP4Config;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
GObjectClass parent;
|
||||||
|
} NMIP4ConfigClass;
|
||||||
|
|
||||||
|
#define NM_IP4_CONFIG_ADDRESS "address"
|
||||||
|
#define NM_IP4_CONFIG_GATEWAY "gateway"
|
||||||
|
#define NM_IP4_CONFIG_NETMASK "netmask"
|
||||||
|
#define NM_IP4_CONFIG_BROADCAST "broadcast"
|
||||||
|
#define NM_IP4_CONFIG_HOSTNAME "hostname"
|
||||||
|
#define NM_IP4_CONFIG_NAMESERVERS "nameservers"
|
||||||
|
#define NM_IP4_CONFIG_DOMAINS "domains"
|
||||||
|
#define NM_IP4_CONFIG_NIS_DOMAIN "nis-domain"
|
||||||
|
#define NM_IP4_CONFIG_NIS_SERVERS "nis-servers"
|
||||||
|
|
||||||
|
GType nm_ip4_config_get_type (void);
|
||||||
|
|
||||||
|
|
||||||
NMIP4Config * nm_ip4_config_new (void);
|
NMIP4Config * nm_ip4_config_new (void);
|
||||||
NMIP4Config * nm_ip4_config_copy (NMIP4Config *config);
|
NMIP4Config * nm_ip4_config_copy (NMIP4Config *config);
|
||||||
void nm_ip4_config_ref (NMIP4Config *config);
|
|
||||||
void nm_ip4_config_unref (NMIP4Config *config);
|
|
||||||
|
|
||||||
gboolean nm_ip4_config_get_secondary (NMIP4Config *config);
|
gboolean nm_ip4_config_get_secondary (NMIP4Config *config);
|
||||||
void nm_ip4_config_set_secondary (NMIP4Config *config, gboolean secondary);
|
void nm_ip4_config_set_secondary (NMIP4Config *config, gboolean secondary);
|
||||||
@@ -86,5 +110,4 @@ void nm_ip4_config_set_mss (NMIP4Config *config, guint32 mss);
|
|||||||
|
|
||||||
struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flags);
|
struct rtnl_addr * nm_ip4_config_to_rtnl_addr (NMIP4Config *config, guint32 flags);
|
||||||
|
|
||||||
|
#endif /* NM_IP4_CONFIG_H */
|
||||||
#endif
|
|
||||||
|
@@ -99,7 +99,7 @@ void nm_vpn_connection_unref (NMVPNConnection *connection)
|
|||||||
if (connection->parent_dev)
|
if (connection->parent_dev)
|
||||||
g_object_unref (G_OBJECT (connection->parent_dev));
|
g_object_unref (G_OBJECT (connection->parent_dev));
|
||||||
if (connection->ip4_config)
|
if (connection->ip4_config)
|
||||||
nm_ip4_config_unref (connection->ip4_config);
|
g_object_unref (connection->ip4_config);
|
||||||
g_free (connection->vpn_iface);
|
g_free (connection->vpn_iface);
|
||||||
|
|
||||||
g_object_unref (connection->named_manager);
|
g_object_unref (connection->named_manager);
|
||||||
@@ -231,15 +231,12 @@ static void nm_vpn_connection_set_ip4_config (NMVPNConnection *con, NMIP4Config
|
|||||||
|
|
||||||
if (con->ip4_config)
|
if (con->ip4_config)
|
||||||
{
|
{
|
||||||
nm_ip4_config_unref (con->ip4_config);
|
g_object_unref (con->ip4_config);
|
||||||
con->ip4_config = NULL;
|
con->ip4_config = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ip4_config)
|
if (ip4_config)
|
||||||
{
|
con->ip4_config = g_object_ref (ip4_config);
|
||||||
nm_ip4_config_ref (ip4_config);
|
|
||||||
con->ip4_config = ip4_config;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nm_vpn_connection_set_parent_device (NMVPNConnection *con, NMDevice *parent_dev)
|
static void nm_vpn_connection_set_parent_device (NMVPNConnection *con, NMDevice *parent_dev)
|
||||||
|
@@ -891,7 +891,7 @@ nm_vpn_service_stage4_ip4_config_get_old (NMVPNService *service,
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (!success) {
|
if (!success) {
|
||||||
nm_ip4_config_unref (config);
|
g_object_unref (config);
|
||||||
nm_warning ("(VPN Service %s): did not receive valid IP config "
|
nm_warning ("(VPN Service %s): did not receive valid IP config "
|
||||||
"information.",
|
"information.",
|
||||||
service->service);
|
service->service);
|
||||||
@@ -1055,7 +1055,7 @@ out:
|
|||||||
if (login_banner) g_free (login_banner);
|
if (login_banner) g_free (login_banner);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
if (config)
|
if (config)
|
||||||
nm_ip4_config_unref (config);
|
g_object_unref (config);
|
||||||
nm_warning ("(VPN Service %s): did not receive valid IP config "
|
nm_warning ("(VPN Service %s): did not receive valid IP config "
|
||||||
"information.",
|
"information.",
|
||||||
service->service);
|
service->service);
|
||||||
|
Reference in New Issue
Block a user