quic 0.0.3 → 0.0.4

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.
data/ext/quic/endpoint.h CHANGED
@@ -10,19 +10,22 @@ extern VALUE rb_cQUICEndpoint;
10
10
  object. Neither touches Ruby objects, so the callbacks need no
11
11
  rb_protect. dissociate leaves an entry that maps to another connection
12
12
  alone. */
13
- void quic_endpoint_associate_cid(quic_endpoint_t *ep, const ngtcp2_cid *cid, VALUE conn);
14
- void quic_endpoint_dissociate_cid(quic_endpoint_t *ep, const ngtcp2_cid *cid, VALUE conn);
13
+ void quic_endpoint_associate_cid(quic_endpoint_t *ep, const ngtcp2_cid *cid,
14
+ VALUE conn);
15
+ void quic_endpoint_dissociate_cid(quic_endpoint_t *ep, const ngtcp2_cid *cid,
16
+ VALUE conn);
15
17
 
16
18
  /* The Stateless Reset token for cid, derived from the Endpoint's secret so
17
19
  that it can be made again for a CID no longer in the table. token is
18
20
  NGTCP2_STATELESS_RESET_TOKENLEN bytes. Returns 0, or -1 on failure. */
19
- int quic_endpoint_generate_reset_token(const quic_endpoint_t *ep, uint8_t *token,
20
- const ngtcp2_cid *cid);
21
+ int quic_endpoint_generate_reset_token(const quic_endpoint_t *ep,
22
+ uint8_t *token, const ngtcp2_cid *cid);
21
23
 
22
24
  /* Connection#close of a connection the Endpoint holds: build the
23
25
  CONNECTION_CLOSE carrying ccerr, queue it for Endpoint#write_pkt and
24
26
  start the closing period. When ngtcp2 cannot build the packet, the
25
27
  connection leaves the table at once. */
26
- void quic_endpoint_close_conn(quic_endpoint_t *ep, quic_conn_t *c, const ngtcp2_ccerr *ccerr);
28
+ void quic_endpoint_close_conn(quic_endpoint_t *ep, quic_conn_t *c,
29
+ const ngtcp2_ccerr *ccerr);
27
30
 
28
31
  #endif /* QUIC_ENDPOINT_H */
data/ext/quic/ext_api.c CHANGED
@@ -4,16 +4,12 @@
4
4
  behind the opaque type. None of these functions raises a Ruby exception
5
5
  except quic_ext_conn_get; they return 0 or a QUIC_EXT_ERR_* code. */
6
6
 
