| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1116,11 +1116,43 @@ typedef struct nghttp3_qpack_encoder nghttp3_qpack_encoder; | |||
| 1116 | 1116 | * | |
| 1117 | 1117 | * :macro:`NGHTTP3_ERR_NOMEM` | |
| 1118 | 1118 | * 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. | ||
| 1119 | 1123 | */ | |
| 1120 | 1124 | NGHTTP3_EXTERN int nghttp3_qpack_encoder_new(nghttp3_qpack_encoder **pencoder, | |
| 1121 | 1125 | size_t hard_max_dtable_capacity, | |
| 1122 | 1126 | const nghttp3_mem *mem); | |
| 1123 | 1127 | ||
| 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 | + | ||
| 1124 | 1156 | /** | |
| 1125 | 1157 | * @function | |
| 1126 | 1158 | * | |
@@ -1605,7 +1637,8 @@ NGHTTP3_EXTERN void nghttp3_set_debug_vprintf_callback( | |||
| 1605 | 1637 | typedef struct nghttp3_conn nghttp3_conn; | |
| 1606 | 1638 | ||
| 1607 | 1639 | #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 | ||
| 1609 | 1642 | ||
| 1610 | 1643 | /** | |
| 1611 | 1644 | * @struct | |
@@ -1652,6 +1685,21 @@ typedef struct nghttp3_settings { | |||
| 1652 | 1685 | * Datagrams (see :rfc:`9297`). | |
| 1653 | 1686 | */ | |
| 1654 | 1687 | 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; | ||
| 1655 | 1703 | } nghttp3_settings; | |
| 1656 | 1704 | ||
| 1657 | 1705 | /** | |
@@ -1891,8 +1939,47 @@ typedef int (*nghttp3_recv_settings)(nghttp3_conn *conn, | |||
| 1891 | 1939 | const nghttp3_settings *settings, | |
| 1892 | 1940 | void *conn_user_data); | |
| 1893 | 1941 | ||
| 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 | + | ||
| 1894 | 1980 | #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 | ||
| 1896 | 1983 | ||
| 1897 | 1984 | /** | |
| 1898 | 1985 | * @struct | |
@@ -1986,6 +2073,28 @@ typedef struct nghttp3_callbacks { | |||
| 1986 | 2073 | * when SETTINGS frame is received. | |
| 1987 | 2074 | */ | |
| 1988 | 2075 | 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; | ||
| 1989 | 2098 | } nghttp3_callbacks; | |
| 1990 | 2099 | ||
| 1991 | 2100 | /** | |
@@ -2106,7 +2215,7 @@ NGHTTP3_EXTERN int nghttp3_conn_bind_qpack_streams(nghttp3_conn *conn, | |||
| 2106 | 2215 | * control credit (both stream and connection) of underlying QUIC | |
| 2107 | 2216 | * connection by that amount. It does not include the amount of data | |
| 2108 | 2217 | * 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 | ||
| 2110 | 2219 | * :type:`nghttp3_recv_data` to handle those bytes. If |fin| is | |
| 2111 | 2220 | * nonzero, this is the last data from remote endpoint in this stream. | |
| 2112 | 2221 | * | |
@@ -2480,8 +2589,6 @@ typedef struct nghttp3_data_reader { | |||
| 2480 | 2589 | * This function returns 0 if it succeeds, or one of the following | |
| 2481 | 2590 | * negative error codes: | |
| 2482 | 2591 | * | |
| 2483 | - * :macro:`NGHTTP3_ERR_INVALID_ARGUMENT` | ||
| 2484 | - * |stream_id| identifies unidirectional stream. | ||
| 2485 | 2592 | * :macro:`NGHTTP3_ERR_CONN_CLOSING` | |
| 2486 | 2593 | * Connection is shutting down, and no new stream is allowed. | |
| 2487 | 2594 | * :macro:`NGHTTP3_ERR_STREAM_IN_USE` | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | * | |
| 32 | 32 | * Version number of the nghttp3 library release. | |
| 33 | 33 | */ | |
| 34 | - #define NGHTTP3_VERSION "1.6.0" | ||
| 34 | + #define NGHTTP3_VERSION "1.11.0" | ||
| 35 | 35 | ||
| 36 | 36 | /** | |
| 37 | 37 | * @macro | |
@@ -41,6 +41,6 @@ | |||
| 41 | 41 | * number, 8 bits for minor and 8 bits for patch. Version 1.2.3 | |
| 42 | 42 | * becomes 0x010203. | |
| 43 | 43 | */ | |
| 44 | - #define NGHTTP3_VERSION_NUM 0x010600 | ||
| 44 | + #define NGHTTP3_VERSION_NUM 0x010b00 | ||
| 45 | 45 | ||
| 46 | 46 | #endif /* !defined(NGHTTP3_VERSION_H) */ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,6 +50,10 @@ size_t nghttp3_buf_cap(const nghttp3_buf *buf) { | |||
| 50 | 50 | return (size_t)(buf->end - buf->begin); | |
| 51 | 51 | } | |
| 52 | 52 | ||
| 53 | + size_t nghttp3_buf_offset(const nghttp3_buf *buf) { | ||
| 54 | + return (size_t)(buf->pos - buf->begin); | ||
| 55 | + } | ||
| 56 | + | ||
| 53 | 57 | void nghttp3_buf_reset(nghttp3_buf *buf) { buf->pos = buf->last = buf->begin; } | |
| 54 | 58 | ||
| 55 | 59 | 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, | |||
| 87 | 91 | nghttp3_buf_type type) { | |
| 88 | 92 | tbuf->buf = *buf; | |
| 89 | 93 | 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; | ||
| 90 | 102 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,6 +42,12 @@ void nghttp3_buf_wrap_init(nghttp3_buf *buf, uint8_t *src, size_t len); | |||
| 42 | 42 | */ | |
| 43 | 43 | size_t nghttp3_buf_cap(const nghttp3_buf *buf); | |
| 44 | 44 | ||
| 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 | + | ||
| 45 | 51 | int nghttp3_buf_reserve(nghttp3_buf *buf, size_t size, const nghttp3_mem *mem); | |
| 46 | 52 | ||
| 47 | 53 | /* | |
@@ -57,8 +63,12 @@ typedef enum nghttp3_buf_type { | |||
| 57 | 63 | memory. */ | |
| 58 | 64 | NGHTTP3_BUF_TYPE_SHARED, | |
| 59 | 65 | /* 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. */ | ||
| 61 | 68 | 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, | ||
| 62 | 72 | } nghttp3_buf_type; | |
| 63 | 73 | ||
| 64 | 74 | typedef struct nghttp3_typed_buf { | |
@@ -69,6 +79,13 @@ typedef struct nghttp3_typed_buf { | |||
| 69 | 79 | void nghttp3_typed_buf_init(nghttp3_typed_buf *tbuf, const nghttp3_buf *buf, | |
| 70 | 80 | nghttp3_buf_type type); | |
| 71 | 81 | ||
| 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 | + | ||
| 72 | 89 | void nghttp3_typed_buf_free(nghttp3_typed_buf *tbuf); | |
| 73 | 90 | ||
| 74 | 91 | #endif /* !defined(NGHTTP3_BUF_H) */ | |
| Original file line number | Diff line number | Diff 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 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments