patchpanel: add System class to wrap common syscalls

This patch prepares to remove external calls to sysctl and introduces a
wrapper for system calls that can be conveniently mocked in unit tests.
Calls to ioctl() in Datapath are migrated to that wrapper.

BUG=b:178980566
TEST=unit tests. Flashed trogdor, verified ARC and Crostini
connectivity.

Change-Id: Ibc0e493e613d12de059cb57a1d37d2f0d9f81c50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2947316
Tested-by: Hugo Benichi <hugobenichi@google.com>
Commit-Queue: Hugo Benichi <hugobenichi@google.com>
Reviewed-by: Garrick Evans <garrick@chromium.org>
diff --git a/patchpanel/system.cc b/patchpanel/system.cc
new file mode 100644
index 0000000..f802b82
--- /dev/null
+++ b/patchpanel/system.cc
@@ -0,0 +1,25 @@
+// Copyright 2021 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.
+
+#include "patchpanel/system.h"
+
+namespace patchpanel {
+
+int System::Ioctl(int fd, ioctl_req_t request, const char* argp) {
+  return ioctl(fd, request, argp);
+}
+
+int System::Ioctl(int fd, ioctl_req_t request, uint64_t arg) {
+  return Ioctl(fd, request, reinterpret_cast<const char*>(arg));
+}
+
+int System::Ioctl(int fd, ioctl_req_t request, struct ifreq* ifr) {
+  return Ioctl(fd, request, reinterpret_cast<const char*>(ifr));
+}
+
+int System::Ioctl(int fd, ioctl_req_t request, struct rtentry* route) {
+  return Ioctl(fd, request, reinterpret_cast<const char*>(route));
+}
+
+}  // namespace patchpanel