1/*
2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#include "includes.h"
16#include <dbus/dbus.h>
17
18#include "common.h"
19#include "eap_peer/eap_methods.h"
20#include "common/ieee802_11_defs.h"
--- 90 unchanged lines hidden (view full) ---
111 if (!os_strlen(ifname))
112 goto error;
113
114 /* Second argument: dict of options */
115 if (dbus_message_iter_next(&iter)) {
116 DBusMessageIter iter_dict;
117 struct wpa_dbus_dict_entry entry;
118
119 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
120 goto error;
121 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
122 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
123 goto error;
124 if (!strcmp(entry.key, "driver") &&
125 (entry.type == DBUS_TYPE_STRING)) {
126 driver = os_strdup(entry.str_value);
127 wpa_dbus_dict_entry_clear(&entry);
--- 96 unchanged lines hidden (view full) ---
224 }
225
226 wpa_s = wpa_supplicant_get_iface_by_dbus_path(global, path);
227 if (wpa_s == NULL) {
228 reply = wpas_dbus_new_invalid_iface_error(message);
229 goto out;
230 }
231
232 if (!wpa_supplicant_remove_iface(global, wpa_s)) {
233 reply = wpas_dbus_new_success_reply(message);
234 } else {
235 reply = dbus_message_new_error(message,
236 WPAS_ERROR_REMOVE_ERROR,
237 "wpa_supplicant couldn't "
238 "remove this interface.");
239 }
240
--- 91 unchanged lines hidden (view full) ---
332 *
333 * Handler function for "scan" method call of a network device. Requests
334 * that wpa_supplicant perform a wireless scan as soon as possible
335 * on a particular wireless interface.
336 */
337DBusMessage * wpas_dbus_iface_scan(DBusMessage *message,
338 struct wpa_supplicant *wpa_s)
339{
340 wpa_s->scan_req = 2;
341 wpa_supplicant_req_scan(wpa_s, 0, 0);
342 return wpas_dbus_new_success_reply(message);
343}
344
345
346/**
347 * wpas_dbus_iface_scan_results - Get the results of a recent scan request
348 * @message: Pointer to incoming dbus message
--- 568 unchanged lines hidden (view full) ---
917 struct wpa_ssid *ssid)
918{
919 DBusMessage *reply = NULL;
920 struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
921 DBusMessageIter iter, iter_dict;
922
923 dbus_message_iter_init(message, &iter);
924
925 if (!wpa_dbus_dict_open_read(&iter, &iter_dict)) {
926 reply = wpas_dbus_new_invalid_opts_error(message, NULL);
927 goto out;
928 }
929
930 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
931 char *value = NULL;
932 size_t size = 50;
933 int ret;
--- 263 unchanged lines hidden (view full) ---
1197 char *opensc_engine_path = NULL;
1198 char *pkcs11_engine_path = NULL;
1199 char *pkcs11_module_path = NULL;
1200 struct wpa_dbus_dict_entry entry;
1201
1202 if (!dbus_message_iter_init(message, &iter))
1203 goto error;
1204
1205 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
1206 goto error;
1207
1208 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
1209 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
1210 goto error;
1211 if (!strcmp(entry.key, "opensc_engine_path") &&
1212 (entry.type == DBUS_TYPE_STRING)) {
1213 opensc_engine_path = os_strdup(entry.str_value);
--- 105 unchanged lines hidden (view full) ---
1319 struct wpa_supplicant *wpa_s)
1320{
1321 DBusMessage *reply = NULL;
1322 struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
1323 DBusMessageIter iter, iter_dict;
1324
1325 dbus_message_iter_init(message, &iter);
1326
1327 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
1328 return wpas_dbus_new_invalid_opts_error(message, NULL);
1329
1330 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
1331 struct wpa_config_blob *blob;
1332
1333 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
1334 reply = wpas_dbus_new_invalid_opts_error(message,
1335 NULL);
--- 93 unchanged lines hidden (view full) ---
1429 }
1430
1431 if (err_msg)
1432 return dbus_message_new_error(message, WPAS_ERROR_REMOVE_ERROR,
1433 err_msg);
1434
1435 return wpas_dbus_new_success_reply(message);
1436}
2 * WPA Supplicant / dbus-based control interface
3 * Copyright (c) 2006, Dan Williams <dcbw@redhat.com> and Red Hat, Inc.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 * Alternatively, this software may be distributed under the terms of BSD
10 * license.
11 *
12 * See README and COPYING for more details.
13 */
14
15#include "includes.h"
16#include <dbus/dbus.h>
17
18#include "common.h"
19#include "eap_peer/eap_methods.h"
20#include "common/ieee802_11_defs.h"
--- 90 unchanged lines hidden (view full) ---
111 if (!os_strlen(ifname))
112 goto error;
113
114 /* Second argument: dict of options */
115 if (dbus_message_iter_next(&iter)) {
116 DBusMessageIter iter_dict;
117 struct wpa_dbus_dict_entry entry;
118
119 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
120 goto error;
121 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
122 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
123 goto error;
124 if (!strcmp(entry.key, "driver") &&
125 (entry.type == DBUS_TYPE_STRING)) {
126 driver = os_strdup(entry.str_value);
127 wpa_dbus_dict_entry_clear(&entry);
--- 96 unchanged lines hidden (view full) ---
224 }
225
226 wpa_s = wpa_supplicant_get_iface_by_dbus_path(global, path);
227 if (wpa_s == NULL) {
228 reply = wpas_dbus_new_invalid_iface_error(message);
229 goto out;
230 }
231
232 if (!wpa_supplicant_remove_iface(global, wpa_s)) {
233 reply = wpas_dbus_new_success_reply(message);
234 } else {
235 reply = dbus_message_new_error(message,
236 WPAS_ERROR_REMOVE_ERROR,
237 "wpa_supplicant couldn't "
238 "remove this interface.");
239 }
240
--- 91 unchanged lines hidden (view full) ---
332 *
333 * Handler function for "scan" method call of a network device. Requests
334 * that wpa_supplicant perform a wireless scan as soon as possible
335 * on a particular wireless interface.
336 */
337DBusMessage * wpas_dbus_iface_scan(DBusMessage *message,
338 struct wpa_supplicant *wpa_s)
339{
340 wpa_s->scan_req = 2;
341 wpa_supplicant_req_scan(wpa_s, 0, 0);
342 return wpas_dbus_new_success_reply(message);
343}
344
345
346/**
347 * wpas_dbus_iface_scan_results - Get the results of a recent scan request
348 * @message: Pointer to incoming dbus message
--- 568 unchanged lines hidden (view full) ---
917 struct wpa_ssid *ssid)
918{
919 DBusMessage *reply = NULL;
920 struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
921 DBusMessageIter iter, iter_dict;
922
923 dbus_message_iter_init(message, &iter);
924
925 if (!wpa_dbus_dict_open_read(&iter, &iter_dict)) {
926 reply = wpas_dbus_new_invalid_opts_error(message, NULL);
927 goto out;
928 }
929
930 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
931 char *value = NULL;
932 size_t size = 50;
933 int ret;
--- 263 unchanged lines hidden (view full) ---
1197 char *opensc_engine_path = NULL;
1198 char *pkcs11_engine_path = NULL;
1199 char *pkcs11_module_path = NULL;
1200 struct wpa_dbus_dict_entry entry;
1201
1202 if (!dbus_message_iter_init(message, &iter))
1203 goto error;
1204
1205 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
1206 goto error;
1207
1208 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
1209 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry))
1210 goto error;
1211 if (!strcmp(entry.key, "opensc_engine_path") &&
1212 (entry.type == DBUS_TYPE_STRING)) {
1213 opensc_engine_path = os_strdup(entry.str_value);
--- 105 unchanged lines hidden (view full) ---
1319 struct wpa_supplicant *wpa_s)
1320{
1321 DBusMessage *reply = NULL;
1322 struct wpa_dbus_dict_entry entry = { .type = DBUS_TYPE_STRING };
1323 DBusMessageIter iter, iter_dict;
1324
1325 dbus_message_iter_init(message, &iter);
1326
1327 if (!wpa_dbus_dict_open_read(&iter, &iter_dict))
1328 return wpas_dbus_new_invalid_opts_error(message, NULL);
1329
1330 while (wpa_dbus_dict_has_dict_entry(&iter_dict)) {
1331 struct wpa_config_blob *blob;
1332
1333 if (!wpa_dbus_dict_get_entry(&iter_dict, &entry)) {
1334 reply = wpas_dbus_new_invalid_opts_error(message,
1335 NULL);
--- 93 unchanged lines hidden (view full) ---
1429 }
1430
1431 if (err_msg)
1432 return dbus_message_new_error(message, WPAS_ERROR_REMOVE_ERROR,
1433 err_msg);
1434
1435 return wpas_dbus_new_success_reply(message);
1436}