1
#pragma once
2

            
3
#include "envoy/stream_info/filter_state.h"
4

            
5
#include "absl/strings/string_view.h"
6

            
7
namespace Envoy {
8
namespace Network {
9

            
10
/**
11
 * Network namespace filepath from the listener address. This filter state is automatically
12
 * populated when a connection is accepted if the listener's local address has a network
13
 * namespace configured. It provides read-only access to the network namespace, which is
14
 * particularly useful for logging, routing decisions, or other filter logic in multi-tenant
15
 * or containerized environments.
16
 */
17
class DownstreamNetworkNamespace : public StreamInfo::FilterState::Object {
18
public:
19
  DownstreamNetworkNamespace(absl::string_view network_namespace_filepath)
20
5
      : network_namespace_filepath_(network_namespace_filepath) {}
21
2
  const std::string& value() const { return network_namespace_filepath_; }
22
3
  absl::optional<std::string> serializeAsString() const override {
23
3
    return network_namespace_filepath_;
24
3
  }
25
  static const std::string& key();
26

            
27
private:
28
  const std::string network_namespace_filepath_;
29
};
30

            
31
} // namespace Network
32
} // namespace Envoy