licentivo-launch 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (143) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +35 -0
  4. data/ext/launch_native/extconf.rb +28 -0
  5. data/lib/licentivo_launch/vendor/licentivo.rb +262 -0
  6. data/lib/licentivo_launch.rb +352 -0
  7. data/vendor/LICENSE +21 -0
  8. data/vendor/NOTICE +17 -0
  9. data/vendor/VERSION +1 -0
  10. data/vendor/c/app.c +33 -0
  11. data/vendor/c/demo.c +77 -0
  12. data/vendor/c/feature_tasks.h +72 -0
  13. data/vendor/c/licentivo.c +382 -0
  14. data/vendor/c/licentivo.h +67 -0
  15. data/vendor/c/quickstart.c +51 -0
  16. data/vendor/c/test_vectors.c +4 -0
  17. data/vendor/c/vendor/Monocypher-LICENCE.md +173 -0
  18. data/vendor/c/vendor/cJSON-LICENSE +20 -0
  19. data/vendor/c/vendor/cJSON.c +3191 -0
  20. data/vendor/c/vendor/cJSON.h +306 -0
  21. data/vendor/c/vendor/monocypher-ed25519.c +500 -0
  22. data/vendor/c/vendor/monocypher-ed25519.h +140 -0
  23. data/vendor/c/vendor/monocypher.c +2956 -0
  24. data/vendor/c/vendor/monocypher.h +321 -0
  25. data/vendor/curl/COPYING.txt +22 -0
  26. data/vendor/curl/bin/libcurl-x64.dll +0 -0
  27. data/vendor/curl/include/brotli/decode.h +409 -0
  28. data/vendor/curl/include/brotli/encode.h +505 -0
  29. data/vendor/curl/include/brotli/port.h +302 -0
  30. data/vendor/curl/include/brotli/shared_dictionary.h +100 -0
  31. data/vendor/curl/include/brotli/types.h +83 -0
  32. data/vendor/curl/include/curl/curl.h +3374 -0
  33. data/vendor/curl/include/curl/curlver.h +77 -0
  34. data/vendor/curl/include/curl/easy.h +123 -0
  35. data/vendor/curl/include/curl/header.h +74 -0
  36. data/vendor/curl/include/curl/mprintf.h +85 -0
  37. data/vendor/curl/include/curl/multi.h +561 -0
  38. data/vendor/curl/include/curl/options.h +70 -0
  39. data/vendor/curl/include/curl/stdcheaders.h +35 -0
  40. data/vendor/curl/include/curl/system.h +399 -0
  41. data/vendor/curl/include/curl/typecheck-gcc.h +964 -0
  42. data/vendor/curl/include/curl/urlapi.h +156 -0
  43. data/vendor/curl/include/curl/websockets.h +98 -0
  44. data/vendor/curl/include/libpsl.h +207 -0
  45. data/vendor/curl/include/libssh2.h +1516 -0
  46. data/vendor/curl/include/libssh2_publickey.h +128 -0
  47. data/vendor/curl/include/libssh2_sftp.h +382 -0
  48. data/vendor/curl/include/nghttp2/nghttp2.h +6878 -0
  49. data/vendor/curl/include/nghttp2/nghttp2ver.h +42 -0
  50. data/vendor/curl/include/nghttp3/nghttp3.h +3704 -0
  51. data/vendor/curl/include/nghttp3/version.h +46 -0
  52. data/vendor/curl/include/ngtcp2/ngtcp2.h +7485 -0
  53. data/vendor/curl/include/ngtcp2/ngtcp2_crypto.h +1071 -0
  54. data/vendor/curl/include/ngtcp2/ngtcp2_crypto_quictls.h +147 -0
  55. data/vendor/curl/include/ngtcp2/version.h +51 -0
  56. data/vendor/curl/include/openssl/aes.h +120 -0
  57. data/vendor/curl/include/openssl/asn1.h +1121 -0
  58. data/vendor/curl/include/openssl/asn1t.h +996 -0
  59. data/vendor/curl/include/openssl/bio.h +716 -0
  60. data/vendor/curl/include/openssl/blowfish.h +106 -0
  61. data/vendor/curl/include/openssl/bn.h +480 -0
  62. data/vendor/curl/include/openssl/buffer.h +102 -0
  63. data/vendor/curl/include/openssl/camellia.h +121 -0
  64. data/vendor/curl/include/openssl/cast.h +99 -0
  65. data/vendor/curl/include/openssl/chacha.h +54 -0
  66. data/vendor/curl/include/openssl/cmac.h +81 -0
  67. data/vendor/curl/include/openssl/cms.h +541 -0
  68. data/vendor/curl/include/openssl/comp.h +7 -0
  69. data/vendor/curl/include/openssl/conf.h +189 -0
  70. data/vendor/curl/include/openssl/crypto.h +458 -0
  71. data/vendor/curl/include/openssl/ct.h +567 -0
  72. data/vendor/curl/include/openssl/curve25519.h +104 -0
  73. data/vendor/curl/include/openssl/des.h +215 -0
  74. data/vendor/curl/include/openssl/dh.h +245 -0
  75. data/vendor/curl/include/openssl/dsa.h +263 -0
  76. data/vendor/curl/include/openssl/dtls1.h +107 -0
  77. data/vendor/curl/include/openssl/ec.h +675 -0
  78. data/vendor/curl/include/openssl/ecdh.h +6 -0
  79. data/vendor/curl/include/openssl/ecdsa.h +6 -0
  80. data/vendor/curl/include/openssl/engine.h +215 -0
  81. data/vendor/curl/include/openssl/err.h +325 -0
  82. data/vendor/curl/include/openssl/evp.h +1288 -0
  83. data/vendor/curl/include/openssl/hkdf.h +65 -0
  84. data/vendor/curl/include/openssl/hmac.h +101 -0
  85. data/vendor/curl/include/openssl/idea.h +99 -0
  86. data/vendor/curl/include/openssl/kdf.h +137 -0
  87. data/vendor/curl/include/openssl/lhash.h +179 -0
  88. data/vendor/curl/include/openssl/md4.h +105 -0
  89. data/vendor/curl/include/openssl/md5.h +99 -0
  90. data/vendor/curl/include/openssl/mlkem.h +236 -0
  91. data/vendor/curl/include/openssl/modes.h +118 -0
  92. data/vendor/curl/include/openssl/obj_mac.h +4646 -0
  93. data/vendor/curl/include/openssl/objects.h +137 -0
  94. data/vendor/curl/include/openssl/ocsp.h +484 -0
  95. data/vendor/curl/include/openssl/opensslconf.h +16 -0
  96. data/vendor/curl/include/openssl/opensslfeatures.h +153 -0
  97. data/vendor/curl/include/openssl/opensslv.h +18 -0
  98. data/vendor/curl/include/openssl/ossl_typ.h +196 -0
  99. data/vendor/curl/include/openssl/pem.h +542 -0
  100. data/vendor/curl/include/openssl/pkcs12.h +284 -0
  101. data/vendor/curl/include/openssl/pkcs7.h +523 -0
  102. data/vendor/curl/include/openssl/poly1305.h +45 -0
  103. data/vendor/curl/include/openssl/posix_time.h +54 -0
  104. data/vendor/curl/include/openssl/rand.h +118 -0
  105. data/vendor/curl/include/openssl/rc2.h +101 -0
  106. data/vendor/curl/include/openssl/rc4.h +88 -0
  107. data/vendor/curl/include/openssl/ripemd.h +107 -0
  108. data/vendor/curl/include/openssl/rsa.h +603 -0
  109. data/vendor/curl/include/openssl/safestack.h +1739 -0
  110. data/vendor/curl/include/openssl/sha.h +190 -0
  111. data/vendor/curl/include/openssl/sm3.h +49 -0
  112. data/vendor/curl/include/openssl/sm4.h +47 -0
  113. data/vendor/curl/include/openssl/srtp.h +148 -0
  114. data/vendor/curl/include/openssl/ssl.h +2336 -0
  115. data/vendor/curl/include/openssl/ssl3.h +441 -0
  116. data/vendor/curl/include/openssl/stack.h +99 -0
  117. data/vendor/curl/include/openssl/tls1.h +764 -0
  118. data/vendor/curl/include/openssl/ts.h +660 -0
  119. data/vendor/curl/include/openssl/txt_db.h +112 -0
  120. data/vendor/curl/include/openssl/ui.h +397 -0
  121. data/vendor/curl/include/openssl/x509.h +1037 -0
  122. data/vendor/curl/include/openssl/x509_vfy.h +464 -0
  123. data/vendor/curl/include/openssl/x509v3.h +1039 -0
  124. data/vendor/curl/include/zconf.h +206 -0
  125. data/vendor/curl/include/zdict.h +481 -0
  126. data/vendor/curl/include/zlib.h +1859 -0
  127. data/vendor/curl/include/zlib_name_mangling.h +8 -0
  128. data/vendor/curl/include/zstd.h +3198 -0
  129. data/vendor/curl/include/zstd_errors.h +107 -0
  130. data/vendor/curl/lib/libcurl.dll.a +0 -0
  131. data/vendor/curl/licenses/brotli/LICENSE.txt +19 -0
  132. data/vendor/curl/licenses/certdata/LICENSE.url +2 -0
  133. data/vendor/curl/licenses/libpsl/COPYING.txt +20 -0
  134. data/vendor/curl/licenses/libressl/COPYING.txt +133 -0
  135. data/vendor/curl/licenses/libssh2/COPYING.txt +43 -0
  136. data/vendor/curl/licenses/nghttp2/COPYING.txt +23 -0
  137. data/vendor/curl/licenses/nghttp3/COPYING.txt +22 -0
  138. data/vendor/curl/licenses/ngtcp2/COPYING.txt +22 -0
  139. data/vendor/curl/licenses/psl/LICENSE.txt +373 -0
  140. data/vendor/curl/licenses/trurl/COPYING.txt +22 -0
  141. data/vendor/curl/licenses/zlibng/LICENSE.md +19 -0
  142. data/vendor/curl/licenses/zstd/LICENSE.txt +30 -0
  143. metadata +205 -0
