blob: 4faa147bb2e288acad3dc2e2acbeba6a163fa55f [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(
26 ERROR_IFACE_UNKNOWN,
27 "wpa_supplicant does not control this interface.");
28 }
29
30 *iface_name_out = ifname_;
31 return android::binder::Status::ok();
32}
33
34/**
35 * Retrieve the underlying |wpa_supplicant| struct pointer for
36 * this iface.
37 * If the underlying iface is removed, then all RPC method calls
38 * on this object will return failure.
39 */
40wpa_supplicant *Iface::retrieveIfacePtr()
41{
42 return wpa_supplicant_get_iface(
43 (struct wpa_global *)wpa_global_, ifname_.c_str());
44}
45
46} // namespace wpa_supplicant_binder