add getClatEgressProgFd() with tests

Test: atest
Bug: 139396664
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I966c873e1dd46dc1030cbbdb14d1b2f4640ec1ae
diff --git a/server/ClatUtils.cpp b/server/ClatUtils.cpp
index c75fcdd..a5b7c44 100644
--- a/server/ClatUtils.cpp
+++ b/server/ClatUtils.cpp
@@ -67,6 +67,12 @@
     return (fd == -1) ? -errno : fd;
 }
 
+int getClatEgressProgFd(bool with_ethernet_header) {
+    const int fd = bpf::bpfFdGet(
+            with_ethernet_header ? CLAT_EGRESS_PROG_ETHER_PATH : CLAT_EGRESS_PROG_RAWIP_PATH, 0);
+    return (fd == -1) ? -errno : fd;
+}
+
 int getClatIngressMapFd(void) {
     const int fd = bpf::bpfFdGet(CLAT_INGRESS_MAP_PATH, 0);
     return (fd == -1) ? -errno : fd;