diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2022-02-15 04:14:08 +0100 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2022-02-15 04:14:08 +0100 |
commit | 46a3704702f58cc2031f10a7d08ff2e12663bb5e (patch) | |
tree | ebb70c8127987f7029be82d63a335af8cc5874b9 /recovery_ui/ethernet_device.cpp | |
parent | Merge "Fix typo in static_assert message." (diff) | |
parent | Enable different interface for fastboot for cf (diff) | |
download | android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar.gz android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar.bz2 android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar.lz android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar.xz android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.tar.zst android_bootable_recovery-46a3704702f58cc2031f10a7d08ff2e12663bb5e.zip |
Diffstat (limited to 'recovery_ui/ethernet_device.cpp')
-rw-r--r-- | recovery_ui/ethernet_device.cpp | 12 |
1 files changed, 7 insertions, 5 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; } |