arc: Move platform2/arc/network/ to platform2/patchpanel
Next step in the arc-networkd -> patchpanel rename, this patch moves the
location of the code.
BUG=b:151879931
TEST=units,flashed image to atlas
TEST=tasts arc.PlayStore, crostini.LaunchTerminal.download
Change-Id: I1b5cf8d670e1631d46f6449b725395157bf88dde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2115863
Tested-by: Garrick Evans <garrick@chromium.org>
Commit-Queue: Garrick Evans <garrick@chromium.org>
Reviewed-by: Hidehiko Abe <hidehiko@chromium.org>
Reviewed-by: Eric Caruso <ejcaruso@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
diff --git a/patchpanel/scoped_ns.h b/patchpanel/scoped_ns.h
new file mode 100644
index 0000000..f790695
--- /dev/null
+++ b/patchpanel/scoped_ns.h
@@ -0,0 +1,32 @@
+// Copyright 2019 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PATCHPANEL_SCOPED_NS_H_
+#define PATCHPANEL_SCOPED_NS_H_
+
+#include <base/files/scoped_file.h>
+#include <base/macros.h>
+
+namespace patchpanel {
+
+// Utility class for running code blocks within the network namespace.
+class ScopedNS {
+ public:
+ explicit ScopedNS(pid_t pid);
+ ~ScopedNS();
+
+ // Returns whether or not the object was able to enter the network namespace.
+ bool IsValid() const { return valid_; }
+
+ private:
+ bool valid_;
+ base::ScopedFD ns_fd_;
+ base::ScopedFD self_fd_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScopedNS);
+};
+
+} // namespace patchpanel
+
+#endif // PATCHPANEL_SCOPED_NS_H_