@@ -0,0 +1,3704 @@
1
+ /*
2
+ * nghttp3
3
+ *
4
+ * Copyright (c) 2018 nghttp3 contributors
5
+ * Copyright (c) 2017 ngtcp2 contributors
6
+ * Copyright (c) 2017 nghttp2 contributors
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining
9
+ * a copy of this software and associated documentation files (the
10
+ * "Software"), to deal in the Software without restriction, including
11
+ * without limitation the rights to use, copy, modify, merge, publish,
12
+ * distribute, sublicense, and/or sell copies of the Software, and to
13
+ * permit persons to whom the Software is furnished to do so, subject to
14
+ * the following conditions:
15
+ *
16
+ * The above copyright notice and this permission notice shall be
17
+ * included in all copies or substantial portions of the Software.
18
+ *
19
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26
+ */
27
+ #ifndef NGHTTP3_H
28
+ #define NGHTTP3_H
29
+
30
+ /* Define WIN32 when build target is Win32 API (borrowed from
31
+ libcurl) */
32
+ #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
33
+ # define WIN32
34
+ #endif /* (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) */
35
+
36
+ #ifdef __cplusplus
37
+ extern "C" {
38
+ #endif /* defined(__cplusplus) */
39
+
40
+ #include <stdlib.h>
41
+ #if defined(_MSC_VER) && (_MSC_VER < 1800)
42
+ /* MSVC < 2013 does not have inttypes.h because it is not C99
43
+ compliant. See compiler macros and version number in
44
+ https://sourceforge.net/p/predef/wiki/Compilers/ */
45
+ # include <stdint.h>
46
+ #else /* !(defined(_MSC_VER) && (_MSC_VER < 1800)) */
47
+ # include <inttypes.h>
48
+ #endif /* !(defined(_MSC_VER) && (_MSC_VER < 1800)) */
49
+ #include <sys/types.h>
50
+ #include <stdarg.h>
51
+ #include <stddef.h>
52
+
53
+ #include <nghttp3/version.h>
54
+
55
+ #ifdef NGHTTP3_STATICLIB
56
+ # define NGHTTP3_EXTERN
57
+ #elif defined(WIN32)
58
+ # ifdef BUILDING_NGHTTP3
59
+ # define NGHTTP3_EXTERN __declspec(dllexport)
60
+ # else /* !defined(BUILDING_NGHTTP3) */
61
+ # define NGHTTP3_EXTERN __declspec(dllimport)
62
+ # endif /* !defined(BUILDING_NGHTTP3) */
63
+ #else /* !(defined(NGHTTP3_STATICLIB) || defined(WIN32)) */
64
+ # ifdef BUILDING_NGHTTP3
65
+ # define NGHTTP3_EXTERN __attribute__((visibility("default")))
66
+ # else /* !defined(BUILDING_NGHTTP3) */
67
+ # define NGHTTP3_EXTERN
68
+ # endif /* !defined(BUILDING_NGHTTP3) */
69
+ #endif /* !(defined(NGHTTP3_STATICLIB) || defined(WIN32)) */
70
+
71
+ #ifdef _MSC_VER
72
+ # define NGHTTP3_ALIGN(N) __declspec(align(N))
73
+ #else /* !defined(_MSC_VER) */
74
+ # define NGHTTP3_ALIGN(N) __attribute__((aligned(N)))
75
+ #endif /* !defined(_MSC_VER) */
76
+
77
+ /**
78
+ * @typedef
79
+ *
80
+ * :type:`nghttp3_ssize` is signed counterpart of size_t.
81
+ */
82
+ typedef ptrdiff_t nghttp3_ssize;
83
+
84
+ /**
85
+ * @typedef
86
+ *
87
+ * :type:`nghttp3_tstamp` is a timestamp with nanosecond resolution.
88
+ * ``UINT64_MAX`` is an invalid value, and it is often used to
89
+ * indicate that no value is set.
90
+ *
91
+ * .. version-added:: 1.12.0
92
+ */
93
+ typedef uint64_t nghttp3_tstamp;
94
+
95
+ /**
96
+ * @typedef
97
+ *
98
+ * :type:`nghttp3_duration` is a period of time in nanosecond
99
+ * resolution. ``UINT64_MAX`` is an invalid value, and it is often
100
+ * used to indicate that no value is set.
101
+ *
102
+ * .. version-added:: 1.12.0.
103
+ */
104
+ typedef uint64_t nghttp3_duration;
105
+
106
+ /**
107
+ * @macro
108
+ *
109
+ * :macro:`NGHTTP3_NANOSECONDS` is a count of tick which corresponds
110
+ * to 1 nanosecond.
111
+ *
112
+ * .. version-added:: 1.12.0
113
+ */
114
+ #define NGHTTP3_NANOSECONDS ((nghttp3_duration)1ULL)
115
+
116
+ /**
117
+ * @macro
118
+ *
119
+ * :macro:`NGHTTP3_MICROSECONDS` is a count of tick which corresponds
120
+ * to 1 microsecond.
121
+ *
122
+ * .. version-added:: 1.12.0
123
+ */
124
+ #define NGHTTP3_MICROSECONDS ((nghttp3_duration)(1000ULL * NGHTTP3_NANOSECONDS))
125
+
126
+ /**
127
+ * @macro
128
+ *
129
+ * :macro:`NGHTTP3_MILLISECONDS` is a count of tick which corresponds
130
+ * to 1 millisecond.
131
+ *
132
+ * .. version-added:: 1.12.0
133
+ */
134
+ #define NGHTTP3_MILLISECONDS \
135
+ ((nghttp3_duration)(1000ULL * NGHTTP3_MICROSECONDS))
136
+
137
+ /**
138
+ * @macro
139
+ *
140
+ * :macro:`NGHTTP3_SECONDS` is a count of tick which corresponds to 1
141
+ * second.
142
+ *
143
+ * .. version-added:: 1.12.0
144
+ */
145
+ #define NGHTTP3_SECONDS ((nghttp3_duration)(1000ULL * NGHTTP3_MILLISECONDS))
146
+
147
+ /**
148
+ * @macro
149
+ *
150
+ * :macro:`NGHTTP3_ALPN_H3` is a serialized form of HTTP/3 ALPN
151
+ * protocol identifier this library supports. Notice that the first
152
+ * byte is the length of the following protocol identifier.
153
+ */
154
+ #define NGHTTP3_ALPN_H3 "\x2h3"
155
+
156
+ /**
157
+ * @macrosection
158
+ *
159
+ * nghttp3 library error codes
160
+ */
161
+
162
+ /**
163
+ * @macro
164
+ *
165
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` indicates that a passed
166
+ * argument is invalid.
167
+ */
168
+ #define NGHTTP3_ERR_INVALID_ARGUMENT -101
169
+ /**
170
+ * @macro
171
+ *
172
+ * :macro:`NGHTTP3_ERR_INVALID_STATE` indicates that a requested
173
+ * operation is not allowed at the current connection state.
174
+ */
175
+ #define NGHTTP3_ERR_INVALID_STATE -102
176
+ /**
177
+ * @macro
178
+ *
179
+ * :macro:`NGHTTP3_ERR_WOULDBLOCK` indicates that an operation might
180
+ * block.
181
+ */
182
+ #define NGHTTP3_ERR_WOULDBLOCK -103
183
+ /**
184
+ * @macro
185
+ *
186
+ * :macro:`NGHTTP3_ERR_STREAM_IN_USE` indicates that a stream ID is
187
+ * already in use.
188
+ */
189
+ #define NGHTTP3_ERR_STREAM_IN_USE -104
190
+ /**
191
+ * @macro
192
+ *
193
+ * :macro:`NGHTTP3_ERR_MALFORMED_HTTP_HEADER` indicates that an HTTP
194
+ * header field is malformed.
195
+ */
196
+ #define NGHTTP3_ERR_MALFORMED_HTTP_HEADER -105
197
+ /**
198
+ * @macro
199
+ *
200
+ * :macro:`NGHTTP3_ERR_REMOVE_HTTP_HEADER` indicates that an HTTP
201
+ * header field is discarded.
202
+ */
203
+ #define NGHTTP3_ERR_REMOVE_HTTP_HEADER -106
204
+ /**
205
+ * @macro
206
+ *
207
+ * :macro:`NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING` indicates that HTTP
208
+ * messaging is malformed.
209
+ */
210
+ #define NGHTTP3_ERR_MALFORMED_HTTP_MESSAGING -107
211
+ /**
212
+ * @macro
213
+ *
214
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL` indicates that a fatal error is
215
+ * occurred during QPACK processing, and it cannot be recoverable.
216
+ */
217
+ #define NGHTTP3_ERR_QPACK_FATAL -108
218
+ /**
219
+ * @macro
220
+ *
221
+ * :macro:`NGHTTP3_ERR_QPACK_HEADER_TOO_LARGE` indicates that a header
222
+ * field is too large to process.
223
+ */
224
+ #define NGHTTP3_ERR_QPACK_HEADER_TOO_LARGE -109
225
+ /**
226
+ * @macro
227
+ *
228
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND` indicates that a stream is
229
+ * not found.
230
+ */
231
+ #define NGHTTP3_ERR_STREAM_NOT_FOUND -110
232
+ /**
233
+ * @macro
234
+ *
235
+ * :macro:`NGHTTP3_ERR_CONN_CLOSING` indicates that a connection is
236
+ * closing state.
237
+ */
238
+ #define NGHTTP3_ERR_CONN_CLOSING -111
239
+ /**
240
+ * @macro
241
+ *
242
+ * :macro:`NGHTTP3_ERR_STREAM_DATA_OVERFLOW` indicates that the length
243
+ * of stream data is too long, and causes overflow.
244
+ */
245
+ #define NGHTTP3_ERR_STREAM_DATA_OVERFLOW -112
246
+ /**
247
+ * @macro
248
+ *
249
+ * :macro:`NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED` indicates that a
250
+ * QPACK decompression failed.
251
+ */
252
+ #define NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED -401
253
+ /**
254
+ * @macro
255
+ *
256
+ * :macro:`NGHTTP3_ERR_QPACK_ENCODER_STREAM_ERROR` indicates that an
257
+ * error occurred while reading QPACK encoder stream.
258
+ */
259
+ #define NGHTTP3_ERR_QPACK_ENCODER_STREAM_ERROR -402
260
+ /**
261
+ * @macro
262
+ *
263
+ * :macro:`NGHTTP3_ERR_QPACK_DECODER_STREAM_ERROR` indicates that an
264
+ * error occurred while reading QPACK decoder stream.
265
+ */
266
+ #define NGHTTP3_ERR_QPACK_DECODER_STREAM_ERROR -403
267
+ /**
268
+ * @macro
269
+ *
270
+ * :macro:`NGHTTP3_ERR_H3_FRAME_UNEXPECTED` indicates that an
271
+ * unexpected HTTP/3 frame is received.
272
+ */
273
+ #define NGHTTP3_ERR_H3_FRAME_UNEXPECTED -601
274
+ /**
275
+ * @macro
276
+ *
277
+ * :macro:`NGHTTP3_ERR_H3_FRAME_ERROR` indicates that an HTTP/3 frame
278
+ * is malformed.
279
+ */
280
+ #define NGHTTP3_ERR_H3_FRAME_ERROR -602
281
+ /**
282
+ * @macro
283
+ *
284
+ * :macro:`NGHTTP3_ERR_H3_MISSING_SETTINGS` indicates that an HTTP/3
285
+ * SETTINGS frame is missing.
286
+ */
287
+ #define NGHTTP3_ERR_H3_MISSING_SETTINGS -603
288
+ /**
289
+ * @macro
290
+ *
291
+ * :macro:`NGHTTP3_ERR_H3_INTERNAL_ERROR` indicates an internal error.
292
+ */
293
+ #define NGHTTP3_ERR_H3_INTERNAL_ERROR -604
294
+ /**
295
+ * @macro
296
+ *
297
+ * :macro:`NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM` indicates that a
298
+ * critical stream is closed.
299
+ */
300
+ #define NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM -605
301
+ /**
302
+ * @macro
303
+ *
304
+ * :macro:`NGHTTP3_ERR_H3_GENERAL_PROTOCOL_ERROR` indicates a general
305
+ * protocol error. This is typically a catch-all error.
306
+ */
307
+ #define NGHTTP3_ERR_H3_GENERAL_PROTOCOL_ERROR -606
308
+ /**
309
+ * @macro
310
+ *
311
+ * :macro:`NGHTTP3_ERR_H3_ID_ERROR` indicates that an ID related error
312
+ * occurred.
313
+ */
314
+ #define NGHTTP3_ERR_H3_ID_ERROR -607
315
+ /**
316
+ * @macro
317
+ *
318
+ * :macro:`NGHTTP3_ERR_H3_SETTINGS_ERROR` indicates that an HTTP/3
319
+ * SETTINGS frame is malformed.
320
+ */
321
+ #define NGHTTP3_ERR_H3_SETTINGS_ERROR -608
322
+ /**
323
+ * @macro
324
+ *
325
+ * :macro:`NGHTTP3_ERR_H3_STREAM_CREATION_ERROR` indicates that a
326
+ * remote endpoint attempts to create a new stream which is not
327
+ * allowed.
328
+ */
329
+ #define NGHTTP3_ERR_H3_STREAM_CREATION_ERROR -609
330
+ /**
331
+ * @macro
332
+ *
333
+ * :macro:`NGHTTP3_ERR_H3_EXCESSIVE_LOAD` indicates that a local
334
+ * endpoint detected that its remote endpoint is exhibiting a behavior
335
+ * that might generating excessive load.
336
+ */
337
+ #define NGHTTP3_ERR_H3_EXCESSIVE_LOAD -610
338
+ /**
339
+ * @macro
340
+ *
341
+ * :macro:`NGHTTP3_ERR_FATAL` indicates that error codes less than
342
+ * this value is fatal error. When this error is returned, an
343
+ * endpoint should drop connection immediately.
344
+ */
345
+ #define NGHTTP3_ERR_FATAL -900
346
+ /**
347
+ * @macro
348
+ *
349
+ * :macro:`NGHTTP3_ERR_NOMEM` indicates out of memory.
350
+ */
351
+ #define NGHTTP3_ERR_NOMEM -901
352
+ /**
353
+ * @macro
354
+ *
355
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` indicates that user defined
356
+ * callback function failed.
357
+ */
358
+ #define NGHTTP3_ERR_CALLBACK_FAILURE -902
359
+
360
+ /**
361
+ * @macrosection
362
+ *
363
+ * HTTP/3 application error code
364
+ */
365
+
366
+ /**
367
+ * @macro
368
+ *
369
+ * :macro:`NGHTTP3_H3_NO_ERROR` is HTTP/3 application error code
370
+ * ``H3_NO_ERROR``.
371
+ */
372
+ #define NGHTTP3_H3_NO_ERROR 0x0100
373
+ /**
374
+ * @macro
375
+ *
376
+ * :macro:`NGHTTP3_H3_GENERAL_PROTOCOL_ERROR` is HTTP/3 application
377
+ * error code ``H3_GENERAL_PROTOCOL_ERROR``.
378
+ */
379
+ #define NGHTTP3_H3_GENERAL_PROTOCOL_ERROR 0x0101
380
+ /**
381
+ * @macro
382
+ *
383
+ * :macro:`NGHTTP3_H3_INTERNAL_ERROR` is HTTP/3 application error code
384
+ * ``H3_INTERNAL_ERROR``.
385
+ */
386
+ #define NGHTTP3_H3_INTERNAL_ERROR 0x0102
387
+ /**
388
+ * @macro
389
+ *
390
+ * :macro:`NGHTTP3_H3_STREAM_CREATION_ERROR` is HTTP/3 application
391
+ * error code ``H3_STREAM_CREATION_ERROR``.
392
+ */
393
+ #define NGHTTP3_H3_STREAM_CREATION_ERROR 0x0103
394
+ /**
395
+ * @macro
396
+ *
397
+ * :macro:`NGHTTP3_H3_CLOSED_CRITICAL_STREAM` is HTTP/3 application
398
+ * error code ``H3_CLOSED_CRITICAL_STREAM``.
399
+ */
400
+ #define NGHTTP3_H3_CLOSED_CRITICAL_STREAM 0x0104
401
+ /**
402
+ * @macro
403
+ *
404
+ * :macro:`NGHTTP3_H3_FRAME_UNEXPECTED` is HTTP/3 application error
405
+ * code ``H3_FRAME_UNEXPECTED``.
406
+ */
407
+ #define NGHTTP3_H3_FRAME_UNEXPECTED 0x0105
408
+ /**
409
+ * @macro
410
+ *
411
+ * :macro:`NGHTTP3_H3_FRAME_ERROR` is HTTP/3 application error code
412
+ * ``H3_FRAME_ERROR``.
413
+ */
414
+ #define NGHTTP3_H3_FRAME_ERROR 0x0106
415
+ /**
416
+ * @macro
417
+ *
418
+ * :macro:`NGHTTP3_H3_EXCESSIVE_LOAD` is HTTP/3 application error code
419
+ * ``H3_EXCESSIVE_LOAD``.
420
+ */
421
+ #define NGHTTP3_H3_EXCESSIVE_LOAD 0x0107
422
+ /**
423
+ * @macro
424
+ *
425
+ * :macro:`NGHTTP3_H3_ID_ERROR` is HTTP/3 application error code
426
+ * ``H3_ID_ERROR``.
427
+ */
428
+ #define NGHTTP3_H3_ID_ERROR 0x0108
429
+ /**
430
+ * @macro
431
+ *
432
+ * :macro:`NGHTTP3_H3_SETTINGS_ERROR` is HTTP/3 application error code
433
+ * ``H3_SETTINGS_ERROR``.
434
+ */
435
+ #define NGHTTP3_H3_SETTINGS_ERROR 0x0109
436
+ /**
437
+ * @macro
438
+ *
439
+ * :macro:`NGHTTP3_H3_MISSING_SETTINGS` is HTTP/3 application error
440
+ * code ``H3_MISSING_SETTINGS``.
441
+ */
442
+ #define NGHTTP3_H3_MISSING_SETTINGS 0x010A
443
+ /**
444
+ * @macro
445
+ *
446
+ * :macro:`NGHTTP3_H3_REQUEST_REJECTED` is HTTP/3 application error
447
+ * code ``H3_REQUEST_REJECTED``.
448
+ */
449
+ #define NGHTTP3_H3_REQUEST_REJECTED 0x010B
450
+ /**
451
+ * @macro
452
+ *
453
+ * :macro:`NGHTTP3_H3_REQUEST_CANCELLED` is HTTP/3 application error
454
+ * code ``H3_REQUEST_CANCELLED``.
455
+ */
456
+ #define NGHTTP3_H3_REQUEST_CANCELLED 0x010C
457
+ /**
458
+ * @macro
459
+ *
460
+ * :macro:`NGHTTP3_H3_REQUEST_INCOMPLETE` is HTTP/3 application error
461
+ * code ``H3_REQUEST_INCOMPLETE``.
462
+ */
463
+ #define NGHTTP3_H3_REQUEST_INCOMPLETE 0x010D
464
+ /**
465
+ * @macro
466
+ *
467
+ * :macro:`NGHTTP3_H3_MESSAGE_ERROR` is HTTP/3 application error code
468
+ * ``H3_MESSAGE_ERROR``.
469
+ */
470
+ #define NGHTTP3_H3_MESSAGE_ERROR 0x010E
471
+ /**
472
+ * @macro
473
+ *
474
+ * :macro:`NGHTTP3_H3_CONNECT_ERROR` is HTTP/3 application error code
475
+ * ``H3_CONNECT_ERROR``.
476
+ */
477
+ #define NGHTTP3_H3_CONNECT_ERROR 0x010F
478
+ /**
479
+ * @macro
480
+ *
481
+ * :macro:`NGHTTP3_H3_VERSION_FALLBACK` is HTTP/3 application error
482
+ * code ``H3_VERSION_FALLBACK``.
483
+ */
484
+ #define NGHTTP3_H3_VERSION_FALLBACK 0x0110
485
+ /**
486
+ * @macro
487
+ *
488
+ * :macro:`NGHTTP3_QPACK_DECOMPRESSION_FAILED` is HTTP/3 application
489
+ * error code ``QPACK_DECOMPRESSION_FAILED``.
490
+ */
491
+ #define NGHTTP3_QPACK_DECOMPRESSION_FAILED 0x0200
492
+ /**
493
+ * @macro
494
+ *
495
+ * :macro:`NGHTTP3_QPACK_ENCODER_STREAM_ERROR` is HTTP/3 application
496
+ * error code ``QPACK_ENCODER_STREAM_ERROR``.
497
+ */
498
+ #define NGHTTP3_QPACK_ENCODER_STREAM_ERROR 0x0201
499
+ /**
500
+ * @macro
501
+ *
502
+ * :macro:`NGHTTP3_QPACK_DECODER_STREAM_ERROR` is HTTP/3 application
503
+ * error code ``QPACK_DECODER_STREAM_ERROR``.
504
+ */
505
+ #define NGHTTP3_QPACK_DECODER_STREAM_ERROR 0x0202
506
+
507
+ /**
508
+ * @functypedef
509
+ *
510
+ * :type:`nghttp3_malloc` is a custom memory allocator to replace
511
+ * :manpage:`malloc(3)`. The |user_data| is the
512
+ * :member:`nghttp3_mem.user_data`.
513
+ */
514
+ typedef void *(*nghttp3_malloc)(size_t size, void *user_data);
515
+
516
+ /**
517
+ * @functypedef
518
+ *
519
+ * :type:`nghttp3_free` is a custom memory allocator to replace
520
+ * :manpage:`free(3)`. The |user_data| is the
521
+ * :member:`nghttp3_mem.user_data`.
522
+ */
523
+ typedef void (*nghttp3_free)(void *ptr, void *user_data);
524
+
525
+ /**
526
+ * @functypedef
527
+ *
528
+ * :type:`nghttp3_calloc` is a custom memory allocator to replace
529
+ * :manpage:`calloc(3)`. The |user_data| is the
530
+ * :member:`nghttp3_mem.user_data`.
531
+ */
532
+ typedef void *(*nghttp3_calloc)(size_t nmemb, size_t size, void *user_data);
533
+
534
+ /**
535
+ * @functypedef
536
+ *
537
+ * :type:`nghttp3_realloc` is a custom memory allocator to replace
538
+ * :manpage:`realloc(3)`. The |user_data| is the
539
+ * :member:`nghttp3_mem.user_data`.
540
+ */
541
+ typedef void *(*nghttp3_realloc)(void *ptr, size_t size, void *user_data);
542
+
543
+ /**
544
+ * @struct
545
+ *
546
+ * :type:`nghttp3_mem` is a custom memory allocator functions and user
547
+ * defined pointer. The :member:`user_data` field is passed to each
548
+ * allocator function. This can be used, for example, to achieve
549
+ * per-session memory pool.
550
+ *
551
+ * In the following example code, ``my_malloc``, ``my_free``,
552
+ * ``my_calloc``, and ``my_realloc`` are the replacement of the
553
+ * standard allocators :manpage:`malloc(3)`, :manpage:`free(3)`,
554
+ * :manpage:`calloc(3)` and :manpage:`realloc(3)` respectively::
555
+ *
556
+ * void *my_malloc_cb(size_t size, void *user_data) {
557
+ * (void)user_data;
558
+ * return my_malloc(size);
559
+ * }
560
+ *
561
+ * void my_free_cb(void *ptr, void *user_data) {
562
+ * (void)user_data;
563
+ * my_free(ptr);
564
+ * }
565
+ *
566
+ * void *my_calloc_cb(size_t nmemb, size_t size, void *user_data) {
567
+ * (void)user_data;
568
+ * return my_calloc(nmemb, size);
569
+ * }
570
+ *
571
+ * void *my_realloc_cb(void *ptr, size_t size, void *user_data) {
572
+ * (void)user_data;
573
+ * return my_realloc(ptr, size);
574
+ * }
575
+ *
576
+ * void conn_new() {
577
+ * nghttp3_mem mem = {NULL, my_malloc_cb, my_free_cb, my_calloc_cb,
578
+ * my_realloc_cb};
579
+ *
580
+ * ...
581
+ * }
582
+ */
583
+ typedef struct nghttp3_mem {
584
+ /**
585
+ * :member:`user_data` is an arbitrary user supplied data. This is
586
+ * passed to each allocator function.
587
+ */
588
+ void *user_data;
589
+ /**
590
+ * :member:`malloc` is a custom allocator function to replace
591
+ * :manpage:`malloc(3)`.
592
+ */
593
+ nghttp3_malloc malloc;
594
+ /**
595
+ * :member:`free` is a custom allocator function to replace
596
+ * :manpage:`free(3)`.
597
+ */
598
+ nghttp3_free free;
599
+ /**
600
+ * :member:`calloc` is a custom allocator function to replace
601
+ * :manpage:`calloc(3)`.
602
+ */
603
+ nghttp3_calloc calloc;
604
+ /**
605
+ * :member:`realloc` is a custom allocator function to replace
606
+ * :manpage:`realloc(3)`.
607
+ */
608
+ nghttp3_realloc realloc;
609
+ } nghttp3_mem;
610
+
611
+ /**
612
+ * @function
613
+ *
614
+ * `nghttp3_mem_default` returns the default memory allocator which
615
+ * uses malloc/calloc/realloc/free.
616
+ */
617
+ NGHTTP3_EXTERN const nghttp3_mem *nghttp3_mem_default(void);
618
+
619
+ /**
620
+ * @struct
621
+ *
622
+ * :type:`nghttp3_vec` is ``struct iovec`` compatible structure to
623
+ * reference arbitrary array of bytes.
624
+ */
625
+ typedef struct nghttp3_vec {
626
+ /**
627
+ * :member:`base` points to the data.
628
+ */
629
+ uint8_t *base;
630
+ /**
631
+ * :member:`len` is the number of bytes which the buffer pointed by
632
+ * :member:`base` contains.
633
+ */
634
+ size_t len;
635
+ } nghttp3_vec;
636
+
637
+ /**
638
+ * @struct
639
+ *
640
+ * :type:`nghttp3_rcbuf` is the object representing reference counted
641
+ * buffer. The details of this structure are intentionally hidden
642
+ * from the public API.
643
+ */
644
+ typedef struct nghttp3_rcbuf nghttp3_rcbuf;
645
+
646
+ /**
647
+ * @function
648
+ *
649
+ * `nghttp3_rcbuf_incref` increments the reference count of |rcbuf| by
650
+ * 1.
651
+ */
652
+ NGHTTP3_EXTERN void nghttp3_rcbuf_incref(nghttp3_rcbuf *rcbuf);
653
+
654
+ /**
655
+ * @function
656
+ *
657
+ * `nghttp3_rcbuf_decref` decrements the reference count of |rcbuf| by
658
+ * 1. If the reference count becomes zero, the object pointed by
659
+ * |rcbuf| will be freed. In this case, application must not use
660
+ * |rcbuf| again.
661
+ */
662
+ NGHTTP3_EXTERN void nghttp3_rcbuf_decref(nghttp3_rcbuf *rcbuf);
663
+
664
+ /**
665
+ * @function
666
+ *
667
+ * `nghttp3_rcbuf_get_buf` returns the underlying buffer managed by
668
+ * |rcbuf|.
669
+ */
670
+ NGHTTP3_EXTERN nghttp3_vec nghttp3_rcbuf_get_buf(const nghttp3_rcbuf *rcbuf);
671
+
672
+ /**
673
+ * @function
674
+ *
675
+ * `nghttp3_rcbuf_is_static` returns nonzero if the underlying buffer
676
+ * is statically allocated, and 0 otherwise. This can be useful for
677
+ * language bindings that wish to avoid creating duplicate strings for
678
+ * these buffers.
679
+ */
680
+ NGHTTP3_EXTERN int nghttp3_rcbuf_is_static(const nghttp3_rcbuf *rcbuf);
681
+
682
+ /**
683
+ * @struct
684
+ *
685
+ * :type:`nghttp3_buf` is the variable size buffer.
686
+ */
687
+ typedef struct nghttp3_buf {
688
+ /**
689
+ * :member:`begin` points to the beginning of the buffer.
690
+ */
691
+ uint8_t *begin;
692
+ /**
693
+ * :member:`end` points to the one beyond of the last byte of the
694
+ * buffer
695
+ */
696
+ uint8_t *end;
697
+ /**
698
+ * :member:`pos` points to the start of data. Typically, this
699
+ * points to the address that next data should be read. Initially,
700
+ * it points to :member:`begin`.
701
+ */
702
+ uint8_t *pos;
703
+ /**
704
+ * :member:`last` points to the one beyond of the last data of the
705
+ * buffer. Typically, new data is written at this point.
706
+ * Initially, it points to :member:`begin`.
707
+ */
708
+ uint8_t *last;
709
+ } nghttp3_buf;
710
+
711
+ /**
712
+ * @function
713
+ *
714
+ * `nghttp3_buf_init` initializes empty |buf|.
715
+ */
716
+ NGHTTP3_EXTERN void nghttp3_buf_init(nghttp3_buf *buf);
717
+
718
+ /**
719
+ * @function
720
+ *
721
+ * `nghttp3_buf_free` frees resources allocated for |buf| using |mem|
722
+ * as memory allocator. :member:`buf->begin <nghttp3_buf.begin>` must
723
+ * be a heap buffer allocated by |mem|.
724
+ */
725
+ NGHTTP3_EXTERN void nghttp3_buf_free(nghttp3_buf *buf, const nghttp3_mem *mem);
726
+
727
+ /**
728
+ * @function
729
+ *
730
+ * `nghttp3_buf_left` returns the number of additional bytes which can
731
+ * be written to the underlying buffer. In other words, it returns
732
+ * :member:`buf->end <nghttp3_buf.end>` - :member:`buf->last
733
+ * <nghttp3_buf.last>`.
734
+ */
735
+ NGHTTP3_EXTERN size_t nghttp3_buf_left(const nghttp3_buf *buf);
736
+
737
+ /**
738
+ * @function
739
+ *
740
+ * `nghttp3_buf_len` returns the number of bytes left to read. In
741
+ * other words, it returns :member:`buf->last <nghttp3_buf.last>` -
742
+ * :member:`buf->pos <nghttp3_buf.pos>`.
743
+ */
744
+ NGHTTP3_EXTERN size_t nghttp3_buf_len(const nghttp3_buf *buf);
745
+
746
+ /**
747
+ * @function
748
+ *
749
+ * `nghttp3_buf_reset` sets :member:`buf->pos <nghttp3_buf.pos>` and
750
+ * :member:`buf->last <nghttp3_buf.last>` to :member:`buf->begin
751
+ * <nghttp3_buf.begin>`.
752
+ */
753
+ NGHTTP3_EXTERN void nghttp3_buf_reset(nghttp3_buf *buf);
754
+
755
+ /**
756
+ * @macrosection
757
+ *
758
+ * Flags for HTTP field name/value pair
759
+ */
760
+
761
+ /**
762
+ * @macro
763
+ *
764
+ * :macro:`NGHTTP3_NV_FLAG_NONE` indicates no flag set.
765
+ */
766
+ #define NGHTTP3_NV_FLAG_NONE 0x00U
767
+
768
+ /**
769
+ * @macro
770
+ *
771
+ * :macro:`NGHTTP3_NV_FLAG_NEVER_INDEX` indicates that this name/value
772
+ * pair must not be indexed. Other implementation calls this bit as
773
+ * "sensitive".
774
+ */
775
+ #define NGHTTP3_NV_FLAG_NEVER_INDEX 0x01U
776
+
777
+ /**
778
+ * @macro
779
+ *
780
+ * :macro:`NGHTTP3_NV_FLAG_NO_COPY_NAME` is set solely by application.
781
+ * If this flag is set, the library does not make a copy of field
782
+ * name. This could improve performance.
783
+ */
784
+ #define NGHTTP3_NV_FLAG_NO_COPY_NAME 0x02U
785
+
786
+ /**
787
+ * @macro
788
+ *
789
+ * :macro:`NGHTTP3_NV_FLAG_NO_COPY_VALUE` is set solely by
790
+ * application. If this flag is set, the library does not make a copy
791
+ * of field value. This could improve performance.
792
+ */
793
+ #define NGHTTP3_NV_FLAG_NO_COPY_VALUE 0x04U
794
+
795
+ /**
796
+ * @macro
797
+ *
798
+ * :macro:`NGHTTP3_NV_FLAG_TRY_INDEX` gives a hint to QPACK encoder to
799
+ * index an HTTP field which is not indexed by default. This is just
800
+ * a hint, and QPACK encoder might not encode the field in various
801
+ * reasons.
802
+ */
803
+ #define NGHTTP3_NV_FLAG_TRY_INDEX 0x08U
804
+
805
+ /**
806
+ * @struct
807
+ *
808
+ * :type:`nghttp3_nv` is the name/value pair, which mainly used to
809
+ * represent HTTP fields.
810
+ */
811
+ typedef struct nghttp3_nv {
812
+ /**
813
+ * :member:`name` is the HTTP field name.
814
+ */
815
+ const uint8_t *name;
816
+ /**
817
+ * :member:`value` is the HTTP field value.
818
+ */
819
+ const uint8_t *value;
820
+ /**
821
+ * :member:`namelen` is the length of the |name|, excluding
822
+ * terminating NULL.
823
+ */
824
+ size_t namelen;
825
+ /**
826
+ * :member:`valuelen` is the length of the |value|, excluding
827
+ * terminating NULL.
828
+ */
829
+ size_t valuelen;
830
+ /**
831
+ * :member:`flags` is bitwise OR of one or more of
832
+ * :macro:`NGHTTP3_NV_FLAG_* <NGHTTP3_NV_FLAG_NONE>`.
833
+ */
834
+ uint8_t flags;
835
+ } nghttp3_nv;
836
+
837
+ /* Generated by mkstatichdtbl.py */
838
+ /**
839
+ * @enum
840
+ *
841
+ * :type:`nghttp3_qpack_token` defines HTTP field name tokens to
842
+ * identify field name quickly. It appears in
843
+ * :member:`nghttp3_qpack_nv.token`.
844
+ */
845
+ typedef enum nghttp3_qpack_token {
846
+ /**
847
+ * :enum:`NGHTTP3_QPACK_TOKEN__AUTHORITY` is a token for
848
+ * ``:authority``.
849
+ */
850
+ NGHTTP3_QPACK_TOKEN__AUTHORITY = 0,
851
+ /**
852
+ * :enum:`NGHTTP3_QPACK_TOKEN__PATH` is a token for ``:path``.
853
+ */
854
+ NGHTTP3_QPACK_TOKEN__PATH = 8,
855
+ /**
856
+ * :enum:`NGHTTP3_QPACK_TOKEN_AGE` is a token for ``age``.
857
+ */
858
+ NGHTTP3_QPACK_TOKEN_AGE = 43,
859
+ /**
860
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION` is a token for
861
+ * ``content-disposition``.
862
+ */
863
+ NGHTTP3_QPACK_TOKEN_CONTENT_DISPOSITION = 52,
864
+ /**
865
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH` is a token for
866
+ * ``content-length``.
867
+ */
868
+ NGHTTP3_QPACK_TOKEN_CONTENT_LENGTH = 55,
869
+ /**
870
+ * :enum:`NGHTTP3_QPACK_TOKEN_COOKIE` is a token for ``cookie``.
871
+ */
872
+ NGHTTP3_QPACK_TOKEN_COOKIE = 68,
873
+ /**
874
+ * :enum:`NGHTTP3_QPACK_TOKEN_DATE` is a token for ``date``.
875
+ */
876
+ NGHTTP3_QPACK_TOKEN_DATE = 69,
877
+ /**
878
+ * :enum:`NGHTTP3_QPACK_TOKEN_ETAG` is a token for ``etag``.
879
+ */
880
+ NGHTTP3_QPACK_TOKEN_ETAG = 71,
881
+ /**
882
+ * :enum:`NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE` is a token for
883
+ * ``if-modified-since``.
884
+ */
885
+ NGHTTP3_QPACK_TOKEN_IF_MODIFIED_SINCE = 74,
886
+ /**
887
+ * :enum:`NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH` is a token for
888
+ * ``if-none-match``.
889
+ */
890
+ NGHTTP3_QPACK_TOKEN_IF_NONE_MATCH = 75,
891
+ /**
892
+ * :enum:`NGHTTP3_QPACK_TOKEN_LAST_MODIFIED` is a token for
893
+ * ``last-modified``.
894
+ */
895
+ NGHTTP3_QPACK_TOKEN_LAST_MODIFIED = 77,
896
+ /**
897
+ * :enum:`NGHTTP3_QPACK_TOKEN_LINK` is a token for ``link``.
898
+ */
899
+ NGHTTP3_QPACK_TOKEN_LINK = 78,
900
+ /**
901
+ * :enum:`NGHTTP3_QPACK_TOKEN_LOCATION` is a token for ``location``.
902
+ */
903
+ NGHTTP3_QPACK_TOKEN_LOCATION = 79,
904
+ /**
905
+ * :enum:`NGHTTP3_QPACK_TOKEN_REFERER` is a token for ``referer``.
906
+ */
907
+ NGHTTP3_QPACK_TOKEN_REFERER = 83,
908
+ /**
909
+ * :enum:`NGHTTP3_QPACK_TOKEN_SET_COOKIE` is a token for
910
+ * ``set-cookie``.
911
+ */
912
+ NGHTTP3_QPACK_TOKEN_SET_COOKIE = 85,
913
+ /**
914
+ * :enum:`NGHTTP3_QPACK_TOKEN__METHOD` is a token for ``:method``.
915
+ */
916
+ NGHTTP3_QPACK_TOKEN__METHOD = 1,
917
+ /**
918
+ * :enum:`NGHTTP3_QPACK_TOKEN__SCHEME` is a token for ``:scheme``.
919
+ */
920
+ NGHTTP3_QPACK_TOKEN__SCHEME = 9,
921
+ /**
922
+ * :enum:`NGHTTP3_QPACK_TOKEN__STATUS` is a token for ``:status``.
923
+ */
924
+ NGHTTP3_QPACK_TOKEN__STATUS = 11,
925
+ /**
926
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT` is a token for ``accept``.
927
+ */
928
+ NGHTTP3_QPACK_TOKEN_ACCEPT = 25,
929
+ /**
930
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING` is a token for
931
+ * ``accept-encoding``.
932
+ */
933
+ NGHTTP3_QPACK_TOKEN_ACCEPT_ENCODING = 27,
934
+ /**
935
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES` is a token for
936
+ * ``accept-ranges``.
937
+ */
938
+ NGHTTP3_QPACK_TOKEN_ACCEPT_RANGES = 29,
939
+ /**
940
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS` is a
941
+ * token for ``access-control-allow-headers``.
942
+ */
943
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_HEADERS = 32,
944
+ /**
945
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN` is a
946
+ * token for ``access-control-allow-origin``.
947
+ */
948
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_ORIGIN = 38,
949
+ /**
950
+ * :enum:`NGHTTP3_QPACK_TOKEN_CACHE_CONTROL` is a token for
951
+ * ``cache-control``.
952
+ */
953
+ NGHTTP3_QPACK_TOKEN_CACHE_CONTROL = 46,
954
+ /**
955
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING` is a token for
956
+ * ``content-encoding``.
957
+ */
958
+ NGHTTP3_QPACK_TOKEN_CONTENT_ENCODING = 53,
959
+ /**
960
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_TYPE` is a token for
961
+ * ``content-type``.
962
+ */
963
+ NGHTTP3_QPACK_TOKEN_CONTENT_TYPE = 57,
964
+ /**
965
+ * :enum:`NGHTTP3_QPACK_TOKEN_RANGE` is a token for ``range``.
966
+ */
967
+ NGHTTP3_QPACK_TOKEN_RANGE = 82,
968
+ /**
969
+ * :enum:`NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY` is a token
970
+ * for ``strict-transport-security``.
971
+ */
972
+ NGHTTP3_QPACK_TOKEN_STRICT_TRANSPORT_SECURITY = 86,
973
+ /**
974
+ * :enum:`NGHTTP3_QPACK_TOKEN_VARY` is a token for ``vary``.
975
+ */
976
+ NGHTTP3_QPACK_TOKEN_VARY = 92,
977
+ /**
978
+ * :enum:`NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS` is a token for
979
+ * ``x-content-type-options``.
980
+ */
981
+ NGHTTP3_QPACK_TOKEN_X_CONTENT_TYPE_OPTIONS = 94,
982
+ /**
983
+ * :enum:`NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION` is a token for
984
+ * ``x-xss-protection``.
985
+ */
986
+ NGHTTP3_QPACK_TOKEN_X_XSS_PROTECTION = 98,
987
+ /**
988
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE` is a token for
989
+ * ``accept-language``.
990
+ */
991
+ NGHTTP3_QPACK_TOKEN_ACCEPT_LANGUAGE = 28,
992
+ /**
993
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS` is a
994
+ * token for ``access-control-allow-credentials``.
995
+ */
996
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_CREDENTIALS = 30,
997
+ /**
998
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS` is a
999
+ * token for ``access-control-allow-methods``.
1000
+ */
1001
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_ALLOW_METHODS = 35,
1002
+ /**
1003
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_EXPOSE_HEADERS` is a
1004
+ * token for ``access-control-expose-headers``.
1005
+ */
1006
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_EXPOSE_HEADERS = 39,
1007
+ /**
1008
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_HEADERS` is a
1009
+ * token for ``access-control-request-headers``.
1010
+ */
1011
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_HEADERS = 40,
1012
+ /**
1013
+ * :enum:`NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD` is a
1014
+ * token for ``access-control-request-method``.
1015
+ */
1016
+ NGHTTP3_QPACK_TOKEN_ACCESS_CONTROL_REQUEST_METHOD = 41,
1017
+ /**
1018
+ * :enum:`NGHTTP3_QPACK_TOKEN_ALT_SVC` is a token for ``alt-svc``.
1019
+ */
1020
+ NGHTTP3_QPACK_TOKEN_ALT_SVC = 44,
1021
+ /**
1022
+ * :enum:`NGHTTP3_QPACK_TOKEN_AUTHORIZATION` is a token for
1023
+ * ``authorization``.
1024
+ */
1025
+ NGHTTP3_QPACK_TOKEN_AUTHORIZATION = 45,
1026
+ /**
1027
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY` is a token
1028
+ * for ``content-security-policy``.
1029
+ */
1030
+ NGHTTP3_QPACK_TOKEN_CONTENT_SECURITY_POLICY = 56,
1031
+ /**
1032
+ * :enum:`NGHTTP3_QPACK_TOKEN_EARLY_DATA` is a token for
1033
+ * ``early-data``.
1034
+ */
1035
+ NGHTTP3_QPACK_TOKEN_EARLY_DATA = 70,
1036
+ /**
1037
+ * :enum:`NGHTTP3_QPACK_TOKEN_EXPECT_CT` is a token for
1038
+ * ``expect-ct``.
1039
+ */
1040
+ NGHTTP3_QPACK_TOKEN_EXPECT_CT = 72,
1041
+ /**
1042
+ * :enum:`NGHTTP3_QPACK_TOKEN_FORWARDED` is a token for
1043
+ * ``forwarded``.
1044
+ */
1045
+ NGHTTP3_QPACK_TOKEN_FORWARDED = 73,
1046
+ /**
1047
+ * :enum:`NGHTTP3_QPACK_TOKEN_IF_RANGE` is a token for ``if-range``.
1048
+ */
1049
+ NGHTTP3_QPACK_TOKEN_IF_RANGE = 76,
1050
+ /**
1051
+ * :enum:`NGHTTP3_QPACK_TOKEN_ORIGIN` is a token for ``origin``.
1052
+ */
1053
+ NGHTTP3_QPACK_TOKEN_ORIGIN = 80,
1054
+ /**
1055
+ * :enum:`NGHTTP3_QPACK_TOKEN_PURPOSE` is a token for ``purpose``.
1056
+ */
1057
+ NGHTTP3_QPACK_TOKEN_PURPOSE = 81,
1058
+ /**
1059
+ * :enum:`NGHTTP3_QPACK_TOKEN_SERVER` is a token for ``server``.
1060
+ */
1061
+ NGHTTP3_QPACK_TOKEN_SERVER = 84,
1062
+ /**
1063
+ * :enum:`NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN` is a token for
1064
+ * ``timing-allow-origin``.
1065
+ */
1066
+ NGHTTP3_QPACK_TOKEN_TIMING_ALLOW_ORIGIN = 89,
1067
+ /**
1068
+ * :enum:`NGHTTP3_QPACK_TOKEN_UPGRADE_INSECURE_REQUESTS` is a token
1069
+ * for ``upgrade-insecure-requests``.
1070
+ */
1071
+ NGHTTP3_QPACK_TOKEN_UPGRADE_INSECURE_REQUESTS = 90,
1072
+ /**
1073
+ * :enum:`NGHTTP3_QPACK_TOKEN_USER_AGENT` is a token for
1074
+ * ``user-agent``.
1075
+ */
1076
+ NGHTTP3_QPACK_TOKEN_USER_AGENT = 91,
1077
+ /**
1078
+ * :enum:`NGHTTP3_QPACK_TOKEN_X_FORWARDED_FOR` is a token for
1079
+ * ``x-forwarded-for``.
1080
+ */
1081
+ NGHTTP3_QPACK_TOKEN_X_FORWARDED_FOR = 95,
1082
+ /**
1083
+ * :enum:`NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS` is a token for
1084
+ * ``x-frame-options``.
1085
+ */
1086
+ NGHTTP3_QPACK_TOKEN_X_FRAME_OPTIONS = 96,
1087
+
1088
+ /* Additional HTTP fields for HTTP messaging validation */
1089
+
1090
+ /**
1091
+ * :enum:`NGHTTP3_QPACK_TOKEN_HOST` is a token for ``host``.
1092
+ */
1093
+ NGHTTP3_QPACK_TOKEN_HOST = 1000,
1094
+ /**
1095
+ * :enum:`NGHTTP3_QPACK_TOKEN_CONNECTION` is a token for
1096
+ * ``connection``.
1097
+ */
1098
+ NGHTTP3_QPACK_TOKEN_CONNECTION,
1099
+ /**
1100
+ * :enum:`NGHTTP3_QPACK_TOKEN_KEEP_ALIVE` is a token for
1101
+ * ``keep-alive``.
1102
+ */
1103
+ NGHTTP3_QPACK_TOKEN_KEEP_ALIVE,
1104
+ /**
1105
+ * :enum:`NGHTTP3_QPACK_TOKEN_PROXY_CONNECTION` is a token for
1106
+ * ``proxy-connection``.
1107
+ */
1108
+ NGHTTP3_QPACK_TOKEN_PROXY_CONNECTION,
1109
+ /**
1110
+ * :enum:`NGHTTP3_QPACK_TOKEN_TRANSFER_ENCODING` is a token for
1111
+ * ``transfer-encoding``.
1112
+ */
1113
+ NGHTTP3_QPACK_TOKEN_TRANSFER_ENCODING,
1114
+ /**
1115
+ * :enum:`NGHTTP3_QPACK_TOKEN_UPGRADE` is a token for ``upgrade``.
1116
+ */
1117
+ NGHTTP3_QPACK_TOKEN_UPGRADE,
1118
+ /**
1119
+ * :enum:`NGHTTP3_QPACK_TOKEN_TE` is a token for ``te``.
1120
+ */
1121
+ NGHTTP3_QPACK_TOKEN_TE,
1122
+ /**
1123
+ * :enum:`NGHTTP3_QPACK_TOKEN__PROTOCOL` is a token for
1124
+ * ``:protocol``.
1125
+ */
1126
+ NGHTTP3_QPACK_TOKEN__PROTOCOL,
1127
+ /**
1128
+ * :enum:`NGHTTP3_QPACK_TOKEN_PRIORITY` is a token for ``priority``.
1129
+ */
1130
+ NGHTTP3_QPACK_TOKEN_PRIORITY
1131
+ } nghttp3_qpack_token;
1132
+
1133
+ /**
1134
+ * @struct
1135
+ *
1136
+ * :type:`nghttp3_qpack_nv` represents HTTP field name/value pair just
1137
+ * like :type:`nghttp3_nv`. It is an extended version of
1138
+ * :type:`nghttp3_nv`, and has reference counted buffers and tokens.
1139
+ */
1140
+ typedef struct nghttp3_qpack_nv {
1141
+ /**
1142
+ * :member:`name` is the buffer containing HTTP field name.
1143
+ * NULL-termination is guaranteed.
1144
+ */
1145
+ nghttp3_rcbuf *name;
1146
+ /**
1147
+ * :member:`value` is the buffer containing HTTP field value.
1148
+ * NULL-termination is guaranteed.
1149
+ */
1150
+ nghttp3_rcbuf *value;
1151
+ /**
1152
+ * :member:`token` is :type:`nghttp3_qpack_token` value of
1153
+ * :member:`name`. It could be -1 if we have no token for that HTTP
1154
+ * field name.
1155
+ */
1156
+ int32_t token;
1157
+ /**
1158
+ * :member:`flags` is a bitwise OR of one or more of
1159
+ * :macro:`NGHTTP3_NV_FLAG_* <NGHTTP3_NV_FLAG_NONE>`.
1160
+ */
1161
+ uint8_t flags;
1162
+ } nghttp3_qpack_nv;
1163
+
1164
+ /**
1165
+ * @enum
1166
+ *
1167
+ * :type:`nghttp3_qpack_indexing_strat` defines the QPACK dynamic
1168
+ * table indexing strategies for fields not defined in
1169
+ * :type:`nghttp3_qpack_token`.
1170
+ *
1171
+ * .. version-added:: 1.13.0
1172
+ */
1173
+ typedef enum nghttp3_qpack_indexing_strat {
1174
+ /**
1175
+ * :enum:`NGHTTP3_QPACK_INDEXING_STRAT_NONE` does not index any
1176
+ * fields not defined in :type:`nghttp3_qpack_token`. This is the
1177
+ * default strategy. You can still use
1178
+ * :macro:`NGHTTP3_NV_FLAG_TRY_INDEX` to index a particular field.
1179
+ *
1180
+ * .. version-added:: 1.13.0
1181
+ */
1182
+ NGHTTP3_QPACK_INDEXING_STRAT_NONE,
1183
+ /**
1184
+ * :enum:`NGHTTP3_QPACK_INDEXING_STRAT_EAGER` indexes all fields not
1185
+ * defined in :type:`nghttp3_qpack_token`. Please note that QPACK
1186
+ * encoder might not index the field in various reasons.
1187
+ *
1188
+ * .. version-added:: 1.13.0
1189
+ */
1190
+ NGHTTP3_QPACK_INDEXING_STRAT_EAGER
1191
+ } nghttp3_qpack_indexing_strat;
1192
+
1193
+ /**
1194
+ * @struct
1195
+ *
1196
+ * :type:`nghttp3_qpack_encoder` is QPACK encoder. The details of
1197
+ * this structure are intentionally hidden from the public API.
1198
+ */
1199
+ typedef struct nghttp3_qpack_encoder nghttp3_qpack_encoder;
1200
+
1201
+ /**
1202
+ * @function
1203
+ *
1204
+ * `nghttp3_qpack_encoder_new` initializes QPACK encoder. |pencoder|
1205
+ * must be non-NULL pointer. |hard_max_dtable_capacity| is the upper
1206
+ * bound of the dynamic table capacity. |mem| is a memory allocator.
1207
+ * This function allocates memory for :type:`nghttp3_qpack_encoder`
1208
+ * itself, and assigns its pointer to |*pencoder| if it succeeds.
1209
+ *
1210
+ * The maximum dynamic table capacity is still 0. In order to change
1211
+ * the maximum dynamic table capacity, call
1212
+ * `nghttp3_qpack_encoder_set_max_dtable_capacity`.
1213
+ *
1214
+ * This function returns 0 if it succeeds, or one of the following
1215
+ * negative error codes:
1216
+ *
1217
+ * :macro:`NGHTTP3_ERR_NOMEM`
1218
+ * Out of memory.
1219
+ *
1220
+ * See also `nghttp3_qpack_encoder_new2`. This function calls
1221
+ * `nghttp3_qpack_encoder_new2` with the given parameters and 0 as
1222
+ * seed.
1223
+ */
1224
+ NGHTTP3_EXTERN int nghttp3_qpack_encoder_new(nghttp3_qpack_encoder **pencoder,
1225
+ size_t hard_max_dtable_capacity,
1226
+ const nghttp3_mem *mem);
1227
+
1228
+ /**
1229
+ * @function
1230
+ *
1231
+ * `nghttp3_qpack_encoder_new2` initializes QPACK encoder. |pencoder|
1232
+ * must be non-NULL pointer. |hard_max_dtable_capacity| is the upper
1233
+ * bound of the dynamic table capacity. |seed| must be unpredictable
1234
+ * value, and is used to seed the internal data structure. |mem| is a
1235
+ * memory allocator. This function allocates memory for
1236
+ * :type:`nghttp3_qpack_encoder` itself, and assigns its pointer to
1237
+ * |*pencoder| if it succeeds.
1238
+ *
1239
+ * The maximum dynamic table capacity is still 0. In order to change
1240
+ * the maximum dynamic table capacity, call
1241
+ * `nghttp3_qpack_encoder_set_max_dtable_capacity`.
1242
+ *
1243
+ * This function returns 0 if it succeeds, or one of the following
1244
+ * negative error codes:
1245
+ *
1246
+ * :macro:`NGHTTP3_ERR_NOMEM`
1247
+ * Out of memory.
1248
+ *
1249
+ * .. version-added:: 1.11.0
1250
+ */
1251
+ NGHTTP3_EXTERN int nghttp3_qpack_encoder_new2(nghttp3_qpack_encoder **pencoder,
1252
+ size_t hard_max_dtable_capacity,
1253
+ uint64_t seed,
1254
+ const nghttp3_mem *mem);
1255
+
1256
+ /**
1257
+ * @function
1258
+ *
1259
+ * `nghttp3_qpack_encoder_del` frees memory allocated for |encoder|.
1260
+ * This function also frees memory pointed by |encoder| itself. This
1261
+ * function does nothing if |encoder| is NULL.
1262
+ */
1263
+ NGHTTP3_EXTERN void nghttp3_qpack_encoder_del(nghttp3_qpack_encoder *encoder);
1264
+
1265
+ /**
1266
+ * @function
1267
+ *
1268
+ * `nghttp3_qpack_encoder_encode` encodes the list of HTTP fields
1269
+ * |nva|. |nvlen| is the length of |nva|. |stream_id| is the
1270
+ * identifier of the stream which these HTTP fields belong to. This
1271
+ * function writes field section prefix, encoded HTTP field section,
1272
+ * and encoder stream to |pbuf|, |rbuf|, and |ebuf| respectively.
1273
+ * Each :member:`nghttp3_buf.last` will be adjusted when data is
1274
+ * written. An application should write |pbuf| and |rbuf| to the
1275
+ * request stream in this order.
1276
+ *
1277
+ * The buffer pointed by |pbuf|, |rbuf|, and |ebuf| can be empty
1278
+ * buffer. It is fine to pass a buffer initialized by
1279
+ * `nghttp3_buf_init(buf) <nghttp3_buf_init>`. This function
1280
+ * allocates memory for these buffers as necessary. In particular, it
1281
+ * frees and expands buffer if the current capacity of buffer is not
1282
+ * enough. If :member:`nghttp3_buf.begin` of any buffer is not NULL,
1283
+ * it must be allocated by the same memory allocator passed to
1284
+ * `nghttp3_qpack_encoder_new`.
1285
+ *
1286
+ * This function returns 0 if it succeeds, or one of the following
1287
+ * negative error codes:
1288
+ *
1289
+ * :macro:`NGHTTP3_ERR_NOMEM`
1290
+ * Out of memory
1291
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
1292
+ * |encoder| is in unrecoverable error state, and cannot be used
1293
+ * anymore.
1294
+ */
1295
+ NGHTTP3_EXTERN int nghttp3_qpack_encoder_encode(
1296
+ nghttp3_qpack_encoder *encoder, nghttp3_buf *pbuf, nghttp3_buf *rbuf,
1297
+ nghttp3_buf *ebuf, int64_t stream_id, const nghttp3_nv *nva, size_t nvlen);
1298
+
1299
+ /**
1300
+ * @function
1301
+ *
1302
+ * `nghttp3_qpack_encoder_read_decoder` reads decoder stream. The
1303
+ * buffer pointed by |src| of length |srclen| contains decoder stream.
1304
+ *
1305
+ * This function returns the number of bytes read, or one of the
1306
+ * following negative error codes:
1307
+ *
1308
+ * :macro:`NGHTTP3_ERR_NOMEM`
1309
+ * Out of memory
1310
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
1311
+ * |encoder| is in unrecoverable error state, and cannot be used
1312
+ * anymore.
1313
+ * :macro:`NGHTTP3_ERR_QPACK_DECODER_STREAM`
1314
+ * |encoder| is unable to process input because it is malformed.
1315
+ */
1316
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_qpack_encoder_read_decoder(
1317
+ nghttp3_qpack_encoder *encoder, const uint8_t *src, size_t srclen);
1318
+
1319
+ /**
1320
+ * @function
1321
+ *
1322
+ * `nghttp3_qpack_encoder_set_max_dtable_capacity` sets max dynamic
1323
+ * table capacity to |max_dtable_capacity|. If |max_dtable_capacity|
1324
+ * is larger than ``hard_max_dtable_capacity`` parameter of
1325
+ * `nghttp3_qpack_encoder_new`, it is truncated to the latter.
1326
+ */
1327
+ NGHTTP3_EXTERN void
1328
+ nghttp3_qpack_encoder_set_max_dtable_capacity(nghttp3_qpack_encoder *encoder,
1329
+ size_t max_dtable_capacity);
1330
+
1331
+ /**
1332
+ * @function
1333
+ *
1334
+ * `nghttp3_qpack_encoder_set_max_blocked_streams` sets the number of
1335
+ * streams which can be blocked to |max_blocked_streams|.
1336
+ */
1337
+ NGHTTP3_EXTERN void
1338
+ nghttp3_qpack_encoder_set_max_blocked_streams(nghttp3_qpack_encoder *encoder,
1339
+ size_t max_blocked_streams);
1340
+
1341
+ /**
1342
+ * @function
1343
+ *
1344
+ * `nghttp3_qpack_encoder_set_indexing_strat` sets the dynamic table
1345
+ * indexing strategy |strat| to |encoder|.
1346
+ *
1347
+ * .. version-added:: 1.13.0
1348
+ */
1349
+ NGHTTP3_EXTERN void
1350
+ nghttp3_qpack_encoder_set_indexing_strat(nghttp3_qpack_encoder *encoder,
1351
+ nghttp3_qpack_indexing_strat strat);
1352
+
1353
+ /**
1354
+ * @function
1355
+ *
1356
+ * `nghttp3_qpack_encoder_ack_everything` tells |encoder| that all
1357
+ * encoded HTTP field sections are acknowledged. This function is
1358
+ * provided for debugging purpose only. In HTTP/3, |encoder| knows
1359
+ * this by reading decoder stream with
1360
+ * `nghttp3_qpack_encoder_read_decoder`.
1361
+ */
1362
+ NGHTTP3_EXTERN void
1363
+ nghttp3_qpack_encoder_ack_everything(nghttp3_qpack_encoder *encoder);
1364
+
1365
+ /**
1366
+ * @function
1367
+ *
1368
+ * .. warning::
1369
+ *
1370
+ * .. version-deprecated:: 1.16.0
1371
+ * Use `nghttp3_qpack_encoder_get_num_blocked_streams2` instead.
1372
+ *
1373
+ * `nghttp3_qpack_encoder_get_num_blocked_streams` returns the number
1374
+ * of streams which are potentially blocked at decoder side.
1375
+ */
1376
+ NGHTTP3_EXTERN size_t
1377
+ nghttp3_qpack_encoder_get_num_blocked_streams(nghttp3_qpack_encoder *encoder);
1378
+
1379
+ /**
1380
+ * @function
1381
+ *
1382
+ * `nghttp3_qpack_encoder_get_num_blocked_streams2` returns the number
1383
+ * of streams which are potentially blocked at decoder side.
1384
+ *
1385
+ * .. version-added:: 1.16.0
1386
+ */
1387
+ NGHTTP3_EXTERN size_t nghttp3_qpack_encoder_get_num_blocked_streams2(
1388
+ const nghttp3_qpack_encoder *encoder);
1389
+
1390
+ /**
1391
+ * @struct
1392
+ *
1393
+ * :type:`nghttp3_qpack_stream_context` is a decoder context for an
1394
+ * individual stream. Its state is per HTTP field section. In order
1395
+ * to reuse this object for another HTTP field section, call
1396
+ * `nghttp3_qpack_stream_context_reset`. The details of this
1397
+ * structure are intentionally hidden from the public API.
1398
+ */
1399
+ typedef struct nghttp3_qpack_stream_context nghttp3_qpack_stream_context;
1400
+
1401
+ /**
1402
+ * @function
1403
+ *
1404
+ * `nghttp3_qpack_stream_context_new` initializes stream context.
1405
+ * |psctx| must be non-NULL pointer. |stream_id| is stream ID. |mem|
1406
+ * is a memory allocator. This function allocates memory for
1407
+ * :type:`nghttp3_qpack_stream_context` itself, and assigns its
1408
+ * pointer to |*psctx| if it succeeds.
1409
+ *
1410
+ * This function returns 0 if it succeeds, or one of the following
1411
+ * negative error codes:
1412
+ *
1413
+ * :macro:`NGHTTP3_ERR_NOMEM`
1414
+ * Out of memory.
1415
+ */
1416
+ NGHTTP3_EXTERN int
1417
+ nghttp3_qpack_stream_context_new(nghttp3_qpack_stream_context **psctx,
1418
+ int64_t stream_id, const nghttp3_mem *mem);
1419
+
1420
+ /**
1421
+ * @function
1422
+ *
1423
+ * `nghttp3_qpack_stream_context_del` frees memory allocated for
1424
+ * |sctx|. This function frees memory pointed by |sctx| itself. This
1425
+ * function does nothing if |sctx| is NULL.
1426
+ */
1427
+ NGHTTP3_EXTERN void
1428
+ nghttp3_qpack_stream_context_del(nghttp3_qpack_stream_context *sctx);
1429
+
1430
+ /**
1431
+ * @function
1432
+ *
1433
+ * .. warning::
1434
+ *
1435
+ * .. version-deprecated:: 1.16.0
1436
+ * Use `nghttp3_qpack_stream_context_get_ricnt2` instead.
1437
+ *
1438
+ * `nghttp3_qpack_stream_context_get_ricnt` returns required insert
1439
+ * count.
1440
+ */
1441
+ NGHTTP3_EXTERN uint64_t
1442
+ nghttp3_qpack_stream_context_get_ricnt(nghttp3_qpack_stream_context *sctx);
1443
+
1444
+ /**
1445
+ * @function
1446
+ *
1447
+ * `nghttp3_qpack_stream_context_get_ricnt2` returns required insert
1448
+ * count.
1449
+ */
1450
+ NGHTTP3_EXTERN uint64_t nghttp3_qpack_stream_context_get_ricnt2(
1451
+ const nghttp3_qpack_stream_context *sctx);
1452
+
1453
+ /**
1454
+ * @function
1455
+ *
1456
+ * `nghttp3_qpack_stream_context_reset` resets the state of |sctx|.
1457
+ * Then it can be reused for decoding an another HTTP field section in
1458
+ * the same stream.
1459
+ */
1460
+ NGHTTP3_EXTERN
1461
+ void nghttp3_qpack_stream_context_reset(nghttp3_qpack_stream_context *sctx);
1462
+
1463
+ /**
1464
+ * @struct
1465
+ *
1466
+ * :type:`nghttp3_qpack_decoder` is QPACK decoder. The details of
1467
+ * this structure are intentionally hidden from the public API.
1468
+ */
1469
+ typedef struct nghttp3_qpack_decoder nghttp3_qpack_decoder;
1470
+
1471
+ /**
1472
+ * @function
1473
+ *
1474
+ * `nghttp3_qpack_decoder_new` initializes QPACK decoder. |pdecoder|
1475
+ * must be non-NULL pointer. |hard_max_dtable_capacity| is the upper
1476
+ * bound of the dynamic table capacity. |max_blocked_streams| is the
1477
+ * maximum number of streams which can be blocked. |mem| is a memory
1478
+ * allocator. This function allocates memory for
1479
+ * :type:`nghttp3_qpack_decoder` itself, and assigns its pointer to
1480
+ * |*pdecoder| if it succeeds.
1481
+ *
1482
+ * This function returns 0 if it succeeds, or one of the following
1483
+ * negative error codes:
1484
+ *
1485
+ * :macro:`NGHTTP3_ERR_NOMEM`
1486
+ * Out of memory.
1487
+ */
1488
+ NGHTTP3_EXTERN int nghttp3_qpack_decoder_new(nghttp3_qpack_decoder **pdecoder,
1489
+ size_t hard_max_dtable_capacity,
1490
+ size_t max_blocked_streams,
1491
+ const nghttp3_mem *mem);
1492
+
1493
+ /**
1494
+ * @function
1495
+ *
1496
+ * `nghttp3_qpack_decoder_del` frees memory allocated for |decoder|.
1497
+ * This function frees memory pointed by |decoder| itself. This
1498
+ * function does nothing if |decoder| is NULL.
1499
+ */
1500
+ NGHTTP3_EXTERN void nghttp3_qpack_decoder_del(nghttp3_qpack_decoder *decoder);
1501
+
1502
+ /**
1503
+ * @function
1504
+ *
1505
+ * `nghttp3_qpack_decoder_read_encoder` reads encoder stream. The
1506
+ * buffer pointed by |src| of length |srclen| contains encoder stream.
1507
+ *
1508
+ * This function returns the number of bytes read, or one of the
1509
+ * following negative error codes:
1510
+ *
1511
+ * :macro:`NGHTTP3_ERR_NOMEM`
1512
+ * Out of memory.
1513
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
1514
+ * |decoder| is in unrecoverable error state, and cannot be used
1515
+ * anymore.
1516
+ * :macro:`NGHTTP3_ERR_QPACK_ENCODER_STREAM`
1517
+ * Could not interpret encoder stream instruction.
1518
+ */
1519
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_qpack_decoder_read_encoder(
1520
+ nghttp3_qpack_decoder *decoder, const uint8_t *src, size_t srclen);
1521
+
1522
+ /**
1523
+ * @function
1524
+ *
1525
+ * `nghttp3_qpack_decoder_get_icnt` returns insert count.
1526
+ */
1527
+ NGHTTP3_EXTERN uint64_t
1528
+ nghttp3_qpack_decoder_get_icnt(const nghttp3_qpack_decoder *decoder);
1529
+
1530
+ /**
1531
+ * @macrosection
1532
+ *
1533
+ * Flags for QPACK decoder
1534
+ */
1535
+
1536
+ /**
1537
+ * @macro
1538
+ *
1539
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_NONE` indicates that no flag set.
1540
+ */
1541
+ #define NGHTTP3_QPACK_DECODE_FLAG_NONE 0x00U
1542
+
1543
+ /**
1544
+ * @macro
1545
+ *
1546
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_EMIT` indicates that an HTTP
1547
+ * field is successfully decoded.
1548
+ */
1549
+ #define NGHTTP3_QPACK_DECODE_FLAG_EMIT 0x01U
1550
+
1551
+ /**
1552
+ * @macro
1553
+ *
1554
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_FINAL` indicates that an entire
1555
+ * HTTP field section has been decoded.
1556
+ */
1557
+ #define NGHTTP3_QPACK_DECODE_FLAG_FINAL 0x02U
1558
+
1559
+ /**
1560
+ * @macro
1561
+ *
1562
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_BLOCKED` indicates that decoding
1563
+ * has been blocked.
1564
+ */
1565
+ #define NGHTTP3_QPACK_DECODE_FLAG_BLOCKED 0x04U
1566
+
1567
+ /**
1568
+ * @function
1569
+ *
1570
+ * `nghttp3_qpack_decoder_read_request` reads request stream. The
1571
+ * request stream is given as the buffer pointed by |src| of length
1572
+ * |srclen|. |sctx| is the stream context, and it must be created by
1573
+ * `nghttp3_qpack_stream_context_new`. |*pflags| must be non-NULL
1574
+ * pointer. |nv| must be non-NULL pointer.
1575
+ *
1576
+ * If this function succeeds, it assigns flags to |*pflags|. If
1577
+ * |*pflags| has :macro:`NGHTTP3_QPACK_DECODE_FLAG_EMIT` set, a
1578
+ * decoded HTTP field is assigned to |nv|. If |*pflags| has
1579
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_FINAL` set, an entire HTTP field
1580
+ * section has been successfully decoded. If |*pflags| has
1581
+ * :macro:`NGHTTP3_QPACK_DECODE_FLAG_BLOCKED` set, decoding is blocked
1582
+ * due to required insert count.
1583
+ *
1584
+ * When an HTTP field is decoded, an application receives it in |nv|.
1585
+ * :member:`nv->name <nghttp3_qpack_nv.name>` and :member:`nv->value
1586
+ * <nghttp3_qpack_nv.value>` are reference counted buffer, and their
1587
+ * reference counts are already incremented for application use.
1588
+ * Therefore, when application finishes processing |nv|, it must call
1589
+ * `nghttp3_rcbuf_decref(nv->name) <nghttp3_rcbuf_decref>` and
1590
+ * `nghttp3_rcbuf_decref(nv->value) <nghttp3_rcbuf_decref>`, or memory
1591
+ * leak might occur. These :type:`nghttp3_rcbuf` objects hold the
1592
+ * pointer to :type:`nghttp3_mem` that is passed to
1593
+ * `nghttp3_qpack_decoder_new` (or either `nghttp3_conn_client_new` or
1594
+ * `nghttp3_conn_server_new` if it is used indirectly). As long as
1595
+ * these objects are alive, the pointed :type:`nghttp3_mem` object
1596
+ * must be available. Otherwise, `nghttp3_rcbuf_decref` will cause
1597
+ * undefined behavior.
1598
+ *
1599
+ * This function returns the number of bytes read, or one of the
1600
+ * following negative error codes:
1601
+ *
1602
+ * :macro:`NGHTTP3_ERR_NOMEM`
1603
+ * Out of memory.
1604
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
1605
+ * |decoder| is in unrecoverable error state, and cannot be used
1606
+ * anymore.
1607
+ * :macro:`NGHTTP3_ERR_QPACK_DECOMPRESSION_FAILED`
1608
+ * Could not interpret field line representations.
1609
+ * :macro:`NGHTTP3_ERR_QPACK_HEADER_TOO_LARGE`
1610
+ * HTTP field is too large.
1611
+ */
1612
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_qpack_decoder_read_request(
1613
+ nghttp3_qpack_decoder *decoder, nghttp3_qpack_stream_context *sctx,
1614
+ nghttp3_qpack_nv *nv, uint8_t *pflags, const uint8_t *src, size_t srclen,
1615
+ int fin);
1616
+
1617
+ /**
1618
+ * @function
1619
+ *
1620
+ * `nghttp3_qpack_decoder_write_decoder` writes decoder stream into
1621
+ * |dbuf|.
1622
+ *
1623
+ * The caller must ensure that `nghttp3_buf_left(dbuf)
1624
+ * <nghttp3_buf_left>` >=
1625
+ * `nghttp3_qpack_decoder_get_decoder_streamlen2(decoder)
1626
+ * <nghttp3_qpack_decoder_get_decoder_streamlen2>`.
1627
+ */
1628
+ NGHTTP3_EXTERN void
1629
+ nghttp3_qpack_decoder_write_decoder(nghttp3_qpack_decoder *decoder,
1630
+ nghttp3_buf *dbuf);
1631
+
1632
+ /**
1633
+ * @function
1634
+ *
1635
+ * .. warning::
1636
+ *
1637
+ * .. version-deprecated:: 1.16.0
1638
+ * Use `nghttp3_qpack_decoder_get_decoder_streamlen2` instead.
1639
+ *
1640
+ * `nghttp3_qpack_decoder_get_decoder_streamlen` returns the length of
1641
+ * decoder stream that is currently pending.
1642
+ */
1643
+ NGHTTP3_EXTERN size_t
1644
+ nghttp3_qpack_decoder_get_decoder_streamlen(nghttp3_qpack_decoder *decoder);
1645
+
1646
+ /**
1647
+ * @function
1648
+ *
1649
+ * `nghttp3_qpack_decoder_get_decoder_streamlen2` returns the length
1650
+ * of decoder stream that is currently pending.
1651
+ *
1652
+ * .. version-added:: 1.16.0
1653
+ */
1654
+ NGHTTP3_EXTERN size_t nghttp3_qpack_decoder_get_decoder_streamlen2(
1655
+ const nghttp3_qpack_decoder *decoder);
1656
+
1657
+ /**
1658
+ * @function
1659
+ *
1660
+ * `nghttp3_qpack_decoder_cancel_stream` cancels HTTP field section
1661
+ * decoding for stream denoted by |stream_id|.
1662
+ *
1663
+ * This function returns 0 if it succeeds, or one of the following
1664
+ * negative error codes:
1665
+ *
1666
+ * :macro:`NGHTTP3_ERR_NOMEM`
1667
+ * Out of memory.
1668
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
1669
+ * Decoder stream overflow.
1670
+ */
1671
+ NGHTTP3_EXTERN int
1672
+ nghttp3_qpack_decoder_cancel_stream(nghttp3_qpack_decoder *decoder,
1673
+ int64_t stream_id);
1674
+
1675
+ /**
1676
+ * @function
1677
+ *
1678
+ * `nghttp3_qpack_decoder_set_max_dtable_capacity` sets
1679
+ * |max_dtable_capacity| as maximum dynamic table size.
1680
+ * |max_dtable_capacity| must be equal to, or smaller than
1681
+ * ``hard_max_dtable_capacity`` parameter of
1682
+ * `nghttp3_qpack_decoder_new`. Normally, the maximum capacity is
1683
+ * communicated in encoder stream. This function is provided for
1684
+ * debugging and testing purpose.
1685
+ *
1686
+ * This function returns 0 if it succeeds, or one of the following
1687
+ * negative error codes:
1688
+ *
1689
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
1690
+ * |max_dtable_capacity| exceeds the upper bound of the dynamic
1691
+ * table capacity.
1692
+ */
1693
+ NGHTTP3_EXTERN int
1694
+ nghttp3_qpack_decoder_set_max_dtable_capacity(nghttp3_qpack_decoder *decoder,
1695
+ size_t max_dtable_capacity);
1696
+
1697
+ /**
1698
+ * @function
1699
+ *
1700
+ * `nghttp3_qpack_decoder_set_max_concurrent_streams` tells |decoder|
1701
+ * the maximum number of concurrent streams that a remote endpoint can
1702
+ * open, including both bidirectional and unidirectional streams which
1703
+ * potentially receive QPACK encoded HEADERS frame. This value is
1704
+ * used as a hint to limit the length of decoder stream.
1705
+ */
1706
+ NGHTTP3_EXTERN void
1707
+ nghttp3_qpack_decoder_set_max_concurrent_streams(nghttp3_qpack_decoder *decoder,
1708
+ size_t max_concurrent_streams);
1709
+
1710
+ /**
1711
+ * @function
1712
+ *
1713
+ * `nghttp3_strerror` returns textual representation of |liberr|.
1714
+ */
1715
+ NGHTTP3_EXTERN const char *nghttp3_strerror(int liberr);
1716
+
1717
+ /**
1718
+ * @function
1719
+ *
1720
+ * `nghttp3_err_infer_quic_app_error_code` returns a QUIC application
1721
+ * error code which corresponds to |liberr|.
1722
+ */
1723
+ NGHTTP3_EXTERN uint64_t nghttp3_err_infer_quic_app_error_code(int liberr);
1724
+
1725
+ /**
1726
+ * @functypedef
1727
+ *
1728
+ * :type:`nghttp3_debug_vprintf_callback` is a callback function
1729
+ * invoked when the library outputs debug logging. The function is
1730
+ * called with arguments suitable for :manpage:`vfprintf(3)`.
1731
+ *
1732
+ * The debug output is only enabled if the library is built with
1733
+ * :macro:`DEBUGBUILD` macro defined.
1734
+ */
1735
+ typedef void (*nghttp3_debug_vprintf_callback)(const char *format,
1736
+ va_list args);
1737
+
1738
+ /**
1739
+ * @function
1740
+ *
1741
+ * `nghttp3_set_debug_vprintf_callback` sets a debug output callback
1742
+ * called by the library when built with :macro:`DEBUGBUILD` macro
1743
+ * defined. If a callback function is not set by this function, debug
1744
+ * log is written into standard error output.
1745
+ *
1746
+ * For builds without :macro:`DEBUGBUILD` macro defined, this function
1747
+ * is noop.
1748
+ *
1749
+ * Note that building with :macro:`DEBUGBUILD` may cause significant
1750
+ * performance penalty to libnghttp3 because of extra processing. It
1751
+ * should be used for debugging purpose only.
1752
+ *
1753
+ * .. Warning::
1754
+ *
1755
+ * Building with :macro:`DEBUGBUILD` may cause significant
1756
+ * performance penalty to libnghttp3 because of extra processing.
1757
+ * It should be used for debugging purpose only. We write this two
1758
+ * times because this is important.
1759
+ */
1760
+ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback(
1761
+ nghttp3_debug_vprintf_callback debug_vprintf_callback);
1762
+
1763
+ /**
1764
+ * @macrosection
1765
+ *
1766
+ * Shutdown related constants
1767
+ */
1768
+
1769
+ /**
1770
+ * @macro
1771
+ *
1772
+ * :macro:`NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID` specifies stream ID sent
1773
+ * by a server when it initiates graceful shutdown of the connection
1774
+ * via `nghttp3_conn_submit_shutdown_notice`.
1775
+ */
1776
+ #define NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID ((1ULL << 62) - 4)
1777
+
1778
+ /**
1779
+ * @macro
1780
+ *
1781
+ * :macro:`NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID` specifies push ID sent by
1782
+ * a client when it initiates graceful shutdown of the connection via
1783
+ * `nghttp3_conn_submit_shutdown_notice`. Note that libnghttp3 does
1784
+ * not implement HTTP/3 Server Push.
1785
+ */
1786
+ #define NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID ((1ULL << 62) - 1)
1787
+
1788
+ /**
1789
+ * @struct
1790
+ *
1791
+ * :type:`nghttp3_conn` represents a single HTTP/3 connection. The
1792
+ * details of this structure are intentionally hidden from the public
1793
+ * API.
1794
+ */
1795
+ typedef struct nghttp3_conn nghttp3_conn;
1796
+
1797
+ #define NGHTTP3_SETTINGS_V1 1
1798
+ #define NGHTTP3_SETTINGS_V2 2
1799
+ #define NGHTTP3_SETTINGS_V3 3
1800
+ #define NGHTTP3_SETTINGS_V4 4
1801
+ #define NGHTTP3_SETTINGS_VERSION NGHTTP3_SETTINGS_V4
1802
+
1803
+ /**
1804
+ * @struct
1805
+ *
1806
+ * :type:`nghttp3_settings` defines HTTP/3 settings.
1807
+ */
1808
+ typedef struct nghttp3_settings {
1809
+ /**
1810
+ * :member:`max_field_section_size` specifies the maximum header
1811
+ * section (block) size. nghttp3 library does not enforce this
1812
+ * limit. Applications are responsible for imposing their own
1813
+ * limits to protect against resource exhaustion. See
1814
+ * https://datatracker.ietf.org/doc/html/rfc9114#section-4.2.2 for
1815
+ * details.
1816
+ */
1817
+ uint64_t max_field_section_size;
1818
+ /**
1819
+ * :member:`qpack_max_dtable_capacity` is the maximum size of QPACK
1820
+ * dynamic table.
1821
+ */
1822
+ size_t qpack_max_dtable_capacity;
1823
+ /**
1824
+ * :member:`qpack_encoder_max_dtable_capacity` is the upper bound of
1825
+ * QPACK dynamic table capacity that the QPACK encoder is willing to
1826
+ * use. The effective maximum dynamic table capacity is the minimum
1827
+ * of this field and the value of the received
1828
+ * SETTINGS_QPACK_MAX_TABLE_CAPACITY. If this field is set to 0,
1829
+ * the encoder does not use the dynamic table.
1830
+ *
1831
+ * When :type:`nghttp3_settings` is passed to
1832
+ * :member:`nghttp3_callbacks.recv_settings` callback, this field
1833
+ * should be ignored.
1834
+ */
1835
+ size_t qpack_encoder_max_dtable_capacity;
1836
+ /**
1837
+ * :member:`qpack_blocked_streams` is the maximum number of streams
1838
+ * which can be blocked while they are being decoded.
1839
+ */
1840
+ size_t qpack_blocked_streams;
1841
+ /**
1842
+ * :member:`enable_connect_protocol`, if set to nonzero, enables
1843
+ * Extended CONNECT Method (see :rfc:`9220`). Client ignores this
1844
+ * field.
1845
+ */
1846
+ uint8_t enable_connect_protocol;
1847
+ /**
1848
+ * :member:`h3_datagram`, if set to nonzero, enables HTTP/3
1849
+ * Datagrams (see :rfc:`9297`).
1850
+ */
1851
+ uint8_t h3_datagram;
1852
+ /* The following fields have been added since
1853
+ NGHTTP3_SETTINGS_V2. */
1854
+ /**
1855
+ * :member:`origin_list`, if set, must contain a serialized HTTP/3
1856
+ * ORIGIN frame (see :rfc:`9412`) payload. The ORIGIN frame payload
1857
+ * is a sequence of zero or more of a length prefixed byte string.
1858
+ * The length is encoded in 2 bytes in network byte order. If
1859
+ * :member:`origin_list->len <nghttp3_vec.len>` is zero, an empty
1860
+ * ORIGIN frame is sent. An application must keep the buffer
1861
+ * pointed by :member:`origin_list->base <nghttp3_vec.base>` alive
1862
+ * until the :type:`nghttp3_conn` to which this field was passed is
1863
+ * freed by `nghttp3_conn_del`. The object pointed to by this field
1864
+ * is copied internally, and does not need to be kept alive. Only
1865
+ * server uses this field.
1866
+ *
1867
+ * .. version-added:: 1.11.0
1868
+ */
1869
+ const nghttp3_vec *origin_list;
1870
+ /* The following fields have been added since
1871
+ NGHTTP3_SETTINGS_V3. */
1872
+ /**
1873
+ * :member:`glitch_ratelim_burst` is the maximum number of tokens
1874
+ * available to "glitch" rate limiter. "glitch" is a suspicious
1875
+ * activity from a remote endpoint. If detected, certain amount of
1876
+ * tokens are consumed. If no tokens are available to consume, the
1877
+ * connection is closed. The rate of token generation is specified
1878
+ * by :member:`glitch_ratelim_rate`. This feature is enabled only
1879
+ * when `nghttp3_conn_read_stream2` is used.
1880
+ *
1881
+ * .. version-added:: 1.12.0
1882
+ */
1883
+ uint64_t glitch_ratelim_burst;
1884
+ /**
1885
+ * :member:`glitch_ratelim_rate` is the number of tokens generated
1886
+ * per second. See :member:`glitch_ratelim_burst` for "glitch" rate
1887
+ * limiter.
1888
+ *
1889
+ * .. version-added:: 1.12.0
1890
+ */
1891
+ uint64_t glitch_ratelim_rate;
1892
+ /* The following fields have been added since
1893
+ NGHTTP3_SETTINGS_V4. */
1894
+ /**
1895
+ * :member:`qpack_indexing_strat` defines the QPACK dynamic table
1896
+ * indexing strategy for those fields that are not defined in
1897
+ * :type:`nghttp3_qpack_token`.
1898
+ *
1899
+ * .. version-added:: 1.13.0
1900
+ */
1901
+ nghttp3_qpack_indexing_strat qpack_indexing_strat;
1902
+ } nghttp3_settings;
1903
+
1904
+ #define NGHTTP3_PROTO_SETTINGS_V1 1
1905
+ #define NGHTTP3_PROTO_SETTINGS_VERSION NGHTTP3_PROTO_SETTINGS_V1
1906
+
1907
+ /**
1908
+ * @struct
1909
+ *
1910
+ * :type:`nghttp3_proto_settings` contains HTTP/3 settings that this
1911
+ * library can recognize.
1912
+ *
1913
+ * .. version-added:: 1.14.0
1914
+ */
1915
+ typedef struct nghttp3_proto_settings {
1916
+ /**
1917
+ * :member:`max_field_section_size` specifies the maximum header
1918
+ * section (block) size.
1919
+ */
1920
+ uint64_t max_field_section_size;
1921
+ /**
1922
+ * :member:`qpack_max_dtable_capacity` is the maximum size of QPACK
1923
+ * dynamic table.
1924
+ */
1925
+ size_t qpack_max_dtable_capacity;
1926
+ /**
1927
+ * :member:`qpack_blocked_streams` is the maximum number of streams
1928
+ * which can be blocked while they are being decoded.
1929
+ */
1930
+ size_t qpack_blocked_streams;
1931
+ /**
1932
+ * :member:`enable_connect_protocol`, if set to nonzero, enables
1933
+ * Extended CONNECT Method (see :rfc:`9220`). Client ignores this
1934
+ * field.
1935
+ */
1936
+ uint8_t enable_connect_protocol;
1937
+ /**
1938
+ * :member:`h3_datagram`, if set to nonzero, enables HTTP/3
1939
+ * Datagrams (see :rfc:`9297`).
1940
+ */
1941
+ uint8_t h3_datagram;
1942
+ } nghttp3_proto_settings;
1943
+
1944
+ /**
1945
+ * @functypedef
1946
+ *
1947
+ * :type:`nghttp3_acked_stream_data` is a callback function which is
1948
+ * invoked when data sent on stream denoted by |stream_id| supplied
1949
+ * from application is acknowledged by remote endpoint. The number of
1950
+ * bytes acknowledged is given in |datalen|.
1951
+ *
1952
+ * The implementation of this callback must return 0 if it succeeds.
1953
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1954
+ * caller immediately. Any values other than 0 is treated as
1955
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1956
+ */
1957
+ typedef int (*nghttp3_acked_stream_data)(nghttp3_conn *conn, int64_t stream_id,
1958
+ uint64_t datalen, void *conn_user_data,
1959
+ void *stream_user_data);
1960
+
1961
+ /**
1962
+ * @functypedef
1963
+ *
1964
+ * :type:`nghttp3_stream_close` is a callback function which is
1965
+ * invoked when a stream identified by |stream_id| is closed. QUIC
1966
+ * application error code |app_error_code| indicates the reason of
1967
+ * this closure.
1968
+ *
1969
+ * The implementation of this callback must return 0 if it succeeds.
1970
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1971
+ * caller immediately. Any values other than 0 is treated as
1972
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1973
+ *
1974
+ * .. seealso::
1975
+ * :type:`nghttp3_stream_close2`
1976
+ */
1977
+ typedef int (*nghttp3_stream_close)(nghttp3_conn *conn, int64_t stream_id,
1978
+ uint64_t app_error_code,
1979
+ void *conn_user_data,
1980
+ void *stream_user_data);
1981
+
1982
+ /**
1983
+ * @functypedef
1984
+ *
1985
+ * :type:`nghttp3_recv_data` is a callback function which is invoked
1986
+ * when a part of request or response body on stream identified by
1987
+ * |stream_id| is received. |data| points to the received data, and
1988
+ * its length is |datalen|.
1989
+ *
1990
+ * The application is responsible for increasing flow control credit
1991
+ * (say, increasing by |datalen| bytes).
1992
+ *
1993
+ * The implementation of this callback must return 0 if it succeeds.
1994
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1995
+ * caller immediately. Any values other than 0 is treated as
1996
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1997
+ */
1998
+ typedef int (*nghttp3_recv_data)(nghttp3_conn *conn, int64_t stream_id,
1999
+ const uint8_t *data, size_t datalen,
2000
+ void *conn_user_data, void *stream_user_data);
2001
+
2002
+ /**
2003
+ * @functypedef
2004
+ *
2005
+ * :type:`nghttp3_deferred_consume` is a callback function which is
2006
+ * invoked when the library consumed |consumed| bytes for a stream
2007
+ * identified by |stream_id|. This callback is used to notify the
2008
+ * consumed bytes for stream blocked due to synchronization between
2009
+ * streams. The application is responsible for increasing flow
2010
+ * control credit by |consumed| bytes.
2011
+ *
2012
+ * The implementation of this callback must return 0 if it succeeds.
2013
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2014
+ * caller immediately. Any values other than 0 is treated as
2015
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2016
+ */
2017
+ typedef int (*nghttp3_deferred_consume)(nghttp3_conn *conn, int64_t stream_id,
2018
+ size_t consumed, void *conn_user_data,
2019
+ void *stream_user_data);
2020
+
2021
+ /**
2022
+ * @functypedef
2023
+ *
2024
+ * :type:`nghttp3_begin_headers` is a callback function which is
2025
+ * invoked when an incoming HTTP field section is started on a stream
2026
+ * denoted by |stream_id|. Each HTTP field is passed to application
2027
+ * by :type:`nghttp3_recv_header` callback. And then
2028
+ * :type:`nghttp3_end_headers` is called when a whole HTTP field
2029
+ * section is processed.
2030
+ *
2031
+ * The implementation of this callback must return 0 if it succeeds.
2032
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2033
+ * caller immediately. Any values other than 0 is treated as
2034
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2035
+ */
2036
+ typedef int (*nghttp3_begin_headers)(nghttp3_conn *conn, int64_t stream_id,
2037
+ void *conn_user_data,
2038
+ void *stream_user_data);
2039
+
2040
+ /**
2041
+ * @functypedef
2042
+ *
2043
+ * :type:`nghttp3_recv_header` is a callback function which is invoked
2044
+ * when an HTTP field is received on a stream denoted by |stream_id|.
2045
+ * |name| contains a field name, and |value| contains a field value.
2046
+ * |token| is one of token defined in :type:`nghttp3_qpack_token` or
2047
+ * -1 if no token is defined for |name|. |flags| is bitwise OR of
2048
+ * zero or more of :macro:`NGHTTP3_NV_FLAG_* <NGHTTP3_NV_FLAG_NONE>`.
2049
+ *
2050
+ * The buffers for |name| and |value| are reference counted. If
2051
+ * application needs to keep them, increment the reference count with
2052
+ * `nghttp3_rcbuf_incref`. When they are no longer used, call
2053
+ * `nghttp3_rcbuf_decref`.
2054
+ *
2055
+ * The implementation of this callback must return 0 if it succeeds.
2056
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2057
+ * caller immediately. Any values other than 0 is treated as
2058
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2059
+ */
2060
+ typedef int (*nghttp3_recv_header)(nghttp3_conn *conn, int64_t stream_id,
2061
+ int32_t token, nghttp3_rcbuf *name,
2062
+ nghttp3_rcbuf *value, uint8_t flags,
2063
+ void *conn_user_data,
2064
+ void *stream_user_data);
2065
+
2066
+ /**
2067
+ * @functypedef
2068
+ *
2069
+ * :type:`nghttp3_end_headers` is a callback function which is invoked
2070
+ * when an incoming HTTP field section has ended.
2071
+ *
2072
+ * If the stream ends with this HTTP field section, |fin| is set to
2073
+ * nonzero.
2074
+ *
2075
+ * The implementation of this callback must return 0 if it succeeds.
2076
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2077
+ * caller immediately. Any values other than 0 is treated as
2078
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2079
+ */
2080
+ typedef int (*nghttp3_end_headers)(nghttp3_conn *conn, int64_t stream_id,
2081
+ int fin, void *conn_user_data,
2082
+ void *stream_user_data);
2083
+
2084
+ /**
2085
+ * @functypedef
2086
+ *
2087
+ * :type:`nghttp3_end_stream` is a callback function which is invoked
2088
+ * when the receiving side of stream is closed. For server, this
2089
+ * callback function is invoked when HTTP request is received
2090
+ * completely. For client, this callback function is invoked when
2091
+ * HTTP response is received completely.
2092
+ *
2093
+ * The implementation of this callback must return 0 if it succeeds.
2094
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2095
+ * caller immediately. Any values other than 0 is treated as
2096
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2097
+ */
2098
+ typedef int (*nghttp3_end_stream)(nghttp3_conn *conn, int64_t stream_id,
2099
+ void *conn_user_data, void *stream_user_data);
2100
+
2101
+ /**
2102
+ * @functypedef
2103
+ *
2104
+ * :type:`nghttp3_stop_sending` is a callback function which is
2105
+ * invoked when the library asks application to send STOP_SENDING to
2106
+ * the stream identified by |stream_id|. QUIC application error code
2107
+ * |app_error_code| indicates the reason for this action.
2108
+ *
2109
+ * The implementation of this callback must return 0 if it succeeds.
2110
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2111
+ * caller immediately. Any values other than 0 is treated as
2112
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2113
+ */
2114
+ typedef int (*nghttp3_stop_sending)(nghttp3_conn *conn, int64_t stream_id,
2115
+ uint64_t app_error_code,
2116
+ void *conn_user_data,
2117
+ void *stream_user_data);
2118
+
2119
+ /**
2120
+ * @functypedef
2121
+ *
2122
+ * :type:`nghttp3_reset_stream` is a callback function which is
2123
+ * invoked when the library asks application to reset stream
2124
+ * identified by |stream_id|. QUIC application error code
2125
+ * |app_error_code| indicates the reason for this action.
2126
+ *
2127
+ * The implementation of this callback must return 0 if it succeeds.
2128
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2129
+ * caller immediately. Any values other than 0 is treated as
2130
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2131
+ */
2132
+ typedef int (*nghttp3_reset_stream)(nghttp3_conn *conn, int64_t stream_id,
2133
+ uint64_t app_error_code,
2134
+ void *conn_user_data,
2135
+ void *stream_user_data);
2136
+
2137
+ /**
2138
+ * @functypedef
2139
+ *
2140
+ * :type:`nghttp3_shutdown` is a callback function which is invoked
2141
+ * when a shutdown is initiated by the remote endpoint. For client,
2142
+ * |id| contains a stream ID of a client initiated stream, for server,
2143
+ * it contains a push ID. All client streams with stream ID, or pushes
2144
+ * with push ID equal to, or larger than |ID| are guaranteed to not be
2145
+ * processed by the remote endpoint. Note that libnghttp3 does not
2146
+ * implement Server Push.
2147
+ *
2148
+ * Parameter |id| for client can contain a special value
2149
+ * :macro:`NGHTTP3_SHUTDOWN_NOTICE_STREAM_ID`, and for server it can
2150
+ * contain special value
2151
+ * :macro:`NGHTTP3_SHUTDOWN_NOTICE_PUSH_ID`. These values signal
2152
+ * request for graceful shutdown of the connection, triggered by
2153
+ * remote endpoint's invocation of
2154
+ * `nghttp3_conn_submit_shutdown_notice`.
2155
+ *
2156
+ * It is possible that this callback is invoked multiple times on a
2157
+ * single connection, however the |id| can only stay the same or
2158
+ * decrease, never increase.
2159
+ *
2160
+ * The implementation of this callback must return 0 if it succeeds.
2161
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2162
+ * caller immediately. Any values other than 0 is treated as
2163
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2164
+ */
2165
+ typedef int (*nghttp3_shutdown)(nghttp3_conn *conn, int64_t id,
2166
+ void *conn_user_data);
2167
+
2168
+ /**
2169
+ * @functypedef
2170
+ *
2171
+ * .. warning::
2172
+ *
2173
+ * .. version-deprecated:: 1.14.0
2174
+ * Use :type:`nghttp3_recv_settings2` instead. New settings will
2175
+ * not be notified with this callback.
2176
+ *
2177
+ * :type:`nghttp3_recv_settings` is a callback function which is
2178
+ * invoked when SETTINGS frame is received. |settings| is a received
2179
+ * remote HTTP/3 settings.
2180
+ *
2181
+ * The implementation of this callback must return 0 if it succeeds.
2182
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2183
+ * caller immediately. Any values other than 0 is treated as
2184
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2185
+ */
2186
+ typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn,
2187
+ const nghttp3_settings *settings,
2188
+ void *conn_user_data);
2189
+
2190
+ /**
2191
+ * @functypedef
2192
+ *
2193
+ * :type:`nghttp3_recv_origin` is a callback function which is invoked
2194
+ * when a single origin in ORIGIN frame is received. |origin| is a
2195
+ * received origin of length |originlen|. |originlen| never be 0.
2196
+ *
2197
+ * The implementation of this callback must return 0 if it succeeds.
2198
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2199
+ * caller immediately. Any values other than 0 is treated as
2200
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2201
+ */
2202
+ typedef int (*nghttp3_recv_origin)(nghttp3_conn *conn, const uint8_t *origin,
2203
+ size_t originlen, void *conn_user_data);
2204
+
2205
+ /**
2206
+ * @functypedef
2207
+ *
2208
+ * :type:`nghttp3_end_origin` is a callback function which is invoked
2209
+ * when an ORIGIN frame has been completely processed.
2210
+ *
2211
+ * The implementation of this callback must return 0 if it succeeds.
2212
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2213
+ * caller immediately. Any values other than 0 is treated as
2214
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2215
+ */
2216
+ typedef int (*nghttp3_end_origin)(nghttp3_conn *conn, void *conn_user_data);
2217
+
2218
+ /**
2219
+ * @functypedef
2220
+ *
2221
+ * :type:`nghttp3_rand` is a callback function which is invoked when
2222
+ * unpredictable data of |destlen| bytes are needed. The
2223
+ * implementation must write unpredictable data of |destlen| bytes
2224
+ * into the buffer pointed by |dest|.
2225
+ */
2226
+ typedef void (*nghttp3_rand)(uint8_t *dest, size_t destlen);
2227
+
2228
+ /**
2229
+ * @functypedef
2230
+ *
2231
+ * :type:`nghttp3_recv_settings2` is a callback function which is
2232
+ * invoked when SETTINGS frame is received. |settings| is a received
2233
+ * remote HTTP/3 settings.
2234
+ *
2235
+ * The implementation of this callback must return 0 if it succeeds.
2236
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2237
+ * caller immediately. Any values other than 0 is treated as
2238
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2239
+ *
2240
+ * .. version-added:: 1.14.0
2241
+ */
2242
+ typedef int (*nghttp3_recv_settings2)(nghttp3_conn *conn,
2243
+ const nghttp3_proto_settings *settings,
2244
+ void *conn_user_data);
2245
+
2246
+ /**
2247
+ * @macrosection
2248
+ *
2249
+ * Stream close flags
2250
+ */
2251
+
2252
+ /**
2253
+ * @macro
2254
+ *
2255
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_NONE` indicates no flag set.
2256
+ *
2257
+ * .. version-added:: 1.18.0
2258
+ */
2259
+ #define NGHTTP3_STREAM_CLOSE_FLAG_NONE 0x00U
2260
+
2261
+ /**
2262
+ * @macro
2263
+ *
2264
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` indicates
2265
+ * that rx_app_error_code parameter is set.
2266
+ *
2267
+ * .. version-added:: 1.18.0
2268
+ */
2269
+ #define NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET 0x01U
2270
+
2271
+ /**
2272
+ * @macro
2273
+ *
2274
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` indicates
2275
+ * that tx_app_error_code parameter is set.
2276
+ *
2277
+ * .. version-added:: 1.18.0
2278
+ */
2279
+ #define NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET 0x02U
2280
+
2281
+ /**
2282
+ * @functypedef
2283
+ *
2284
+ * :type:`nghttp3_stream_close2` is a callback function which is
2285
+ * invoked when a stream identified by |stream_id| is closed. If
2286
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` is set in
2287
+ * |flags|, |rx_app_error_code| is the QUIC application error code
2288
+ * that shut down the receiving side of the stream. If
2289
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` is set in
2290
+ * |flags|, |tx_app_error_code| is the QUIC application error code
2291
+ * that shut down the sending side of the stream. No application code
2292
+ * means that direction of stream is closed without any error.
2293
+ *
2294
+ * This callback should be used with `nghttp3_conn_close_stream2`. If
2295
+ * `nghttp3_conn_close_stream` is used, the app_error_code is set to
2296
+ * both |rx_app_error_code| and |tx_app_error_code|, and
2297
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` and
2298
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` are set in
2299
+ * |flags|.
2300
+ *
2301
+ * The implementation of this callback must return 0 if it succeeds.
2302
+ * Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
2303
+ * caller immediately. Any values other than 0 is treated as
2304
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
2305
+ *
2306
+ * .. version-added:: 1.18.0
2307
+ */
2308
+ typedef int (*nghttp3_stream_close2)(nghttp3_conn *conn, uint32_t flags,
2309
+ int64_t stream_id,
2310
+ uint64_t rx_app_error_code,
2311
+ uint64_t tx_app_error_code,
2312
+ void *conn_user_data,
2313
+ void *stream_user_data);
2314
+
2315
+ #define NGHTTP3_CALLBACKS_V1 1
2316
+ #define NGHTTP3_CALLBACKS_V2 2
2317
+ #define NGHTTP3_CALLBACKS_V3 3
2318
+ #define NGHTTP3_CALLBACKS_V4 4
2319
+ #define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V4
2320
+
2321
+ /**
2322
+ * @struct
2323
+ *
2324
+ * :type:`nghttp3_callbacks` holds a set of callback functions.
2325
+ */
2326
+ typedef struct nghttp3_callbacks {
2327
+ /**
2328
+ * :member:`acked_stream_data` is a callback function which is
2329
+ * invoked when data sent on a particular stream have been
2330
+ * acknowledged by a remote endpoint.
2331
+ */
2332
+ nghttp3_acked_stream_data acked_stream_data;
2333
+ /**
2334
+ * :member:`stream_close` is a callback function which is invoked
2335
+ * when a particular stream has closed.
2336
+ *
2337
+ * .. seealso::
2338
+ * :member:`stream_close2`
2339
+ */
2340
+ nghttp3_stream_close stream_close;
2341
+ /**
2342
+ * :member:`recv_data` is a callback function which is invoked when
2343
+ * stream data is received.
2344
+ */
2345
+ nghttp3_recv_data recv_data;
2346
+ /**
2347
+ * :member:`deferred_consume` is a callback function which is
2348
+ * invoked when the library consumed data for a particular stream
2349
+ * which had been blocked for synchronization between streams.
2350
+ */
2351
+ nghttp3_deferred_consume deferred_consume;
2352
+ /**
2353
+ * :member:`begin_headers` is a callback function which is invoked
2354
+ * when an HTTP header field section has started on a particular
2355
+ * stream.
2356
+ */
2357
+ nghttp3_begin_headers begin_headers;
2358
+ /**
2359
+ * :member:`recv_header` is a callback function which is invoked
2360
+ * when a single HTTP header field is received on a particular
2361
+ * stream.
2362
+ */
2363
+ nghttp3_recv_header recv_header;
2364
+ /**
2365
+ * :member:`end_headers` is a callback function which is invoked
2366
+ * when an HTTP header field section has ended on a particular
2367
+ * stream.
2368
+ */
2369
+ nghttp3_end_headers end_headers;
2370
+ /**
2371
+ * :member:`begin_trailers` is a callback function which is invoked
2372
+ * when an HTTP trailer field section has started on a particular
2373
+ * stream.
2374
+ */
2375
+ nghttp3_begin_headers begin_trailers;
2376
+ /**
2377
+ * :member:`recv_trailer` is a callback function which is invoked
2378
+ * when a single HTTP trailer field is received on a particular
2379
+ * stream.
2380
+ */
2381
+ nghttp3_recv_header recv_trailer;
2382
+ /**
2383
+ * :member:`end_trailers` is a callback function which is invoked
2384
+ * when an HTTP trailer field section has ended on a particular
2385
+ * stream.
2386
+ */
2387
+ nghttp3_end_headers end_trailers;
2388
+ /**
2389
+ * :member:`stop_sending` is a callback function which is invoked
2390
+ * when the library asks application to send STOP_SENDING to a
2391
+ * particular stream.
2392
+ */
2393
+ nghttp3_stop_sending stop_sending;
2394
+ /**
2395
+ * :member:`end_stream` is a callback function which is invoked when
2396
+ * a receiving side of stream has been closed.
2397
+ */
2398
+ nghttp3_end_stream end_stream;
2399
+ /**
2400
+ * :member:`reset_stream` is a callback function which is invoked
2401
+ * when the library asks application to reset stream (by sending
2402
+ * RESET_STREAM).
2403
+ */
2404
+ nghttp3_reset_stream reset_stream;
2405
+ /**
2406
+ * :member:`shutdown` is a callback function which is invoked when
2407
+ * the remote endpoint has signalled initiation of connection
2408
+ * shutdown.
2409
+ */
2410
+ nghttp3_shutdown shutdown;
2411
+ /**
2412
+ * .. warning::
2413
+ *
2414
+ * .. version-deprecated:: 1.14.0
2415
+ * Use :member:`recv_settings2` instead.
2416
+ *
2417
+ * :member:`recv_settings` is a callback function which is invoked
2418
+ * when SETTINGS frame is received.
2419
+ */
2420
+ nghttp3_recv_settings recv_settings;
2421
+ /* The following fields have been added since
2422
+ NGHTTP3_CALLBACKS_V2. */
2423
+ /**
2424
+ * :member:`recv_origin` is a callback function which is invoked
2425
+ * when a single origin in an ORIGIN frame is received.
2426
+ *
2427
+ * .. version-added:: 1.11.0
2428
+ */
2429
+ nghttp3_recv_origin recv_origin;
2430
+ /**
2431
+ * :member:`end_origin` is a callback function which is invoked when
2432
+ * an ORIGIN frame has been completely processed.
2433
+ *
2434
+ * .. version-added:: 1.11.0
2435
+ */
2436
+ nghttp3_end_origin end_origin;
2437
+ /**
2438
+ * :member:`rand` is a callback function which is invoked when
2439
+ * unpredictable data are needed. Although this field is optional
2440
+ * due to the backward compatibility, it is recommended to specify
2441
+ * this field to harden the runtime behavior against suspicious
2442
+ * activities of a remote endpoint.
2443
+ *
2444
+ * .. version-added:: 1.11.0
2445
+ */
2446
+ nghttp3_rand rand;
2447
+ /* The following fields have been added since
2448
+ NGHTTP3_CALLBACKS_V3. */
2449
+ /**
2450
+ * :member:`recv_settings2` is a callback function which is invoked
2451
+ * when SETTINGS frame is received.
2452
+ *
2453
+ * .. version-added:: 1.14.0
2454
+ */
2455
+ nghttp3_recv_settings2 recv_settings2;
2456
+ /* The following fields have been added since
2457
+ NGHTTP3_CALLBACKS_V4. */
2458
+ /**
2459
+ * :member:`stream_close2` is a callback function which is invoked
2460
+ * when a particular stream has closed.
2461
+ *
2462
+ * .. version-added:: 1.18.0
2463
+ */
2464
+ nghttp3_stream_close2 stream_close2;
2465
+ } nghttp3_callbacks;
2466
+
2467
+ /**
2468
+ * @function
2469
+ *
2470
+ * `nghttp3_settings_default` fills |settings| with the default
2471
+ * values.
2472
+ *
2473
+ * - :member:`max_field_section_size
2474
+ * <nghttp3_settings.max_field_section_size>` = :expr:`((1ULL << 62) - 1)`
2475
+ * - :member:`qpack_max_dtable_capacity
2476
+ * <nghttp3_settings.qpack_max_dtable_capacity>` = 0
2477
+ * - :member:`qpack_encoder_max_dtable_capacity
2478
+ * <nghttp3_settings.qpack_encoder_max_dtable_capacity>` = 4096
2479
+ * - :member:`qpack_blocked_streams
2480
+ * <nghttp3_settings.qpack_blocked_streams>` = 0
2481
+ * - :member:`enable_connect_protocol
2482
+ * <nghttp3_settings.enable_connect_protocol>` = 0
2483
+ * - :member:`glitch_ratelim_burst
2484
+ * <nghttp3_settings.glitch_ratelim_burst>` = 1000
2485
+ * - :member:`glitch_ratelim_rate
2486
+ * <nghttp3_settings.glitch_ratelim_rate>` = 33
2487
+ */
2488
+ NGHTTP3_EXTERN void
2489
+ nghttp3_settings_default_versioned(int settings_version,
2490
+ nghttp3_settings *settings);
2491
+
2492
+ /**
2493
+ * @function
2494
+ *
2495
+ * `nghttp3_conn_client_new` creates :type:`nghttp3_conn`, and
2496
+ * initializes it for client use. The pointer to the object is stored
2497
+ * in |*pconn|. If |mem| is ``NULL``, the memory allocator returned
2498
+ * by `nghttp3_mem_default` is used.
2499
+ *
2500
+ * This function returns 0 if it succeeds, or one of the following
2501
+ * negative error codes:
2502
+ *
2503
+ * :macro:`NGHTTP3_ERR_NOMEM`
2504
+ * Out of memory.
2505
+ */
2506
+ NGHTTP3_EXTERN int
2507
+ nghttp3_conn_client_new_versioned(nghttp3_conn **pconn, int callbacks_version,
2508
+ const nghttp3_callbacks *callbacks,
2509
+ int settings_version,
2510
+ const nghttp3_settings *settings,
2511
+ const nghttp3_mem *mem, void *conn_user_data);
2512
+
2513
+ /**
2514
+ * @function
2515
+ *
2516
+ * `nghttp3_conn_server_new` creates :type:`nghttp3_conn`, and
2517
+ * initializes it for server use. The pointer to the object is stored
2518
+ * in |*pconn|. If |mem| is ``NULL``, the memory allocator returned
2519
+ * by `nghttp3_mem_default` is used.
2520
+ *
2521
+ * This function returns 0 if it succeeds, or one of the following
2522
+ * negative error codes:
2523
+ *
2524
+ * :macro:`NGHTTP3_ERR_NOMEM`
2525
+ * Out of memory.
2526
+ */
2527
+ NGHTTP3_EXTERN int
2528
+ nghttp3_conn_server_new_versioned(nghttp3_conn **pconn, int callbacks_version,
2529
+ const nghttp3_callbacks *callbacks,
2530
+ int settings_version,
2531
+ const nghttp3_settings *settings,
2532
+ const nghttp3_mem *mem, void *conn_user_data);
2533
+
2534
+ /**
2535
+ * @function
2536
+ *
2537
+ * `nghttp3_conn_del` frees resources allocated for |conn|. This
2538
+ * function also frees memory pointed by |conn| itself. This function
2539
+ * does nothing if |conn| is NULL.
2540
+ */
2541
+ NGHTTP3_EXTERN void nghttp3_conn_del(nghttp3_conn *conn);
2542
+
2543
+ /**
2544
+ * @function
2545
+ *
2546
+ * `nghttp3_conn_bind_control_stream` binds stream denoted by
2547
+ * |stream_id| to outgoing unidirectional control stream.
2548
+ *
2549
+ * This function returns 0 if it succeeds, or one of the following
2550
+ * negative error codes:
2551
+ *
2552
+ * :macro:`NGHTTP3_ERR_INVALID_STATE`
2553
+ * Control stream has already corresponding stream ID.
2554
+ * :macro:`NGHTTP3_ERR_NOMEM`
2555
+ * Out of memory.
2556
+ */
2557
+ NGHTTP3_EXTERN int nghttp3_conn_bind_control_stream(nghttp3_conn *conn,
2558
+ int64_t stream_id);
2559
+
2560
+ /**
2561
+ * @function
2562
+ *
2563
+ * `nghttp3_conn_bind_qpack_streams` binds stream denoted by
2564
+ * |qenc_stream_id| to outgoing QPACK encoder stream, and stream
2565
+ * denoted by |qdec_stream_id| to outgoing QPACK encoder stream.
2566
+ *
2567
+ * This function returns 0 if it succeeds, or one of the following
2568
+ * negative error codes:
2569
+ *
2570
+ * :macro:`NGHTTP3_ERR_INVALID_STATE`
2571
+ * QPACK encoder/decoder stream have already corresponding stream
2572
+ * IDs.
2573
+ * :macro:`NGHTTP3_ERR_NOMEM`
2574
+ * Out of memory.
2575
+ */
2576
+ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
2577
+ int64_t qenc_stream_id,
2578
+ int64_t qdec_stream_id);
2579
+
2580
+ /**
2581
+ * @function
2582
+ *
2583
+ * .. warning::
2584
+ *
2585
+ * .. version-deprecated:: 1.12.0
2586
+ * Use `nghttp3_conn_read_stream2` instead.
2587
+ *
2588
+ * `nghttp3_conn_read_stream` reads data |src| of length |srclen| on
2589
+ * stream identified by |stream_id|. It returns the number of bytes
2590
+ * consumed. The "consumed" means that application can increase flow
2591
+ * control credit (both stream and connection) of underlying QUIC
2592
+ * connection by that amount. It does not include the amount of data
2593
+ * carried by DATA frame which contains application data (excluding
2594
+ * any control or QPACK unidirectional streams). See
2595
+ * :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
2596
+ * nonzero, this is the last data from remote endpoint in this stream.
2597
+ *
2598
+ * This function returns the number of bytes consumed, or one of the
2599
+ * following negative error codes:
2600
+ *
2601
+ * :macro:`NGHTTP3_ERR_NOMEM`
2602
+ * Out of memory.
2603
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2604
+ * User callback failed.
2605
+ *
2606
+ * It may return the other error codes. The negative error code means
2607
+ * that |conn| encountered a connection error, and the connection must
2608
+ * be closed. Calling nghttp3 API other than `nghttp3_conn_del`
2609
+ * causes undefined behavior.
2610
+ */
2611
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream(nghttp3_conn *conn,
2612
+ int64_t stream_id,
2613
+ const uint8_t *src,
2614
+ size_t srclen, int fin);
2615
+
2616
+ /**
2617
+ * @function
2618
+ *
2619
+ * `nghttp3_conn_read_stream2` reads data |src| of length |srclen| on
2620
+ * stream identified by |stream_id|. It returns the number of bytes
2621
+ * consumed. The "consumed" means that application can increase flow
2622
+ * control credit (both stream and connection) of underlying QUIC
2623
+ * connection by that amount. It does not include the amount of data
2624
+ * carried by DATA frame which contains application data (excluding
2625
+ * any control or QPACK unidirectional streams). See
2626
+ * :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
2627
+ * nonzero, this is the last data from remote endpoint in this stream.
2628
+ * |ts| is the current timestamp, and must be non-decreasing. It
2629
+ * should be obtained from the clock that is steadily increasing.
2630
+ *
2631
+ * This function returns the number of bytes consumed, or one of the
2632
+ * following negative error codes:
2633
+ *
2634
+ * :macro:`NGHTTP3_ERR_NOMEM`
2635
+ * Out of memory.
2636
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2637
+ * User callback failed.
2638
+ *
2639
+ * It may return the other error codes. The negative error code means
2640
+ * that |conn| encountered a connection error, and the connection must
2641
+ * be closed. Calling nghttp3 API other than `nghttp3_conn_del`
2642
+ * causes undefined behavior.
2643
+ *
2644
+ * .. version-added:: 1.12.0
2645
+ */
2646
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_read_stream2(nghttp3_conn *conn,
2647
+ int64_t stream_id,
2648
+ const uint8_t *src,
2649
+ size_t srclen, int fin,
2650
+ nghttp3_tstamp ts);
2651
+
2652
+ /**
2653
+ * @function
2654
+ *
2655
+ * `nghttp3_conn_writev_stream` stores stream data to send to |vec| of
2656
+ * length |veccnt|, and returns the number of nghttp3_vec object in
2657
+ * which it stored data. It stores stream ID to |*pstream_id|. An
2658
+ * application has to call `nghttp3_conn_add_write_offset` to inform
2659
+ * |conn| of the actual number of bytes that underlying QUIC stack
2660
+ * accepted. |*pfin| will be nonzero if this is the last data to
2661
+ * send. If there is no stream to write data or send fin, this
2662
+ * function returns 0, and -1 is assigned to |*pstream_id|. This
2663
+ * function may return 0, and |*pstream_id| is not -1, and |*pfin| is
2664
+ * nonzero. It means 0 length data to |*pstream_id|, and it is the
2665
+ * last data to the stream. They must be passed to QUIC stack, and
2666
+ * they are accepted, the application has to call
2667
+ * `nghttp3_conn_add_write_offset` with 0 byte.
2668
+ *
2669
+ * This function returns the number of bytes consumed, or one of the
2670
+ * following negative error codes:
2671
+ *
2672
+ * :macro:`NGHTTP3_ERR_NOMEM`
2673
+ * Out of memory.
2674
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2675
+ * User callback failed.
2676
+ *
2677
+ * It may return the other error codes. The negative error code means
2678
+ * that |conn| encountered a connection error, and the connection must
2679
+ * be closed. Calling nghttp3 API other than `nghttp3_conn_del`
2680
+ * causes undefined behavior.
2681
+ */
2682
+ NGHTTP3_EXTERN nghttp3_ssize nghttp3_conn_writev_stream(nghttp3_conn *conn,
2683
+ int64_t *pstream_id,
2684
+ int *pfin,
2685
+ nghttp3_vec *vec,
2686
+ size_t veccnt);
2687
+
2688
+ /**
2689
+ * @function
2690
+ *
2691
+ * `nghttp3_conn_add_write_offset` tells |conn| the number of bytes
2692
+ * |n| for stream denoted by |stream_id| QUIC stack accepted.
2693
+ *
2694
+ * If stream has no data to send but just sends fin (closing the write
2695
+ * side of a stream), the number of bytes sent is 0. It is important
2696
+ * to call this function even if |n| is 0 in this case. It is safe to
2697
+ * call this function if |n| is 0.
2698
+ *
2699
+ * `nghttp3_conn_writev_stream` must be called before calling this
2700
+ * function to get data to send, and those data must be fed into QUIC
2701
+ * stack.
2702
+ *
2703
+ * If a stream denoted by |stream_id| is not found, this function
2704
+ * returns 0.
2705
+ *
2706
+ * This function returns 0 if it succeeds, or one of the following
2707
+ * negative error codes:
2708
+ *
2709
+ * :macro:`NGHTTP3_ERR_NOMEM`
2710
+ * Out of memory.
2711
+ */
2712
+ NGHTTP3_EXTERN int nghttp3_conn_add_write_offset(nghttp3_conn *conn,
2713
+ int64_t stream_id, size_t n);
2714
+
2715
+ /**
2716
+ * @function
2717
+ *
2718
+ * `nghttp3_conn_is_stream_flushed` returns nonzero if all stream data
2719
+ * for a stream identified by |stream_id| so far have been accepted by
2720
+ * QUIC stack. This means that the cumulative number of bytes that
2721
+ * `nghttp3_conn_add_write_offset` notified covers all stream data
2722
+ * currently held. This does not mean more stream data cannot be
2723
+ * submitted to this stream via :type:`nghttp3_read_data_callback` and
2724
+ * all stream data have been acknowledged.
2725
+ *
2726
+ * If there is no stream identified by |stream_id|, this function
2727
+ * returns nonzero.
2728
+ *
2729
+ * .. version-added:: 1.17.0
2730
+ */
2731
+ NGHTTP3_EXTERN int nghttp3_conn_is_stream_flushed(const nghttp3_conn *conn,
2732
+ int64_t stream_id);
2733
+
2734
+ /**
2735
+ * @function
2736
+ *
2737
+ * `nghttp3_conn_add_ack_offset` tells |conn| the number of bytes |n|
2738
+ * for stream denoted by |stream_id| QUIC stack has acknowledged.
2739
+ *
2740
+ * If a stream denoted by |stream_id| is not found, this function
2741
+ * returns 0.
2742
+ *
2743
+ * Alternatively, `nghttp3_conn_update_ack_offset` can be used to
2744
+ * accomplish the same thing.
2745
+ *
2746
+ * This function returns 0 if it succeeds, or one of the following
2747
+ * negative error codes:
2748
+ *
2749
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2750
+ * User callback failed.
2751
+ */
2752
+ NGHTTP3_EXTERN int nghttp3_conn_add_ack_offset(nghttp3_conn *conn,
2753
+ int64_t stream_id, uint64_t n);
2754
+
2755
+ /**
2756
+ * @function
2757
+ *
2758
+ * `nghttp3_conn_update_ack_offset` tells |conn| that QUIC stack has
2759
+ * acknowledged the stream data up to |offset| for a stream denoted by
2760
+ * |stream_id|.
2761
+ *
2762
+ * If a stream denoted by |stream_id| is not found, this function
2763
+ * returns 0.
2764
+ *
2765
+ * Alternatively, `nghttp3_conn_add_ack_offset` can be used to
2766
+ * accomplish the same thing.
2767
+ *
2768
+ * This function returns 0 if it succeeds, or one of the following
2769
+ * negative error codes:
2770
+ *
2771
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2772
+ * |offset| is less than the number of bytes acknowledged so far.
2773
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2774
+ * User callback failed.
2775
+ */
2776
+ NGHTTP3_EXTERN int nghttp3_conn_update_ack_offset(nghttp3_conn *conn,
2777
+ int64_t stream_id,
2778
+ uint64_t offset);
2779
+
2780
+ /**
2781
+ * @function
2782
+ *
2783
+ * `nghttp3_conn_block_stream` tells the library that stream
2784
+ * identified by |stream_id| is blocked due to QUIC flow control.
2785
+ */
2786
+ NGHTTP3_EXTERN void nghttp3_conn_block_stream(nghttp3_conn *conn,
2787
+ int64_t stream_id);
2788
+
2789
+ /**
2790
+ * @function
2791
+ *
2792
+ * `nghttp3_conn_unblock_stream` tells the library that stream
2793
+ * identified by |stream_id| which was blocked by QUIC flow control
2794
+ * (see `nghttp3_conn_block_stream`) is unblocked.
2795
+ *
2796
+ * If a stream denoted by |stream_id| is not found, this function
2797
+ * returns 0.
2798
+ *
2799
+ * This function returns 0 if it succeeds, or one of the following
2800
+ * negative error codes:
2801
+ *
2802
+ * :macro:`NGHTTP3_ERR_NOMEM`
2803
+ * Out of memory.
2804
+ */
2805
+ NGHTTP3_EXTERN int nghttp3_conn_unblock_stream(nghttp3_conn *conn,
2806
+ int64_t stream_id);
2807
+
2808
+ /**
2809
+ * @function
2810
+ *
2811
+ * .. warning::
2812
+ *
2813
+ * .. version-deprecated:: 1.16.0
2814
+ * Use `nghttp3_conn_is_stream_writable2` instead.
2815
+ *
2816
+ * `nghttp3_conn_is_stream_writable` returns nonzero if a stream
2817
+ * identified by |stream_id| is writable. It is not writable if:
2818
+ *
2819
+ * - the stream does not exist; or,
2820
+ * - the stream is closed (e.g., `nghttp3_conn_close_stream` is
2821
+ * called); or,
2822
+ * - the stream is QUIC flow control blocked (e.g.,
2823
+ * `nghttp3_conn_block_stream` is called); or,
2824
+ * - the stream is input data blocked (e.g.,
2825
+ * :macro:`NGHTTP3_ERR_WOULDBLOCK` is returned from
2826
+ * :type:`nghttp3_read_data_callback`); or,
2827
+ * - the stream is half-closed local (e.g.,
2828
+ * `nghttp3_conn_shutdown_stream_write` is called).
2829
+ */
2830
+ NGHTTP3_EXTERN int nghttp3_conn_is_stream_writable(nghttp3_conn *conn,
2831
+ int64_t stream_id);
2832
+
2833
+ /**
2834
+ * @function
2835
+ *
2836
+ * `nghttp3_conn_is_stream_writable2` returns nonzero if a stream
2837
+ * identified by |stream_id| is writable. It is not writable if:
2838
+ *
2839
+ * - the stream does not exist; or,
2840
+ * - the stream is closed (e.g., `nghttp3_conn_close_stream` is
2841
+ * called); or,
2842
+ * - the stream is QUIC flow control blocked (e.g.,
2843
+ * `nghttp3_conn_block_stream` is called); or,
2844
+ * - the stream is input data blocked (e.g.,
2845
+ * :macro:`NGHTTP3_ERR_WOULDBLOCK` is returned from
2846
+ * :type:`nghttp3_read_data_callback`); or,
2847
+ * - the stream is half-closed local (e.g.,
2848
+ * `nghttp3_conn_shutdown_stream_write` is called).
2849
+ *
2850
+ * .. version-added:: 1.16.0
2851
+ */
2852
+ NGHTTP3_EXTERN int nghttp3_conn_is_stream_writable2(const nghttp3_conn *conn,
2853
+ int64_t stream_id);
2854
+
2855
+ /**
2856
+ * @function
2857
+ *
2858
+ * `nghttp3_conn_shutdown_stream_write` tells the library that any
2859
+ * further write operation to stream identified by |stream_id| is
2860
+ * prohibited. This works like `nghttp3_conn_block_stream`, but it
2861
+ * cannot be unblocked by `nghttp3_conn_unblock_stream`.
2862
+ */
2863
+ NGHTTP3_EXTERN void nghttp3_conn_shutdown_stream_write(nghttp3_conn *conn,
2864
+ int64_t stream_id);
2865
+
2866
+ /**
2867
+ * @function
2868
+ *
2869
+ * `nghttp3_conn_shutdown_stream_read` tells the library that
2870
+ * read-side of stream denoted by |stream_id| is abruptly closed, and
2871
+ * any further incoming data and pending stream data should be
2872
+ * discarded.
2873
+ *
2874
+ * If a stream denoted by |stream_id| is not client bidirectional
2875
+ * stream, this function returns 0. If the stream has already
2876
+ * shutdown read-side stream, this function returns 0.
2877
+ *
2878
+ * This function does not fail if a stream denoted by |stream_id| is
2879
+ * not found, although it may fail with the other reasons.
2880
+ *
2881
+ * This function returns 0 if it succeeds, or one of the following
2882
+ * negative error codes:
2883
+ *
2884
+ * :macro:`NGHTTP3_ERR_NOMEM`
2885
+ * Out of memory.
2886
+ * :macro:`NGHTTP3_ERR_QPACK_FATAL`
2887
+ * QPACK decoder stream overflow.
2888
+ */
2889
+ NGHTTP3_EXTERN int nghttp3_conn_shutdown_stream_read(nghttp3_conn *conn,
2890
+ int64_t stream_id);
2891
+
2892
+ /**
2893
+ * @function
2894
+ *
2895
+ * `nghttp3_conn_resume_stream` resumes stream identified by
2896
+ * |stream_id| which was previously unable to provide data. See
2897
+ * :type:`nghttp3_read_data_callback`.
2898
+ *
2899
+ * If a stream denoted by |stream_id| is not found, this function
2900
+ * returns 0.
2901
+ *
2902
+ * This function returns 0 if it succeeds, or one of the following
2903
+ * negative error codes:
2904
+ *
2905
+ * :macro:`NGHTTP3_ERR_NOMEM`
2906
+ * Out of memory.
2907
+ */
2908
+ NGHTTP3_EXTERN int nghttp3_conn_resume_stream(nghttp3_conn *conn,
2909
+ int64_t stream_id);
2910
+
2911
+ /**
2912
+ * @function
2913
+ *
2914
+ * `nghttp3_conn_close_stream` tells the library that a stream
2915
+ * identified by |stream_id| has been closed. QUIC application error
2916
+ * code |app_error_code| is the reason of the closure.
2917
+ *
2918
+ * This function returns 0 if it succeeds, or one of the following
2919
+ * negative error codes:
2920
+ *
2921
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
2922
+ * Stream not found.
2923
+ * :macro:`NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM`
2924
+ * A critical stream is closed.
2925
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2926
+ * User callback failed
2927
+ *
2928
+ * .. seealso::
2929
+ * `nghttp3_conn_close_stream2`
2930
+ */
2931
+ NGHTTP3_EXTERN int nghttp3_conn_close_stream(nghttp3_conn *conn,
2932
+ int64_t stream_id,
2933
+ uint64_t app_error_code);
2934
+
2935
+ /**
2936
+ * @function
2937
+ *
2938
+ * `nghttp3_conn_close_stream2` tells the library that a stream
2939
+ * identified by |stream_id| has been closed. If
2940
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_RX_APP_ERROR_CODE_SET` is set in
2941
+ * |flags|, |rx_app_error_code| is the QUIC application error code
2942
+ * that shut down the receiving side of the stream. Similarly,
2943
+ * :macro:`NGHTTP3_STREAM_CLOSE_FLAG_TX_APP_ERROR_CODE_SET` is set in
2944
+ * |flags|, |tx_app_error_code| is the QUIC application error code
2945
+ * that shut down the sending side of the stream.
2946
+ *
2947
+ * For stream close callback, prefer
2948
+ * :member:`nghttp3_callbacks.stream_close2` to
2949
+ * :member:`nghttp3_callbacks.stream_close`.
2950
+ *
2951
+ * This function returns 0 if it succeeds, or one of the following
2952
+ * negative error codes:
2953
+ *
2954
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
2955
+ * Stream not found.
2956
+ * :macro:`NGHTTP3_ERR_H3_CLOSED_CRITICAL_STREAM`
2957
+ * A critical stream is closed.
2958
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`
2959
+ * User callback failed
2960
+ *
2961
+ * .. version-added:: 1.18.0
2962
+ */
2963
+ NGHTTP3_EXTERN int nghttp3_conn_close_stream2(nghttp3_conn *conn,
2964
+ uint32_t flags, int64_t stream_id,
2965
+ uint64_t rx_app_error_code,
2966
+ uint64_t tx_app_error_code);
2967
+
2968
+ /**
2969
+ * @macrosection
2970
+ *
2971
+ * Data flags
2972
+ */
2973
+
2974
+ /**
2975
+ * @macro
2976
+ *
2977
+ * :macro:`NGHTTP3_DATA_FLAG_NONE` indicates no flag set.
2978
+ */
2979
+ #define NGHTTP3_DATA_FLAG_NONE 0x00U
2980
+
2981
+ /**
2982
+ * @macro
2983
+ *
2984
+ * :macro:`NGHTTP3_DATA_FLAG_EOF` indicates that all request or
2985
+ * response body has been provided to the library. It also indicates
2986
+ * that sending side of stream is closed unless
2987
+ * :macro:`NGHTTP3_DATA_FLAG_NO_END_STREAM` is given at the same time.
2988
+ */
2989
+ #define NGHTTP3_DATA_FLAG_EOF 0x01U
2990
+
2991
+ /**
2992
+ * @macro
2993
+ *
2994
+ * :macro:`NGHTTP3_DATA_FLAG_NO_END_STREAM` indicates that sending
2995
+ * side of stream is not closed even if :macro:`NGHTTP3_DATA_FLAG_EOF`
2996
+ * is set. Usually this flag is used to send trailer fields with
2997
+ * `nghttp3_conn_submit_trailers`. If `nghttp3_conn_submit_trailers`
2998
+ * has been called, regardless of this flag, the submitted trailer
2999
+ * fields are sent.
3000
+ */
3001
+ #define NGHTTP3_DATA_FLAG_NO_END_STREAM 0x02U
3002
+
3003
+ /**
3004
+ * @function
3005
+ *
3006
+ * `nghttp3_conn_set_max_client_streams_bidi` tells |conn| the
3007
+ * cumulative number of bidirectional streams that client can open.
3008
+ */
3009
+ NGHTTP3_EXTERN void
3010
+ nghttp3_conn_set_max_client_streams_bidi(nghttp3_conn *conn,
3011
+ uint64_t max_streams);
3012
+
3013
+ /**
3014
+ * @function
3015
+ *
3016
+ * `nghttp3_conn_set_max_concurrent_streams` tells |conn| the maximum
3017
+ * number of concurrent streams that a remote endpoint can open,
3018
+ * including both bidirectional and unidirectional streams which
3019
+ * potentially receive QPACK encoded HEADERS frame. This value is
3020
+ * used as a hint to limit the internal resource consumption.
3021
+ */
3022
+ NGHTTP3_EXTERN void
3023
+ nghttp3_conn_set_max_concurrent_streams(nghttp3_conn *conn,
3024
+ size_t max_concurrent_streams);
3025
+
3026
+ /**
3027
+ * @functypedef
3028
+ *
3029
+ * :type:`nghttp3_read_data_callback` is a callback function invoked
3030
+ * when the library asks an application to provide stream data for a
3031
+ * stream denoted by |stream_id|.
3032
+ *
3033
+ * The library provides |vec| of length |veccnt| to the application.
3034
+ * The application should fill data and its length to |vec|. It has
3035
+ * to return the number of the filled objects. The application must
3036
+ * retain data until they are safe to free. It is notified by
3037
+ * :type:`nghttp3_acked_stream_data` callback.
3038
+ *
3039
+ * If this is the last data to send (or there is no data to send
3040
+ * because all data have been sent already), set
3041
+ * :macro:`NGHTTP3_DATA_FLAG_EOF` to |*pflags|.
3042
+ *
3043
+ * If the application is unable to provide data temporarily, return
3044
+ * :macro:`NGHTTP3_ERR_WOULDBLOCK`. When it is ready to provide data,
3045
+ * call `nghttp3_conn_resume_stream`.
3046
+ *
3047
+ * The callback should return the number of objects in |vec| that the
3048
+ * application filled if it succeeds, or
3049
+ * :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
3050
+ *
3051
+ * TODO Add NGHTTP3_ERR_TEMPORAL_CALLBACK_FAILURE to reset just this
3052
+ * stream.
3053
+ */
3054
+ typedef nghttp3_ssize (*nghttp3_read_data_callback)(
3055
+ nghttp3_conn *conn, int64_t stream_id, nghttp3_vec *vec, size_t veccnt,
3056
+ uint32_t *pflags, void *conn_user_data, void *stream_user_data);
3057
+
3058
+ /**
3059
+ * @struct
3060
+ *
3061
+ * :type:`nghttp3_data_reader` specifies the way how to generate
3062
+ * request or response body.
3063
+ */
3064
+ typedef struct nghttp3_data_reader {
3065
+ /**
3066
+ * :member:`read_data` is a callback function to generate body.
3067
+ */
3068
+ nghttp3_read_data_callback read_data;
3069
+ } nghttp3_data_reader;
3070
+
3071
+ /**
3072
+ * @function
3073
+ *
3074
+ * `nghttp3_conn_submit_request` submits HTTP request header fields
3075
+ * and body on the stream identified by |stream_id|. |stream_id| must
3076
+ * be a client initiated bidirectional stream. Only client can submit
3077
+ * HTTP request. |nva| of length |nvlen| specifies HTTP request
3078
+ * header fields. |dr| specifies a request body. If there is no
3079
+ * request body, specify NULL. If |dr| is NULL, it implies the end of
3080
+ * stream. |stream_user_data| is an opaque pointer attached to the
3081
+ * stream.
3082
+ *
3083
+ * This function returns 0 if it succeeds, or one of the following
3084
+ * negative error codes:
3085
+ *
3086
+ * :macro:`NGHTTP3_ERR_CONN_CLOSING`
3087
+ * Connection is shutting down, and no new stream is allowed.
3088
+ * :macro:`NGHTTP3_ERR_STREAM_IN_USE`
3089
+ * Stream has already been opened.
3090
+ * :macro:`NGHTTP3_ERR_NOMEM`
3091
+ * Out of memory.
3092
+ */
3093
+ NGHTTP3_EXTERN int nghttp3_conn_submit_request(
3094
+ nghttp3_conn *conn, int64_t stream_id, const nghttp3_nv *nva, size_t nvlen,
3095
+ const nghttp3_data_reader *dr, void *stream_user_data);
3096
+
3097
+ /**
3098
+ * @function
3099
+ *
3100
+ * `nghttp3_conn_submit_info` submits HTTP non-final response header
3101
+ * fields on the stream identified by |stream_id|. |nva| of length
3102
+ * |nvlen| specifies HTTP response header fields.
3103
+ *
3104
+ * This function returns 0 if it succeeds, or one of the following
3105
+ * negative error codes:
3106
+ *
3107
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3108
+ * Stream not found
3109
+ * :macro:`NGHTTP3_ERR_NOMEM`
3110
+ * Out of memory.
3111
+ */
3112
+ NGHTTP3_EXTERN int nghttp3_conn_submit_info(nghttp3_conn *conn,
3113
+ int64_t stream_id,
3114
+ const nghttp3_nv *nva,
3115
+ size_t nvlen);
3116
+
3117
+ /**
3118
+ * @function
3119
+ *
3120
+ * `nghttp3_conn_submit_response` submits HTTP response header fields
3121
+ * and body on the stream identified by |stream_id|. |nva| of length
3122
+ * |nvlen| specifies HTTP response header fields. |dr| specifies a
3123
+ * response body. If there is no response body, specify NULL. If
3124
+ * |dr| is NULL, it implies the end of stream.
3125
+ *
3126
+ * This function returns 0 if it succeeds, or one of the following
3127
+ * negative error codes:
3128
+ *
3129
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3130
+ * Stream not found
3131
+ * :macro:`NGHTTP3_ERR_NOMEM`
3132
+ * Out of memory.
3133
+ */
3134
+ NGHTTP3_EXTERN int nghttp3_conn_submit_response(nghttp3_conn *conn,
3135
+ int64_t stream_id,
3136
+ const nghttp3_nv *nva,
3137
+ size_t nvlen,
3138
+ const nghttp3_data_reader *dr);
3139
+
3140
+ /**
3141
+ * @function
3142
+ *
3143
+ * `nghttp3_conn_submit_trailers` submits HTTP trailer fields on the
3144
+ * stream identified by |stream_id|. |nva| of length |nvlen|
3145
+ * specifies HTTP trailer fields. Calling this function implies the
3146
+ * end of stream.
3147
+ *
3148
+ * This function returns 0 if it succeeds, or one of the following
3149
+ * negative error codes:
3150
+ *
3151
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3152
+ * Stream not found
3153
+ * :macro:`NGHTTP3_ERR_INVALID_STATE`
3154
+ * Application has already submitted fin to stream.
3155
+ * :macro:`NGHTTP3_ERR_NOMEM`
3156
+ * Out of memory.
3157
+ */
3158
+ NGHTTP3_EXTERN int nghttp3_conn_submit_trailers(nghttp3_conn *conn,
3159
+ int64_t stream_id,
3160
+ const nghttp3_nv *nva,
3161
+ size_t nvlen);
3162
+
3163
+ /**
3164
+ * @function
3165
+ *
3166
+ * `nghttp3_conn_submit_shutdown_notice` notifies the other endpoint
3167
+ * to stop creating new stream. After a couple of RTTs later, call
3168
+ * `nghttp3_conn_shutdown` to start graceful shutdown.
3169
+ *
3170
+ * This function returns 0 if it succeeds, or one of the following
3171
+ * negative error codes:
3172
+ *
3173
+ * :macro:`NGHTTP3_ERR_NOMEM`
3174
+ * Out of memory.
3175
+ */
3176
+ NGHTTP3_EXTERN int nghttp3_conn_submit_shutdown_notice(nghttp3_conn *conn);
3177
+
3178
+ /**
3179
+ * @function
3180
+ *
3181
+ * `nghttp3_conn_shutdown` starts graceful shutdown. It should be
3182
+ * called after `nghttp3_conn_submit_shutdown_notice` and a couple of
3183
+ * RTTs. After calling this function, the local endpoint starts
3184
+ * rejecting new incoming streams. The existing streams are processed
3185
+ * normally. See also `nghttp3_conn_is_drained`.
3186
+ *
3187
+ * This function returns 0 if it succeeds, or one of the following
3188
+ * negative error codes:
3189
+ *
3190
+ * :macro:`NGHTTP3_ERR_NOMEM`
3191
+ * Out of memory.
3192
+ */
3193
+ NGHTTP3_EXTERN int nghttp3_conn_shutdown(nghttp3_conn *conn);
3194
+
3195
+ /**
3196
+ * @function
3197
+ *
3198
+ * `nghttp3_conn_set_stream_user_data` sets |stream_user_data| to the
3199
+ * stream identified by |stream_id|.
3200
+ *
3201
+ * This function returns 0 if it succeeds, or one of the following
3202
+ * negative error codes:
3203
+ *
3204
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3205
+ * Stream not found.
3206
+ */
3207
+ NGHTTP3_EXTERN int nghttp3_conn_set_stream_user_data(nghttp3_conn *conn,
3208
+ int64_t stream_id,
3209
+ void *stream_user_data);
3210
+
3211
+ /**
3212
+ * @function
3213
+ *
3214
+ * `nghttp3_conn_get_stream_user_data` returns the user data
3215
+ * associated to the stream identified by |stream_id|. If no data is
3216
+ * associated or the stream is not found, this function returns NULL.
3217
+ *
3218
+ * The user data can be associated to the stream by the following
3219
+ * functions:
3220
+ *
3221
+ * - `nghttp3_conn_set_stream_user_data`
3222
+ * - `nghttp3_conn_submit_request`
3223
+ *
3224
+ * .. version-added:: 1.16.0
3225
+ */
3226
+ NGHTTP3_EXTERN void *nghttp3_conn_get_stream_user_data(const nghttp3_conn *conn,
3227
+ int64_t stream_id);
3228
+
3229
+ /**
3230
+ * @function
3231
+ *
3232
+ * .. warning::
3233
+ *
3234
+ * .. version-deprecated:: 1.16.0
3235
+ * Use `nghttp3_conn_get_frame_payload_left2` instead.
3236
+ *
3237
+ * `nghttp3_conn_get_frame_payload_left` returns the number of bytes
3238
+ * left to read current frame payload for a stream denoted by
3239
+ * |stream_id|. If no such stream is found, or |stream_id| identifies
3240
+ * neither client bidirectional stream nor remote control stream, it
3241
+ * returns 0.
3242
+ */
3243
+ NGHTTP3_EXTERN uint64_t nghttp3_conn_get_frame_payload_left(nghttp3_conn *conn,
3244
+ int64_t stream_id);
3245
+
3246
+ /**
3247
+ * @function
3248
+ *
3249
+ * `nghttp3_conn_get_frame_payload_left2` returns the number of bytes
3250
+ * left to read current frame payload for a stream denoted by
3251
+ * |stream_id|. If no such stream is found, or |stream_id| identifies
3252
+ * neither client bidirectional stream nor remote control stream, it
3253
+ * returns 0.
3254
+ *
3255
+ * .. version-added:: 1.16.0
3256
+ */
3257
+ NGHTTP3_EXTERN uint64_t nghttp3_conn_get_frame_payload_left2(
3258
+ const nghttp3_conn *conn, int64_t stream_id);
3259
+
3260
+ /**
3261
+ * @macrosection
3262
+ *
3263
+ * HTTP stream priority flags
3264
+ */
3265
+
3266
+ /**
3267
+ * @macro
3268
+ *
3269
+ * :macro:`NGHTTP3_DEFAULT_URGENCY` is the default urgency level.
3270
+ */
3271
+ #define NGHTTP3_DEFAULT_URGENCY 3
3272
+
3273
+ /**
3274
+ * @macro
3275
+ *
3276
+ * :macro:`NGHTTP3_URGENCY_HIGH` is the highest urgency level.
3277
+ */
3278
+ #define NGHTTP3_URGENCY_HIGH 0
3279
+
3280
+ /**
3281
+ * @macro
3282
+ *
3283
+ * :macro:`NGHTTP3_URGENCY_LOW` is the lowest urgency level.
3284
+ */
3285
+ #define NGHTTP3_URGENCY_LOW 7
3286
+
3287
+ /**
3288
+ * @macro
3289
+ *
3290
+ * :macro:`NGHTTP3_URGENCY_LEVELS` is the number of urgency levels.
3291
+ */
3292
+ #define NGHTTP3_URGENCY_LEVELS (NGHTTP3_URGENCY_LOW + 1)
3293
+
3294
+ #define NGHTTP3_PRI_V1 1
3295
+ #define NGHTTP3_PRI_VERSION NGHTTP3_PRI_V1
3296
+
3297
+ /**
3298
+ * @struct
3299
+ *
3300
+ * :type:`nghttp3_pri` represents HTTP priority.
3301
+ */
3302
+ typedef struct NGHTTP3_ALIGN(8) nghttp3_pri {
3303
+ /**
3304
+ * :member:`urgency` is the urgency of a stream, it must be in
3305
+ * [:macro:`NGHTTP3_URGENCY_HIGH`, :macro:`NGHTTP3_URGENCY_LOW`],
3306
+ * inclusive, and 0 is the highest urgency.
3307
+ */
3308
+ uint32_t urgency;
3309
+ /**
3310
+ * :member:`inc` indicates that a content can be processed
3311
+ * incrementally or not. If it is 0, it cannot be processed
3312
+ * incrementally. If it is 1, it can be processed incrementally.
3313
+ * Other value is not permitted.
3314
+ */
3315
+ uint8_t inc;
3316
+ } nghttp3_pri;
3317
+
3318
+ /**
3319
+ * @function
3320
+ *
3321
+ * .. warning::
3322
+ *
3323
+ * .. version-deprecated:: 1.16.0
3324
+ * Use `nghttp3_conn_get_stream_priority2` instead.
3325
+ *
3326
+ * `nghttp3_conn_get_stream_priority` stores stream priority of a
3327
+ * stream denoted by |stream_id| into |*dest|. |stream_id| must
3328
+ * identify client initiated bidirectional stream. Only server can
3329
+ * use this function.
3330
+ *
3331
+ * This function must not be called if |conn| is initialized as
3332
+ * client.
3333
+ *
3334
+ * This function returns 0 if it succeeds, or one of the following
3335
+ * negative error codes:
3336
+ *
3337
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3338
+ * |stream_id| is not a client initiated bidirectional stream ID.
3339
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3340
+ * Stream not found.
3341
+ */
3342
+ NGHTTP3_EXTERN int nghttp3_conn_get_stream_priority_versioned(
3343
+ nghttp3_conn *conn, int pri_version, nghttp3_pri *dest, int64_t stream_id);
3344
+
3345
+ /**
3346
+ * @function
3347
+ *
3348
+ * `nghttp3_conn_get_stream_priority2` stores stream priority of a
3349
+ * stream denoted by |stream_id| into |*dest|. |stream_id| must
3350
+ * identify client initiated bidirectional stream. Only server can
3351
+ * use this function.
3352
+ *
3353
+ * This function must not be called if |conn| is initialized as
3354
+ * client.
3355
+ *
3356
+ * This function returns 0 if it succeeds, or one of the following
3357
+ * negative error codes:
3358
+ *
3359
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3360
+ * |stream_id| is not a client initiated bidirectional stream ID.
3361
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3362
+ * Stream not found.
3363
+ *
3364
+ * .. version-added:: 1.16.0
3365
+ */
3366
+ NGHTTP3_EXTERN int
3367
+ nghttp3_conn_get_stream_priority2_versioned(const nghttp3_conn *conn,
3368
+ int pri_version, nghttp3_pri *dest,
3369
+ int64_t stream_id);
3370
+
3371
+ /**
3372
+ * @function
3373
+ *
3374
+ * `nghttp3_conn_set_client_stream_priority` updates priority of a
3375
+ * stream denoted by |stream_id| with the value pointed by |data| of
3376
+ * length |datalen|, which should be a serialized :rfc:`9218` priority
3377
+ * field value. |stream_id| must identify client initiated
3378
+ * bidirectional stream.
3379
+ *
3380
+ * This function must not be called if |conn| is initialized as
3381
+ * server.
3382
+ *
3383
+ * This function returns 0 if it succeeds, or one of the following
3384
+ * negative error codes:
3385
+ *
3386
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3387
+ * |stream_id| is not a client initiated bidirectional stream ID.
3388
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3389
+ * Stream not found.
3390
+ * :macro:`NGHTTP3_ERR_NOMEM`
3391
+ * Out of memory.
3392
+ */
3393
+ NGHTTP3_EXTERN int nghttp3_conn_set_client_stream_priority(nghttp3_conn *conn,
3394
+ int64_t stream_id,
3395
+ const uint8_t *data,
3396
+ size_t datalen);
3397
+
3398
+ /**
3399
+ * @function
3400
+ *
3401
+ * `nghttp3_conn_set_server_stream_priority` updates priority of a
3402
+ * stream denoted by |stream_id| with the value pointed by |pri|.
3403
+ * |stream_id| must identify client initiated bidirectional stream.
3404
+ *
3405
+ * This function must not be called if |conn| is initialized as
3406
+ * client.
3407
+ *
3408
+ * This function completely overrides stream priority set by client,
3409
+ * and any attempts to update priority by client are ignored.
3410
+ *
3411
+ * This function returns 0 if it succeeds, or one of the following
3412
+ * negative error codes:
3413
+ *
3414
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3415
+ * |stream_id| is not a client initiated bidirectional stream ID.
3416
+ * :macro:`NGHTTP3_ERR_STREAM_NOT_FOUND`
3417
+ * Stream not found.
3418
+ * :macro:`NGHTTP3_ERR_NOMEM`
3419
+ * Out of memory.
3420
+ */
3421
+ NGHTTP3_EXTERN int nghttp3_conn_set_server_stream_priority_versioned(
3422
+ nghttp3_conn *conn, int64_t stream_id, int pri_version,
3423
+ const nghttp3_pri *pri);
3424
+
3425
+ /**
3426
+ * @function
3427
+ *
3428
+ * `nghttp3_vec_len` returns the sum of length in |vec| of |cnt|
3429
+ * elements.
3430
+ */
3431
+ NGHTTP3_EXTERN uint64_t nghttp3_vec_len(const nghttp3_vec *vec, size_t cnt);
3432
+
3433
+ /**
3434
+ * @function
3435
+ *
3436
+ * `nghttp3_check_header_name` returns nonzero if HTTP field name
3437
+ * |name| of length |len| is valid according to
3438
+ * :rfc:`7230#section-3.2`.
3439
+ *
3440
+ * Because this is an HTTP field name in HTTP/3, the upper cased
3441
+ * alphabet is treated as error.
3442
+ */
3443
+ NGHTTP3_EXTERN int nghttp3_check_header_name(const uint8_t *name, size_t len);
3444
+
3445
+ /**
3446
+ * @function
3447
+ *
3448
+ * `nghttp3_check_header_value` returns nonzero if HTTP field value
3449
+ * |value| of length |len| is valid according to
3450
+ * :rfc:`7230#section-3.2`.
3451
+ */
3452
+ NGHTTP3_EXTERN int nghttp3_check_header_value(const uint8_t *value, size_t len);
3453
+
3454
+ /**
3455
+ * @function
3456
+ *
3457
+ * .. warning::
3458
+ *
3459
+ * .. version-deprecated:: 1.16.0
3460
+ * Use `nghttp3_conn_is_drained2` instead.
3461
+ *
3462
+ * `nghttp3_conn_is_drained` returns nonzero if
3463
+ * `nghttp3_conn_shutdown` has been called, and there is no active
3464
+ * remote streams. This function is for server use only.
3465
+ */
3466
+ NGHTTP3_EXTERN int nghttp3_conn_is_drained(nghttp3_conn *conn);
3467
+
3468
+ /**
3469
+ * @function
3470
+ *
3471
+ * `nghttp3_conn_is_drained2` returns nonzero if
3472
+ * `nghttp3_conn_shutdown` has been called, and there is no active
3473
+ * remote streams. This function is for server use only.
3474
+ *
3475
+ * .. version-added:: 1.16.0
3476
+ */
3477
+ NGHTTP3_EXTERN int nghttp3_conn_is_drained2(const nghttp3_conn *conn);
3478
+
3479
+ /**
3480
+ * @function
3481
+ *
3482
+ * `nghttp3_pri_parse_priority` parses Priority header field value
3483
+ * pointed by |value| of length |len|, and stores the result in the
3484
+ * object pointed by |dest|. Priority header field is defined in
3485
+ * :rfc:`9218`.
3486
+ *
3487
+ * This function does not initialize the object pointed by |dest|
3488
+ * before storing the result. It only assigns the values that the
3489
+ * parser correctly extracted to fields.
3490
+ *
3491
+ * This function returns 0 if it succeeds, or one of the following
3492
+ * negative error codes:
3493
+ *
3494
+ * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
3495
+ * Failed to parse the header field value.
3496
+ */
3497
+ NGHTTP3_EXTERN int nghttp3_pri_parse_priority_versioned(int pri_version,
3498
+ nghttp3_pri *dest,
3499
+ const uint8_t *value,
3500
+ size_t len);
3501
+
3502
+ /**
3503
+ * @macrosection
3504
+ *
3505
+ * nghttp3_info flags
3506
+ */
3507
+
3508
+ /**
3509
+ * @macro
3510
+ *
3511
+ * :macro:`NGHTTP3_VERSION_AGE` is the age of :type:`nghttp3_info`.
3512
+ */
3513
+ #define NGHTTP3_VERSION_AGE 1
3514
+
3515
+ /**
3516
+ * @struct
3517
+ *
3518
+ * :type:`nghttp3_info` is what `nghttp3_version` returns. It holds
3519
+ * information about the particular nghttp3 version.
3520
+ */
3521
+ typedef struct nghttp3_info {
3522
+ /**
3523
+ * :member:`age` is the age of this struct. This instance of
3524
+ * nghttp3 sets it to :macro:`NGHTTP3_VERSION_AGE` but a future
3525
+ * version may bump it and add more struct fields at the bottom
3526
+ */
3527
+ int age;
3528
+ /**
3529
+ * :member:`version_num` is the :macro:`NGHTTP3_VERSION_NUM` number
3530
+ * (since age == 1)
3531
+ */
3532
+ int version_num;
3533
+ /**
3534
+ * :member:`version_str` points to the :macro:`NGHTTP3_VERSION`
3535
+ * string (since age ==1)
3536
+ */
3537
+ const char *version_str;
3538
+ /* -------- the above fields all exist when age == 1 */
3539
+ } nghttp3_info;
3540
+
3541
+ /**
3542
+ * @function
3543
+ *
3544
+ * `nghttp3_version` returns a pointer to a :type:`nghttp3_info`
3545
+ * struct with version information about the run-time library in use.
3546
+ * The |least_version| argument can be set to a 24 bit numerical value
3547
+ * for the least accepted version number, and if the condition is not
3548
+ * met, this function will return a ``NULL``. Pass in 0 to skip the
3549
+ * version checking.
3550
+ */
3551
+ NGHTTP3_EXTERN const nghttp3_info *nghttp3_version(int least_version);
3552
+
3553
+ /**
3554
+ * @function
3555
+ *
3556
+ * `nghttp3_err_is_fatal` returns nonzero if |liberr| is a fatal
3557
+ * error. |liberr| must be one of nghttp3 library error codes (which
3558
+ * is defined as NGHTTP3_ERR_* macro, such as
3559
+ * :macro:`NGHTTP3_ERR_NOMEM`).
3560
+ */
3561
+ NGHTTP3_EXTERN int nghttp3_err_is_fatal(int liberr);
3562
+
3563
+ /**
3564
+ * @function
3565
+ *
3566
+ * `nghttp3_get_uvarint` reads variable-length unsigned integer from
3567
+ * the buffer pointed by |p|, and stores it in the object pointed by
3568
+ * |dest| in host byte order. It returns |p| plus the number of bytes
3569
+ * read from |p|. This function assumes that |p| points to the buffer
3570
+ * that contains a valid variable-length unsigned integer. Use
3571
+ * `nghttp3_get_uvarintlen` to get the number of bytes to successfully
3572
+ * decode an integer.
3573
+ *
3574
+ * .. version-added:: 1.17.0
3575
+ */
3576
+ NGHTTP3_EXTERN const uint8_t *nghttp3_get_uvarint(uint64_t *dest,
3577
+ const uint8_t *p);
3578
+
3579
+ /**
3580
+ * @function
3581
+ *
3582
+ * `nghttp3_get_uvarintlen` returns the required number of bytes to
3583
+ * read variable-length unsigned integer starting at |p|. |p| must
3584
+ * not be NULL. This function only reads the single byte from the
3585
+ * buffer pointed by |p|, and determines the number of bytes to read.
3586
+ *
3587
+ * .. version-added:: 1.17.0
3588
+ */
3589
+ NGHTTP3_EXTERN size_t nghttp3_get_uvarintlen(const uint8_t *p);
3590
+
3591
+ /**
3592
+ * @function
3593
+ *
3594
+ * `nghttp3_get_varint` reads variable-length unsigned integer from
3595
+ * the buffer pointed by |p|, and stores it in the object pointed by
3596
+ * |dest| in host byte order. It returns |p| plus the number of bytes
3597
+ * read from |p|. This function assumes that |p| points to the buffer
3598
+ * that contains a valid variable-length unsigned integer. Use
3599
+ * `nghttp3_get_uvarintlen` to get the number of bytes to successfully
3600
+ * decode an integer.
3601
+ *
3602
+ * .. version-added:: 1.17.0
3603
+ */
3604
+ NGHTTP3_EXTERN const uint8_t *nghttp3_get_varint(int64_t *dest,
3605
+ const uint8_t *p);
3606
+
3607
+ /**
3608
+ * @function
3609
+ *
3610
+ * `nghttp3_put_uvarint` writes |n| to the buffer pointed by |p| using
3611
+ * variable-length unsigned integer encoding. It returns the one
3612
+ * beyond of the last written position. This function assumes that
3613
+ * the buffer pointed by |p| has sufficient capacity to encode |n|.
3614
+ * To know the required capacity, use `nghttp3_put_uvarintlen`. |n|
3615
+ * must be less than or equal to (1 << 62) - 1.
3616
+ *
3617
+ * .. version-added:: 1.17.0
3618
+ */
3619
+ NGHTTP3_EXTERN uint8_t *nghttp3_put_uvarint(uint8_t *p, uint64_t n);
3620
+
3621
+ /**
3622
+ * @function
3623
+ *
3624
+ * `nghttp3_put_uvarintlen` returns the required number of bytes to
3625
+ * encode |n| in variable-length unsigned integer encoding. |n| must
3626
+ * be less than or equal to (1 << 62) - 1.
3627
+ *
3628
+ * .. version-added:: 1.17.0
3629
+ */
3630
+ NGHTTP3_EXTERN size_t nghttp3_put_uvarintlen(uint64_t n);
3631
+
3632
+ /*
3633
+ * Versioned function wrappers
3634
+ */
3635
+
3636
+ /*
3637
+ * `nghttp3_settings_default` is a wrapper around
3638
+ * `nghttp3_settings_default_versioned` to set the correct struct
3639
+ * version.
3640
+ */
3641
+ #define nghttp3_settings_default(SETTINGS) \
3642
+ nghttp3_settings_default_versioned(NGHTTP3_SETTINGS_VERSION, (SETTINGS))
3643
+
3644
+ /*
3645
+ * `nghttp3_conn_client_new` is a wrapper around
3646
+ * `nghttp3_conn_client_new_versioned` to set the correct struct
3647
+ * version.
3648
+ */
3649
+ #define nghttp3_conn_client_new(PCONN, CALLBACKS, SETTINGS, MEM, USER_DATA) \
3650
+ nghttp3_conn_client_new_versioned((PCONN), NGHTTP3_CALLBACKS_VERSION, \
3651
+ (CALLBACKS), NGHTTP3_SETTINGS_VERSION, \
3652
+ (SETTINGS), (MEM), (USER_DATA))
3653
+
3654
+ /*
3655
+ * `nghttp3_conn_server_new` is a wrapper around
3656
+ * `nghttp3_conn_server_new_versioned` to set the correct struct
3657
+ * version.
3658
+ */
3659
+ #define nghttp3_conn_server_new(PCONN, CALLBACKS, SETTINGS, MEM, USER_DATA) \
3660
+ nghttp3_conn_server_new_versioned((PCONN), NGHTTP3_CALLBACKS_VERSION, \
3661
+ (CALLBACKS), NGHTTP3_SETTINGS_VERSION, \
3662
+ (SETTINGS), (MEM), (USER_DATA))
3663
+
3664
+ /*
3665
+ * `nghttp3_conn_set_server_stream_priority` is a wrapper around
3666
+ * `nghttp3_conn_set_server_stream_priority_versioned` to set the
3667
+ * correct struct version.
3668
+ */
3669
+ #define nghttp3_conn_set_server_stream_priority(CONN, STREAM_ID, PRI) \
3670
+ nghttp3_conn_set_server_stream_priority_versioned( \
3671
+ (CONN), (STREAM_ID), NGHTTP3_PRI_VERSION, (PRI))
3672
+
3673
+ /*
3674
+ * `nghttp3_conn_get_stream_priority` is a wrapper around
3675
+ * `nghttp3_conn_get_stream_priority_versioned` to set the correct
3676
+ * struct version.
3677
+ */
3678
+ #define nghttp3_conn_get_stream_priority(CONN, DEST, STREAM_ID) \
3679
+ nghttp3_conn_get_stream_priority_versioned((CONN), NGHTTP3_PRI_VERSION, \
3680
+ (DEST), (STREAM_ID))
3681
+
3682
+ /*
3683
+ * `nghttp3_conn_get_stream_priority2` is a wrapper around
3684
+ * `nghttp3_conn_get_stream_priority2_versioned` to set the correct
3685
+ * struct version.
3686
+ */
3687
+ #define nghttp3_conn_get_stream_priority2(CONN, DEST, STREAM_ID) \
3688
+ nghttp3_conn_get_stream_priority2_versioned((CONN), NGHTTP3_PRI_VERSION, \
3689
+ (DEST), (STREAM_ID))
3690
+
3691
+ /*
3692
+ * `nghttp3_pri_parse_priority` is a wrapper around
3693
+ * `nghttp3_pri_parse_priority_versioned` to set the correct struct
3694
+ * version.
3695
+ */
3696
+ #define nghttp3_pri_parse_priority(DEST, VALUE, LEN) \
3697
+ nghttp3_pri_parse_priority_versioned(NGHTTP3_PRI_VERSION, (DEST), (VALUE), \
3698
+ (LEN))
3699
+
3700
+ #ifdef __cplusplus
3701
+ }
3702
+ #endif /* defined(__cplusplus) */
3703
+
3704
+ #endif /* !defined(NGHTTP3_H) */