11cb0ef41Sopenharmony_ci/* 21cb0ef41Sopenharmony_ci * nghttp2 - HTTP/2 C Library 31cb0ef41Sopenharmony_ci * 41cb0ef41Sopenharmony_ci * Copyright (c) 2012 Tatsuhiro Tsujikawa 51cb0ef41Sopenharmony_ci * 61cb0ef41Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining 71cb0ef41Sopenharmony_ci * a copy of this software and associated documentation files (the 81cb0ef41Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 91cb0ef41Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 101cb0ef41Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to 111cb0ef41Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 121cb0ef41Sopenharmony_ci * the following conditions: 131cb0ef41Sopenharmony_ci * 141cb0ef41Sopenharmony_ci * The above copyright notice and this permission notice shall be 151cb0ef41Sopenharmony_ci * included in all copies or substantial portions of the Software. 161cb0ef41Sopenharmony_ci * 171cb0ef41Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 181cb0ef41Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 191cb0ef41Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 201cb0ef41Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 211cb0ef41Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 221cb0ef41Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 231cb0ef41Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 241cb0ef41Sopenharmony_ci */ 251cb0ef41Sopenharmony_ci#ifndef NGHTTP2_FRAME_H 261cb0ef41Sopenharmony_ci#define NGHTTP2_FRAME_H 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci#ifdef HAVE_CONFIG_H 291cb0ef41Sopenharmony_ci# include <config.h> 301cb0ef41Sopenharmony_ci#endif /* HAVE_CONFIG_H */ 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci#include <nghttp2/nghttp2.h> 331cb0ef41Sopenharmony_ci#include "nghttp2_hd.h" 341cb0ef41Sopenharmony_ci#include "nghttp2_buf.h" 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci#define NGHTTP2_STREAM_ID_MASK ((1u << 31) - 1) 371cb0ef41Sopenharmony_ci#define NGHTTP2_PRI_GROUP_ID_MASK ((1u << 31) - 1) 381cb0ef41Sopenharmony_ci#define NGHTTP2_PRIORITY_MASK ((1u << 31) - 1) 391cb0ef41Sopenharmony_ci#define NGHTTP2_WINDOW_SIZE_INCREMENT_MASK ((1u << 31) - 1) 401cb0ef41Sopenharmony_ci#define NGHTTP2_SETTINGS_ID_MASK ((1 << 24) - 1) 411cb0ef41Sopenharmony_ci 421cb0ef41Sopenharmony_ci/* The number of bytes of frame header. */ 431cb0ef41Sopenharmony_ci#define NGHTTP2_FRAME_HDLEN 9 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_FRAME_SIZE_MAX ((1 << 24) - 1) 461cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_FRAME_SIZE_MIN (1 << 14) 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_PAYLOADLEN 16384 491cb0ef41Sopenharmony_ci/* The one frame buffer length for transmission. We may use several of 501cb0ef41Sopenharmony_ci them to support CONTINUATION. To account for Pad Length field, we 511cb0ef41Sopenharmony_ci allocate extra 1 byte, which saves extra large memcopying. */ 521cb0ef41Sopenharmony_ci#define NGHTTP2_FRAMEBUF_CHUNKLEN \ 531cb0ef41Sopenharmony_ci (NGHTTP2_FRAME_HDLEN + 1 + NGHTTP2_MAX_PAYLOADLEN) 541cb0ef41Sopenharmony_ci 551cb0ef41Sopenharmony_ci/* The default length of DATA frame payload. */ 561cb0ef41Sopenharmony_ci#define NGHTTP2_DATA_PAYLOADLEN NGHTTP2_MAX_FRAME_SIZE_MIN 571cb0ef41Sopenharmony_ci 581cb0ef41Sopenharmony_ci/* Maximum headers block size to send, calculated using 591cb0ef41Sopenharmony_ci nghttp2_hd_deflate_bound(). This is the default value, and can be 601cb0ef41Sopenharmony_ci overridden by nghttp2_option_set_max_send_header_block_length(). */ 611cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_HEADERSLEN 65536 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci/* The number of bytes for each SETTINGS entry */ 641cb0ef41Sopenharmony_ci#define NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH 6 651cb0ef41Sopenharmony_ci 661cb0ef41Sopenharmony_ci/* Length of priority related fields in HEADERS/PRIORITY frames */ 671cb0ef41Sopenharmony_ci#define NGHTTP2_PRIORITY_SPECLEN 5 681cb0ef41Sopenharmony_ci 691cb0ef41Sopenharmony_ci/* Maximum length of padding in bytes. */ 701cb0ef41Sopenharmony_ci#define NGHTTP2_MAX_PADLEN 256 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci/* Union of extension frame payload */ 731cb0ef41Sopenharmony_citypedef union { 741cb0ef41Sopenharmony_ci nghttp2_ext_altsvc altsvc; 751cb0ef41Sopenharmony_ci nghttp2_ext_origin origin; 761cb0ef41Sopenharmony_ci nghttp2_ext_priority_update priority_update; 771cb0ef41Sopenharmony_ci} nghttp2_ext_frame_payload; 781cb0ef41Sopenharmony_ci 791cb0ef41Sopenharmony_civoid nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd); 801cb0ef41Sopenharmony_ci 811cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_frame_hd(nghttp2_frame_hd *hd, const uint8_t *buf); 821cb0ef41Sopenharmony_ci 831cb0ef41Sopenharmony_ci/** 841cb0ef41Sopenharmony_ci * Initializes frame header |hd| with given parameters. Reserved bit 851cb0ef41Sopenharmony_ci * is set to 0. 861cb0ef41Sopenharmony_ci */ 871cb0ef41Sopenharmony_civoid nghttp2_frame_hd_init(nghttp2_frame_hd *hd, size_t length, uint8_t type, 881cb0ef41Sopenharmony_ci uint8_t flags, int32_t stream_id); 891cb0ef41Sopenharmony_ci 901cb0ef41Sopenharmony_ci/** 911cb0ef41Sopenharmony_ci * Returns the number of priority field depending on the |flags|. If 921cb0ef41Sopenharmony_ci * |flags| has neither NGHTTP2_FLAG_PRIORITY_GROUP nor 931cb0ef41Sopenharmony_ci * NGHTTP2_FLAG_PRIORITY_DEPENDENCY set, return 0. 941cb0ef41Sopenharmony_ci */ 951cb0ef41Sopenharmony_cisize_t nghttp2_frame_priority_len(uint8_t flags); 961cb0ef41Sopenharmony_ci 971cb0ef41Sopenharmony_ci/** 981cb0ef41Sopenharmony_ci * Packs the |pri_spec| in |buf|. This function assumes |buf| has 991cb0ef41Sopenharmony_ci * enough space for serialization. 1001cb0ef41Sopenharmony_ci */ 1011cb0ef41Sopenharmony_civoid nghttp2_frame_pack_priority_spec(uint8_t *buf, 1021cb0ef41Sopenharmony_ci const nghttp2_priority_spec *pri_spec); 1031cb0ef41Sopenharmony_ci 1041cb0ef41Sopenharmony_ci/** 1051cb0ef41Sopenharmony_ci * Unpacks the priority specification from payload |payload| of length 1061cb0ef41Sopenharmony_ci * |payloadlen| to |pri_spec|. The |flags| is used to determine what 1071cb0ef41Sopenharmony_ci * kind of priority specification is in |payload|. This function 1081cb0ef41Sopenharmony_ci * assumes the |payload| contains whole priority specification. 1091cb0ef41Sopenharmony_ci */ 1101cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec, 1111cb0ef41Sopenharmony_ci const uint8_t *payload); 1121cb0ef41Sopenharmony_ci 1131cb0ef41Sopenharmony_ci/* 1141cb0ef41Sopenharmony_ci * Returns the offset from the HEADERS frame payload where the 1151cb0ef41Sopenharmony_ci * compressed header block starts. The frame payload does not include 1161cb0ef41Sopenharmony_ci * frame header. 1171cb0ef41Sopenharmony_ci */ 1181cb0ef41Sopenharmony_cisize_t nghttp2_frame_headers_payload_nv_offset(nghttp2_headers *frame); 1191cb0ef41Sopenharmony_ci 1201cb0ef41Sopenharmony_ci/* 1211cb0ef41Sopenharmony_ci * Packs HEADERS frame |frame| in wire format and store it in |bufs|. 1221cb0ef41Sopenharmony_ci * This function expands |bufs| as necessary to store frame. 1231cb0ef41Sopenharmony_ci * 1241cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 1251cb0ef41Sopenharmony_ci * before calling this function. 1261cb0ef41Sopenharmony_ci * 1271cb0ef41Sopenharmony_ci * frame->hd.length is assigned after length is determined during 1281cb0ef41Sopenharmony_ci * packing process. CONTINUATION frames are also serialized in this 1291cb0ef41Sopenharmony_ci * function. This function does not handle padding. 1301cb0ef41Sopenharmony_ci * 1311cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or returns one of the 1321cb0ef41Sopenharmony_ci * following negative error codes: 1331cb0ef41Sopenharmony_ci * 1341cb0ef41Sopenharmony_ci * NGHTTP2_ERR_HEADER_COMP 1351cb0ef41Sopenharmony_ci * The deflate operation failed. 1361cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 1371cb0ef41Sopenharmony_ci * Out of memory. 1381cb0ef41Sopenharmony_ci */ 1391cb0ef41Sopenharmony_ciint nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame, 1401cb0ef41Sopenharmony_ci nghttp2_hd_deflater *deflater); 1411cb0ef41Sopenharmony_ci 1421cb0ef41Sopenharmony_ci/* 1431cb0ef41Sopenharmony_ci * Unpacks HEADERS frame byte sequence into |frame|. This function 1441cb0ef41Sopenharmony_ci * only unapcks bytes that come before name/value header block and 1451cb0ef41Sopenharmony_ci * after possible Pad Length field. 1461cb0ef41Sopenharmony_ci */ 1471cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, 1481cb0ef41Sopenharmony_ci const uint8_t *payload); 1491cb0ef41Sopenharmony_ci 1501cb0ef41Sopenharmony_ci/* 1511cb0ef41Sopenharmony_ci * Packs PRIORITY frame |frame| in wire format and store it in 1521cb0ef41Sopenharmony_ci * |bufs|. 1531cb0ef41Sopenharmony_ci * 1541cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 1551cb0ef41Sopenharmony_ci * before calling this function. 1561cb0ef41Sopenharmony_ci */ 1571cb0ef41Sopenharmony_civoid nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame); 1581cb0ef41Sopenharmony_ci 1591cb0ef41Sopenharmony_ci/* 1601cb0ef41Sopenharmony_ci * Unpacks PRIORITY wire format into |frame|. 1611cb0ef41Sopenharmony_ci */ 1621cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, 1631cb0ef41Sopenharmony_ci const uint8_t *payload); 1641cb0ef41Sopenharmony_ci 1651cb0ef41Sopenharmony_ci/* 1661cb0ef41Sopenharmony_ci * Packs RST_STREAM frame |frame| in wire frame format and store it in 1671cb0ef41Sopenharmony_ci * |bufs|. 1681cb0ef41Sopenharmony_ci * 1691cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 1701cb0ef41Sopenharmony_ci * before calling this function. 1711cb0ef41Sopenharmony_ci */ 1721cb0ef41Sopenharmony_civoid nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, 1731cb0ef41Sopenharmony_ci nghttp2_rst_stream *frame); 1741cb0ef41Sopenharmony_ci 1751cb0ef41Sopenharmony_ci/* 1761cb0ef41Sopenharmony_ci * Unpacks RST_STREAM frame byte sequence into |frame|. 1771cb0ef41Sopenharmony_ci */ 1781cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame, 1791cb0ef41Sopenharmony_ci const uint8_t *payload); 1801cb0ef41Sopenharmony_ci 1811cb0ef41Sopenharmony_ci/* 1821cb0ef41Sopenharmony_ci * Packs SETTINGS frame |frame| in wire format and store it in 1831cb0ef41Sopenharmony_ci * |bufs|. 1841cb0ef41Sopenharmony_ci * 1851cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 1861cb0ef41Sopenharmony_ci * before calling this function. 1871cb0ef41Sopenharmony_ci * 1881cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or returns one of the 1891cb0ef41Sopenharmony_ci * following negative error codes: 1901cb0ef41Sopenharmony_ci * 1911cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FRAME_SIZE_ERROR 1921cb0ef41Sopenharmony_ci * The length of the frame is too large. 1931cb0ef41Sopenharmony_ci */ 1941cb0ef41Sopenharmony_ciint nghttp2_frame_pack_settings(nghttp2_bufs *bufs, nghttp2_settings *frame); 1951cb0ef41Sopenharmony_ci 1961cb0ef41Sopenharmony_ci/* 1971cb0ef41Sopenharmony_ci * Packs the |iv|, which includes |niv| entries, in the |buf|, 1981cb0ef41Sopenharmony_ci * assuming the |buf| has at least 8 * |niv| bytes. 1991cb0ef41Sopenharmony_ci * 2001cb0ef41Sopenharmony_ci * Returns the number of bytes written into the |buf|. 2011cb0ef41Sopenharmony_ci */ 2021cb0ef41Sopenharmony_cisize_t nghttp2_frame_pack_settings_payload(uint8_t *buf, 2031cb0ef41Sopenharmony_ci const nghttp2_settings_entry *iv, 2041cb0ef41Sopenharmony_ci size_t niv); 2051cb0ef41Sopenharmony_ci 2061cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_settings_entry(nghttp2_settings_entry *iv, 2071cb0ef41Sopenharmony_ci const uint8_t *payload); 2081cb0ef41Sopenharmony_ci 2091cb0ef41Sopenharmony_ci/* 2101cb0ef41Sopenharmony_ci * Initializes payload of frame->settings. The |frame| takes 2111cb0ef41Sopenharmony_ci * ownership of |iv|. 2121cb0ef41Sopenharmony_ci */ 2131cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_settings_payload(nghttp2_settings *frame, 2141cb0ef41Sopenharmony_ci nghttp2_settings_entry *iv, 2151cb0ef41Sopenharmony_ci size_t niv); 2161cb0ef41Sopenharmony_ci 2171cb0ef41Sopenharmony_ci/* 2181cb0ef41Sopenharmony_ci * Unpacks SETTINGS payload into |*iv_ptr|. The number of entries are 2191cb0ef41Sopenharmony_ci * assigned to the |*niv_ptr|. This function allocates enough memory 2201cb0ef41Sopenharmony_ci * to store the result in |*iv_ptr|. The caller is responsible to free 2211cb0ef41Sopenharmony_ci * |*iv_ptr| after its use. 2221cb0ef41Sopenharmony_ci * 2231cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds or one of the following 2241cb0ef41Sopenharmony_ci * negative error codes: 2251cb0ef41Sopenharmony_ci * 2261cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 2271cb0ef41Sopenharmony_ci * Out of memory. 2281cb0ef41Sopenharmony_ci */ 2291cb0ef41Sopenharmony_ciint nghttp2_frame_unpack_settings_payload2(nghttp2_settings_entry **iv_ptr, 2301cb0ef41Sopenharmony_ci size_t *niv_ptr, 2311cb0ef41Sopenharmony_ci const uint8_t *payload, 2321cb0ef41Sopenharmony_ci size_t payloadlen, nghttp2_mem *mem); 2331cb0ef41Sopenharmony_ci 2341cb0ef41Sopenharmony_ci/* 2351cb0ef41Sopenharmony_ci * Packs PUSH_PROMISE frame |frame| in wire format and store it in 2361cb0ef41Sopenharmony_ci * |bufs|. This function expands |bufs| as necessary to store 2371cb0ef41Sopenharmony_ci * frame. 2381cb0ef41Sopenharmony_ci * 2391cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 2401cb0ef41Sopenharmony_ci * before calling this function. 2411cb0ef41Sopenharmony_ci * 2421cb0ef41Sopenharmony_ci * frame->hd.length is assigned after length is determined during 2431cb0ef41Sopenharmony_ci * packing process. CONTINUATION frames are also serialized in this 2441cb0ef41Sopenharmony_ci * function. This function does not handle padding. 2451cb0ef41Sopenharmony_ci * 2461cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or returns one of the 2471cb0ef41Sopenharmony_ci * following negative error codes: 2481cb0ef41Sopenharmony_ci * 2491cb0ef41Sopenharmony_ci * NGHTTP2_ERR_HEADER_COMP 2501cb0ef41Sopenharmony_ci * The deflate operation failed. 2511cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 2521cb0ef41Sopenharmony_ci * Out of memory. 2531cb0ef41Sopenharmony_ci */ 2541cb0ef41Sopenharmony_ciint nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs, 2551cb0ef41Sopenharmony_ci nghttp2_push_promise *frame, 2561cb0ef41Sopenharmony_ci nghttp2_hd_deflater *deflater); 2571cb0ef41Sopenharmony_ci 2581cb0ef41Sopenharmony_ci/* 2591cb0ef41Sopenharmony_ci * Unpacks PUSH_PROMISE frame byte sequence into |frame|. This 2601cb0ef41Sopenharmony_ci * function only unapcks bytes that come before name/value header 2611cb0ef41Sopenharmony_ci * block and after possible Pad Length field. 2621cb0ef41Sopenharmony_ci */ 2631cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, 2641cb0ef41Sopenharmony_ci const uint8_t *payload); 2651cb0ef41Sopenharmony_ci 2661cb0ef41Sopenharmony_ci/* 2671cb0ef41Sopenharmony_ci * Packs PING frame |frame| in wire format and store it in 2681cb0ef41Sopenharmony_ci * |bufs|. 2691cb0ef41Sopenharmony_ci * 2701cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 2711cb0ef41Sopenharmony_ci * before calling this function. 2721cb0ef41Sopenharmony_ci */ 2731cb0ef41Sopenharmony_civoid nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame); 2741cb0ef41Sopenharmony_ci 2751cb0ef41Sopenharmony_ci/* 2761cb0ef41Sopenharmony_ci * Unpacks PING wire format into |frame|. 2771cb0ef41Sopenharmony_ci */ 2781cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame, 2791cb0ef41Sopenharmony_ci const uint8_t *payload); 2801cb0ef41Sopenharmony_ci 2811cb0ef41Sopenharmony_ci/* 2821cb0ef41Sopenharmony_ci * Packs GOAWAY frame |frame| in wire format and store it in |bufs|. 2831cb0ef41Sopenharmony_ci * This function expands |bufs| as necessary to store frame. 2841cb0ef41Sopenharmony_ci * 2851cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 2861cb0ef41Sopenharmony_ci * before calling this function. 2871cb0ef41Sopenharmony_ci * 2881cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds or one of the following 2891cb0ef41Sopenharmony_ci * negative error codes: 2901cb0ef41Sopenharmony_ci * 2911cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 2921cb0ef41Sopenharmony_ci * Out of memory. 2931cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FRAME_SIZE_ERROR 2941cb0ef41Sopenharmony_ci * The length of the frame is too large. 2951cb0ef41Sopenharmony_ci */ 2961cb0ef41Sopenharmony_ciint nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame); 2971cb0ef41Sopenharmony_ci 2981cb0ef41Sopenharmony_ci/* 2991cb0ef41Sopenharmony_ci * Unpacks GOAWAY wire format into |frame|. The |payload| of length 3001cb0ef41Sopenharmony_ci * |payloadlen| contains first 8 bytes of payload. The 3011cb0ef41Sopenharmony_ci * |var_gift_payload| of length |var_gift_payloadlen| contains 3021cb0ef41Sopenharmony_ci * remaining payload and its buffer is gifted to the function and then 3031cb0ef41Sopenharmony_ci * |frame|. The |var_gift_payloadlen| must be freed by 3041cb0ef41Sopenharmony_ci * nghttp2_frame_goaway_free(). 3051cb0ef41Sopenharmony_ci */ 3061cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame, 3071cb0ef41Sopenharmony_ci const uint8_t *payload, 3081cb0ef41Sopenharmony_ci uint8_t *var_gift_payload, 3091cb0ef41Sopenharmony_ci size_t var_gift_payloadlen); 3101cb0ef41Sopenharmony_ci 3111cb0ef41Sopenharmony_ci/* 3121cb0ef41Sopenharmony_ci * Unpacks GOAWAY wire format into |frame|. This function only exists 3131cb0ef41Sopenharmony_ci * for unit test. After allocating buffer for debug data, this 3141cb0ef41Sopenharmony_ci * function internally calls nghttp2_frame_unpack_goaway_payload(). 3151cb0ef41Sopenharmony_ci * 3161cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3171cb0ef41Sopenharmony_ci * negative error codes: 3181cb0ef41Sopenharmony_ci * 3191cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 3201cb0ef41Sopenharmony_ci * Out of memory. 3211cb0ef41Sopenharmony_ci */ 3221cb0ef41Sopenharmony_ciint nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame, 3231cb0ef41Sopenharmony_ci const uint8_t *payload, 3241cb0ef41Sopenharmony_ci size_t payloadlen, nghttp2_mem *mem); 3251cb0ef41Sopenharmony_ci 3261cb0ef41Sopenharmony_ci/* 3271cb0ef41Sopenharmony_ci * Packs WINDOW_UPDATE frame |frame| in wire frame format and store it 3281cb0ef41Sopenharmony_ci * in |bufs|. 3291cb0ef41Sopenharmony_ci * 3301cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 3311cb0ef41Sopenharmony_ci * before calling this function. 3321cb0ef41Sopenharmony_ci */ 3331cb0ef41Sopenharmony_civoid nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, 3341cb0ef41Sopenharmony_ci nghttp2_window_update *frame); 3351cb0ef41Sopenharmony_ci 3361cb0ef41Sopenharmony_ci/* 3371cb0ef41Sopenharmony_ci * Unpacks WINDOW_UPDATE frame byte sequence into |frame|. 3381cb0ef41Sopenharmony_ci */ 3391cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame, 3401cb0ef41Sopenharmony_ci const uint8_t *payload); 3411cb0ef41Sopenharmony_ci 3421cb0ef41Sopenharmony_ci/* 3431cb0ef41Sopenharmony_ci * Packs ALTSVC frame |frame| in wire frame format and store it in 3441cb0ef41Sopenharmony_ci * |bufs|. 3451cb0ef41Sopenharmony_ci * 3461cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 3471cb0ef41Sopenharmony_ci * before calling this function. 3481cb0ef41Sopenharmony_ci */ 3491cb0ef41Sopenharmony_civoid nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *ext); 3501cb0ef41Sopenharmony_ci 3511cb0ef41Sopenharmony_ci/* 3521cb0ef41Sopenharmony_ci * Unpacks ALTSVC wire format into |frame|. The |payload| of 3531cb0ef41Sopenharmony_ci * |payloadlen| bytes contains frame payload. This function assumes 3541cb0ef41Sopenharmony_ci * that frame->payload points to the nghttp2_ext_altsvc object. 3551cb0ef41Sopenharmony_ci */ 3561cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame, 3571cb0ef41Sopenharmony_ci size_t origin_len, uint8_t *payload, 3581cb0ef41Sopenharmony_ci size_t payloadlen); 3591cb0ef41Sopenharmony_ci 3601cb0ef41Sopenharmony_ci/* 3611cb0ef41Sopenharmony_ci * Unpacks ALTSVC wire format into |frame|. This function only exists 3621cb0ef41Sopenharmony_ci * for unit test. After allocating buffer for fields, this function 3631cb0ef41Sopenharmony_ci * internally calls nghttp2_frame_unpack_altsvc_payload(). 3641cb0ef41Sopenharmony_ci * 3651cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3661cb0ef41Sopenharmony_ci * negative error codes: 3671cb0ef41Sopenharmony_ci * 3681cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 3691cb0ef41Sopenharmony_ci * Out of memory. 3701cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FRAME_SIZE_ERROR 3711cb0ef41Sopenharmony_ci * The payload is too small. 3721cb0ef41Sopenharmony_ci */ 3731cb0ef41Sopenharmony_ciint nghttp2_frame_unpack_altsvc_payload2(nghttp2_extension *frame, 3741cb0ef41Sopenharmony_ci const uint8_t *payload, 3751cb0ef41Sopenharmony_ci size_t payloadlen, nghttp2_mem *mem); 3761cb0ef41Sopenharmony_ci 3771cb0ef41Sopenharmony_ci/* 3781cb0ef41Sopenharmony_ci * Packs ORIGIN frame |frame| in wire frame format and store it in 3791cb0ef41Sopenharmony_ci * |bufs|. 3801cb0ef41Sopenharmony_ci * 3811cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 3821cb0ef41Sopenharmony_ci * before calling this function. 3831cb0ef41Sopenharmony_ci * 3841cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3851cb0ef41Sopenharmony_ci * negative error codes: 3861cb0ef41Sopenharmony_ci * 3871cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FRAME_SIZE_ERROR 3881cb0ef41Sopenharmony_ci * The length of the frame is too large. 3891cb0ef41Sopenharmony_ci */ 3901cb0ef41Sopenharmony_ciint nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *ext); 3911cb0ef41Sopenharmony_ci 3921cb0ef41Sopenharmony_ci/* 3931cb0ef41Sopenharmony_ci * Unpacks ORIGIN wire format into |frame|. The |payload| of length 3941cb0ef41Sopenharmony_ci * |payloadlen| contains the frame payload. 3951cb0ef41Sopenharmony_ci * 3961cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds, or one of the following 3971cb0ef41Sopenharmony_ci * negative error codes: 3981cb0ef41Sopenharmony_ci * 3991cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 4001cb0ef41Sopenharmony_ci * Out of memory. 4011cb0ef41Sopenharmony_ci * NGHTTP2_ERR_FRAME_SIZE_ERROR 4021cb0ef41Sopenharmony_ci * The payload is too small. 4031cb0ef41Sopenharmony_ci */ 4041cb0ef41Sopenharmony_ciint nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, 4051cb0ef41Sopenharmony_ci const uint8_t *payload, 4061cb0ef41Sopenharmony_ci size_t payloadlen, nghttp2_mem *mem); 4071cb0ef41Sopenharmony_ci 4081cb0ef41Sopenharmony_ci/* 4091cb0ef41Sopenharmony_ci * Packs PRIORITY_UPDATE frame |frame| in wire frame format and store 4101cb0ef41Sopenharmony_ci * it in |bufs|. 4111cb0ef41Sopenharmony_ci * 4121cb0ef41Sopenharmony_ci * The caller must make sure that nghttp2_bufs_reset(bufs) is called 4131cb0ef41Sopenharmony_ci * before calling this function. 4141cb0ef41Sopenharmony_ci */ 4151cb0ef41Sopenharmony_civoid nghttp2_frame_pack_priority_update(nghttp2_bufs *bufs, 4161cb0ef41Sopenharmony_ci nghttp2_extension *ext); 4171cb0ef41Sopenharmony_ci 4181cb0ef41Sopenharmony_ci/* 4191cb0ef41Sopenharmony_ci * Unpacks PRIORITY_UPDATE wire format into |frame|. The |payload| of 4201cb0ef41Sopenharmony_ci * |payloadlen| bytes contains frame payload. This function assumes 4211cb0ef41Sopenharmony_ci * that frame->payload points to the nghttp2_ext_priority_update 4221cb0ef41Sopenharmony_ci * object. 4231cb0ef41Sopenharmony_ci */ 4241cb0ef41Sopenharmony_civoid nghttp2_frame_unpack_priority_update_payload(nghttp2_extension *frame, 4251cb0ef41Sopenharmony_ci uint8_t *payload, 4261cb0ef41Sopenharmony_ci size_t payloadlen); 4271cb0ef41Sopenharmony_ci 4281cb0ef41Sopenharmony_ci/* 4291cb0ef41Sopenharmony_ci * Initializes HEADERS frame |frame| with given values. |frame| takes 4301cb0ef41Sopenharmony_ci * ownership of |nva|, so caller must not free it. If |stream_id| is 4311cb0ef41Sopenharmony_ci * not assigned yet, it must be -1. 4321cb0ef41Sopenharmony_ci */ 4331cb0ef41Sopenharmony_civoid nghttp2_frame_headers_init(nghttp2_headers *frame, uint8_t flags, 4341cb0ef41Sopenharmony_ci int32_t stream_id, nghttp2_headers_category cat, 4351cb0ef41Sopenharmony_ci const nghttp2_priority_spec *pri_spec, 4361cb0ef41Sopenharmony_ci nghttp2_nv *nva, size_t nvlen); 4371cb0ef41Sopenharmony_ci 4381cb0ef41Sopenharmony_civoid nghttp2_frame_headers_free(nghttp2_headers *frame, nghttp2_mem *mem); 4391cb0ef41Sopenharmony_ci 4401cb0ef41Sopenharmony_civoid nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id, 4411cb0ef41Sopenharmony_ci const nghttp2_priority_spec *pri_spec); 4421cb0ef41Sopenharmony_ci 4431cb0ef41Sopenharmony_civoid nghttp2_frame_priority_free(nghttp2_priority *frame); 4441cb0ef41Sopenharmony_ci 4451cb0ef41Sopenharmony_civoid nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame, int32_t stream_id, 4461cb0ef41Sopenharmony_ci uint32_t error_code); 4471cb0ef41Sopenharmony_ci 4481cb0ef41Sopenharmony_civoid nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame); 4491cb0ef41Sopenharmony_ci 4501cb0ef41Sopenharmony_ci/* 4511cb0ef41Sopenharmony_ci * Initializes PUSH_PROMISE frame |frame| with given values. |frame| 4521cb0ef41Sopenharmony_ci * takes ownership of |nva|, so caller must not free it. 4531cb0ef41Sopenharmony_ci */ 4541cb0ef41Sopenharmony_civoid nghttp2_frame_push_promise_init(nghttp2_push_promise *frame, uint8_t flags, 4551cb0ef41Sopenharmony_ci int32_t stream_id, 4561cb0ef41Sopenharmony_ci int32_t promised_stream_id, 4571cb0ef41Sopenharmony_ci nghttp2_nv *nva, size_t nvlen); 4581cb0ef41Sopenharmony_ci 4591cb0ef41Sopenharmony_civoid nghttp2_frame_push_promise_free(nghttp2_push_promise *frame, 4601cb0ef41Sopenharmony_ci nghttp2_mem *mem); 4611cb0ef41Sopenharmony_ci 4621cb0ef41Sopenharmony_ci/* 4631cb0ef41Sopenharmony_ci * Initializes SETTINGS frame |frame| with given values. |frame| takes 4641cb0ef41Sopenharmony_ci * ownership of |iv|, so caller must not free it. The |flags| are 4651cb0ef41Sopenharmony_ci * bitwise-OR of one or more of nghttp2_settings_flag. 4661cb0ef41Sopenharmony_ci */ 4671cb0ef41Sopenharmony_civoid nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags, 4681cb0ef41Sopenharmony_ci nghttp2_settings_entry *iv, size_t niv); 4691cb0ef41Sopenharmony_ci 4701cb0ef41Sopenharmony_civoid nghttp2_frame_settings_free(nghttp2_settings *frame, nghttp2_mem *mem); 4711cb0ef41Sopenharmony_ci 4721cb0ef41Sopenharmony_ci/* 4731cb0ef41Sopenharmony_ci * Initializes PING frame |frame| with given values. If the 4741cb0ef41Sopenharmony_ci * |opqeue_data| is not NULL, it must point to 8 bytes memory region 4751cb0ef41Sopenharmony_ci * of data. The data pointed by |opaque_data| is copied. It can be 4761cb0ef41Sopenharmony_ci * NULL. In this case, 8 bytes NULL is used. 4771cb0ef41Sopenharmony_ci */ 4781cb0ef41Sopenharmony_civoid nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags, 4791cb0ef41Sopenharmony_ci const uint8_t *opque_data); 4801cb0ef41Sopenharmony_ci 4811cb0ef41Sopenharmony_civoid nghttp2_frame_ping_free(nghttp2_ping *frame); 4821cb0ef41Sopenharmony_ci 4831cb0ef41Sopenharmony_ci/* 4841cb0ef41Sopenharmony_ci * Initializes GOAWAY frame |frame| with given values. On success, 4851cb0ef41Sopenharmony_ci * this function takes ownership of |opaque_data|, so caller must not 4861cb0ef41Sopenharmony_ci * free it. If the |opaque_data_len| is 0, opaque_data could be NULL. 4871cb0ef41Sopenharmony_ci */ 4881cb0ef41Sopenharmony_civoid nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id, 4891cb0ef41Sopenharmony_ci uint32_t error_code, uint8_t *opaque_data, 4901cb0ef41Sopenharmony_ci size_t opaque_data_len); 4911cb0ef41Sopenharmony_ci 4921cb0ef41Sopenharmony_civoid nghttp2_frame_goaway_free(nghttp2_goaway *frame, nghttp2_mem *mem); 4931cb0ef41Sopenharmony_ci 4941cb0ef41Sopenharmony_civoid nghttp2_frame_window_update_init(nghttp2_window_update *frame, 4951cb0ef41Sopenharmony_ci uint8_t flags, int32_t stream_id, 4961cb0ef41Sopenharmony_ci int32_t window_size_increment); 4971cb0ef41Sopenharmony_ci 4981cb0ef41Sopenharmony_civoid nghttp2_frame_window_update_free(nghttp2_window_update *frame); 4991cb0ef41Sopenharmony_ci 5001cb0ef41Sopenharmony_civoid nghttp2_frame_extension_init(nghttp2_extension *frame, uint8_t type, 5011cb0ef41Sopenharmony_ci uint8_t flags, int32_t stream_id, 5021cb0ef41Sopenharmony_ci void *payload); 5031cb0ef41Sopenharmony_ci 5041cb0ef41Sopenharmony_civoid nghttp2_frame_extension_free(nghttp2_extension *frame); 5051cb0ef41Sopenharmony_ci 5061cb0ef41Sopenharmony_ci/* 5071cb0ef41Sopenharmony_ci * Initializes ALTSVC frame |frame| with given values. This function 5081cb0ef41Sopenharmony_ci * assumes that frame->payload points to nghttp2_ext_altsvc object. 5091cb0ef41Sopenharmony_ci * Also |origin| and |field_value| are allocated in single buffer, 5101cb0ef41Sopenharmony_ci * starting |origin|. On success, this function takes ownership of 5111cb0ef41Sopenharmony_ci * |origin|, so caller must not free it. 5121cb0ef41Sopenharmony_ci */ 5131cb0ef41Sopenharmony_civoid nghttp2_frame_altsvc_init(nghttp2_extension *frame, int32_t stream_id, 5141cb0ef41Sopenharmony_ci uint8_t *origin, size_t origin_len, 5151cb0ef41Sopenharmony_ci uint8_t *field_value, size_t field_value_len); 5161cb0ef41Sopenharmony_ci 5171cb0ef41Sopenharmony_ci/* 5181cb0ef41Sopenharmony_ci * Frees up resources under |frame|. This function does not free 5191cb0ef41Sopenharmony_ci * nghttp2_ext_altsvc object pointed by frame->payload. This function 5201cb0ef41Sopenharmony_ci * only frees origin pointed by nghttp2_ext_altsvc.origin. Therefore, 5211cb0ef41Sopenharmony_ci * other fields must be allocated in the same buffer with origin. 5221cb0ef41Sopenharmony_ci */ 5231cb0ef41Sopenharmony_civoid nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem); 5241cb0ef41Sopenharmony_ci 5251cb0ef41Sopenharmony_ci/* 5261cb0ef41Sopenharmony_ci * Initializes ORIGIN frame |frame| with given values. This function 5271cb0ef41Sopenharmony_ci * assumes that frame->payload points to nghttp2_ext_origin object. 5281cb0ef41Sopenharmony_ci * Also |ov| and the memory pointed by the field of its elements are 5291cb0ef41Sopenharmony_ci * allocated in single buffer, starting with |ov|. On success, this 5301cb0ef41Sopenharmony_ci * function takes ownership of |ov|, so caller must not free it. 5311cb0ef41Sopenharmony_ci */ 5321cb0ef41Sopenharmony_civoid nghttp2_frame_origin_init(nghttp2_extension *frame, 5331cb0ef41Sopenharmony_ci nghttp2_origin_entry *ov, size_t nov); 5341cb0ef41Sopenharmony_ci 5351cb0ef41Sopenharmony_ci/* 5361cb0ef41Sopenharmony_ci * Frees up resources under |frame|. This function does not free 5371cb0ef41Sopenharmony_ci * nghttp2_ext_origin object pointed by frame->payload. This function 5381cb0ef41Sopenharmony_ci * only frees nghttp2_ext_origin.ov. Therefore, other fields must be 5391cb0ef41Sopenharmony_ci * allocated in the same buffer with ov. 5401cb0ef41Sopenharmony_ci */ 5411cb0ef41Sopenharmony_civoid nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem); 5421cb0ef41Sopenharmony_ci 5431cb0ef41Sopenharmony_ci/* 5441cb0ef41Sopenharmony_ci * Initializes PRIORITY_UPDATE frame |frame| with given values. This 5451cb0ef41Sopenharmony_ci * function assumes that frame->payload points to 5461cb0ef41Sopenharmony_ci * nghttp2_ext_priority_update object. On success, this function 5471cb0ef41Sopenharmony_ci * takes ownership of |field_value|, so caller must not free it. 5481cb0ef41Sopenharmony_ci */ 5491cb0ef41Sopenharmony_civoid nghttp2_frame_priority_update_init(nghttp2_extension *frame, 5501cb0ef41Sopenharmony_ci int32_t stream_id, uint8_t *field_value, 5511cb0ef41Sopenharmony_ci size_t field_value_len); 5521cb0ef41Sopenharmony_ci 5531cb0ef41Sopenharmony_ci/* 5541cb0ef41Sopenharmony_ci * Frees up resources under |frame|. This function does not free 5551cb0ef41Sopenharmony_ci * nghttp2_ext_priority_update object pointed by frame->payload. This 5561cb0ef41Sopenharmony_ci * function only frees field_value pointed by 5571cb0ef41Sopenharmony_ci * nghttp2_ext_priority_update.field_value. 5581cb0ef41Sopenharmony_ci */ 5591cb0ef41Sopenharmony_civoid nghttp2_frame_priority_update_free(nghttp2_extension *frame, 5601cb0ef41Sopenharmony_ci nghttp2_mem *mem); 5611cb0ef41Sopenharmony_ci 5621cb0ef41Sopenharmony_ci/* 5631cb0ef41Sopenharmony_ci * Returns the number of padding bytes after payload. The total 5641cb0ef41Sopenharmony_ci * padding length is given in the |padlen|. The returned value does 5651cb0ef41Sopenharmony_ci * not include the Pad Length field. If |padlen| is 0, this function 5661cb0ef41Sopenharmony_ci * returns 0, regardless of frame->hd.flags. 5671cb0ef41Sopenharmony_ci */ 5681cb0ef41Sopenharmony_cisize_t nghttp2_frame_trail_padlen(nghttp2_frame *frame, size_t padlen); 5691cb0ef41Sopenharmony_ci 5701cb0ef41Sopenharmony_civoid nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags, 5711cb0ef41Sopenharmony_ci int32_t stream_id); 5721cb0ef41Sopenharmony_ci 5731cb0ef41Sopenharmony_civoid nghttp2_frame_data_free(nghttp2_data *frame); 5741cb0ef41Sopenharmony_ci 5751cb0ef41Sopenharmony_ci/* 5761cb0ef41Sopenharmony_ci * Makes copy of |iv| and return the copy. The |niv| is the number of 5771cb0ef41Sopenharmony_ci * entries in |iv|. This function returns the pointer to the copy if 5781cb0ef41Sopenharmony_ci * it succeeds, or NULL. 5791cb0ef41Sopenharmony_ci */ 5801cb0ef41Sopenharmony_cinghttp2_settings_entry *nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv, 5811cb0ef41Sopenharmony_ci size_t niv, nghttp2_mem *mem); 5821cb0ef41Sopenharmony_ci 5831cb0ef41Sopenharmony_ci/* 5841cb0ef41Sopenharmony_ci * Sorts the |nva| in ascending order of name and value. If names are 5851cb0ef41Sopenharmony_ci * equivalent, sort them by value. 5861cb0ef41Sopenharmony_ci */ 5871cb0ef41Sopenharmony_civoid nghttp2_nv_array_sort(nghttp2_nv *nva, size_t nvlen); 5881cb0ef41Sopenharmony_ci 5891cb0ef41Sopenharmony_ci/* 5901cb0ef41Sopenharmony_ci * Copies name/value pairs from |nva|, which contains |nvlen| pairs, 5911cb0ef41Sopenharmony_ci * to |*nva_ptr|, which is dynamically allocated so that all items can 5921cb0ef41Sopenharmony_ci * be stored. The resultant name and value in nghttp2_nv are 5931cb0ef41Sopenharmony_ci * guaranteed to be NULL-terminated even if the input is not 5941cb0ef41Sopenharmony_ci * null-terminated. 5951cb0ef41Sopenharmony_ci * 5961cb0ef41Sopenharmony_ci * The |*nva_ptr| must be freed using nghttp2_nv_array_del(). 5971cb0ef41Sopenharmony_ci * 5981cb0ef41Sopenharmony_ci * This function returns 0 if it succeeds or one of the following 5991cb0ef41Sopenharmony_ci * negative error codes: 6001cb0ef41Sopenharmony_ci * 6011cb0ef41Sopenharmony_ci * NGHTTP2_ERR_NOMEM 6021cb0ef41Sopenharmony_ci * Out of memory. 6031cb0ef41Sopenharmony_ci */ 6041cb0ef41Sopenharmony_ciint nghttp2_nv_array_copy(nghttp2_nv **nva_ptr, const nghttp2_nv *nva, 6051cb0ef41Sopenharmony_ci size_t nvlen, nghttp2_mem *mem); 6061cb0ef41Sopenharmony_ci 6071cb0ef41Sopenharmony_ci/* 6081cb0ef41Sopenharmony_ci * Returns nonzero if the name/value pair |a| equals to |b|. The name 6091cb0ef41Sopenharmony_ci * is compared in case-sensitive, because we ensure that this function 6101cb0ef41Sopenharmony_ci * is called after the name is lower-cased. 6111cb0ef41Sopenharmony_ci */ 6121cb0ef41Sopenharmony_ciint nghttp2_nv_equal(const nghttp2_nv *a, const nghttp2_nv *b); 6131cb0ef41Sopenharmony_ci 6141cb0ef41Sopenharmony_ci/* 6151cb0ef41Sopenharmony_ci * Frees |nva|. 6161cb0ef41Sopenharmony_ci */ 6171cb0ef41Sopenharmony_civoid nghttp2_nv_array_del(nghttp2_nv *nva, nghttp2_mem *mem); 6181cb0ef41Sopenharmony_ci 6191cb0ef41Sopenharmony_ci/* 6201cb0ef41Sopenharmony_ci * Checks that the |iv|, which includes |niv| entries, does not have 6211cb0ef41Sopenharmony_ci * invalid values. 6221cb0ef41Sopenharmony_ci * 6231cb0ef41Sopenharmony_ci * This function returns nonzero if it succeeds, or 0. 6241cb0ef41Sopenharmony_ci */ 6251cb0ef41Sopenharmony_ciint nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv); 6261cb0ef41Sopenharmony_ci 6271cb0ef41Sopenharmony_ci/* 6281cb0ef41Sopenharmony_ci * Sets Pad Length field and flags and adjusts frame header position 6291cb0ef41Sopenharmony_ci * of each buffers in |bufs|. The number of padding is given in the 6301cb0ef41Sopenharmony_ci * |padlen| including Pad Length field. The |hd| is the frame header 6311cb0ef41Sopenharmony_ci * for the serialized data. This function fills zeros padding region 6321cb0ef41Sopenharmony_ci * unless framehd_only is nonzero. 6331cb0ef41Sopenharmony_ci */ 6341cb0ef41Sopenharmony_civoid nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, 6351cb0ef41Sopenharmony_ci size_t padlen, int framehd_only); 6361cb0ef41Sopenharmony_ci 6371cb0ef41Sopenharmony_ci#endif /* NGHTTP2_FRAME_H */ 638