Add binder IPCs to add and remove downstream IPv6 tethering rules

Test: None
Change-Id: Idcb6b9c80de499fafb29e4e8b9202d7b7386340c
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index 86826f5..9c91249 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -131,6 +131,14 @@
     return binder::Status::fromServiceSpecificError(status.code(), status.msg().c_str());
 }
 
+template <typename T>
+binder::Status asBinderStatus(const base::Result<T> result) {
+    if (result.ok()) return binder::Status::ok();
+
+    return binder::Status::fromServiceSpecificError(result.error().code(),
+                                                    result.error().message().c_str());
+}
+
 inline binder::Status statusFromErrcode(int ret) {
     if (ret) {
         return binder::Status::fromServiceSpecificError(-ret, strerror(-ret));
@@ -1238,5 +1246,21 @@
     return binder::Status::ok();
 }
 
+binder::Status NetdNativeService::tetherRuleAddDownstreamIpv6(
+        int intIfaceIndex, int extIfaceIndex, const std::vector<uint8_t>& ipAddress,
+        const std::vector<uint8_t>& srcL2Address, const std::vector<uint8_t>& dstL2Address) {
+    ENFORCE_NETWORK_STACK_PERMISSIONS();
+
+    return asBinderStatus(gCtls->tetherCtrl.addDownstreamIpv6Rule(
+            intIfaceIndex, extIfaceIndex, ipAddress, srcL2Address, dstL2Address));
+}
+
+binder::Status NetdNativeService::tetherRuleRemoveDownstreamIpv6(
+        int extIfaceIndex, const std::vector<uint8_t>& ipAddress) {
+    ENFORCE_NETWORK_STACK_PERMISSIONS();
+
+    return asBinderStatus(gCtls->tetherCtrl.removeDownstreamIpv6Rule(extIfaceIndex, ipAddress));
+}
+
 }  // namespace net
 }  // namespace android