Skip to content

Commit ebfc28a

Browse files
committed
deps: update nghttp3 to 1.11.0
Signed-off-by: James M Snell <[email protected]> PR-URL: #59249 Reviewed-By: Matteo Collina <[email protected]>
1 parent dceb1fc commit ebfc28a

36 files changed

+1642
-2293
lines changed

deps/ngtcp2/nghttp3/lib/includes/nghttp3/nghttp3.h

Lines changed: 112 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,11 +1116,43 @@ typedef struct nghttp3_qpack_encoder nghttp3_qpack_encoder;
11161116
*
11171117
* :macro:`NGHTTP3_ERR_NOMEM`
11181118
* Out of memory.
1119+
*
1120+
* See also `nghttp3_qpack_encoder_new2`. This function calls
1121+
* `nghttp3_qpack_encoder_new2` with the given parameters and 0 as
1122+
* seed.
11191123
*/
11201124
NGHTTP3_EXTERN int nghttp3_qpack_encoder_new(nghttp3_qpack_encoder **pencoder,
11211125
size_t hard_max_dtable_capacity,
11221126
const nghttp3_mem *mem);
11231127

1128+
/**
1129+
* @function
1130+
*
1131+
* `nghttp3_qpack_encoder_new2` initializes QPACK encoder. |pencoder|
1132+
* must be non-NULL pointer. |hard_max_dtable_capacity| is the upper
1133+
* bound of the dynamic table capacity. |seed| must be unpredictable
1134+
* value, and is used to seed the internal data structure. |mem| is a
1135+
* memory allocator. This function allocates memory for
1136+
* :type:`nghttp3_qpack_encoder` itself, and assigns its pointer to
1137+
* |*pencoder| if it succeeds.
1138+
*
1139+
* The maximum dynamic table capacity is still 0. In order to change
1140+
* the maximum dynamic table capacity, call
1141+
* `nghttp3_qpack_encoder_set_max_dtable_capacity`.
1142+
*
1143+
* This function returns 0 if it succeeds, or one of the following
1144+
* negative error codes:
1145+
*
1146+
* :macro:`NGHTTP3_ERR_NOMEM`
1147+
* Out of memory.
1148+
*
1149+
* This function is available since v1.11.0.
1150+
*/
1151+
NGHTTP3_EXTERN int nghttp3_qpack_encoder_new2(nghttp3_qpack_encoder **pencoder,
1152+
size_t hard_max_dtable_capacity,
1153+
uint64_t seed,
1154+
const nghttp3_mem *mem);
1155+
11241156
/**
11251157
* @function
11261158
*
@@ -1605,7 +1637,8 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback(
16051637
typedef struct nghttp3_conn nghttp3_conn;
16061638

16071639
#define NGHTTP3_SETTINGS_V1 1
1608-
#define NGHTTP3_SETTINGS_VERSION NGHTTP3_SETTINGS_V1
1640+
#define NGHTTP3_SETTINGS_V2 2
1641+
#define NGHTTP3_SETTINGS_VERSION NGHTTP3_SETTINGS_V2
16091642

16101643
/**
16111644
* @struct
@@ -1652,6 +1685,21 @@ typedef struct nghttp3_settings {
16521685
* Datagrams (see :rfc:`9297`).
16531686
*/
16541687
uint8_t h3_datagram;
1688+
/* The following fields have been added since NGHTTP3_SETTINGS_V2. */
1689+
/**
1690+
* :member:`origin_list`, if set, must contain a serialized HTTP/3
1691+
* ORIGIN frame (see :rfc:`9412`) payload. The ORIGIN frame payload
1692+
* is a sequence of zero or more of a length prefixed byte string.
1693+
* The length is encoded in 2 bytes in network byte order. If
1694+
* :member:`origin_list->len <nghttp3_vec.len>` is zero, an empty
1695+
* ORIGIN frame is sent. An application must keep the buffer
1696+
* pointed by :member:`origin_list->base <nghttp3_vec.base>` alive
1697+
* until the :type:`nghttp3_conn` to which this field was passed is
1698+
* freed by `nghttp3_conn_del`. The object pointed to by this field
1699+
* is copied internally, and does not need to be kept alive. Only
1700+
* server uses this field. This field is available since v1.11.0.
1701+
*/
1702+
const nghttp3_vec *origin_list;
16551703
} nghttp3_settings;
16561704

