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/socket.h b/patchpanel/socket.h
new file mode 100644
index 0000000..c4d3cc3
--- /dev/null
+++ b/patchpanel/socket.h
@@ -0,0 +1,59 @@
+// 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_SOCKET_H_
+#define PATCHPANEL_SOCKET_H_
+
+#include <netinet/ip.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include <memory>
+#include <string>
+
+#include <base/files/scoped_file.h>
+#include <base/macros.h>
+#include <brillo/brillo_export.h>
+
+namespace patchpanel {
+
+// Wrapper around various syscalls used for socket communications.
+class BRILLO_EXPORT Socket {
+ public:
+  Socket(int family, int type);
+  explicit Socket(base::ScopedFD fd);
+  virtual ~Socket() = default;
+
+  bool Bind(const struct sockaddr* addr, socklen_t addrlen);
+  bool Connect(const struct sockaddr* addr, socklen_t addrlen);
+  bool Listen(int backlog) const;
+  std::unique_ptr<Socket> Accept(struct sockaddr* addr = nullptr,
+                                 socklen_t* addrlen = nullptr) const;
+
+  ssize_t SendTo(const void* data,
+                 size_t len,
+                 const struct sockaddr* addr = nullptr,
+                 socklen_t addrlen = 0);
+  ssize_t RecvFrom(void* data,
+                   size_t len,
+                   struct sockaddr* addr = nullptr,
+                   socklen_t addrlen = 0);
+
+  int fd() const { return fd_.get(); }
+
+  // Releases the underlying fd rendering the Socket instance invalid.
+  int release() { return fd_.release(); }
+
+ private:
+  base::ScopedFD fd_;
+
+  DISALLOW_COPY_AND_ASSIGN(Socket);
+};
+
+BRILLO_EXPORT std::ostream& operator<<(std::ostream& stream,
+                                       const Socket& socket);
+
+}  // namespace patchpanel
+
+#endif  // PATCHPANEL_SOCKET_H_