7
- static quic_conn_t *
8
- quic_ext_conn_struct(quic_ext_conn *ec)
9
- {
7
+ static quic_conn_t *quic_ext_conn_struct(quic_ext_conn *ec) {
10
8
  return (quic_conn_t *)ec;
11
9
  }
12
10
 
13
11
  /* Raises TypeError unless conn is a QUIC::Connection::Client or Server. */
14
- static quic_ext_conn *
15
- quic_ext_conn_get(VALUE conn)
16
- {
12
+ static quic_ext_conn *quic_ext_conn_get(VALUE conn) {
17
13
  return (quic_ext_conn *)rb_check_typeddata(conn, &quic_conn_data_type);
18
14
  }
19
15
 
@@ -22,15 +18,17 @@ quic_ext_conn_get(VALUE conn)
22
18
  Every member of the ABI 1.0 handler is called, so h must be at least that
23
19
  large. @stream_handler marks the connection for the Ruby side, which then
24
20
  refuses #accept_stream. */
25
- static int
26
- quic_ext_set_stream_handler(quic_ext_conn *ec, const quic_ext_stream_handler *h,
27
- void *ud, VALUE owner)
28
- {
21
+ static int quic_ext_set_stream_handler(quic_ext_conn *ec,
22
+ const quic_ext_stream_handler *h,
23
+ void *ud, VALUE owner) {
29
24
  quic_conn_t *c = quic_ext_conn_struct(ec);
30
- if (h == NULL || h->size < sizeof(quic_ext_stream_handler)) return QUIC_EXT_ERR_OTHER;
31
- if (c->handler != NULL) return QUIC_EXT_ERR_INVALID_STATE;
25
+ if (h == NULL || h->size < sizeof(quic_ext_stream_handler))
26
+ return QUIC_EXT_ERR_OTHER;
27
+ if (c->handler != NULL)
28
+ return QUIC_EXT_ERR_INVALID_STATE;
32
29
  VALUE streams = rb_ivar_get(c->owner, rb_intern("@streams"));
33
- if (RB_TYPE_P(streams, T_HASH) && RHASH_SIZE(streams) > 0) return QUIC_EXT_ERR_INVALID_STATE;
30
+ if (RB_TYPE_P(streams, T_HASH) && RHASH_SIZE(streams) > 0)
31
+ return QUIC_EXT_ERR_INVALID_STATE;
34
32
 
35
33
  c->handler = h;
36
34
  c->handler_ud = ud;
@@ -39,58 +37,54 @@ quic_ext_set_stream_handler(quic_ext_conn *ec, const quic_ext_stream_handler *h,
39
37
  return 0;
40
38
  }
41
39
 
42
- static int
43
- quic_ext_open_uni_stream(quic_ext_conn *ec, int64_t *id)
44
- {
40
+ static int quic_ext_open_uni_stream(quic_ext_conn *ec, int64_t *id) {
45
41
  quic_conn_t *c = quic_ext_conn_struct(ec);
46
42
  int rv = ngtcp2_conn_open_uni_stream(c->conn, id, NULL);
47
- if (rv == NGTCP2_ERR_STREAM_ID_BLOCKED) return QUIC_EXT_ERR_STREAM_ID_BLOCKED;
43
+ if (rv == NGTCP2_ERR_STREAM_ID_BLOCKED)
44
+ return QUIC_EXT_ERR_STREAM_ID_BLOCKED;
48
45
  return rv == 0 ? 0 : QUIC_EXT_ERR_OTHER;
49
46
  }
50
47
 
51
48
  /* Give the peer n more bytes of credit on the stream and the connection,
52
49
  for data the handler has now consumed (for HTTP/3, request body handed
53
50
  to the application). */
54
- static int
55
- quic_ext_consume(quic_ext_conn *ec, int64_t id, uint64_t n)
56
- {
51
+ static int quic_ext_consume(quic_ext_conn *ec, int64_t id, uint64_t n) {
57
52
  quic_conn_t *c = quic_ext_conn_struct(ec);
58
- if (ngtcp2_conn_extend_max_stream_offset(c->conn, id, n) != 0) return QUIC_EXT_ERR_OTHER;
53
+ if (ngtcp2_conn_extend_max_stream_offset(c->conn, id, n) != 0)
54
+ return QUIC_EXT_ERR_OTHER;
59
55
  ngtcp2_conn_extend_max_offset(c->conn, n);
60
56
  return 0;
61
57
  }
62
58
 
63
59
  /* Both return 0 for a stream ngtcp2 no longer knows. */
64
- static int
65
- quic_ext_shutdown_stream_read(quic_ext_conn *ec, int64_t id, uint64_t app_error_code)
66
- {
60
+ static int quic_ext_shutdown_stream_read(quic_ext_conn *ec, int64_t id,
61
+ uint64_t app_error_code) {
67
62
  quic_conn_t *c = quic_ext_conn_struct(ec);
68
63
  return ngtcp2_conn_shutdown_stream_read(c->conn, 0, id, app_error_code) == 0
69
- ? 0 : QUIC_EXT_ERR_OTHER;
64
+ ? 0
65
+ : QUIC_EXT_ERR_OTHER;
70
66
  }
71
67
 
72
- static int
73
- quic_ext_shutdown_stream_write(quic_ext_conn *ec, int64_t id, uint64_t app_error_code)
74
- {
68
+ static int quic_ext_shutdown_stream_write(quic_ext_conn *ec, int64_t id,
69
+ uint64_t app_error_code) {
75
70
  quic_conn_t *c = quic_ext_conn_struct(ec);
76
71
  return ngtcp2_conn_shutdown_stream_write(c->conn, 0, id, app_error_code) == 0
77
- ? 0 : QUIC_EXT_ERR_OTHER;
72
+ ? 0
73
+ : QUIC_EXT_ERR_OTHER;
78
74
  }
79
75
 
80
76
  /* This endpoint's initial_max_streams_bidi. nghttp3 needs it at setup;
81
77
  later raises arrive through the extend_max_remote_streams_bidi handler. */
82
- static uint64_t
83
- quic_ext_local_max_streams_bidi(quic_ext_conn *ec)
84
- {
78
+ static uint64_t quic_ext_local_max_streams_bidi(quic_ext_conn *ec) {
85
79
  quic_conn_t *c = quic_ext_conn_struct(ec);
86
- return ngtcp2_conn_get_local_transport_params2(c->conn)->initial_max_streams_bidi;
80
+ return ngtcp2_conn_get_local_transport_params2(c->conn)
81
+ ->initial_max_streams_bidi;
87
82
  }
88
83
 
89
84
  /* Remember the application error to close the connection with after the
90
85
  handler reports a failure (for HTTP/3, the H3_* code nghttp3 gave). */
91
- static int
92
- quic_ext_set_application_error(quic_ext_conn *ec, uint64_t app_error_code)
93
- {
86
+ static int quic_ext_set_application_error(quic_ext_conn *ec,
87
+ uint64_t app_error_code) {
94
88
  quic_conn_t *c = quic_ext_conn_struct(ec);
95
89
  ngtcp2_ccerr_set_application_error(&c->close_error, app_error_code, NULL, 0);
96
90
  c->close_error_set = true;
@@ -98,15 +92,15 @@ quic_ext_set_application_error(quic_ext_conn *ec, uint64_t app_error_code)
98
92
  }
99
93
 
100
94
  const quic_ext_api quic_ext_api_table = {
101
- .abi_major = QUIC_EXT_ABI_MAJOR,
102
- .abi_minor = 0,
103
- .size = sizeof(quic_ext_api),
104
- .conn_get = quic_ext_conn_get,
105
- .set_stream_handler = quic_ext_set_stream_handler,
106
- .open_uni_stream = quic_ext_open_uni_stream,
107
- .consume = quic_ext_consume,
108
- .shutdown_stream_read = quic_ext_shutdown_stream_read,
109
- .shutdown_stream_write = quic_ext_shutdown_stream_write,
110
- .local_max_streams_bidi = quic_ext_local_max_streams_bidi,
111
- .set_application_error = quic_ext_set_application_error,
95
+ .abi_major = QUIC_EXT_ABI_MAJOR,
96
+ .abi_minor = 0,
97
+ .size = sizeof(quic_ext_api),
98
+ .conn_get = quic_ext_conn_get,
99
+ .set_stream_handler = quic_ext_set_stream_handler,
100
+ .open_uni_stream = quic_ext_open_uni_stream,
101
+ .consume = quic_ext_consume,
102
+ .shutdown_stream_read = quic_ext_shutdown_stream_read,
103
+ .shutdown_stream_write = quic_ext_shutdown_stream_write,
104
+ .local_max_streams_bidi = quic_ext_local_max_streams_bidi,
105
+ .set_application_error = quic_ext_set_application_error,
112
106
  };
@@ -4,8 +4,8 @@
4
4
  * connection and drives it through this table instead of QUIC::Stream.
5
5
  * Obtain the table after rb_require("quic") with
6
6
  *
7
- * quic_ext_get_api_fn get =
8
- * (quic_ext_get_api_fn)rb_ext_resolve_symbol("quic/quic", "quic_ext_get_api");
7
+ * quic_ext_get_api_fn get = (quic_ext_get_api_fn)rb_ext_resolve_symbol(
8
+ * "quic/quic", "quic_ext_get_api");
9
9
  * const quic_ext_api *api = get ? get(QUIC_EXT_ABI_MAJOR) : NULL;
10
10
  *
11
11
  * Rules:
@@ -32,26 +32,29 @@
32
32
  #ifndef QUIC_EXT_H
33
33
  #define QUIC_EXT_H 1
34
34
 
35
+ #include <ruby.h>
35
36
  #include <stddef.h>
36
37
  #include <stdint.h>
37
- #include <ruby.h>
38
38
 
39
39
  #define QUIC_EXT_ABI_MAJOR 1
40
40
 
41
- #define QUIC_EXT_ERR_INVALID_STATE (-1)
41
+ #define QUIC_EXT_ERR_INVALID_STATE (-1)
42
42
  #define QUIC_EXT_ERR_STREAM_ID_BLOCKED (-2)
43
- #define QUIC_EXT_ERR_STREAM_NOT_FOUND (-3)
44
- #define QUIC_EXT_ERR_OTHER (-99)
43
+ #define QUIC_EXT_ERR_STREAM_NOT_FOUND (-3)
44
+ #define QUIC_EXT_ERR_OTHER (-99)
45
45
 
46
- typedef struct { const uint8_t *base; size_t len; } quic_ext_vec; /* same layout as ngtcp2_vec */
47
- typedef struct quic_ext_conn quic_ext_conn; /* opaque */
46
+ typedef struct {
47
+ const uint8_t *base;
48
+ size_t len;
49
+ } quic_ext_vec; /* same layout as ngtcp2_vec */
50
+ typedef struct quic_ext_conn quic_ext_conn; /* opaque */
48
51
 
49
52
  typedef struct {
50
- size_t size; /* sizeof(quic_ext_stream_handler); tells which members exist */
53
+ size_t size; /* sizeof(quic_ext_stream_handler); tells which members exist */
51
54
  int (*recv_stream_data)(void *ud, int64_t id, const uint8_t *data, size_t len,
52
55
  int fin, uint64_t ts, size_t *consumed);
53
- int (*next_stream_data)(void *ud, int64_t *id, int *fin,
54
- quic_ext_vec *vecs, size_t cap, size_t *nvecs);
56
+ int (*next_stream_data)(void *ud, int64_t *id, int *fin, quic_ext_vec *vecs,
57
+ size_t cap, size_t *nvecs);
55
58
  int (*stream_data_written)(void *ud, int64_t id, size_t n);
56
59
  int (*stream_blocked)(void *ud, int64_t id);
57
60
  int (*stream_shut_write)(void *ud, int64_t id);
@@ -59,22 +62,26 @@ typedef struct {
59
62
  int (*extend_max_stream_data)(void *ud, int64_t id);
60
63
  int (*extend_max_remote_streams_bidi)(void *ud, uint64_t max);
61
64
  int (*stream_stop_sending)(void *ud, int64_t id, uint64_t app_error_code);
62
- int (*stream_reset)(void *ud, int64_t id, uint64_t final_size, uint64_t app_error_code);
63
- int (*stream_close)(void *ud, int64_t id, int has_code, uint64_t app_error_code);
65
+ int (*stream_reset)(void *ud, int64_t id, uint64_t final_size,
66
+ uint64_t app_error_code);
67
+ int (*stream_close)(void *ud, int64_t id, int has_code,
68
+ uint64_t app_error_code);
64
69
  int (*handshake_completed)(void *ud);
65
70
  } quic_ext_stream_handler;
66
71
 
67
72
  typedef struct {
68
- uint32_t abi_major; /* bumped only to break compatibility */
69
- uint32_t abi_minor; /* bumped whenever a member is appended */
70
- size_t size; /* sizeof(quic_ext_api) */
71
- quic_ext_conn *(*conn_get)(VALUE conn); /* TypeError for a wrong object */
73
+ uint32_t abi_major; /* bumped only to break compatibility */
74
+ uint32_t abi_minor; /* bumped whenever a member is appended */
75
+ size_t size; /* sizeof(quic_ext_api) */
76
+ quic_ext_conn *(*conn_get)(VALUE conn); /* TypeError for a wrong object */
72
77
  int (*set_stream_handler)(quic_ext_conn *c, const quic_ext_stream_handler *h,
73
78
  void *ud, VALUE owner);
74
79
  int (*open_uni_stream)(quic_ext_conn *c, int64_t *id);
75
80
  int (*consume)(quic_ext_conn *c, int64_t id, uint64_t n);
76
- int (*shutdown_stream_read)(quic_ext_conn *c, int64_t id, uint64_t app_error_code);
77
- int (*shutdown_stream_write)(quic_ext_conn *c, int64_t id, uint64_t app_error_code);
81
+ int (*shutdown_stream_read)(quic_ext_conn *c, int64_t id,
82
+ uint64_t app_error_code);
83
+ int (*shutdown_stream_write)(quic_ext_conn *c, int64_t id,
84
+ uint64_t app_error_code);
78
85
  uint64_t (*local_max_streams_bidi)(quic_ext_conn *c);
79
86
  int (*set_application_error)(quic_ext_conn *c, uint64_t app_error_code);
80
87
  } quic_ext_api;
data/ext/quic/quic.c CHANGED
@@ -1,6 +1,6 @@
1
1
  #include "quic.h"
2
- #include "stream.h"
3
2
  #include "connection_common.h"
3
+ #include "stream.h"
4
4
 
5
5
  VALUE rb_mQUIC;
6
6
  VALUE rb_mQUICConnection;
@@ -28,15 +28,11 @@ VALUE rb_eQUICErrorInvalidState;
28
28
  look it up with rb_ext_resolve_symbol("quic/quic", "quic_ext_get_api")
29
29
  and get the C function table declared in quic/ext.h. NULL means the
30
30
  caller was built against an incompatible major version. */
31
- RUBY_FUNC_EXPORTED const quic_ext_api *
32
- quic_ext_get_api(uint32_t abi_major)
33
- {
31
+ RUBY_FUNC_EXPORTED const quic_ext_api *quic_ext_get_api(uint32_t abi_major) {
34
32
  return abi_major == QUIC_EXT_ABI_MAJOR ? &quic_ext_api_table : NULL;
35
33
  }
36
34
 
37
- static VALUE
38
- quic_library_versions(VALUE self)
39
- {
35
+ static VALUE quic_library_versions(VALUE self) {
40
36
  (void)self;
41
37
  VALUE h = rb_hash_new();
42
38
  rb_hash_aset(h, ID2SYM(rb_intern("ngtcp2")),
@@ -51,41 +47,40 @@ quic_library_versions(VALUE self)
51
47
  }
52
48
 
53
49
  VALUE
54
- quic_ngtcp2_error_new(int rv)
55
- {
50
+ quic_ngtcp2_error_new(int rv) {
56
51
  VALUE cls;
57
52
  switch (rv) {
58
- case NGTCP2_ERR_PROTO:
59
- cls = rb_eQUICErrorProto;
60
- break;
61
- case NGTCP2_ERR_DROP_CONN:
62
- cls = rb_eQUICErrorDropConn;
63
- break;
64
- case NGTCP2_ERR_RETRY:
65
- cls = rb_eQUICErrorRetry;
66
- break;
67
- case NGTCP2_ERR_CLOSING:
68
- case NGTCP2_ERR_DRAINING:
69
- cls = rb_eQUICErrorClosed;
70
- break;
71
- case NGTCP2_ERR_IDLE_CLOSE:
72
- cls = rb_eQUICErrorClosed;
73
- break;
74
- case NGTCP2_ERR_CRYPTO:
75
- cls = rb_eQUICErrorCryptoError;
76
- break;
77
- case NGTCP2_ERR_HANDSHAKE_TIMEOUT:
78
- cls = rb_eQUICErrorHandshakeTimeout;
79
- break;
80
- case NGTCP2_ERR_STREAM_DATA_BLOCKED:
81
- cls = rb_eQUICErrorFlowControl;
82
- break;
83
- case NGTCP2_ERR_STREAM_SHUT_WR:
84
- cls = rb_eQUICErrorStreamClosed;
85
- break;
86
- default:
87
- cls = rb_eQUICErrorUnknown;
88
- break;
53
+ case NGTCP2_ERR_PROTO:
54
+ cls = rb_eQUICErrorProto;
55
+ break;
56
+ case NGTCP2_ERR_DROP_CONN:
57
+ cls = rb_eQUICErrorDropConn;
58
+ break;
59
+ case NGTCP2_ERR_RETRY:
60
+ cls = rb_eQUICErrorRetry;
61
+ break;
62
+ case NGTCP2_ERR_CLOSING:
63
+ case NGTCP2_ERR_DRAINING:
64
+ cls = rb_eQUICErrorClosed;
65
+ break;
66
+ case NGTCP2_ERR_IDLE_CLOSE:
67
+ cls = rb_eQUICErrorClosed;
68
+ break;
69
+ case NGTCP2_ERR_CRYPTO:
70
+ cls = rb_eQUICErrorCryptoError;
71
+ break;
72
+ case NGTCP2_ERR_HANDSHAKE_TIMEOUT:
73
+ cls = rb_eQUICErrorHandshakeTimeout;
74
+ break;
75
+ case NGTCP2_ERR_STREAM_DATA_BLOCKED:
76
+ cls = rb_eQUICErrorFlowControl;
77
+ break;
78
+ case NGTCP2_ERR_STREAM_SHUT_WR:
79
+ cls = rb_eQUICErrorStreamClosed;
80
+ break;
81
+ default:
82
+ cls = rb_eQUICErrorUnknown;
83
+ break;
89
84
  }
90
85
 
91
86
  VALUE exc = rb_exc_new_cstr(cls, ngtcp2_strerror(rv));
@@ -93,55 +88,68 @@ quic_ngtcp2_error_new(int rv)
93
88
  return exc;
94
89
  }
95
90
 
96
- void
97
- quic_raise_ngtcp2_error(int rv)
98
- {
91
+ void quic_raise_ngtcp2_error(int rv) {
99
92
  rb_exc_raise(quic_ngtcp2_error_new(rv));
100
93
  }
101
94
 
102
- RUBY_FUNC_EXPORTED void
103
- Init_quic(void)
104
- {
95
+ RUBY_FUNC_EXPORTED void Init_quic(void) {
105
96
  rb_mQUIC = rb_define_module("QUIC");
106
97
  rb_mQUICConnection = rb_define_module_under(rb_mQUIC, "Connection");
107
- rb_define_singleton_method(rb_mQUIC, "library_versions", quic_library_versions, 0);
98
+ rb_define_singleton_method(rb_mQUIC, "library_versions",
99
+ quic_library_versions, 0);
108
100
 
109
101
  /* QUIC::Error is defined in Ruby (lib/quic.rb) before this Init_quic runs,
110
102
  so rb_const_get retrieves the already-defined base class. Subclasses live
111
103
  under QUIC::Error::<Name>. */
112
104
  rb_eQUICError = rb_const_get(rb_mQUIC, rb_intern("Error"));
113
- rb_eQUICErrorProto = rb_define_class_under(rb_eQUICError, "Proto", rb_eQUICError);
114
- rb_eQUICErrorDropConn = rb_define_class_under(rb_eQUICError, "DropConn", rb_eQUICError);
115
- rb_eQUICErrorRetry = rb_define_class_under(rb_eQUICError, "Retry", rb_eQUICError);
116
- rb_eQUICErrorClosed = rb_define_class_under(rb_eQUICError, "Closed", rb_eQUICError);
117
- rb_eQUICErrorCryptoError = rb_define_class_under(rb_eQUICError, "CryptoError", rb_eQUICError);
105
+ rb_eQUICErrorProto =
106
+ rb_define_class_under(rb_eQUICError, "Proto", rb_eQUICError);
107
+ rb_eQUICErrorDropConn =
108
+ rb_define_class_under(rb_eQUICError, "DropConn", rb_eQUICError);
109
+ rb_eQUICErrorRetry =
110
+ rb_define_class_under(rb_eQUICError, "Retry", rb_eQUICError);
111
+ rb_eQUICErrorClosed =
112
+ rb_define_class_under(rb_eQUICError, "Closed", rb_eQUICError);
113
+ rb_eQUICErrorCryptoError =
114
+ rb_define_class_under(rb_eQUICError, "CryptoError", rb_eQUICError);
118
115
  /* The TLS alert this endpoint sent, when read_pkt fails in the handshake.
119
116
  Alerts received from the peer are not recorded by ngtcp2. */
120
117
  rb_define_attr(rb_eQUICErrorCryptoError, "tls_alert", 1, 0);
121
- rb_eQUICErrorCertificateVerifyFailed =
122
- rb_define_class_under(rb_eQUICError, "CertificateVerifyFailed", rb_eQUICErrorCryptoError);
123
- /* X509_V_ERR_* from the chain / name check, or nil when no certificate came. */
118
+ rb_eQUICErrorCertificateVerifyFailed = rb_define_class_under(
119
+ rb_eQUICError, "CertificateVerifyFailed", rb_eQUICErrorCryptoError);
120
+ /* X509_V_ERR_* from the chain / name check, or nil when no certificate came.
121
+ */
124
122
  rb_define_attr(rb_eQUICErrorCertificateVerifyFailed, "verify_result", 1, 0);
125
- rb_eQUICErrorHandshakeTimeout = rb_define_class_under(rb_eQUICError, "HandshakeTimeout", rb_eQUICError);
126
- rb_eQUICErrorFlowControl = rb_define_class_under(rb_eQUICError, "FlowControl", rb_eQUICError);
127
- rb_eQUICErrorUnknown = rb_define_class_under(rb_eQUICError, "Unknown", rb_eQUICError);
123
+ rb_eQUICErrorHandshakeTimeout =
124
+ rb_define_class_under(rb_eQUICError, "HandshakeTimeout", rb_eQUICError);
125
+ rb_eQUICErrorFlowControl =
126
+ rb_define_class_under(rb_eQUICError, "FlowControl", rb_eQUICError);
127
+ rb_eQUICErrorUnknown =
128
+ rb_define_class_under(rb_eQUICError, "Unknown", rb_eQUICError);
128
129
 
129
- /* IO-style non-blocking errors. Mix in the standard IO::Wait{Readable,Writable}
130
- modules so callers can `rescue IO::WaitReadable` (or the QUIC subclass)
131
- interchangeably with stdlib IO objects. */
130
+ /* IO-style non-blocking errors. Mix in the standard
131
+ IO::Wait{Readable,Writable} modules so callers can `rescue
132
+ IO::WaitReadable` (or the QUIC subclass) interchangeably with stdlib IO
133
+ objects. */
132
134
  VALUE io_wait_readable = rb_const_get(rb_cIO, rb_intern("WaitReadable"));
133
135
  VALUE io_wait_writable = rb_const_get(rb_cIO, rb_intern("WaitWritable"));
134
- rb_eQUICErrorWaitReadable = rb_define_class_under(rb_eQUICError, "WaitReadable", rb_eQUICError);
136
+ rb_eQUICErrorWaitReadable =
137
+ rb_define_class_under(rb_eQUICError, "WaitReadable", rb_eQUICError);
135
138
  rb_include_module(rb_eQUICErrorWaitReadable, io_wait_readable);
136
- rb_eQUICErrorWaitWritable = rb_define_class_under(rb_eQUICError, "WaitWritable", rb_eQUICError);
139
+ rb_eQUICErrorWaitWritable =
140
+ rb_define_class_under(rb_eQUICError, "WaitWritable", rb_eQUICError);
137
141
  rb_include_module(rb_eQUICErrorWaitWritable, io_wait_writable);
138
142
 
139
- rb_eQUICErrorStreamClosed = rb_define_class_under(rb_eQUICError, "StreamClosed", rb_eQUICError);
140
- rb_eQUICErrorStreamReset = rb_define_class_under(rb_eQUICError, "StreamReset", rb_eQUICError);
141
- rb_eQUICErrorNotBound = rb_define_class_under(rb_eQUICError, "NotBound", rb_eQUICError);
143
+ rb_eQUICErrorStreamClosed =
144
+ rb_define_class_under(rb_eQUICError, "StreamClosed", rb_eQUICError);
145
+ rb_eQUICErrorStreamReset =
146
+ rb_define_class_under(rb_eQUICError, "StreamReset", rb_eQUICError);
147
+ rb_eQUICErrorNotBound =
148
+ rb_define_class_under(rb_eQUICError, "NotBound", rb_eQUICError);
142
149
  /* Raised by the QUIC::Stream methods of a connection whose streams a C
143
150
  stream handler (quic/ext.h) owns. */
144
- rb_eQUICErrorInvalidState = rb_define_class_under(rb_eQUICError, "InvalidState", rb_eQUICError);
151
+ rb_eQUICErrorInvalidState =
152
+ rb_define_class_under(rb_eQUICError, "InvalidState", rb_eQUICError);
145
153
 
146
154
  Init_quic_tls_context(rb_mQUIC);
147
155
  Init_quic_connection_client(rb_mQUICConnection);
data/ext/quic/quic.h CHANGED
@@ -6,16 +6,18 @@
6
6
 
7
7
  #include <ngtcp2/ngtcp2.h>
8
8
  #include <ngtcp2/ngtcp2_crypto.h>
9
- #include <picotls.h>
10
- #include <picotls/openssl.h>
11
9
  #include <ngtcp2/ngtcp2_crypto_picotls.h>
12
10
  #include <openssl/crypto.h>
11
+ #include <picotls.h>
12
+ #include <picotls/openssl.h>
13
13
 
14
14
  /* picotls disables ptls_openssl_x25519 unless it is built with the patch in
15
15
  ext/quic/patches/picotls/. extconf.rb checks the same condition at configure
16
16
  time; this catches a prebuilt ports/ tree whose patch was swapped out. */
17
17
  #if !PTLS_OPENSSL_HAVE_X25519
18
+ /* clang-format off */
18
19
  #error "picotls was built without X25519; is ext/quic/patches/picotls/*.patch applied?"
20
+ /* clang-format on */
19
21
  #endif
20
22
 
21
23
  extern VALUE rb_mQUIC;