mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-28 18:28:23 -05:00
binder: Clang format the source code
Add a ".clang-format" file which is pretty close to the rest of wpa_supplicant code base and reformat the binder codebase. Signed-off-by: Roshan Pius <rpius@google.com>
This commit is contained in:
parent
fe1d0771f7
commit
a1979469fd
9
wpa_supplicant/binder/.clang-format
Normal file
9
wpa_supplicant/binder/.clang-format
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 8
|
||||||
|
UseTab: Always
|
||||||
|
BreakBeforeBraces: Mozilla
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
IndentCaseLabels: false
|
||||||
|
AccessModifierOffset: -8
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
SortIncludes: false
|
@ -8,36 +8,35 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <binder/IPCThreadState.h>
|
#include <binder/IPCThreadState.h>
|
||||||
#include <binder/ProcessState.h>
|
|
||||||
#include <binder/IServiceManager.h>
|
#include <binder/IServiceManager.h>
|
||||||
|
#include <binder/ProcessState.h>
|
||||||
|
|
||||||
#include "binder_manager.h"
|
#include "binder_manager.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "utils/includes.h"
|
|
||||||
#include "utils/common.h"
|
|
||||||
#include "utils/eloop.h"
|
|
||||||
#include "binder.h"
|
#include "binder.h"
|
||||||
#include "binder_i.h"
|
#include "binder_i.h"
|
||||||
|
#include "utils/common.h"
|
||||||
|
#include "utils/eloop.h"
|
||||||
|
#include "utils/includes.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
void wpas_binder_sock_handler(int sock, void *eloop_ctx, void *sock_ctx)
|
void wpas_binder_sock_handler(int sock, void *eloop_ctx, void *sock_ctx)
|
||||||
{
|
{
|
||||||
struct wpa_global *global = (wpa_global *) eloop_ctx;
|
struct wpa_global *global = (wpa_global *)eloop_ctx;
|
||||||
struct wpas_binder_priv *priv = (wpas_binder_priv *) sock_ctx;
|
struct wpas_binder_priv *priv = (wpas_binder_priv *)sock_ctx;
|
||||||
|
|
||||||
wpa_printf(MSG_DEBUG, "Processing binder events on FD %d",
|
wpa_printf(
|
||||||
priv->binder_fd);
|
MSG_DEBUG, "Processing binder events on FD %d", priv->binder_fd);
|
||||||
android::IPCThreadState::self()->handlePolledCommands();
|
android::IPCThreadState::self()->handlePolledCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wpas_binder_priv *wpas_binder_init(struct wpa_global *global)
|
||||||
struct wpas_binder_priv * wpas_binder_init(struct wpa_global *global)
|
|
||||||
{
|
{
|
||||||
struct wpas_binder_priv *priv;
|
struct wpas_binder_priv *priv;
|
||||||
wpa_supplicant_binder::BinderManager *binder_manager;
|
wpa_supplicant_binder::BinderManager *binder_manager;
|
||||||
|
|
||||||
priv = (wpas_binder_priv *) os_zalloc(sizeof(*priv));
|
priv = (wpas_binder_priv *)os_zalloc(sizeof(*priv));
|
||||||
if (!priv)
|
if (!priv)
|
||||||
return NULL;
|
return NULL;
|
||||||
priv->global = global;
|
priv->global = global;
|
||||||
@ -49,8 +48,8 @@ struct wpas_binder_priv * wpas_binder_init(struct wpa_global *global)
|
|||||||
if (priv->binder_fd < 0)
|
if (priv->binder_fd < 0)
|
||||||
goto err;
|
goto err;
|
||||||
/* Look for read events from the binder socket in the eloop. */
|
/* Look for read events from the binder socket in the eloop. */
|
||||||
if (eloop_register_read_sock(priv->binder_fd, wpas_binder_sock_handler,
|
if (eloop_register_read_sock(
|
||||||
global, priv) < 0)
|
priv->binder_fd, wpas_binder_sock_handler, global, priv) < 0)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
binder_manager = wpa_supplicant_binder::BinderManager::getInstance();
|
binder_manager = wpa_supplicant_binder::BinderManager::getInstance();
|
||||||
@ -59,7 +58,7 @@ struct wpas_binder_priv * wpas_binder_init(struct wpa_global *global)
|
|||||||
binder_manager->registerBinderService(global);
|
binder_manager->registerBinderService(global);
|
||||||
/* We may not need to store this binder manager reference in the
|
/* We may not need to store this binder manager reference in the
|
||||||
* global data strucure because we've made it a singleton class. */
|
* global data strucure because we've made it a singleton class. */
|
||||||
priv->binder_manager = (void *) binder_manager;
|
priv->binder_manager = (void *)binder_manager;
|
||||||
|
|
||||||
return priv;
|
return priv;
|
||||||
|
|
||||||
@ -68,7 +67,6 @@ err:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wpas_binder_deinit(struct wpas_binder_priv *priv)
|
void wpas_binder_deinit(struct wpas_binder_priv *priv)
|
||||||
{
|
{
|
||||||
if (!priv)
|
if (!priv)
|
||||||
@ -79,28 +77,26 @@ void wpas_binder_deinit(struct wpas_binder_priv *priv)
|
|||||||
android::IPCThreadState::shutdown();
|
android::IPCThreadState::shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
|
int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
if (!wpa_s->global->binder)
|
if (!wpa_s->global->binder)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
wpa_supplicant_binder::BinderManager *binder_manager =
|
wpa_supplicant_binder::BinderManager *binder_manager =
|
||||||
wpa_supplicant_binder::BinderManager::getInstance();
|
wpa_supplicant_binder::BinderManager::getInstance();
|
||||||
if (!binder_manager)
|
if (!binder_manager)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
return binder_manager->registerInterface(wpa_s);
|
return binder_manager->registerInterface(wpa_s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s)
|
int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
if (!wpa_s->global->binder)
|
if (!wpa_s->global->binder)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
wpa_supplicant_binder::BinderManager *binder_manager =
|
wpa_supplicant_binder::BinderManager *binder_manager =
|
||||||
wpa_supplicant_binder::BinderManager::getInstance();
|
wpa_supplicant_binder::BinderManager::getInstance();
|
||||||
if (!binder_manager)
|
if (!binder_manager)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BINDER_H
|
#ifndef WPA_SUPPLICANT_BINDER_BINDER_H
|
||||||
#define BINDER_H
|
#define WPA_SUPPLICANT_BINDER_BINDER_H
|
||||||
|
|
||||||
#ifdef _cplusplus
|
#ifdef _cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -22,13 +22,13 @@ extern "C" {
|
|||||||
struct wpas_binder_priv;
|
struct wpas_binder_priv;
|
||||||
struct wpa_global;
|
struct wpa_global;
|
||||||
|
|
||||||
struct wpas_binder_priv * wpas_binder_init(struct wpa_global *global);
|
struct wpas_binder_priv *wpas_binder_init(struct wpa_global *global);
|
||||||
void wpas_binder_deinit(struct wpas_binder_priv *priv);
|
void wpas_binder_deinit(struct wpas_binder_priv *priv);
|
||||||
|
|
||||||
#ifdef CONFIG_CTRL_IFACE_BINDER
|
#ifdef CONFIG_CTRL_IFACE_BINDER
|
||||||
int wpas_binder_register_interface(struct wpa_supplicant *wpa_s);
|
int wpas_binder_register_interface(struct wpa_supplicant *wpa_s);
|
||||||
int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s);
|
int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s);
|
||||||
#else /* CONFIG_CTRL_IFACE_BINDER */
|
#else /* CONFIG_CTRL_IFACE_BINDER */
|
||||||
static inline int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
|
static inline int wpas_binder_register_interface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
@ -43,4 +43,4 @@ static inline int wpas_binder_unregister_interface(struct wpa_supplicant *wpa_s)
|
|||||||
}
|
}
|
||||||
#endif /* _cplusplus */
|
#endif /* _cplusplus */
|
||||||
|
|
||||||
#endif /* BINDER_H */
|
#endif /* WPA_SUPPLICANT_BINDER_BINDER_H */
|
||||||
|
@ -7,8 +7,8 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BINDER_CONSTANTS_H
|
#ifndef WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H
|
||||||
#define BINDER_CONSTANTS_H
|
#define WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H
|
||||||
|
|
||||||
namespace wpa_supplicant_binder {
|
namespace wpa_supplicant_binder {
|
||||||
namespace binder_constants {
|
namespace binder_constants {
|
||||||
@ -18,4 +18,4 @@ extern const char kServiceName[];
|
|||||||
} /* namespace binder_constants */
|
} /* namespace binder_constants */
|
||||||
} /* namespace wpa_supplicant_binder */
|
} /* namespace wpa_supplicant_binder */
|
||||||
|
|
||||||
#endif /* BINDER_CONSTANTS_H */
|
#endif /* WPA_SUPPLICANT_BINDER_BINDER_CONSTANTS_H */
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif // _cplusplus
|
#endif // _cplusplus
|
||||||
|
|
||||||
struct wpas_binder_priv {
|
struct wpas_binder_priv
|
||||||
|
{
|
||||||
int binder_fd;
|
int binder_fd;
|
||||||
struct wpa_global *global;
|
struct wpa_global *global;
|
||||||
void *binder_manager;
|
void *binder_manager;
|
||||||
|
@ -13,22 +13,21 @@
|
|||||||
#include "binder_manager.h"
|
#include "binder_manager.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "utils/includes.h"
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
|
#include "utils/includes.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace wpa_supplicant_binder {
|
namespace wpa_supplicant_binder {
|
||||||
|
|
||||||
BinderManager *BinderManager::instance_ = NULL;
|
BinderManager *BinderManager::instance_ = NULL;
|
||||||
|
|
||||||
BinderManager * BinderManager::getInstance()
|
BinderManager *BinderManager::getInstance()
|
||||||
{
|
{
|
||||||
if (!instance_)
|
if (!instance_)
|
||||||
instance_ = new BinderManager();
|
instance_ = new BinderManager();
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BinderManager::destroyInstance()
|
void BinderManager::destroyInstance()
|
||||||
{
|
{
|
||||||
if (instance_)
|
if (instance_)
|
||||||
@ -36,7 +35,6 @@ void BinderManager::destroyInstance()
|
|||||||
instance_ = NULL;
|
instance_ = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BinderManager::registerBinderService(struct wpa_global *global)
|
int BinderManager::registerBinderService(struct wpa_global *global)
|
||||||
{
|
{
|
||||||
/* Create the main binder service object and register with
|
/* Create the main binder service object and register with
|
||||||
@ -44,12 +42,10 @@ int BinderManager::registerBinderService(struct wpa_global *global)
|
|||||||
supplicant_object_ = new Supplicant(global);
|
supplicant_object_ = new Supplicant(global);
|
||||||
android::String16 service_name(binder_constants::kServiceName);
|
android::String16 service_name(binder_constants::kServiceName);
|
||||||
android::defaultServiceManager()->addService(
|
android::defaultServiceManager()->addService(
|
||||||
service_name,
|
service_name, android::IInterface::asBinder(supplicant_object_));
|
||||||
android::IInterface::asBinder(supplicant_object_));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BinderManager::registerInterface(struct wpa_supplicant *wpa_s)
|
int BinderManager::registerInterface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
if (!wpa_s)
|
if (!wpa_s)
|
||||||
@ -72,7 +68,6 @@ int BinderManager::registerInterface(struct wpa_supplicant *wpa_s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BinderManager::unregisterInterface(struct wpa_supplicant *wpa_s)
|
int BinderManager::unregisterInterface(struct wpa_supplicant *wpa_s)
|
||||||
{
|
{
|
||||||
if (!wpa_s || !wpa_s->binder_object_key)
|
if (!wpa_s || !wpa_s->binder_object_key)
|
||||||
@ -88,10 +83,9 @@ int BinderManager::unregisterInterface(struct wpa_supplicant *wpa_s)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int BinderManager::getIfaceBinderObjectByKey(
|
int BinderManager::getIfaceBinderObjectByKey(
|
||||||
const void *iface_object_key,
|
const void *iface_object_key,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *iface_object)
|
android::sp<fi::w1::wpa_supplicant::IIface> *iface_object)
|
||||||
{
|
{
|
||||||
if (!iface_object_key || !iface_object)
|
if (!iface_object_key || !iface_object)
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef BINDER_MANAGER_H
|
#ifndef WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
|
||||||
#define BINDER_MANAGER_H
|
#define WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "supplicant.h"
|
|
||||||
#include "iface.h"
|
#include "iface.h"
|
||||||
|
#include "supplicant.h"
|
||||||
|
|
||||||
struct wpa_global;
|
struct wpa_global;
|
||||||
struct wpa_supplicant;
|
struct wpa_supplicant;
|
||||||
@ -27,16 +27,17 @@ namespace wpa_supplicant_binder {
|
|||||||
* class which is created by the supplicant core and can be used
|
* class which is created by the supplicant core and can be used
|
||||||
* to get references to the binder objects.
|
* to get references to the binder objects.
|
||||||
*/
|
*/
|
||||||
class BinderManager {
|
class BinderManager
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static BinderManager * getInstance();
|
static BinderManager *getInstance();
|
||||||
static void destroyInstance();
|
static void destroyInstance();
|
||||||
int registerBinderService(struct wpa_global *global);
|
int registerBinderService(struct wpa_global *global);
|
||||||
int registerInterface(struct wpa_supplicant *wpa_s);
|
int registerInterface(struct wpa_supplicant *wpa_s);
|
||||||
int unregisterInterface(struct wpa_supplicant *wpa_s);
|
int unregisterInterface(struct wpa_supplicant *wpa_s);
|
||||||
int getIfaceBinderObjectByKey(
|
int getIfaceBinderObjectByKey(
|
||||||
const void *iface_object_key,
|
const void *iface_object_key,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
|
android::sp<fi::w1::wpa_supplicant::IIface> *iface_object);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinderManager() = default;
|
BinderManager() = default;
|
||||||
@ -54,4 +55,4 @@ private:
|
|||||||
|
|
||||||
} /* namespace wpa_supplicant_binder */
|
} /* namespace wpa_supplicant_binder */
|
||||||
|
|
||||||
#endif /* BINDER_MANAGER_H */
|
#endif /* WPA_SUPPLICANT_BINDER_BINDER_MANAGER_H */
|
||||||
|
@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
namespace wpa_supplicant_binder {
|
namespace wpa_supplicant_binder {
|
||||||
|
|
||||||
Iface::Iface(struct wpa_supplicant *wpa_s)
|
Iface::Iface(struct wpa_supplicant *wpa_s) : wpa_s_(wpa_s) {}
|
||||||
: wpa_s_(wpa_s)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
} /* namespace wpa_supplicant_binder */
|
} /* namespace wpa_supplicant_binder */
|
||||||
|
@ -7,14 +7,14 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IFACE_H
|
#ifndef WPA_SUPPLICANT_BINDER_IFACE_H
|
||||||
#define IFACE_H
|
#define WPA_SUPPLICANT_BINDER_IFACE_H
|
||||||
|
|
||||||
#include "fi/w1/wpa_supplicant/BnIface.h"
|
#include "fi/w1/wpa_supplicant/BnIface.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "utils/includes.h"
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
|
#include "utils/includes.h"
|
||||||
#include "../wpa_supplicant_i.h"
|
#include "../wpa_supplicant_i.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,4 +39,4 @@ private:
|
|||||||
|
|
||||||
} /* namespace wpa_supplicant_binder */
|
} /* namespace wpa_supplicant_binder */
|
||||||
|
|
||||||
#endif /* IFACE_H */
|
#endif /* WPA_SUPPLICANT_BINDER_IFACE_H */
|
||||||
|
@ -7,28 +7,24 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "binder_manager.h"
|
|
||||||
#include "supplicant.h"
|
#include "supplicant.h"
|
||||||
|
#include "binder_manager.h"
|
||||||
|
|
||||||
namespace wpa_supplicant_binder {
|
namespace wpa_supplicant_binder {
|
||||||
|
|
||||||
Supplicant::Supplicant(struct wpa_global *global)
|
Supplicant::Supplicant(struct wpa_global *global) : wpa_global_(global) {}
|
||||||
: wpa_global_(global)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
android::binder::Status Supplicant::CreateInterface(
|
android::binder::Status Supplicant::CreateInterface(
|
||||||
const android::os::PersistableBundle ¶ms,
|
const android::os::PersistableBundle ¶ms,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
||||||
{
|
{
|
||||||
android::String16 driver, ifname, confname, bridge_ifname;
|
android::String16 driver, ifname, confname, bridge_ifname;
|
||||||
|
|
||||||
/* Check if required Ifname argument is missing */
|
/* Check if required Ifname argument is missing */
|
||||||
if (!params.getString(android::String16("Ifname"), &ifname))
|
if (!params.getString(android::String16("Ifname"), &ifname))
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_INVALID_ARGS,
|
ERROR_INVALID_ARGS,
|
||||||
android::String8("Ifname missing in params."));
|
android::String8("Ifname missing in params."));
|
||||||
/* Retrieve the remaining params from the dictionary */
|
/* Retrieve the remaining params from the dictionary */
|
||||||
params.getString(android::String16("Driver"), &driver);
|
params.getString(android::String16("Driver"), &driver);
|
||||||
params.getString(android::String16("ConfigFile"), &confname);
|
params.getString(android::String16("ConfigFile"), &confname);
|
||||||
@ -38,11 +34,12 @@ android::binder::Status Supplicant::CreateInterface(
|
|||||||
* Try to get the wpa_supplicant record for this iface, return
|
* Try to get the wpa_supplicant record for this iface, return
|
||||||
* an error if we already control it.
|
* an error if we already control it.
|
||||||
*/
|
*/
|
||||||
if (wpa_supplicant_get_iface(wpa_global_,
|
if (wpa_supplicant_get_iface(
|
||||||
android::String8(ifname).string()) != NULL)
|
wpa_global_, android::String8(ifname).string()) != NULL)
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_IFACE_EXISTS,
|
ERROR_IFACE_EXISTS,
|
||||||
android::String8("wpa_supplicant already controls this interface."));
|
android::String8("wpa_supplicant already controls this "
|
||||||
|
"interface."));
|
||||||
|
|
||||||
android::binder::Status status;
|
android::binder::Status status;
|
||||||
struct wpa_supplicant *wpa_s = NULL;
|
struct wpa_supplicant *wpa_s = NULL;
|
||||||
@ -52,36 +49,38 @@ android::binder::Status Supplicant::CreateInterface(
|
|||||||
iface.driver = os_strdup(android::String8(driver).string());
|
iface.driver = os_strdup(android::String8(driver).string());
|
||||||
iface.ifname = os_strdup(android::String8(ifname).string());
|
iface.ifname = os_strdup(android::String8(ifname).string());
|
||||||
iface.confname = os_strdup(android::String8(confname).string());
|
iface.confname = os_strdup(android::String8(confname).string());
|
||||||
iface.bridge_ifname = os_strdup(
|
iface.bridge_ifname =
|
||||||
android::String8(bridge_ifname).string());
|
os_strdup(android::String8(bridge_ifname).string());
|
||||||
/* Otherwise, have wpa_supplicant attach to it. */
|
/* Otherwise, have wpa_supplicant attach to it. */
|
||||||
wpa_s = wpa_supplicant_add_iface(wpa_global_, &iface, NULL);
|
wpa_s = wpa_supplicant_add_iface(wpa_global_, &iface, NULL);
|
||||||
/* The supplicant core creates a corresponding binder object via
|
/* The supplicant core creates a corresponding binder object via
|
||||||
* BinderManager when |wpa_supplicant_add_iface| is called. */
|
* BinderManager when |wpa_supplicant_add_iface| is called. */
|
||||||
if (!wpa_s || !wpa_s->binder_object_key) {
|
if (!wpa_s || !wpa_s->binder_object_key) {
|
||||||
status = android::binder::Status::fromServiceSpecificError(
|
status = android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_UNKNOWN,
|
ERROR_UNKNOWN,
|
||||||
android::String8("wpa_supplicant couldn't grab this interface."));
|
android::String8(
|
||||||
|
"wpa_supplicant couldn't grab this interface."));
|
||||||
} else {
|
} else {
|
||||||
BinderManager *binder_manager = BinderManager::getInstance();
|
BinderManager *binder_manager = BinderManager::getInstance();
|
||||||
|
|
||||||
if (!binder_manager ||
|
if (!binder_manager ||
|
||||||
binder_manager->getIfaceBinderObjectByKey(
|
binder_manager->getIfaceBinderObjectByKey(
|
||||||
wpa_s->binder_object_key, aidl_return))
|
wpa_s->binder_object_key, aidl_return))
|
||||||
status = android::binder::Status::fromServiceSpecificError(
|
status =
|
||||||
|
android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_UNKNOWN,
|
ERROR_UNKNOWN,
|
||||||
android::String8("wpa_supplicant encountered a binder error."));
|
android::String8("wpa_supplicant encountered a "
|
||||||
|
"binder error."));
|
||||||
else
|
else
|
||||||
status = android::binder::Status::ok();
|
status = android::binder::Status::ok();
|
||||||
}
|
}
|
||||||
os_free((void *) iface.driver);
|
os_free((void *)iface.driver);
|
||||||
os_free((void *) iface.ifname);
|
os_free((void *)iface.ifname);
|
||||||
os_free((void *) iface.confname);
|
os_free((void *)iface.confname);
|
||||||
os_free((void *) iface.bridge_ifname);
|
os_free((void *)iface.bridge_ifname);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android::binder::Status Supplicant::RemoveInterface(const std::string &ifname)
|
android::binder::Status Supplicant::RemoveInterface(const std::string &ifname)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s;
|
struct wpa_supplicant *wpa_s;
|
||||||
@ -89,35 +88,38 @@ android::binder::Status Supplicant::RemoveInterface(const std::string &ifname)
|
|||||||
wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
|
wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
|
||||||
if (!wpa_s || !wpa_s->binder_object_key)
|
if (!wpa_s || !wpa_s->binder_object_key)
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_IFACE_UNKNOWN,
|
ERROR_IFACE_UNKNOWN,
|
||||||
android::String8("wpa_supplicant does not control this interface."));
|
android::String8("wpa_supplicant does not control this "
|
||||||
|
"interface."));
|
||||||
if (wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0))
|
if (wpa_supplicant_remove_iface(wpa_global_, wpa_s, 0))
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_UNKNOWN,
|
ERROR_UNKNOWN,
|
||||||
android::String8("wpa_supplicant couldn't remove this interface."));
|
android::String8(
|
||||||
|
"wpa_supplicant couldn't remove this interface."));
|
||||||
return android::binder::Status::ok();
|
return android::binder::Status::ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
android::binder::Status Supplicant::GetInterface(
|
android::binder::Status Supplicant::GetInterface(
|
||||||
const std::string &ifname,
|
const std::string &ifname,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s;
|
struct wpa_supplicant *wpa_s;
|
||||||
|
|
||||||
wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
|
wpa_s = wpa_supplicant_get_iface(wpa_global_, ifname.c_str());
|
||||||
if (!wpa_s || !wpa_s->binder_object_key)
|
if (!wpa_s || !wpa_s->binder_object_key)
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_IFACE_UNKNOWN,
|
ERROR_IFACE_UNKNOWN,
|
||||||
android::String8("wpa_supplicant does not control this interface."));
|
android::String8(
|
||||||
|
"wpa_supplicant does not control this interface."));
|
||||||
|
|
||||||
BinderManager *binder_manager = BinderManager::getInstance();
|
BinderManager *binder_manager = BinderManager::getInstance();
|
||||||
if (!binder_manager ||
|
if (!binder_manager ||
|
||||||
binder_manager->getIfaceBinderObjectByKey(wpa_s->binder_object_key,
|
binder_manager->getIfaceBinderObjectByKey(
|
||||||
aidl_return))
|
wpa_s->binder_object_key, aidl_return))
|
||||||
return android::binder::Status::fromServiceSpecificError(
|
return android::binder::Status::fromServiceSpecificError(
|
||||||
ERROR_UNKNOWN,
|
ERROR_UNKNOWN,
|
||||||
android::String8("wpa_supplicant encountered a binder error."));
|
android::String8(
|
||||||
|
"wpa_supplicant encountered a binder error."));
|
||||||
|
|
||||||
return android::binder::Status::ok();
|
return android::binder::Status::ok();
|
||||||
}
|
}
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
* See README for more details.
|
* See README for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SUPPLICANT_H
|
#ifndef WPA_SUPPLICANT_BINDER_SUPPLICANT_H
|
||||||
#define SUPPLICANT_H
|
#define WPA_SUPPLICANT_BINDER_SUPPLICANT_H
|
||||||
|
|
||||||
#include "fi/w1/wpa_supplicant/BnSupplicant.h"
|
#include "fi/w1/wpa_supplicant/BnSupplicant.h"
|
||||||
#include "fi/w1/wpa_supplicant/IIface.h"
|
#include "fi/w1/wpa_supplicant/IIface.h"
|
||||||
#include "fi/w1/wpa_supplicant/ISupplicantCallbacks.h"
|
#include "fi/w1/wpa_supplicant/ISupplicantCallbacks.h"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "utils/includes.h"
|
|
||||||
#include "utils/common.h"
|
#include "utils/common.h"
|
||||||
|
#include "utils/includes.h"
|
||||||
#include "../wpa_supplicant_i.h"
|
#include "../wpa_supplicant_i.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,24 +34,22 @@ public:
|
|||||||
virtual ~Supplicant() = default;
|
virtual ~Supplicant() = default;
|
||||||
|
|
||||||
android::binder::Status CreateInterface(
|
android::binder::Status CreateInterface(
|
||||||
const android::os::PersistableBundle ¶ms,
|
const android::os::PersistableBundle ¶ms,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return) override;
|
||||||
override;
|
android::binder::Status
|
||||||
android::binder::Status RemoveInterface(
|
RemoveInterface(const std::string &ifname) override;
|
||||||
const std::string &ifname) override;
|
|
||||||
android::binder::Status GetInterface(
|
android::binder::Status GetInterface(
|
||||||
const std::string &ifname,
|
const std::string &ifname,
|
||||||
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return)
|
android::sp<fi::w1::wpa_supplicant::IIface> *aidl_return) override;
|
||||||
override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/* Raw pointer to the global structure maintained by the core. */
|
/* Raw pointer to the global structure maintained by the core. */
|
||||||
struct wpa_global *wpa_global_;
|
struct wpa_global *wpa_global_;
|
||||||
/* All the callback objects registered by the clients. */
|
/* All the callback objects registered by the clients. */
|
||||||
std::vector<android::sp<fi::w1::wpa_supplicant::ISupplicantCallbacks>>
|
std::vector<android::sp<fi::w1::wpa_supplicant::ISupplicantCallbacks>>
|
||||||
callbacks_;
|
callbacks_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace wpa_supplicant_binder */
|
} /* namespace wpa_supplicant_binder */
|
||||||
|
|
||||||
#endif /* SUPPLICANT_H */
|
#endif /* WPA_SUPPLICANT_BINDER_SUPPLICANT_H */
|
||||||
|
Loading…
Reference in New Issue
Block a user