Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1471797 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 8185746 from a7be0ca0 to tm-d1-release

Change-Id: I80107a308da3d42c8d49f0cef536e7ec92745d99
parents b1b01e8c a7be0ca0
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -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;
    }

+2 −1
Original line number Diff line number Diff line
@@ -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