16571705
/**
@@ -1891,8 +1939,47 @@ typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn,
18911939
const nghttp3_settings *settings,
18921940
void *conn_user_data);
18931941

1942+
/**
1943+
* @functypedef
1944+
*
1945+
* :type:`nghttp3_recv_origin` is a callback function which is invoked
1946+
* when a single origin in ORIGIN frame is received. |origin| is a
1947+
* received origin of length |originlen|. |originlen| never be 0.
1948+
*
1949+
* The implementation of this callback must return 0 if it succeeds.
1950+
* Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1951+
* caller immediately. Any values other than 0 is treated as
1952+
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1953+
*/
1954+
typedef int (*nghttp3_recv_origin)(nghttp3_conn *conn, const uint8_t *origin,
1955+
size_t originlen, void *conn_user_data);
1956+
1957+
/**
1958+
* @functypedef
1959+
*
1960+
* :type:`nghttp3_end_origin` is a callback function which is invoked
1961+
* when an ORIGIN frame has been completely processed.
1962+
*
1963+
* The implementation of this callback must return 0 if it succeeds.
1964+
* Returning :macro:`NGHTTP3_ERR_CALLBACK_FAILURE` will return to the
1965+
* caller immediately. Any values other than 0 is treated as
1966+
* :macro:`NGHTTP3_ERR_CALLBACK_FAILURE`.
1967+
*/
1968+
typedef int (*nghttp3_end_origin)(nghttp3_conn *conn, void *conn_user_data);
1969+
1970+
/**
1971+
* @functypedef
1972+
*
1973+
* :type:`nghttp3_rand` is a callback function which is invoked when
1974+
* unpredictable data of |destlen| bytes are needed. The
1975+
* implementation must write unpredictable data of |destlen| bytes
1976+
* into the buffer pointed by |dest|.
1977+
*/
1978+
typedef void (*nghttp3_rand)(uint8_t *dest, size_t destlen);
1979+
18941980
#define NGHTTP3_CALLBACKS_V1 1
1895-
#define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V1
1981+
#define NGHTTP3_CALLBACKS_V2 2
1982+
#define NGHTTP3_CALLBACKS_VERSION NGHTTP3_CALLBACKS_V2
18961983

18971984
/**
18981985
* @struct
@@ -1986,6 +2073,28 @@ typedef struct nghttp3_callbacks {
19862073
* when SETTINGS frame is received.
19872074
*/
19882075
nghttp3_recv_settings recv_settings;
2076+
/* The following fields have been added since NGHTTP3_CALLBACKS_V2. */
2077+
/**
2078+
* :member:`recv_origin` is a callback function which is invoked
2079+
* when a single origin in an ORIGIN frame is received. This field
2080+
* is available since v1.11.0.
2081+
*/
2082+
nghttp3_recv_origin recv_origin;
2083+
/**
2084+
* :member:`end_origin` is a callback function which is invoked when
2085+
* an ORIGIN frame has been completely processed. This field is
2086+
* available since v1.11.0.
2087+
*/
2088+
nghttp3_end_origin end_origin;
2089+
/**
2090+
* :member:`rand` is a callback function which is invoked when
2091+
* unpredictable data are needed. Although this field is optional
2092+
* due to the backward compatibility, it is recommended to specify
2093+
* this field to harden the runtime behavior against suspicious
2094+
* activities of a remote endpoint. This field is available since
2095+
* v1.11.0.
2096+
*/
2097+
nghttp3_rand rand;
19892098
} nghttp3_callbacks;
19902099

