Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 12 | namespace wpa_supplicant_binder { |
| 13 | |
Roshan Pius | 54e763a | 2016-07-06 15:41:53 -0700 | [diff] [blame] | 14 | Iface::Iface(struct wpa_global *wpa_global, const char ifname[]) |
| 15 | : wpa_global_(wpa_global), ifname_(ifname) |
| 16 | { |
| 17 | } |
Dmitry Shmidt | e466304 | 2016-04-04 10:07:49 -0700 | [diff] [blame] | 18 | |
Roshan Pius | 54e763a | 2016-07-06 15:41:53 -0700 | [diff] [blame] | 19 | android::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 Pius | d6e3751 | 2016-07-07 13:20:46 -0700 | [diff] [blame] | 26 | ERROR_IFACE_INVALID, |
Roshan Pius | 54e763a | 2016-07-06 15:41:53 -0700 | [diff] [blame] | 27 | "wpa_supplicant does not control this interface."); |
| 28 | } |
| 29 | |
| 30 | *iface_name_out = ifname_; |
| 31 | return android::binder::Status::ok(); |
| 32 | } |
| 33 | |
Roshan Pius | d6e3751 | 2016-07-07 13:20:46 -0700 | [diff] [blame] | 34 | android::binder::Status Iface::AddNetwork( |
| 35 | android::sp<fi::w1::wpa_supplicant::INetwork> *network_object_out) |
| 36 | { |
| 37 | return android::binder::Status::ok(); |
| 38 | } |
| 39 | |
| 40 | android::binder::Status Iface::RemoveNetwork(int network_id) |
| 41 | { |
| 42 | return android::binder::Status::ok(); |
| 43 | } |
| 44 | |
Roshan Pius | 54e763a | 2016-07-06 15:41:53 -0700 | [diff] [blame] | 45 | /** |
| 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 | */ |
| 51 | wpa_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 |