2006-01-04 Dan Williams <dcbw@redhat.com>
First dump of wpa_supplicant-related code. It's not hooked up to anything yet though. Thanks to Kay Sievers for wpa_supplicant_wrapper.c, which formed the basis for this work, and to Jouni Malinen for writing wpa_ctrl.c and wpa_ctrl.h. * src/Makefile.am src/wpa_ctrl.[ch] - Add wpa_ctrl stuff from wpa_supplicant so we can talk to it * src/NetworkManagerUtils.[ch] - (nm_utils_supplicant_request, nm_utils_supplicant_request_with_check): Add convenience functions for talking to wpa_supplicant * src/nm-ap-security.[ch] src/nm-ap-security-wep.c src/nm-ap-security-wpa-psk.[ch] - Update and implement real_write_supplicant_config functions in all security types - (nm_ap_security_wpa_psk_new_from_ap): implement in nm-ap-security-wpa-psk.c * src/nm-device-802-11-wireless.c - (supplicant_cleanup, supplicant_watch_cb, supplicant_monitor_status_cb, wpa_supplicant_start, wpa_supplicant_interface_init, wpa_supplicant_send_network_config): add functions to talk to wpa_supplicant and write network config to it git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1267 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-802-11-wireless.h"
|
||||
#include "nm-device-802-3-ethernet.h"
|
||||
#include "wpa_ctrl.h"
|
||||
|
||||
#include <netlink/addr.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -698,3 +699,84 @@ int nm_utils_ip4_netmask_to_prefix (guint32 ip4_netmask)
|
||||
return (32 - (i-1));
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
nm_utils_supplicant_request (struct wpa_ctrl *ctrl,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
size_t len;
|
||||
char * response = NULL;
|
||||
char * command;
|
||||
|
||||
g_return_val_if_fail (ctrl != NULL, NULL);
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
va_start (args, format);
|
||||
if (!(command = g_strdup_vprintf (format, args)))
|
||||
return NULL;
|
||||
va_end (args);
|
||||
|
||||
response = g_malloc (2048);
|
||||
wpa_ctrl_request (ctrl, command, strlen (command), response, &len, NULL);
|
||||
g_free (command);
|
||||
response[len] = '\0';
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
nm_utils_supplicant_request_with_check (struct wpa_ctrl *ctrl,
|
||||
const char *expected,
|
||||
const char *func,
|
||||
const char *err_msg_cmd,
|
||||
const char *format,
|
||||
...)
|
||||
{
|
||||
va_list args;
|
||||
gboolean success = FALSE;
|
||||
size_t len;
|
||||
char * response = NULL;
|
||||
char * command;
|
||||
char * temp;
|
||||
|
||||
g_return_val_if_fail (ctrl != NULL, FALSE);
|
||||
g_return_val_if_fail (expected != NULL, FALSE);
|
||||
g_return_val_if_fail (format != NULL, FALSE);
|
||||
|
||||
va_start (args, format);
|
||||
if (!(command = g_strdup_vprintf (format, args)))
|
||||
goto out;
|
||||
|
||||
response = g_malloc (2048);
|
||||
wpa_ctrl_request (ctrl, command, strlen (command), response, &len, NULL);
|
||||
response[len] = '\0';
|
||||
|
||||
if (response)
|
||||
{
|
||||
if (strncmp (response, expected, strlen (expected)) == 0)
|
||||
success = TRUE;
|
||||
else
|
||||
{
|
||||
temp = g_strdup_printf ("%s: supplicant error for '%s'. Response: '%s'",
|
||||
func, err_msg_cmd ? err_msg_cmd : command, response);
|
||||
nm_warning_str (temp);
|
||||
g_free (temp);
|
||||
}
|
||||
g_free (response);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = g_strdup_printf ("%s: supplicant error for '%s'. No response.",
|
||||
func, err_msg_cmd ? err_msg_cmd : command);
|
||||
nm_warning_str (temp);
|
||||
g_free (temp);
|
||||
}
|
||||
g_free (command);
|
||||
|
||||
out:
|
||||
va_end (args);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user