1
#pragma once
2

            
3
#include <cstdint>
4
#include <vector>
5

            
6
#include "envoy/config/core/v3/socket_option.pb.h"
7
#include "envoy/network/socket.h"
8

            
9
#include "source/common/common/logger.h"
10

            
11
#include "absl/types/optional.h"
12

            
13
namespace Envoy {
14
namespace Cilium {
15

            
16
// Socket Option that sets the socket option IP_TRANSPARENT (IPV6_TRANSPARENT) on the socket.
17
// It uses the Cilium Privileged Service to call out to the starter process to do the actual
18
// privileged syscall - as the Envoy process itself doesn't have the required capabilities.
19
class IpTransparentSocketOption : public Network::Socket::Option,
20
                                  public Logger::Loggable<Logger::Id::filter> {
21
public:
22
  IpTransparentSocketOption();
23

            
24
  absl::optional<Network::Socket::Option::Details>
25
  getOptionDetails(const Network::Socket&,
26
                   envoy::config::core::v3::SocketOption::SocketState) const override {
27
    return absl::nullopt;
28
  }
29

            
30
  bool setOption(Network::Socket& socket,
31
                 envoy::config::core::v3::SocketOption::SocketState state) const override;
32

            
33
  void hashKey([[maybe_unused]] std::vector<uint8_t>& key) const override {}
34

            
35
  bool isSupported() const override { return true; }
36
};
37

            
38
} // namespace Cilium
39
} // namespace Envoy