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/routing_service.h b/patchpanel/routing_service.h
new file mode 100644
index 0000000..cda7b66
--- /dev/null
+++ b/patchpanel/routing_service.h
@@ -0,0 +1,43 @@
+// Copyright 2020 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_ROUTING_SERVICE_H_
+#define PATCHPANEL_ROUTING_SERVICE_H_
+
+#include <stdint.h>
+#include <sys/socket.h>
+
+#include <patchpanel/proto_bindings/patchpanel_service.pb.h>
+
+namespace patchpanel {
+
+// Service implementing routing features of patchpanel.
+// TODO(hugobenichi) Explain how this coordinates with shill's RoutingTable.
+class RoutingService {
+ public:
+ RoutingService();
+ RoutingService(const RoutingService&) = delete;
+ RoutingService& operator=(const RoutingService&) = delete;
+ virtual ~RoutingService() = default;
+
+ // Sets the VPN bits of the fwmark for the given socket according to the
+ // given policy. Preserves any other bits of the fwmark already set.
+ bool SetVpnFwmark(int sockfd,
+ patchpanel::SetVpnIntentRequest::VpnRoutingPolicy policy);
+
+ // Sets the fwmark on the given socket with the given mask.
+ // Preserves any other bits of the fwmark already set.
+ bool SetFwmark(int sockfd, uint32_t mark, uint32_t mask);
+
+ protected:
+ // Can be overridden in tests.
+ virtual int GetSockopt(
+ int sockfd, int level, int optname, void* optval, socklen_t* optlen);
+ virtual int SetSockopt(
+ int sockfd, int level, int optname, const void* optval, socklen_t optlen);
+};
+
+} // namespace patchpanel
+
+#endif // PATCHPANEL_ROUTING_SERVICE_H_