Skip to content

Commit 2afc1ab

Browse files
committed
quic: fixup constant exports, export all protocol error codes
PR-URL: #34137 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: David Carlier <devnexen@gmail.com>
1 parent b1fab88 commit 2afc1ab

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/quic/node_quic.cc

+18-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ void Initialize(Local<Object> target,
189189
V(NGTCP2_APP_NOERROR) \
190190
V(NGTCP2_PATH_VALIDATION_RESULT_FAILURE) \
191191
V(NGTCP2_PATH_VALIDATION_RESULT_SUCCESS) \
192-
V(NGTCP2_DEFAULT_MAX_PKTLEN) \
193192
V(NGTCP2_CC_ALGO_CUBIC) \
194193
V(NGTCP2_CC_ALGO_RENO) \
195194
V(QUIC_ERROR_APPLICATION) \
@@ -232,11 +231,29 @@ void Initialize(Local<Object> target,
232231
QUIC_CONSTANTS(V)
233232
#undef V
234233

234+
NODE_DEFINE_CONSTANT(constants, NGTCP2_DEFAULT_MAX_PKTLEN);
235235
NODE_DEFINE_CONSTANT(constants, NGTCP2_PROTO_VER);
236236
NODE_DEFINE_CONSTANT(constants, NGTCP2_DEFAULT_MAX_ACK_DELAY);
237237
NODE_DEFINE_CONSTANT(constants, NGTCP2_MAX_CIDLEN);
238238
NODE_DEFINE_CONSTANT(constants, NGTCP2_MIN_CIDLEN);
239+
239240
NODE_DEFINE_CONSTANT(constants, NGTCP2_NO_ERROR);
241+
NODE_DEFINE_CONSTANT(constants, NGTCP2_INTERNAL_ERROR);
242+
NODE_DEFINE_CONSTANT(constants, NGTCP2_CONNECTION_REFUSED);
243+
NODE_DEFINE_CONSTANT(constants, NGTCP2_FLOW_CONTROL_ERROR);
244+
NODE_DEFINE_CONSTANT(constants, NGTCP2_STREAM_LIMIT_ERROR);
245+
NODE_DEFINE_CONSTANT(constants, NGTCP2_STREAM_STATE_ERROR);
246+
NODE_DEFINE_CONSTANT(constants, NGTCP2_FINAL_SIZE_ERROR);
247+
NODE_DEFINE_CONSTANT(constants, NGTCP2_FRAME_ENCODING_ERROR);
248+
NODE_DEFINE_CONSTANT(constants, NGTCP2_TRANSPORT_PARAMETER_ERROR);
249+
NODE_DEFINE_CONSTANT(constants, NGTCP2_CONNECTION_ID_LIMIT_ERROR);
250+
NODE_DEFINE_CONSTANT(constants, NGTCP2_PROTOCOL_VIOLATION);
251+
NODE_DEFINE_CONSTANT(constants, NGTCP2_INVALID_TOKEN);
252+
NODE_DEFINE_CONSTANT(constants, NGTCP2_APPLICATION_ERROR);
253+
NODE_DEFINE_CONSTANT(constants, NGTCP2_CRYPTO_BUFFER_EXCEEDED);
254+
NODE_DEFINE_CONSTANT(constants, NGTCP2_KEY_UPDATE_ERROR);
255+
NODE_DEFINE_CONSTANT(constants, NGTCP2_CRYPTO_ERROR);
256+
240257
NODE_DEFINE_CONSTANT(constants, AF_INET);
241258
NODE_DEFINE_CONSTANT(constants, AF_INET6);
242259
NODE_DEFINE_STRING_CONSTANT(constants,

test/parallel/test-quic-binding.js

+17
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,23 @@ assert(quic.constants);
2020
assert.strictEqual(quic.constants.NGTCP2_PROTO_VER.toString(16), 'ff00001d');
2121
assert.strictEqual(quic.constants.NGHTTP3_ALPN_H3, '\u0005h3-29');
2222

23+
assert.strictEqual(quic.constants.NGTCP2_NO_ERROR, 0);
24+
assert.strictEqual(quic.constants.NGTCP2_INTERNAL_ERROR, 1);
25+
assert.strictEqual(quic.constants.NGTCP2_CONNECTION_REFUSED, 2);
26+
assert.strictEqual(quic.constants.NGTCP2_FLOW_CONTROL_ERROR, 3);
27+
assert.strictEqual(quic.constants.NGTCP2_STREAM_LIMIT_ERROR, 4);
28+
assert.strictEqual(quic.constants.NGTCP2_STREAM_STATE_ERROR, 5);
29+
assert.strictEqual(quic.constants.NGTCP2_FINAL_SIZE_ERROR, 6);
30+
assert.strictEqual(quic.constants.NGTCP2_FRAME_ENCODING_ERROR, 7);
31+
assert.strictEqual(quic.constants.NGTCP2_TRANSPORT_PARAMETER_ERROR, 8);
32+
assert.strictEqual(quic.constants.NGTCP2_CONNECTION_ID_LIMIT_ERROR, 9);
33+
assert.strictEqual(quic.constants.NGTCP2_PROTOCOL_VIOLATION, 0xa);
34+
assert.strictEqual(quic.constants.NGTCP2_INVALID_TOKEN, 0xb);
35+
assert.strictEqual(quic.constants.NGTCP2_APPLICATION_ERROR, 0xc);
36+
assert.strictEqual(quic.constants.NGTCP2_CRYPTO_BUFFER_EXCEEDED, 0xd);
37+
assert.strictEqual(quic.constants.NGTCP2_KEY_UPDATE_ERROR, 0xe);
38+
assert.strictEqual(quic.constants.NGTCP2_CRYPTO_ERROR, 0x100);
39+
2340
// The following just tests for the presence of things we absolutely need.
2441
// They don't test the functionality of those things.
2542

0 commit comments

Comments
 (0)