summaryrefslogtreecommitdiffstats
path: root/recovery_ui
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-16 05:00:57 +0100
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2022-02-16 05:00:57 +0100
commitab08594e8b4c0feb1fd573842d6c647de21673ff (patch)
treed3b015058c2c66e4c0b3d72ee2aa755958370b8f /recovery_ui
parentSnap for 8183730 from 5a9717d210e7cce03ef4919dbe87defa68ea924a to udc-release (diff)
parentMerge "Enable different interface for fastboot for cf" am: 46a3704702 am: 65700df1fe am: 4aed1b7059 (diff)
downloadandroid_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar.gz
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar.bz2
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar.lz
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar.xz
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.tar.zst
android_bootable_recovery-ab08594e8b4c0feb1fd573842d6c647de21673ff.zip
Diffstat (limited to 'recovery_ui')
-rw-r--r--recovery_ui/ethernet_device.cpp12
-rw-r--r--recovery_ui/include/recovery_ui/ethernet_device.h3
2 files changed, 9 insertions, 6 deletions
diff --git a/recovery_ui/ethernet_device.cpp b/recovery_ui/ethernet_device.cpp
index d79f41dec..0318db853 100644
--- a/recovery_ui/ethernet_device.cpp
+++ b/recovery_ui/ethernet_device.cpp
@@ -30,10 +30,12 @@
#include "recovery_ui/ethernet_device.h"
#include "recovery_ui/ethernet_ui.h"
-const std::string EthernetDevice::interface = "eth0";
+// Android TV defaults to eth0 for it's interface
+EthernetDevice::EthernetDevice(EthernetRecoveryUI* ui) : EthernetDevice(ui, "eth0") {}
-EthernetDevice::EthernetDevice(EthernetRecoveryUI* ui)
- : Device(ui), ctl_sock_(socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)) {
+// Allow future users to define the interface as they prefer
+EthernetDevice::EthernetDevice(EthernetRecoveryUI* ui, std::string interface)
+ : Device(ui), ctl_sock_(socket(AF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0)), interface_(interface) {
if (ctl_sock_ < 0) {
PLOG(ERROR) << "Failed to open socket";
}
@@ -63,7 +65,7 @@ int EthernetDevice::SetInterfaceFlags(const unsigned set, const unsigned clr) {
}
memset(&ifr, 0, sizeof(struct ifreq));
- strncpy(ifr.ifr_name, interface.c_str(), IFNAMSIZ);
+ strncpy(ifr.ifr_name, interface_.c_str(), IFNAMSIZ);
ifr.ifr_name[IFNAMSIZ - 1] = 0;
if (ioctl(ctl_sock_, SIOCGIFFLAGS, &ifr) < 0) {
@@ -96,7 +98,7 @@ void EthernetDevice::SetTitleIPv6LinkLocalAddress(const bool interface_up) {
std::unique_ptr<struct ifaddrs, decltype(&freeifaddrs)> guard{ ifaddr, freeifaddrs };
for (struct ifaddrs* ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) {
- if (ifa->ifa_addr->sa_family != AF_INET6 || interface != ifa->ifa_name) {
+ if (ifa->ifa_addr->sa_family != AF_INET6 || interface_ != ifa->ifa_name) {
continue;
}
diff --git a/recovery_ui/include/recovery_ui/ethernet_device.h b/recovery_ui/include/recovery_ui/ethernet_device.h
index ea710ab93..3aadea200 100644
--- a/recovery_ui/include/recovery_ui/ethernet_device.h
+++ b/recovery_ui/include/recovery_ui/ethernet_device.h
@@ -27,6 +27,7 @@ class EthernetRecoveryUI;
class EthernetDevice : public Device {
public:
explicit EthernetDevice(EthernetRecoveryUI* ui);
+ explicit EthernetDevice(EthernetRecoveryUI* ui, std::string interface);
void PreRecovery() override;
void PreFastboot() override;
@@ -36,7 +37,7 @@ class EthernetDevice : public Device {
void SetTitleIPv6LinkLocalAddress(const bool interface_up);
android::base::unique_fd ctl_sock_;
- static const std::string interface;
+ std::string interface_;
};
#endif // _ETHERNET_RECOVERY_DEVICE_H