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