19912100
/**
@@ -2106,7 +2215,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn,
21062215
* control credit (both stream and connection) of underlying QUIC
21072216
* connection by that amount. It does not include the amount of data
21082217
* carried by DATA frame which contains application data (excluding
2109-
* any control or QPACK unidirectional streams) . See
2218+
* any control or QPACK unidirectional streams). See
21102219
* :type:`nghttp3_recv_data` to handle those bytes. If |fin| is
21112220
* nonzero, this is the last data from remote endpoint in this stream.
21122221
*
@@ -2480,8 +2589,6 @@ typedef struct nghttp3_data_reader {
24802589
* This function returns 0 if it succeeds, or one of the following
24812590
* negative error codes:
24822591
*
2483-
* :macro:`NGHTTP3_ERR_INVALID_ARGUMENT`
2484-
* |stream_id| identifies unidirectional stream.
24852592
* :macro:`NGHTTP3_ERR_CONN_CLOSING`
24862593
* Connection is shutting down, and no new stream is allowed.
24872594
* :macro:`NGHTTP3_ERR_STREAM_IN_USE`

deps/ngtcp2/nghttp3/lib/includes/nghttp3/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
* Version number of the nghttp3 library release.
3333
*/
34-
#define NGHTTP3_VERSION "1.6.0"
34+
#define NGHTTP3_VERSION "1.11.0"
3535

3636
/**
3737
* @macro
@@ -41,6 +41,6 @@
4141
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
4242
* becomes 0x010203.
4343
*/
44-
#define NGHTTP3_VERSION_NUM 0x010600
44+
#define NGHTTP3_VERSION_NUM 0x010b00
4545

4646
#endif /* !defined(NGHTTP3_VERSION_H) */

deps/ngtcp2/nghttp3/lib/nghttp3_buf.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ size_t nghttp3_buf_cap(const nghttp3_buf *buf) {
5050
return (size_t)(buf->end - buf->begin);
5151
}
5252

53+
size_t nghttp3_buf_offset(const nghttp3_buf *buf) {
54+
return (size_t)(buf->pos - buf->begin);
55+
}
56+
5357
void nghttp3_buf_reset(nghttp3_buf *buf) { buf->pos = buf->last = buf->begin; }
5458

5559
int nghttp3_buf_reserve(nghttp3_buf *buf, size_t size, const nghttp3_mem *mem) {
@@ -87,4 +91,12 @@ void nghttp3_typed_buf_init(nghttp3_typed_buf *tbuf, const nghttp3_buf *buf,
8791
nghttp3_buf_type type) {
8892
tbuf->buf = *buf;
8993
tbuf->type = type;
94+
tbuf->buf.begin = tbuf->buf.pos;
95+
}
96+
97+
void nghttp3_typed_buf_shared_init(nghttp3_typed_buf *tbuf,
98+
const nghttp3_buf *chunk) {
99+
tbuf->buf = *chunk;
100+
tbuf->type = NGHTTP3_BUF_TYPE_SHARED;
101+
tbuf->buf.begin = tbuf->buf.pos = tbuf->buf.last;
90102
}

deps/ngtcp2/nghttp3/lib/nghttp3_buf.h

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ void nghttp3_buf_wrap_init(nghttp3_buf *buf, uint8_t *src, size_t len);
4242
*/
4343
size_t nghttp3_buf_cap(const nghttp3_buf *buf);
4444

45+
/*
46+
* nghttp3_buf_offset returns the distance from tbuf->begin to
47+
* tbuf->pos. In other words, it returns buf->pos - buf->begin.
48+
*/
49+
size_t nghttp3_buf_offset(const nghttp3_buf *buf);
50+
4551
int nghttp3_buf_reserve(nghttp3_buf *buf, size_t size, const nghttp3_mem *mem);
4652

4753
/*
@@ -57,8 +63,12 @@ typedef enum nghttp3_buf_type {
5763
memory. */
5864
NGHTTP3_BUF_TYPE_SHARED,
5965
/* NGHTTP3_BUF_TYPE_ALIEN indicates that the buffer points to a
60-
memory which comes from outside of the library. */
66+
memory which comes from outside of the library. When
67+
acknowledged, acked_data callback is called. */
6168
NGHTTP3_BUF_TYPE_ALIEN,
69+
/* NGHTTP3_BUF_TYPE_ALIEN_NO_ACK is like NGHTTP3_BUF_TYPE_ALIEN, but
70+
acked_data callback is not called. */
71+
NGHTTP3_BUF_TYPE_ALIEN_NO_ACK,
6272
} nghttp3_buf_type;
6373

