VLC 4.0.0-dev
Loading...
Searching...
No Matches
h2frame.h
Go to the documentation of this file.
1/*****************************************************************************
2 * h2frame.h: HTTP/2 frame formatting
3 *****************************************************************************
4 * Copyright (C) 2015 RĂ©mi Denis-Courmont
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
20
21#include <stdbool.h>
22#include <stdint.h>
23
24/**
25 * \defgroup h2_frames HTTP/2 frames
26 * \ingroup h2
27 * @{
28 */
29
31{
33 uint8_t data[];
34};
35
36size_t vlc_h2_frame_size(const struct vlc_h2_frame *);
37
38struct vlc_h2_frame *
39vlc_h2_frame_headers(uint_fast32_t stream_id, uint_fast32_t mtu, bool eos,
40 unsigned count, const char *const headers[][2]);
41struct vlc_h2_frame *
42vlc_h2_frame_data(uint_fast32_t stream_id, const void *buf, size_t len,
43 bool eos);
44struct vlc_h2_frame *
45vlc_h2_frame_rst_stream(uint_fast32_t stream_id, uint_fast32_t error_code);
48struct vlc_h2_frame *vlc_h2_frame_ping(uint64_t opaque);
49struct vlc_h2_frame *vlc_h2_frame_pong(uint64_t opaque);
50struct vlc_h2_frame *
51vlc_h2_frame_goaway(uint_fast32_t last_stream_id, uint_fast32_t error_code);
52struct vlc_h2_frame *
53vlc_h2_frame_window_update(uint_fast32_t stream_id, uint_fast32_t credit);
54
55void vlc_h2_frame_dump(void *, const struct vlc_h2_frame *, const char *);
56
73
74const char *vlc_h2_strerror(uint_fast32_t);
75
84
85const char *vlc_h2_setting_name(uint_fast16_t);
86
87/* Our settings */
88#define VLC_H2_MAX_HEADER_TABLE 4096 /* Header (compression) table size */
89#define VLC_H2_MAX_STREAMS 0 /* Concurrent peer-initiated streams */
90#define VLC_H2_INIT_WINDOW 1048575 /* Initial congestion window size */
91#define VLC_H2_MAX_FRAME 1048576 /* Frame size */
92#define VLC_H2_MAX_HEADER_LIST 65536 /* Header (decompressed) list size */
93
94/* Protocol default settings */
95#define VLC_H2_DEFAULT_MAX_HEADER_TABLE 4096
96#define VLC_H2_DEFAULT_INIT_WINDOW 65535
97#define VLC_H2_MIN_MAX_FRAME 16384
98#define VLC_H2_DEFAULT_MAX_FRAME 16384
99#define VLC_H2_MAX_MAX_FRAME 16777215
100
101struct vlc_h2_parser;
103{
104 void (*setting)(void *ctx, uint_fast16_t id, uint_fast32_t value);
105 int (*settings_done)(void *ctx);
106 int (*ping)(void *ctx, uint_fast64_t opaque);
107 void (*error)(void *ctx, uint_fast32_t code);
108 int (*reset)(void *ctx, uint_fast32_t last_seq, uint_fast32_t code);
109 void (*window_status)(void *ctx, uint32_t * restrict rcwd);
110 void (*window_update)(void *ctx, uint_fast32_t credit);
111
112 void *(*stream_lookup)(void *ctx, uint_fast32_t id);
113 int (*stream_error)(void *ctx, uint_fast32_t id, uint_fast32_t code);
114 void (*stream_headers)(void *ctx, unsigned count,
115 const char *const headers[][2]);
116 int (*stream_data)(void *ctx, struct vlc_h2_frame *f);
117 void (*stream_end)(void *ctx);
118 int (*stream_reset)(void *ctx, uint_fast32_t code);
119 void (*stream_window_update)(void *ctx, uint_fast32_t credit);
120};
121
122struct vlc_h2_parser *vlc_h2_parse_init(void *ctx,
123 const struct vlc_h2_parser_cbs *cbs);
124int vlc_h2_parse(struct vlc_h2_parser *, struct vlc_h2_frame *);
126
127#define VLC_H2_MAX_HEADERS 255
128
129const uint8_t *vlc_h2_frame_data_get(const struct vlc_h2_frame *f,
130 size_t *restrict len);
131#define vlc_h2_frame_data_get(f, l) \
132 _Generic((f), \
133 const struct vlc_h2_frame *: (vlc_h2_frame_data_get)(f, l), \
134 struct vlc_h2_frame *: (uint8_t *)(vlc_h2_frame_data_get)(f, l))
135
136/** @} */
size_t count
Definition core.c:403
struct vlc_h2_frame * vlc_h2_frame_goaway(uint_fast32_t last_stream_id, uint_fast32_t error_code)
Definition h2frame.c:352
vlc_h2_error
Definition h2frame.h:57
const char * vlc_h2_setting_name(uint_fast16_t)
Definition h2frame.c:317
struct vlc_h2_frame * vlc_h2_frame_headers(uint_fast32_t stream_id, uint_fast32_t mtu, bool eos, unsigned count, const char *const headers[][2])
Definition h2frame.c:155
size_t vlc_h2_frame_size(const struct vlc_h2_frame *)
Definition h2frame.c:72
struct vlc_h2_frame * vlc_h2_frame_settings(void)
Definition h2frame.c:250
struct vlc_h2_parser * vlc_h2_parse_init(void *ctx, const struct vlc_h2_parser_cbs *cbs)
Definition h2frame.c:1030
struct vlc_h2_frame * vlc_h2_frame_window_update(uint_fast32_t stream_id, uint_fast32_t credit)
Definition h2frame.c:366
void vlc_h2_frame_dump(void *, const struct vlc_h2_frame *, const char *)
Definition h2frame.c:405
const char * vlc_h2_strerror(uint_fast32_t)
Definition h2frame.c:381
struct vlc_h2_frame * vlc_h2_frame_settings_ack(void)
Definition h2frame.c:311
struct vlc_h2_frame * vlc_h2_frame_ping(uint64_t opaque)
Definition h2frame.c:334
struct vlc_h2_frame * vlc_h2_frame_data(uint_fast32_t stream_id, const void *buf, size_t len, bool eos)
Definition h2frame.c:228
vlc_h2_setting
Definition h2frame.h:76
struct vlc_h2_frame * vlc_h2_frame_rst_stream(uint_fast32_t stream_id, uint_fast32_t error_code)
Definition h2frame.c:241
void vlc_h2_parse_destroy(struct vlc_h2_parser *)
Definition h2frame.c:1053
#define vlc_h2_frame_data_get(f, l)
Definition h2frame.h:131
struct vlc_h2_frame * vlc_h2_frame_pong(uint64_t opaque)
Definition h2frame.c:342
int vlc_h2_parse(struct vlc_h2_parser *, struct vlc_h2_frame *)
Definition h2frame.c:1010
@ VLC_H2_ENHANCE_YOUR_CALM
Definition h2frame.h:69
@ VLC_H2_STREAM_CLOSED
Definition h2frame.h:63
@ VLC_H2_INTERNAL_ERROR
Definition h2frame.h:60
@ VLC_H2_REFUSED_STREAM
Definition h2frame.h:65
@ VLC_H2_FLOW_CONTROL_ERROR
Definition h2frame.h:61
@ VLC_H2_FRAME_SIZE_ERROR
Definition h2frame.h:64
@ VLC_H2_COMPRESSION_ERROR
Definition h2frame.h:67
@ VLC_H2_CANCEL
Definition h2frame.h:66
@ VLC_H2_HTTP_1_1_REQUIRED
Definition h2frame.h:71
@ VLC_H2_CONNECT_ERROR
Definition h2frame.h:68
@ VLC_H2_SETTINGS_TIMEOUT
Definition h2frame.h:62
@ VLC_H2_PROTOCOL_ERROR
Definition h2frame.h:59
@ VLC_H2_NO_ERROR
Definition h2frame.h:58
@ VLC_H2_INADEQUATE_SECURITY
Definition h2frame.h:70
@ VLC_H2_SETTING_MAX_CONCURRENT_STREAMS
Definition h2frame.h:79
@ VLC_H2_SETTING_INITIAL_WINDOW_SIZE
Definition h2frame.h:80
@ VLC_H2_SETTING_MAX_HEADER_LIST_SIZE
Definition h2frame.h:82
@ VLC_H2_SETTING_HEADER_TABLE_SIZE
Definition h2frame.h:77
@ VLC_H2_SETTING_ENABLE_PUSH
Definition h2frame.h:78
@ VLC_H2_SETTING_MAX_FRAME_SIZE
Definition h2frame.h:81
Definition h2frame.h:31
uint8_t data[]
Definition h2frame.h:33
struct vlc_h2_frame * next
Definition h2frame.h:32
Definition h2frame.h:103
void(* stream_end)(void *ctx)
Definition h2frame.h:117
int(* stream_reset)(void *ctx, uint_fast32_t code)
Definition h2frame.h:118
void(* setting)(void *ctx, uint_fast16_t id, uint_fast32_t value)
Definition h2frame.h:104
int(* settings_done)(void *ctx)
Definition h2frame.h:105
void(* window_update)(void *ctx, uint_fast32_t credit)
Definition h2frame.h:110
void(* stream_headers)(void *ctx, unsigned count, const char *const headers[][2])
Definition h2frame.h:114
void(* stream_window_update)(void *ctx, uint_fast32_t credit)
Definition h2frame.h:119
int(* reset)(void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
Definition h2frame.h:108
void(* error)(void *ctx, uint_fast32_t code)
Definition h2frame.h:107
int(* ping)(void *ctx, uint_fast64_t opaque)
Definition h2frame.h:106
void(* window_status)(void *ctx, uint32_t *restrict rcwd)
Definition h2frame.h:109
int(* stream_error)(void *ctx, uint_fast32_t id, uint_fast32_t code)
Definition h2frame.h:113
int(* stream_data)(void *ctx, struct vlc_h2_frame *f)
Definition h2frame.h:116
HTTP/2 incoming frames parser.
Definition h2frame.c:448
size_t len
Definition h2frame.c:458
const struct vlc_h2_parser_cbs * cbs
Definition h2frame.c:450