Nat-related commands porting
Test: built, flashed, booted
system/netd/tests/runtests.sh passes
Change-Id: I14e80377bc1b7c08993c3cf8fbf2b6fd0f99f4ba
diff --git a/server/NetdNativeService.cpp b/server/NetdNativeService.cpp
index c993f30..7647e20 100644
--- a/server/NetdNativeService.cpp
+++ b/server/NetdNativeService.cpp
@@ -1487,5 +1487,31 @@
return statusFromErrcode(res);
}
+binder::Status NetdNativeService::tetherAddForward(const std::string& intIface,
+ const std::string& extIface) {
+ NETD_LOCKING_RPC(NETWORK_STACK, gCtls->tetherCtrl.lock);
+ auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).args(intIface, extIface);
+
+ int res = gCtls->tetherCtrl.enableNat(intIface.c_str(), extIface.c_str());
+ if (!res) {
+ std::lock_guard lock(gCtls->bandwidthCtrl.lock);
+ res = gCtls->bandwidthCtrl.setGlobalAlertInForwardChain();
+ }
+ gLog.log(entry.returns(res).withAutomaticDuration());
+ return statusFromErrcode(res);
+}
+
+binder::Status NetdNativeService::tetherRemoveForward(const std::string& intIface,
+ const std::string& extIface) {
+ NETD_LOCKING_RPC(NETWORK_STACK, gCtls->tetherCtrl.lock);
+ std::lock_guard lock(gCtls->bandwidthCtrl.lock);
+ auto entry = gLog.newEntry().prettyFunction(__PRETTY_FUNCTION__).args(intIface, extIface);
+
+ int res = gCtls->bandwidthCtrl.removeGlobalAlertInForwardChain();
+ res |= gCtls->tetherCtrl.disableNat(intIface.c_str(), extIface.c_str());
+ gLog.log(entry.returns(res).withAutomaticDuration());
+ return statusFromErrcode(res);
+}
+
} // namespace net
} // namespace android