6474
typedef struct nghttp3_typed_buf {
@@ -69,6 +79,13 @@ typedef struct nghttp3_typed_buf {
6979
void nghttp3_typed_buf_init(nghttp3_typed_buf *tbuf, const nghttp3_buf *buf,
7080
nghttp3_buf_type type);
7181

82+
/*
83+
* nghttp3_typed_buf_shared_init initializes |tbuf| of type
84+
* NGHTTP3_BUF_TYPE_SHARED.
85+
*/
86+
void nghttp3_typed_buf_shared_init(nghttp3_typed_buf *tbuf,
87+
const nghttp3_buf *chunk);
88+
7289
void nghttp3_typed_buf_free(nghttp3_typed_buf *tbuf);
7390

7491
#endif /* !defined(NGHTTP3_BUF_H) */
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* nghttp3
3+
*
4+
* Copyright (c) 2025 nghttp3 contributors
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining
7+
* a copy of this software and associated documentation files (the
8+
* "Software"), to deal in the Software without restriction, including
9+
* without limitation the rights to use, copy, modify, merge, publish,
10+
* distribute, sublicense, and/or sell copies of the Software, and to
11+
* permit persons to whom the Software is furnished to do so, subject to
12+
* the following conditions:
13+
*
14+
* The above copyright notice and this permission notice shall be
15+
* included in all copies or substantial portions of the Software.
16+
*
17+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24+
*/
25+
#include "nghttp3_callbacks.h"
26+
27+
#include <string.h>
28+
#include <assert.h>
29+
30+
#include "nghttp3_unreachable.h"
31+
32+
static void callbacks_copy(nghttp3_callbacks *dest,
33+
const nghttp3_callbacks *src,
34+
int callbacks_version) {
35+
assert(callbacks_version != NGHTTP3_CALLBACKS_VERSION);
36+
37+
memcpy(dest, src, nghttp3_callbackslen_version(callbacks_version));
38+
}
39+
40+
const nghttp3_callbacks *
41+
nghttp3_callbacks_convert_to_latest(nghttp3_callbacks *dest,
42+
int callbacks_version,
43+
const nghttp3_callbacks *src) {
44+
if (callbacks_version == NGHTTP3_CALLBACKS_VERSION) {
45+
return src;
46+
}
47+
48+
memset(dest, 0, sizeof(*dest));
49+
50+
callbacks_copy(dest, src, callbacks_version);
51+
52+
return dest;
53+
}
54+
55+
void nghttp3_callbacks_convert_to_old(int callbacks_version,
56+
nghttp3_callbacks *dest,
57+
const nghttp3_callbacks *src) {
58+
assert(callbacks_version != NGHTTP3_CALLBACKS_VERSION);
59+
60+
callbacks_copy(dest, src, callbacks_version);
61+
}
62+
63+
size_t nghttp3_callbackslen_version(int callbacks_version) {
64+
nghttp3_callbacks callbacks;
65+
66+
switch (callbacks_version) {
67+
case NGHTTP3_CALLBACKS_VERSION:
68+
return sizeof(callbacks);
69+
case NGHTTP3_CALLBACKS_V1:
70+
return offsetof(nghttp3_callbacks, recv_settings) +
71+
sizeof(callbacks.recv_settings);
72+
default:
73+
nghttp3_unreachable();
74+
}
75+
}

0 commit comments

Comments
 (0)