OffloadUtils: move existing ethernet device check to isEthernet() helper
Preparation for tethering bpf offload
Test: manual clatd test
1. Connect to IPv6-Only WiFi hotspot
2. Browse 172.217.0.46 (google.com) successfully
3. Disconnect from WiFi
Repeat the above steps three times.
Change-Id: Ib2fdc644c6048acaacf51c46c6960e8cd6cbc445
diff --git a/server/OffloadUtils.h b/server/OffloadUtils.h
index b44ffdf..cdb0d33 100644
--- a/server/OffloadUtils.h
+++ b/server/OffloadUtils.h
@@ -16,6 +16,7 @@
#pragma once
+#include <android-base/result.h>
#include <errno.h>
#include <linux/if_ether.h>
#include <linux/rtnetlink.h>
@@ -28,9 +29,6 @@
namespace android {
namespace net {
-// this returns an ARPHRD_* constant or a -errno
-int hardwareAddressType(const std::string& interface);
-
// For better code clarity - do not change values - used for booleans like
// with_ethernet_header or isEthernet.
constexpr bool RAWIP = false;
@@ -44,6 +42,11 @@
constexpr uint16_t PRIO_CLAT = 1;
constexpr uint16_t PRIO_TETHER = 2;
+// this returns an ARPHRD_* constant or a -errno
+int hardwareAddressType(const std::string& interface);
+
+base::Result<bool> isEthernet(const std::string& interface);
+
inline int getClatEgressMapFd(void) {
const int fd = bpf::bpfFdGet(CLAT_EGRESS_MAP_PATH, 0);
return (fd == -1) ? -errno : fd;