summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Qiu <zqiu@google.com>2015-10-22 15:21:27 -0700
committerPeter Qiu <zqiu@google.com>2015-10-22 16:32:50 -0700
commitc7717b6a957218665fe390115a5c8535dcf39c11 (patch)
tree949559104d281791472c584f0479005a134c13d4
parentbe12882aa9307c62e1ae6ad8a69d5c663bed3b3e (diff)
downloadapmanager-c7717b6a957218665fe390115a5c8535dcf39c11.tar.gz
shill_manager: add APIs for setting interface modes
This is needed to allow apmanager to setup an AP/station mode interface when starting/stopping an AP service. Bug: 25113165 TEST=Device setup on Brillo boards Change-Id: I2b5b708409fe1c59e0333b1e4347d46ba0162847
-rw-r--r--shill_dbus_proxy.cc30
-rw-r--r--shill_dbus_proxy.h4
-rw-r--r--shill_manager.cc12
-rw-r--r--shill_manager.h6
-rw-r--r--shill_proxy_interface.h6
5 files changed, 58 insertions, 0 deletions
diff --git a/shill_dbus_proxy.cc b/shill_dbus_proxy.cc
index fed6555..75d243f 100644
--- a/shill_dbus_proxy.cc
+++ b/shill_dbus_proxy.cc
@@ -82,6 +82,36 @@ bool ShillDBusProxy::ReleaseInterface(const string& interface_name) {
return true;
}
+#if defined(__BRILLO__)
+bool ShillDBusProxy::SetupApModeInterface(string* interface_name) {
+ if (!service_available_) {
+ LOG(ERROR) << "SetupApModeInterface failed: service not available";
+ return false;
+ }
+ brillo::ErrorPtr error;
+ if (!manager_proxy_->SetupApModeInterface(interface_name, &error)) {
+ LOG(ERROR) << "Failed to setup AP mode interface from shill: "
+ << error->GetCode() << " " << error->GetMessage();
+ return false;
+ }
+ return true;
+}
+
+bool ShillDBusProxy::SetupStationModeInterface(string* interface_name) {
+ if (!service_available_) {
+ LOG(ERROR) << "SetupStationModeInterface failed: service not available";
+ return false;
+ }
+ brillo::ErrorPtr error;
+ if (!manager_proxy_->SetupStationModeInterface(interface_name, &error)) {
+ LOG(ERROR) << "Failed to setup station mode interface from shill: "
+ << error->GetCode() << " " << error->GetMessage();
+ return false;
+ }
+ return true;
+}
+#endif // __BRILLO__
+
void ShillDBusProxy::OnServiceAvailable(bool available) {
LOG(INFO) << __func__ << ": " << available;
// Nothing to be done if proxy service not available.
diff --git a/shill_dbus_proxy.h b/shill_dbus_proxy.h
index 55ce169..8d5db25 100644
--- a/shill_dbus_proxy.h
+++ b/shill_dbus_proxy.h
@@ -38,6 +38,10 @@ class ShillDBusProxy : public ShillProxyInterface {
// Implementation of ShillProxyInterface.
bool ClaimInterface(const std::string& interface_name) override;
bool ReleaseInterface(const std::string& interface_name) override;
+#if defined(__BRILLO__)
+ bool SetupApModeInterface(std::string* interface_name) override;
+ bool SetupStationModeInterface(std::string* interface_name) override;
+#endif // __BRILLO__
private:
void OnServiceAvailable(bool service_available);
diff --git a/shill_manager.cc b/shill_manager.cc
index 1e5c2fa..2261b8e 100644
--- a/shill_manager.cc
+++ b/shill_manager.cc
@@ -51,6 +51,18 @@ void ShillManager::ReleaseInterface(const string& interface_name) {
claimed_interfaces_.erase(interface_name);
}
+#if defined(__BRILLO__)
+bool ShillManager::SetupApModeInterface(string* interface_name) {
+ CHECK(shill_proxy_) << "Proxy not initialized yet";
+ return shill_proxy_->SetupApModeInterface(interface_name);
+}
+
+bool ShillManager::SetupStationModeInterface(string* interface_name) {
+ CHECK(shill_proxy_) << "Proxy not initialized yet";
+ return shill_proxy_->SetupStationModeInterface(interface_name);
+}
+#endif // __BRILLO__
+
void ShillManager::OnShillServiceAppeared() {
LOG(INFO) << __func__;
// Claim all interfaces from shill service in case this is a new instance.
diff --git a/shill_manager.h b/shill_manager.h
index dd0089b..12e9d16 100644
--- a/shill_manager.h
+++ b/shill_manager.h
@@ -40,6 +40,12 @@ class ShillManager {
virtual void ClaimInterface(const std::string& interface_name);
// Release the given interface |interface_name| to shill.
virtual void ReleaseInterface(const std::string& interface_name);
+#if defined(__BRILLO__)
+ // Setup an AP mode interface.
+ virtual bool SetupApModeInterface(std::string* interface_name);
+ // Setup a station mode interface.
+ virtual bool SetupStationModeInterface(std::string* interface_name);
+#endif // __BRILLO__
private:
void OnShillServiceAppeared();
diff --git a/shill_proxy_interface.h b/shill_proxy_interface.h
index 9fe6b80..73bf85c 100644
--- a/shill_proxy_interface.h
+++ b/shill_proxy_interface.h
@@ -29,6 +29,12 @@ class ShillProxyInterface {
virtual bool ClaimInterface(const std::string& interface_name) = 0;
// Release the given interface |interface_name| to shill.
virtual bool ReleaseInterface(const std::string& interface_name) = 0;
+#if defined(__BRILLO__)
+ // Setup an AP mode interface.
+ virtual bool SetupApModeInterface(std::string* interface_name) = 0;
+ // Setup a station mode interface.
+ virtual bool SetupStationModeInterface(std::string* interface_name) = 0;
+#endif // __BRILLO__
};
} // namespace apmanager