1
#pragma once
2

            
3
#include "envoy/config/core/v3/base.pb.h"
4
#include "envoy/stream_info/filter_state.h"
5

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

            
8
namespace Envoy {
9
namespace Upstream {
10

            
11
/**
12
 * Data structure holding context for transport socket matching.
13
 * This provides access to:
14
 * - Endpoint metadata: metadata associated with the selected upstream endpoint.
15
 * - Locality metadata: metadata associated with the endpoint's locality.
16
 * - Filter state: shared filter state from downstream connection (via TransportSocketOptions).
17
 *
18
 * Filter state enables downstream-connection-based matching by allowing filters to explicitly
19
 * pass any data (e.g., network namespace, custom attributes) from downstream to upstream.
20
 * This follows the same pattern as tunneling in Envoy.
21
 */
22
struct TransportSocketMatchingData {
23
5237
  static absl::string_view name() { return "transport_socket"; }
24

            
25
  TransportSocketMatchingData(const envoy::config::core::v3::Metadata* endpoint_metadata,
26
                              const envoy::config::core::v3::Metadata* locality_metadata,
27
                              const StreamInfo::FilterState* filter_state = nullptr)
28
29
      : endpoint_metadata_(endpoint_metadata), locality_metadata_(locality_metadata),
29
29
        filter_state_(filter_state) {}
30

            
31
  const envoy::config::core::v3::Metadata* endpoint_metadata_;
32
  const envoy::config::core::v3::Metadata* locality_metadata_;
33
  const StreamInfo::FilterState* filter_state_;
34
};
35

            
36
} // namespace Upstream
37
} // namespace Envoy