blob: 6a3e223e47165a11aa3c23b359932ca74462977c [file] [log] [blame]
Dmitry Shmidte4663042016-04-04 10:07:49 -07001/*
2 * binder interface for wpa_supplicant daemon
3 * Copyright (c) 2004-2016, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2004-2016, Roshan Pius <rpius@google.com>
5 *
6 * This software may be distributed under the terms of the BSD license.
7 * See README for more details.
8 */
9
10#include "iface.h"
11
12namespace wpa_supplicant_binder {
13
Roshan Pius54e763a2016-07-06 15:41:53 -070014Iface::Iface(struct wpa_global *wpa_global, const char ifname[])
15 : wpa_global_(wpa_global), ifname_(ifname)
16{
17}
Dmitry Shmidte4663042016-04-04 10:07:49 -070018
Roshan Pius54e763a2016-07-06 15:41:53 -070019android::binder::Status Iface::GetName(std::string *iface_name_out)
20{
21 // We could directly return the name we hold, but let's verify
22 // if the underlying iface still exists.
23 struct wpa_supplicant *wpa_s = retrieveIfacePtr();
24 if (!wpa_s) {
25 return android::binder::Status::fromServiceSpecificError(
Roshan Piusd6e37512016-07-07 13:20:46 -070026 ERROR_IFACE_INVALID,
Roshan Pius54e763a2016-07-06 15:41:53 -070027 "wpa_supplicant does not control this interface.");
28 }
29
30 *iface_name_out = ifname_;
31 return android::binder::Status::ok();
32}
33
Roshan Piusd6e37512016-07-07 13:20:46 -070034android::binder::Status Iface::AddNetwork(
35 android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out)
36{
37 return android::binder::Status::ok();
38}
39
40android::binder::Status Iface::RemoveNetwork(int network_id)
41{
42 return android::binder::Status::ok();
43}
44
Roshan Pius54e763a2016-07-06 15:41:53 -070045/**
46 * Retrieve the underlying |wpa_supplicant| struct pointer for
47 * this iface.
48 * If the underlying iface is removed, then all RPC method calls
49 * on this object will return failure.
50 */
51wpa_supplicant *Iface::retrieveIfacePtr()
52{
53 return wpa_supplicant_get_iface(
54 (struct wpa_global *)wpa_global_, ifname_.c_str());
55}
56
57} // namespace wpa_supplicant_binder