1
#pragma once
2

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

            
6
namespace Envoy {
7

            
8
namespace Http2 {
9
namespace Utility {
10

            
11
// Limits and defaults for `envoy::config::core::v3::Http2ProtocolOptions` protos.
12
struct OptionsLimits {
13
  // disable HPACK compression
14
  static const uint32_t MIN_HPACK_TABLE_SIZE = 0;
15
  // initial value from HTTP/2 spec, same as NGHTTP2_DEFAULT_HEADER_TABLE_SIZE from nghttp2
16
  static const uint32_t DEFAULT_HPACK_TABLE_SIZE = (1 << 12);
17
  // no maximum from HTTP/2 spec, use unsigned 32-bit maximum
18
  static const uint32_t MAX_HPACK_TABLE_SIZE = std::numeric_limits<uint32_t>::max();
19
  // TODO(jwfang): make this 0, the HTTP/2 spec minimum
20
  static const uint32_t MIN_MAX_CONCURRENT_STREAMS = 1;
21
  // defaults to maximum, same as nghttp2
22
  static const uint32_t DEFAULT_MAX_CONCURRENT_STREAMS_LEGACY = (1U << 31) - 1;
23
  // Defaults to 1024 for safety and enough for most use cases.
24
  static const uint32_t DEFAULT_MAX_CONCURRENT_STREAMS = 1024;
25
  // no maximum from HTTP/2 spec, total streams is unsigned 32-bit maximum,
26
  // one-side (client/server) is half that, and we need to exclude stream 0.
27
  // same as NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS from nghttp2
28
  static const uint32_t MAX_MAX_CONCURRENT_STREAMS = (1U << 31) - 1;
29

            
30
  // initial value from HTTP/2 spec, same as NGHTTP2_INITIAL_WINDOW_SIZE from nghttp2
31
  // NOTE: we only support increasing window size now, so this is also the minimum
32
  // TODO(jwfang): make this 0 to support decrease window size
33
  static const uint32_t MIN_INITIAL_STREAM_WINDOW_SIZE = (1 << 16) - 1;
34
  // Initial value from HTTP/2 spec is 65535 (64KiB - 1) and we want more (16MiB).
35
  static const uint32_t DEFAULT_INITIAL_STREAM_WINDOW_SIZE = 16 * 1024 * 1024;
36
  static const uint32_t DEFAULT_INITIAL_STREAM_WINDOW_SIZE_LEGACY = 256 * 1024 * 1024;
37
  // maximum from HTTP/2 spec, same as NGHTTP2_MAX_WINDOW_SIZE from nghttp2
38
  static const uint32_t MAX_INITIAL_STREAM_WINDOW_SIZE = (1U << 31) - 1;
39

            
40
  // CONNECTION_WINDOW_SIZE is similar to STREAM_WINDOW_SIZE, but for connection-level window
41
  // TODO(jwfang): make this 0 to support decrease window size
42
  static const uint32_t MIN_INITIAL_CONNECTION_WINDOW_SIZE = (1 << 16) - 1;
43
  static const uint32_t DEFAULT_INITIAL_CONNECTION_WINDOW_SIZE = 24 * 1024 * 1024;
44
  static const uint32_t DEFAULT_INITIAL_CONNECTION_WINDOW_SIZE_LEGACY = 256 * 1024 * 1024;
45
  static const uint32_t MAX_INITIAL_CONNECTION_WINDOW_SIZE = (1U << 31) - 1;
46

            
47
  // Default limit on the number of outbound frames of all types.
48
  static const uint32_t DEFAULT_MAX_OUTBOUND_FRAMES = 10000;
49
  // Default limit on the number of outbound frames of types PING, SETTINGS and RST_STREAM.
50
  static const uint32_t DEFAULT_MAX_OUTBOUND_CONTROL_FRAMES = 1000;
51
  // Default limit on the number of consecutive inbound frames with an empty payload
52
  // and no end stream flag.
53
  static const uint32_t DEFAULT_MAX_CONSECUTIVE_INBOUND_FRAMES_WITH_EMPTY_PAYLOAD = 1;
54
  // Default limit on the number of inbound frames of type PRIORITY (per stream).
55
  static const uint32_t DEFAULT_MAX_INBOUND_PRIORITY_FRAMES_PER_STREAM = 100;
56
  // Default limit on the number of inbound frames of type WINDOW_UPDATE (per DATA frame sent).
57
  static const uint32_t DEFAULT_MAX_INBOUND_WINDOW_UPDATE_FRAMES_PER_DATA_FRAME_SENT = 10;
58
};
59

            
60
} // namespace Utility
61
} // namespace Http2
62

            
63
namespace Http3 {
64
namespace Utility {
65

            
66
// Limits and defaults for `envoy::config::core::v3::Http3ProtocolOptions` protos.
67
struct OptionsLimits {
68
  // The same as kStreamReceiveWindowLimit in QUICHE which is the maximum supported by QUICHE.
69
  static const uint32_t DEFAULT_INITIAL_STREAM_WINDOW_SIZE = 16 * 1024 * 1024;
70
  // The same as kSessionReceiveWindowLimit in QUICHE which is the maximum supported by QUICHE.
71
  static const uint32_t DEFAULT_INITIAL_CONNECTION_WINDOW_SIZE = 24 * 1024 * 1024;
72
};
73

            
74
} // namespace Utility
75
} // namespace Http3
76
} // namespace Envoy