1 /* 2 * nghttp2 - HTTP/2 C Library 3 * 4 * Copyright (c) 2012 Tatsuhiro Tsujikawa 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 #ifndef NGHTTP2_FRAME_H 26 #define NGHTTP2_FRAME_H 27 28 #ifdef HAVE_CONFIG_H 29 # include <config.h> 30 #endif /* HAVE_CONFIG_H */ 31 32 #include <nghttp2/nghttp2.h> 33 #include "nghttp2_hd.h" 34 #include "nghttp2_buf.h" 35 36 #define NGHTTP2_STREAM_ID_MASK ((1u << 31) - 1) 37 #define NGHTTP2_PRI_GROUP_ID_MASK ((1u << 31) - 1) 38 #define NGHTTP2_PRIORITY_MASK ((1u << 31) - 1) 39 #define NGHTTP2_WINDOW_SIZE_INCREMENT_MASK ((1u << 31) - 1) 40 #define NGHTTP2_SETTINGS_ID_MASK ((1 << 24) - 1) 41 42 /* The number of bytes of frame header. */ 43 #define NGHTTP2_FRAME_HDLEN 9 44 45 #define NGHTTP2_MAX_FRAME_SIZE_MAX ((1 << 24) - 1) 46 #define NGHTTP2_MAX_FRAME_SIZE_MIN (1 << 14) 47 48 #define NGHTTP2_MAX_PAYLOADLEN 16384 49 /* The one frame buffer length for tranmission. We may use several of 50 them to support CONTINUATION. To account for Pad Length field, we 51 allocate extra 1 byte, which saves extra large memcopying. */ 52 #define NGHTTP2_FRAMEBUF_CHUNKLEN \ 53 (NGHTTP2_FRAME_HDLEN + 1 + NGHTTP2_MAX_PAYLOADLEN) 54 55 /* The default length of DATA frame payload. */ 56 #define NGHTTP2_DATA_PAYLOADLEN NGHTTP2_MAX_FRAME_SIZE_MIN 57 58 /* Maximum headers block size to send, calculated using 59 nghttp2_hd_deflate_bound(). This is the default value, and can be 60 overridden by nghttp2_option_set_max_send_header_block_size(). */ 61 #define NGHTTP2_MAX_HEADERSLEN 65536 62 63 /* The number of bytes for each SETTINGS entry */ 64 #define NGHTTP2_FRAME_SETTINGS_ENTRY_LENGTH 6 65 66 /* Length of priority related fields in HEADERS/PRIORITY frames */ 67 #define NGHTTP2_PRIORITY_SPECLEN 5 68 69 /* Maximum length of padding in bytes. */ 70 #define NGHTTP2_MAX_PADLEN 256 71 72 /* Union of extension frame payload */ 73 typedef union { 74 nghttp2_ext_altsvc altsvc; 75 nghttp2_ext_origin origin; 76 } nghttp2_ext_frame_payload; 77 78 void nghttp2_frame_pack_frame_hd(uint8_t *buf, const nghttp2_frame_hd *hd); 79 80 void nghttp2_frame_unpack_frame_hd(nghttp2_frame_hd *hd, const uint8_t *buf); 81 82 /** 83 * Initializes frame header |hd| with given parameters. Reserved bit 84 * is set to 0. 85 */ 86 void nghttp2_frame_hd_init(nghttp2_frame_hd *hd, size_t length, uint8_t type, 87 uint8_t flags, int32_t stream_id); 88 89 /** 90 * Returns the number of priority field depending on the |flags|. If 91 * |flags| has neither NGHTTP2_FLAG_PRIORITY_GROUP nor 92 * NGHTTP2_FLAG_PRIORITY_DEPENDENCY set, return 0. 93 */ 94 size_t nghttp2_frame_priority_len(uint8_t flags); 95 96 /** 97 * Packs the |pri_spec| in |buf|. This function assumes |buf| has 98 * enough space for serialization. 99 */ 100 void nghttp2_frame_pack_priority_spec(uint8_t *buf, 101 const nghttp2_priority_spec *pri_spec); 102 103 /** 104 * Unpacks the priority specification from payload |payload| of length 105 * |payloadlen| to |pri_spec|. The |flags| is used to determine what 106 * kind of priority specification is in |payload|. This function 107 * assumes the |payload| contains whole priority specification. 108 */ 109 void nghttp2_frame_unpack_priority_spec(nghttp2_priority_spec *pri_spec, 110 const uint8_t *payload); 111 112 /* 113 * Returns the offset from the HEADERS frame payload where the 114 * compressed header block starts. The frame payload does not include 115 * frame header. 116 */ 117 size_t nghttp2_frame_headers_payload_nv_offset(nghttp2_headers *frame); 118 119 /* 120 * Packs HEADERS frame |frame| in wire format and store it in |bufs|. 121 * This function expands |bufs| as necessary to store frame. 122 * 123 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 124 * before calling this function. 125 * 126 * frame->hd.length is assigned after length is determined during 127 * packing process. CONTINUATION frames are also serialized in this 128 * function. This function does not handle padding. 129 * 130 * This function returns 0 if it succeeds, or returns one of the 131 * following negative error codes: 132 * 133 * NGHTTP2_ERR_HEADER_COMP 134 * The deflate operation failed. 135 * NGHTTP2_ERR_NOMEM 136 * Out of memory. 137 */ 138 int nghttp2_frame_pack_headers(nghttp2_bufs *bufs, nghttp2_headers *frame, 139 nghttp2_hd_deflater *deflater); 140 141 /* 142 * Unpacks HEADERS frame byte sequence into |frame|. This function 143 * only unapcks bytes that come before name/value header block and 144 * after possible Pad Length field. 145 * 146 * This function always succeeds and returns 0. 147 */ 148 int nghttp2_frame_unpack_headers_payload(nghttp2_headers *frame, 149 const uint8_t *payload); 150 151 /* 152 * Packs PRIORITY frame |frame| in wire format and store it in 153 * |bufs|. 154 * 155 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 156 * before calling this function. 157 * 158 * This function always succeeds and returns 0. 159 */ 160 int nghttp2_frame_pack_priority(nghttp2_bufs *bufs, nghttp2_priority *frame); 161 162 /* 163 * Unpacks PRIORITY wire format into |frame|. 164 */ 165 void nghttp2_frame_unpack_priority_payload(nghttp2_priority *frame, 166 const uint8_t *payload); 167 168 /* 169 * Packs RST_STREAM frame |frame| in wire frame format and store it in 170 * |bufs|. 171 * 172 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 173 * before calling this function. 174 * 175 * This function always succeeds and returns 0. 176 */ 177 int nghttp2_frame_pack_rst_stream(nghttp2_bufs *bufs, 178 nghttp2_rst_stream *frame); 179 180 /* 181 * Unpacks RST_STREAM frame byte sequence into |frame|. 182 */ 183 void nghttp2_frame_unpack_rst_stream_payload(nghttp2_rst_stream *frame, 184 const uint8_t *payload); 185 186 /* 187 * Packs SETTINGS frame |frame| in wire format and store it in 188 * |bufs|. 189 * 190 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 191 * before calling this function. 192 * 193 * This function returns 0 if it succeeds, or returns one of the 194 * following negative error codes: 195 * 196 * NGHTTP2_ERR_FRAME_SIZE_ERROR 197 * The length of the frame is too large. 198 */ 199 int nghttp2_frame_pack_settings(nghttp2_bufs *bufs, nghttp2_settings *frame); 200 201 /* 202 * Packs the |iv|, which includes |niv| entries, in the |buf|, 203 * assuming the |buf| has at least 8 * |niv| bytes. 204 * 205 * Returns the number of bytes written into the |buf|. 206 */ 207 size_t nghttp2_frame_pack_settings_payload(uint8_t *buf, 208 const nghttp2_settings_entry *iv, 209 size_t niv); 210 211 void nghttp2_frame_unpack_settings_entry(nghttp2_settings_entry *iv, 212 const uint8_t *payload); 213 214 /* 215 * Initializes payload of frame->settings. The |frame| takes 216 * ownership of |iv|. 217 */ 218 void nghttp2_frame_unpack_settings_payload(nghttp2_settings *frame, 219 nghttp2_settings_entry *iv, 220 size_t niv); 221 222 /* 223 * Unpacks SETTINGS payload into |*iv_ptr|. The number of entries are 224 * assigned to the |*niv_ptr|. This function allocates enough memory 225 * to store the result in |*iv_ptr|. The caller is responsible to free 226 * |*iv_ptr| after its use. 227 * 228 * This function returns 0 if it succeeds or one of the following 229 * negative error codes: 230 * 231 * NGHTTP2_ERR_NOMEM 232 * Out of memory. 233 */ 234 int nghttp2_frame_unpack_settings_payload2(nghttp2_settings_entry **iv_ptr, 235 size_t *niv_ptr, 236 const uint8_t *payload, 237 size_t payloadlen, nghttp2_mem *mem); 238 239 /* 240 * Packs PUSH_PROMISE frame |frame| in wire format and store it in 241 * |bufs|. This function expands |bufs| as necessary to store 242 * frame. 243 * 244 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 245 * before calling this function. 246 * 247 * frame->hd.length is assigned after length is determined during 248 * packing process. CONTINUATION frames are also serialized in this 249 * function. This function does not handle padding. 250 * 251 * This function returns 0 if it succeeds, or returns one of the 252 * following negative error codes: 253 * 254 * NGHTTP2_ERR_HEADER_COMP 255 * The deflate operation failed. 256 * NGHTTP2_ERR_NOMEM 257 * Out of memory. 258 */ 259 int nghttp2_frame_pack_push_promise(nghttp2_bufs *bufs, 260 nghttp2_push_promise *frame, 261 nghttp2_hd_deflater *deflater); 262 263 /* 264 * Unpacks PUSH_PROMISE frame byte sequence into |frame|. This 265 * function only unapcks bytes that come before name/value header 266 * block and after possible Pad Length field. 267 * 268 * This function returns 0 if it succeeds or one of the following 269 * negative error codes: 270 * 271 * NGHTTP2_ERR_PROTO 272 * TODO END_HEADERS flag is not set 273 */ 274 int nghttp2_frame_unpack_push_promise_payload(nghttp2_push_promise *frame, 275 const uint8_t *payload); 276 277 /* 278 * Packs PING frame |frame| in wire format and store it in 279 * |bufs|. 280 * 281 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 282 * before calling this function. 283 * 284 * This function always succeeds and returns 0. 285 */ 286 int nghttp2_frame_pack_ping(nghttp2_bufs *bufs, nghttp2_ping *frame); 287 288 /* 289 * Unpacks PING wire format into |frame|. 290 */ 291 void nghttp2_frame_unpack_ping_payload(nghttp2_ping *frame, 292 const uint8_t *payload); 293 294 /* 295 * Packs GOAWAY frame |frame| in wire format and store it in |bufs|. 296 * This function expands |bufs| as necessary to store frame. 297 * 298 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 299 * before calling this function. 300 * 301 * This function returns 0 if it succeeds or one of the following 302 * negative error codes: 303 * 304 * NGHTTP2_ERR_NOMEM 305 * Out of memory. 306 * NGHTTP2_ERR_FRAME_SIZE_ERROR 307 * The length of the frame is too large. 308 */ 309 int nghttp2_frame_pack_goaway(nghttp2_bufs *bufs, nghttp2_goaway *frame); 310 311 /* 312 * Unpacks GOAWAY wire format into |frame|. The |payload| of length 313 * |payloadlen| contains first 8 bytes of payload. The 314 * |var_gift_payload| of length |var_gift_payloadlen| contains 315 * remaining payload and its buffer is gifted to the function and then 316 * |frame|. The |var_gift_payloadlen| must be freed by 317 * nghttp2_frame_goaway_free(). 318 */ 319 void nghttp2_frame_unpack_goaway_payload(nghttp2_goaway *frame, 320 const uint8_t *payload, 321 uint8_t *var_gift_payload, 322 size_t var_gift_payloadlen); 323 324 /* 325 * Unpacks GOAWAY wire format into |frame|. This function only exists 326 * for unit test. After allocating buffer for debug data, this 327 * function internally calls nghttp2_frame_unpack_goaway_payload(). 328 * 329 * This function returns 0 if it succeeds, or one of the following 330 * negative error codes: 331 * 332 * NGHTTP2_ERR_NOMEM 333 * Out of memory. 334 */ 335 int nghttp2_frame_unpack_goaway_payload2(nghttp2_goaway *frame, 336 const uint8_t *payload, 337 size_t payloadlen, nghttp2_mem *mem); 338 339 /* 340 * Packs WINDOW_UPDATE frame |frame| in wire frame format and store it 341 * in |bufs|. 342 * 343 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 344 * before calling this function. 345 * 346 * This function always succeeds and returns 0. 347 */ 348 int nghttp2_frame_pack_window_update(nghttp2_bufs *bufs, 349 nghttp2_window_update *frame); 350 351 /* 352 * Unpacks WINDOW_UPDATE frame byte sequence into |frame|. 353 */ 354 void nghttp2_frame_unpack_window_update_payload(nghttp2_window_update *frame, 355 const uint8_t *payload); 356 357 /* 358 * Packs ALTSVC frame |frame| in wire frame format and store it in 359 * |bufs|. 360 * 361 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 362 * before calling this function. 363 * 364 * This function always succeeds and returns 0. 365 */ 366 int nghttp2_frame_pack_altsvc(nghttp2_bufs *bufs, nghttp2_extension *ext); 367 368 /* 369 * Unpacks ALTSVC wire format into |frame|. The |payload| of 370 * |payloadlen| bytes contains frame payload. This function assumes 371 * that frame->payload points to the nghttp2_ext_altsvc object. 372 * 373 * This function always succeeds and returns 0. 374 */ 375 void nghttp2_frame_unpack_altsvc_payload(nghttp2_extension *frame, 376 size_t origin_len, uint8_t *payload, 377 size_t payloadlen); 378 379 /* 380 * Unpacks ALTSVC wire format into |frame|. This function only exists 381 * for unit test. After allocating buffer for fields, this function 382 * internally calls nghttp2_frame_unpack_altsvc_payload(). 383 * 384 * This function returns 0 if it succeeds, or one of the following 385 * negative error codes: 386 * 387 * NGHTTP2_ERR_NOMEM 388 * Out of memory. 389 * NGHTTP2_ERR_FRAME_SIZE_ERROR 390 * The payload is too small. 391 */ 392 int nghttp2_frame_unpack_altsvc_payload2(nghttp2_extension *frame, 393 const uint8_t *payload, 394 size_t payloadlen, nghttp2_mem *mem); 395 396 /* 397 * Packs ORIGIN frame |frame| in wire frame format and store it in 398 * |bufs|. 399 * 400 * The caller must make sure that nghttp2_bufs_reset(bufs) is called 401 * before calling this function. 402 * 403 * This function returns 0 if it succeeds, or one of the following 404 * negative error codes: 405 * 406 * NGHTTP2_ERR_FRAME_SIZE_ERROR 407 * The length of the frame is too large. 408 */ 409 int nghttp2_frame_pack_origin(nghttp2_bufs *bufs, nghttp2_extension *ext); 410 411 /* 412 * Unpacks ORIGIN wire format into |frame|. The |payload| of length 413 * |payloadlen| contains the frame payload. 414 * 415 * This function returns 0 if it succeeds, or one of the following 416 * negative error codes: 417 * 418 * NGHTTP2_ERR_NOMEM 419 * Out of memory. 420 * NGHTTP2_ERR_FRAME_SIZE_ERROR 421 * The payload is too small. 422 */ 423 int nghttp2_frame_unpack_origin_payload(nghttp2_extension *frame, 424 const uint8_t *payload, 425 size_t payloadlen, nghttp2_mem *mem); 426 /* 427 * Initializes HEADERS frame |frame| with given values. |frame| takes 428 * ownership of |nva|, so caller must not free it. If |stream_id| is 429 * not assigned yet, it must be -1. 430 */ 431 void nghttp2_frame_headers_init(nghttp2_headers *frame, uint8_t flags, 432 int32_t stream_id, nghttp2_headers_category cat, 433 const nghttp2_priority_spec *pri_spec, 434 nghttp2_nv *nva, size_t nvlen); 435 436 void nghttp2_frame_headers_free(nghttp2_headers *frame, nghttp2_mem *mem); 437 438 void nghttp2_frame_priority_init(nghttp2_priority *frame, int32_t stream_id, 439 const nghttp2_priority_spec *pri_spec); 440 441 void nghttp2_frame_priority_free(nghttp2_priority *frame); 442 443 void nghttp2_frame_rst_stream_init(nghttp2_rst_stream *frame, int32_t stream_id, 444 uint32_t error_code); 445 446 void nghttp2_frame_rst_stream_free(nghttp2_rst_stream *frame); 447 448 /* 449 * Initializes PUSH_PROMISE frame |frame| with given values. |frame| 450 * takes ownership of |nva|, so caller must not free it. 451 */ 452 void nghttp2_frame_push_promise_init(nghttp2_push_promise *frame, uint8_t flags, 453 int32_t stream_id, 454 int32_t promised_stream_id, 455 nghttp2_nv *nva, size_t nvlen); 456 457 void nghttp2_frame_push_promise_free(nghttp2_push_promise *frame, 458 nghttp2_mem *mem); 459 460 /* 461 * Initializes SETTINGS frame |frame| with given values. |frame| takes 462 * ownership of |iv|, so caller must not free it. The |flags| are 463 * bitwise-OR of one or more of nghttp2_settings_flag. 464 */ 465 void nghttp2_frame_settings_init(nghttp2_settings *frame, uint8_t flags, 466 nghttp2_settings_entry *iv, size_t niv); 467 468 void nghttp2_frame_settings_free(nghttp2_settings *frame, nghttp2_mem *mem); 469 470 /* 471 * Initializes PING frame |frame| with given values. If the 472 * |opqeue_data| is not NULL, it must point to 8 bytes memory region 473 * of data. The data pointed by |opaque_data| is copied. It can be 474 * NULL. In this case, 8 bytes NULL is used. 475 */ 476 void nghttp2_frame_ping_init(nghttp2_ping *frame, uint8_t flags, 477 const uint8_t *opque_data); 478 479 void nghttp2_frame_ping_free(nghttp2_ping *frame); 480 481 /* 482 * Initializes GOAWAY frame |frame| with given values. On success, 483 * this function takes ownership of |opaque_data|, so caller must not 484 * free it. If the |opaque_data_len| is 0, opaque_data could be NULL. 485 */ 486 void nghttp2_frame_goaway_init(nghttp2_goaway *frame, int32_t last_stream_id, 487 uint32_t error_code, uint8_t *opaque_data, 488 size_t opaque_data_len); 489 490 void nghttp2_frame_goaway_free(nghttp2_goaway *frame, nghttp2_mem *mem); 491 492 void nghttp2_frame_window_update_init(nghttp2_window_update *frame, 493 uint8_t flags, int32_t stream_id, 494 int32_t window_size_increment); 495 496 void nghttp2_frame_window_update_free(nghttp2_window_update *frame); 497 498 void nghttp2_frame_extension_init(nghttp2_extension *frame, uint8_t type, 499 uint8_t flags, int32_t stream_id, 500 void *payload); 501 502 void nghttp2_frame_extension_free(nghttp2_extension *frame); 503 504 /* 505 * Initializes ALTSVC frame |frame| with given values. This function 506 * assumes that frame->payload points to nghttp2_ext_altsvc object. 507 * Also |origin| and |field_value| are allocated in single buffer, 508 * starting |origin|. On success, this function takes ownership of 509 * |origin|, so caller must not free it. 510 */ 511 void nghttp2_frame_altsvc_init(nghttp2_extension *frame, int32_t stream_id, 512 uint8_t *origin, size_t origin_len, 513 uint8_t *field_value, size_t field_value_len); 514 515 /* 516 * Frees up resources under |frame|. This function does not free 517 * nghttp2_ext_altsvc object pointed by frame->payload. This function 518 * only frees origin pointed by nghttp2_ext_altsvc.origin. Therefore, 519 * other fields must be allocated in the same buffer with origin. 520 */ 521 void nghttp2_frame_altsvc_free(nghttp2_extension *frame, nghttp2_mem *mem); 522 523 /* 524 * Initializes ORIGIN frame |frame| with given values. This function 525 * assumes that frame->payload points to nghttp2_ext_origin object. 526 * Also |ov| and the memory pointed by the field of its elements are 527 * allocated in single buffer, starting with |ov|. On success, this 528 * function takes ownership of |ov|, so caller must not free it. 529 */ 530 void nghttp2_frame_origin_init(nghttp2_extension *frame, 531 nghttp2_origin_entry *ov, size_t nov); 532 533 /* 534 * Frees up resources under |frame|. This function does not free 535 * nghttp2_ext_origin object pointed by frame->payload. This function 536 * only frees nghttp2_ext_origin.ov. Therefore, other fields must be 537 * allocated in the same buffer with ov. 538 */ 539 void nghttp2_frame_origin_free(nghttp2_extension *frame, nghttp2_mem *mem); 540 541 /* 542 * Returns the number of padding bytes after payload. The total 543 * padding length is given in the |padlen|. The returned value does 544 * not include the Pad Length field. If |padlen| is 0, this function 545 * returns 0, regardless of frame->hd.flags. 546 */ 547 size_t nghttp2_frame_trail_padlen(nghttp2_frame *frame, size_t padlen); 548 549 void nghttp2_frame_data_init(nghttp2_data *frame, uint8_t flags, 550 int32_t stream_id); 551 552 void nghttp2_frame_data_free(nghttp2_data *frame); 553 554 /* 555 * Makes copy of |iv| and return the copy. The |niv| is the number of 556 * entries in |iv|. This function returns the pointer to the copy if 557 * it succeeds, or NULL. 558 */ 559 nghttp2_settings_entry *nghttp2_frame_iv_copy(const nghttp2_settings_entry *iv, 560 size_t niv, nghttp2_mem *mem); 561 562 /* 563 * Sorts the |nva| in ascending order of name and value. If names are 564 * equivalent, sort them by value. 565 */ 566 void nghttp2_nv_array_sort(nghttp2_nv *nva, size_t nvlen); 567 568 /* 569 * Copies name/value pairs from |nva|, which contains |nvlen| pairs, 570 * to |*nva_ptr|, which is dynamically allocated so that all items can 571 * be stored. The resultant name and value in nghttp2_nv are 572 * guaranteed to be NULL-terminated even if the input is not 573 * null-terminated. 574 * 575 * The |*nva_ptr| must be freed using nghttp2_nv_array_del(). 576 * 577 * This function returns 0 if it succeeds or one of the following 578 * negative error codes: 579 * 580 * NGHTTP2_ERR_NOMEM 581 * Out of memory. 582 */ 583 int nghttp2_nv_array_copy(nghttp2_nv **nva_ptr, const nghttp2_nv *nva, 584 size_t nvlen, nghttp2_mem *mem); 585 586 /* 587 * Returns nonzero if the name/value pair |a| equals to |b|. The name 588 * is compared in case-sensitive, because we ensure that this function 589 * is called after the name is lower-cased. 590 */ 591 int nghttp2_nv_equal(const nghttp2_nv *a, const nghttp2_nv *b); 592 593 /* 594 * Frees |nva|. 595 */ 596 void nghttp2_nv_array_del(nghttp2_nv *nva, nghttp2_mem *mem); 597 598 /* 599 * Checks that the |iv|, which includes |niv| entries, does not have 600 * invalid values. 601 * 602 * This function returns nonzero if it succeeds, or 0. 603 */ 604 int nghttp2_iv_check(const nghttp2_settings_entry *iv, size_t niv); 605 606 /* 607 * Sets Pad Length field and flags and adjusts frame header position 608 * of each buffers in |bufs|. The number of padding is given in the 609 * |padlen| including Pad Length field. The |hd| is the frame header 610 * for the serialized data. This function fills zeros padding region 611 * unless framehd_only is nonzero. 612 * 613 * This function returns 0 if it succeeds, or one of the following 614 * negative error codes: 615 * 616 * NGHTTP2_ERR_NOMEM 617 * Out of memory. 618 * NGHTTP2_ERR_FRAME_SIZE_ERROR 619 * The length of the resulting frame is too large. 620 */ 621 int nghttp2_frame_add_pad(nghttp2_bufs *bufs, nghttp2_frame_hd *hd, 622 size_t padlen, int framehd_only); 623 624 #endif /* NGHTTP2_FRAME_H */ 625