VLC  4.0.0-dev
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 {
32  struct vlc_h2_frame *next;
33  uint8_t data[];
34 };
35 
36 size_t vlc_h2_frame_size(const struct vlc_h2_frame *);
37 
38 struct vlc_h2_frame *
39 vlc_h2_frame_headers(uint_fast32_t stream_id, uint_fast32_t mtu, bool eos,
40  unsigned count, const char *const headers[][2]);
41 struct vlc_h2_frame *
42 vlc_h2_frame_data(uint_fast32_t stream_id, const void *buf, size_t len,
43  bool eos);
44 struct vlc_h2_frame *
45 vlc_h2_frame_rst_stream(uint_fast32_t stream_id, uint_fast32_t error_code);
48 struct vlc_h2_frame *vlc_h2_frame_ping(uint64_t opaque);
49 struct vlc_h2_frame *vlc_h2_frame_pong(uint64_t opaque);
50 struct vlc_h2_frame *
51 vlc_h2_frame_goaway(uint_fast32_t last_stream_id, uint_fast32_t error_code);
52 struct vlc_h2_frame *
53 vlc_h2_frame_window_update(uint_fast32_t stream_id, uint_fast32_t credit);
54 
55 void vlc_h2_frame_dump(void *, const struct vlc_h2_frame *, const char *);
56 
72 };
73 
74 const char *vlc_h2_strerror(uint_fast32_t);
75 
83 };
84 
85 const 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 
101 struct 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 *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 
122 struct vlc_h2_parser *vlc_h2_parse_init(void *ctx,
123  const struct vlc_h2_parser_cbs *cbs);
124 int vlc_h2_parse(struct vlc_h2_parser *, struct vlc_h2_frame *);
125 void vlc_h2_parse_destroy(struct vlc_h2_parser *);
126 
127 #define VLC_H2_MAX_HEADERS 255
128 
129 const 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 /** @} */
vlc_cond_broadcast
void vlc_cond_broadcast(vlc_cond_t *cond)
Wakes up all threads waiting on a condition variable.
Definition: threads.c:280
hpack_decode_init
struct hpack_decoder * hpack_decode_init(size_t header_table_size)
Definition: hpack.c:72
vlc_h1_stream_conn
static struct vlc_h1_conn * vlc_h1_stream_conn(struct vlc_http_stream *stream)
Definition: h1conn.c:138
vlc_h2_parser_cbs::window_update
void(* window_update)(void *ctx, uint_fast32_t credit)
Definition: h2frame.h:110
vlc_mutex_init
void vlc_mutex_init(vlc_mutex_t *mtx)
Initializes a fast mutex.
Definition: threads.c:123
vlc_h2_parse_frame_settings
static int vlc_h2_parse_frame_settings(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 SETTINGS frame.
Definition: h2frame.c:725
VLC_H2_REFUSED_STREAM
@ VLC_H2_REFUSED_STREAM
Definition: h2frame.h:65
vlc_h2_conn_create
struct vlc_http_conn * vlc_h2_conn_create(void *ctx, struct vlc_tls *tls)
Definition: h2conn.c:877
count
size_t count
Definition: core.c:401
vlc_h2_conn::thread
vlc_thread_t thread
Receive thread.
Definition: h2conn.c:65
vlc_h2_conn_queue
static int vlc_h2_conn_queue(struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
Definition: h2conn.c:93
VLC_H2_INTERNAL_ERROR
@ VLC_H2_INTERNAL_ERROR
Definition: h2frame.h:60
GetDWBE
#define GetDWBE(p)
Definition: vlc_common.h:1014
vlc_h2_parser::sid
uint32_t sid
Definition: h2frame.c:458
VLC_H2_PROTOCOL_ERROR
@ VLC_H2_PROTOCOL_ERROR
Definition: h2frame.h:59
vlc_h1_stream_write
static ssize_t vlc_h1_stream_write(struct vlc_http_stream *stream, const void *base, size_t length, bool eos)
Definition: h1conn.c:231
vlc_h2_stream_reset
static int vlc_h2_stream_reset(void *ctx, uint_fast32_t code)
Reports remote stream error.
Definition: h2conn.c:207
vlc_h2_stream_close
static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool aborted)
Terminates a stream.
Definition: h2conn.c:452
vlc_h2_stream_read
static block_t * vlc_h2_stream_read(struct vlc_http_stream *stream)
Receives stream data.
Definition: h2conn.c:384
vlc_cleanup_push
#define vlc_cleanup_push(routine, arg)
Registers a thread cancellation handler.
Definition: vlc_threads.h:1010
vlc_h2_parse_generic
static int vlc_h2_parse_generic(struct vlc_h2_parser *, struct vlc_h2_frame *, size_t, uint_fast32_t)
Parses any HTTP/2 frame.
Definition: h2frame.c:971
vlc_h2_parser::len
size_t len
Definition: h2frame.c:460
VLC_H2_MAX_STREAMS
#define VLC_H2_MAX_STREAMS
Definition: h2frame.h:89
VLC_H2_MAX_FRAME
#define VLC_H2_MAX_FRAME
Definition: h2frame.h:91
vlc_h1_request
struct vlc_http_stream * vlc_h1_request(void *ctx, const char *hostname, unsigned port, bool proxy, const struct vlc_http_msg *req, bool idempotent, bool has_data, struct vlc_http_conn **restrict connp)
Sends an HTTP/1.x request through a new connection.
Definition: h1conn.c:357
vlc_h2_parser::decoder
struct hpack_decoder * decoder
Definition: h2frame.c:462
vlc_h2_parse_headers_append
static int vlc_h2_parse_headers_append(struct vlc_h2_parser *p, const uint8_t *data, size_t len)
Definition: h2frame.c:503
vlc_h2_parse_frame_continuation
static int vlc_h2_parse_frame_continuation(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 CONTINUATION frame.
Definition: h2frame.c:890
hpack_decoder
Definition: hpack.c:64
vlc_h2_stream_lookup
static void * vlc_h2_stream_lookup(struct vlc_h2_parser *p, uint_fast32_t id)
Definition: h2frame.c:486
vlc_h2_stream_wait
static struct vlc_http_msg * vlc_h2_stream_wait(struct vlc_http_stream *stream)
Definition: h2conn.c:262
VLC_H2_FRAME_CONTINUATION
@ VLC_H2_FRAME_CONTINUATION
Definition: h2frame.c:102
unlikely
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:227
vlc_http_msg_h2_frame
struct vlc_h2_frame * vlc_http_msg_h2_frame(const struct vlc_http_msg *m, uint_fast32_t stream_id, bool eos)
Formats an HTTP 2.0 HEADER frame.
Definition: message.c:425
vlc_http_stream::cbs
const struct vlc_http_stream_cbs * cbs
Definition: message.h:368
VLC_H2_COMPRESSION_ERROR
@ VLC_H2_COMPRESSION_ERROR
Definition: h2frame.h:67
VLC_H2_CANCEL
@ VLC_H2_CANCEL
Definition: h2frame.h:66
vlc_h2_strerror
const char * vlc_h2_strerror(uint_fast32_t code)
Definition: h2frame.c:383
vlc_chunked_open
struct vlc_http_stream * vlc_chunked_open(struct vlc_http_stream *parent, struct vlc_tls *tls)
Definition: chunked.c:180
vlc_common.h
vlc_h2_parse_frame_unknown
static int vlc_h2_parse_frame_unknown(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 frame of unknown type.
Definition: h2frame.c:919
vlc_h2_stream::recv_head
struct vlc_h2_frame * recv_head
Earliest pending received buffer.
Definition: h2conn.c:85
vlc_tls_Read
ssize_t vlc_tls_Read(vlc_tls_t *session, void *buf, size_t len, bool waitall)
Receives data through a socket.
Definition: stream.c:53
VLC_H2_FRAME_PRIORITY
@ VLC_H2_FRAME_PRIORITY
Definition: h2frame.c:95
vlc_h2_parser_cbs::stream_data
int(* stream_data)(void *ctx, struct vlc_h2_frame *f)
Definition: h2frame.h:116
vlc_h2_frame_payload
#define vlc_h2_frame_payload(f)
Definition: h2frame.c:64
vlc_h2_stream::recv_tailp
struct vlc_h2_frame ** recv_tailp
Tail of receive queue.
Definition: h2conn.c:86
vlc_h2_type_name
static const char * vlc_h2_type_name(uint_fast8_t type)
Definition: h2frame.c:105
vlc_h2_window_update
static void vlc_h2_window_update(void *ctx, uint_fast32_t credit)
Definition: h2conn.c:671
vlc_h2_conn::send_cwnd
uint64_t send_cwnd
Send congestion window.
Definition: h2conn.c:61
vlc_h2_parse_headers_block
static int vlc_h2_parse_headers_block(struct vlc_h2_parser *, struct vlc_h2_frame *, size_t, uint_fast32_t)
Definition: h2frame.c:987
vlc_http_msg_format
char * vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp, bool proxied, bool chunked)
Formats an HTTP 1.1 message header.
Definition: message.c:331
vlc_h2_parser_cbs::window_status
void(* window_status)(void *ctx, uint32_t *rcwd)
Definition: h2frame.h:109
vlc_h1_stream_open
static struct vlc_http_stream * vlc_h1_stream_open(struct vlc_http_conn *c, const struct vlc_http_msg *req, bool has_data)
Definition: h1conn.c:143
vlc_h2_parser
HTTP/2 incoming frames parser.
Definition: h2frame.c:449
vlc_h2_parser_cbs::setting
void(* setting)(void *ctx, uint_fast16_t id, uint_fast32_t value)
Definition: h2frame.h:104
vlc_h2_frame_pong
struct vlc_h2_frame * vlc_h2_frame_pong(uint64_t opaque)
Definition: h2frame.c:344
vlc_h1_stream_close
static void vlc_h1_stream_close(struct vlc_http_stream *stream, bool abort)
Definition: h1conn.c:287
vlc_h2_parser_cbs::stream_end
void(* stream_end)(void *ctx)
Definition: h2frame.h:117
vlc_h2_stream_error
static int vlc_h2_stream_error(void *ctx, uint_fast32_t id, uint_fast32_t code)
Reports a local stream error.
Definition: h2conn.c:121
vlc_h2_parse_headers_start
static void vlc_h2_parse_headers_start(struct vlc_h2_parser *p, uint_fast32_t sid, bool eos)
Definition: h2frame.c:491
block_t::i_buffer
size_t i_buffer
Payload length.
Definition: vlc_block.h:122
vlc_interrupt.h
vlc_h2_conn::opaque
void * opaque
Definition: h2conn.c:53
VLC_H2_FRAME_PUSH_PROMISE
@ VLC_H2_FRAME_PUSH_PROMISE
Definition: h2frame.c:98
vlc_http_dbg
void void vlc_http_dbg(void *, const char *msg,...) VLC_FORMAT(2
vlc_http_msg_h2_headers
struct vlc_http_msg * vlc_http_msg_h2_headers(unsigned n, const char *const hdrs[][2])
Parses an HTTP 2.0 header table.
Definition: message.c:487
vlc_http_conn::cbs
const struct vlc_http_conn_cbs * cbs
Definition: conn.h:43
pollfd::fd
int fd
Definition: vlc_fixups.h:419
vlc_h2_error
static void vlc_h2_error(void *ctx, uint_fast32_t code)
Reports a local HTTP/2 connection failure.
Definition: h2conn.c:622
VLC_H2_NO_ERROR
@ VLC_H2_NO_ERROR
Definition: h2frame.h:58
vlc_h1_conn_callbacks
static const struct vlc_http_conn_cbs vlc_h1_conn_callbacks
Definition: h1conn.c:334
vlc_http_msg_destroy
void vlc_http_msg_destroy(struct vlc_http_msg *m)
Destroys an HTTP message.
Definition: message.c:193
vlc_h1_conn::released
bool released
Definition: h1conn.c:117
vlc_h2_frame_data_get
#define vlc_h2_frame_data_get(f, l)
Definition: h2frame.h:131
vlc_h2_recv_thread
static void * vlc_h2_recv_thread(void *data)
HTTP/2 receive thread.
Definition: h2conn.c:796
vlc_h2_initial_window_update
static void vlc_h2_initial_window_update(struct vlc_h2_conn *conn, uint_fast32_t value)
Definition: h2conn.c:568
vlc_h1_conn::content_length
uintmax_t content_length
Definition: h1conn.c:114
CO
#define CO(conn)
Definition: h1conn.c:122
VLC_H2_SETTING_MAX_CONCURRENT_STREAMS
@ VLC_H2_SETTING_MAX_CONCURRENT_STREAMS
Definition: h2frame.h:79
VLC_H2_FRAME_WINDOW_UPDATE
@ VLC_H2_FRAME_WINDOW_UPDATE
Definition: h2frame.c:101
VLC_H2_HTTP_1_1_REQUIRED
@ VLC_H2_HTTP_1_1_REQUIRED
Definition: h2frame.h:71
vlc_tls_GetPollFD
static int vlc_tls_GetPollFD(vlc_tls_t *tls, short *events)
Generates an event polling description.
Definition: vlc_tls.h:314
VLC_H2_DEFAULT_INIT_WINDOW
#define VLC_H2_DEFAULT_INIT_WINDOW
Definition: h2frame.h:96
pollfd
Definition: vlc_fixups.h:417
h2output.h
VLC_H2_FRAME_SIZE_ERROR
@ VLC_H2_FRAME_SIZE_ERROR
Definition: h2frame.h:64
vlc_h2_stream_callbacks
static const struct vlc_http_stream_cbs vlc_h2_stream_callbacks
Definition: h2conn.c:494
vlc_cond_wait
void vlc_cond_wait(vlc_cond_t *cond, vlc_mutex_t *mutex)
Waits on a condition variable.
Definition: threads.c:340
vlc_h1_conn_create
struct vlc_http_conn * vlc_h1_conn_create(void *ctx, vlc_tls_t *tls, bool proxy)
Definition: h1conn.c:340
vlc_h2_conn::init_send_cwnd
uint32_t init_send_cwnd
Initial send congestion window.
Definition: h2conn.c:60
vlc_h2_stream::interrupted
bool interrupted
Definition: h2conn.c:79
VLC_H2_HEADERS_END_STREAM
@ VLC_H2_HEADERS_END_STREAM
Definition: h2frame.c:131
vlc_tls
Transport layer socket.
Definition: vlc_tls.h:65
vlc_h2_frame_recv
static struct vlc_h2_frame * vlc_h2_frame_recv(struct vlc_tls *tls)
Receives an HTTP/2 frame through TLS.
Definition: h2conn.c:759
vlc_h2_frame_type
static uint_fast8_t vlc_h2_frame_type(const struct vlc_h2_frame *f)
Definition: h2frame.c:77
SO
#define SO(s)
Definition: h2conn.c:46
vlc_h2_stream_window_update
static void vlc_h2_stream_window_update(void *ctx, uint_fast32_t credit)
Reports remote window size increments.
Definition: h2conn.c:221
cleanup_parser
static void cleanup_parser(void *data)
Definition: h2conn.c:790
vlc_h2_conn
HTTP/2 connection.
Definition: h2conn.c:49
vlc_h2_frame_alloc
static struct vlc_h2_frame * vlc_h2_frame_alloc(uint_fast8_t type, uint_fast8_t flags, uint_fast32_t stream_id, size_t length)
Definition: h2frame.c:39
vlc_h2_frame_settings_ack
struct vlc_h2_frame * vlc_h2_frame_settings_ack(void)
Definition: h2frame.c:313
vlc_h2_stream::recv_err
int recv_err
Standard C error code.
Definition: h2conn.c:81
vlc_https_headers_recv
static char * vlc_https_headers_recv(struct vlc_tls *tls, size_t *restrict lenp)
Receives HTTP headers.
Definition: h1conn.c:57
poll
int poll(struct pollfd *, unsigned, int)
vlc_h2_frame_dump
void vlc_h2_frame_dump(void *opaque, const struct vlc_h2_frame *f, const char *msg)
Definition: h2frame.c:407
vlc_h2_parser::cbs
const struct vlc_h2_parser_cbs * cbs
Definition: h2frame.c:452
VLC_H2_HEADERS_PADDED
@ VLC_H2_HEADERS_PADDED
Definition: h2frame.c:133
vlc_h2_stream::recv_cwnd
size_t recv_cwnd
Free space in receive congestion window.
Definition: h2conn.c:84
vlc_h2_parse_frame_window_update
static int vlc_h2_parse_frame_window_update(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 WINDOW_UPDATE frame.
Definition: h2frame.c:853
VLC_H2_FRAME_DATA
@ VLC_H2_FRAME_DATA
Definition: h2frame.c:93
vlc_http_next_token
const char * vlc_http_next_token(const char *value)
Finds next token.
Definition: message.c:642
vlc_h2_window_status
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition: h2conn.c:659
VLC_H2_INADEQUATE_SECURITY
@ VLC_H2_INADEQUATE_SECURITY
Definition: h2frame.h:70
vlc_h2_output_create
struct vlc_h2_output * vlc_h2_output_create(struct vlc_tls *tls, bool client)
Definition: h2output.c:302
vlc_http_stream_open
static struct vlc_http_stream * vlc_http_stream_open(struct vlc_http_conn *conn, const struct vlc_http_msg *m, bool has_data)
Definition: conn.h:48
vlc_h2_parser::buf
uint8_t * buf
Definition: h2frame.c:461
vlc_interrupt_unregister
int vlc_interrupt_unregister(void)
Definition: interrupt.c:166
VLC_H2_CONNECT_ERROR
@ VLC_H2_CONNECT_ERROR
Definition: h2frame.h:68
VLC_H2_FRAME_RST_STREAM
@ VLC_H2_FRAME_RST_STREAM
Definition: h2frame.c:96
vlc_h2_stream_headers
static void vlc_h2_stream_headers(void *ctx, unsigned count, const char *const hdrs[][2])
Reports received stream headers.
Definition: h2conn.c:142
vlc_h1_conn::active
bool active
Definition: h1conn.c:116
block_heap_Alloc
block_t * block_heap_Alloc(void *addr, size_t length)
Wraps heap in a block.
Definition: block.c:254
vlc_cond_signal
void vlc_cond_signal(vlc_cond_t *cond)
Wakes up one thread waiting on a condition variable.
Definition: threads.c:253
vlc_http_stream_cbs
HTTP stream callbacks.
Definition: message.h:357
vlc_http_conn
Definition: conn.h:41
vlc_h2_conn::streams
struct vlc_h2_stream * streams
List of open streams.
Definition: h2conn.c:55
vlc_h2_parse_frame_data
static int vlc_h2_parse_frame_data(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 DATA frame.
Definition: h2frame.c:574
VLC_H2_FRAME_PING
@ VLC_H2_FRAME_PING
Definition: h2frame.c:99
conn.h
vlc_mutex_t
Mutex.
Definition: vlc_threads.h:225
VLC_H2_MAX_HEADERS
#define VLC_H2_MAX_HEADERS
Definition: h2frame.h:127
vlc_h1_conn_destroy
static void vlc_h1_conn_destroy(struct vlc_h1_conn *conn)
Definition: h1conn.c:310
vlc_h2_error
vlc_h2_error
Definition: h2frame.h:57
vlc_h2_frame_ping
struct vlc_h2_frame * vlc_h2_frame_ping(uint64_t opaque)
Definition: h2frame.c:336
vlc_tls_SocketOpenAddrInfo
vlc_tls_t * vlc_tls_SocketOpenAddrInfo(const struct addrinfo *restrict info, bool defer_connect)
Definition: stream.c:408
VLC_H2_PING_ACK
@ VLC_H2_PING_ACK
Definition: h2frame.c:147
vlc_h2_stream::send_wait
vlc_cond_t send_wait
Definition: h2conn.c:90
VLC_H2_FRAME_SETTINGS
@ VLC_H2_FRAME_SETTINGS
Definition: h2frame.c:97
vlc_h2_frame_data_get
const uint8_t *() vlc_h2_frame_data_get(const struct vlc_h2_frame *f, size_t *restrict lenp)
Definition: h2frame.c:425
vlc_http_msg::payload
struct vlc_http_stream * payload
Definition: message.c:69
vlc_clone
int vlc_clone(vlc_thread_t *th, void *(*entry)(void *), void *data, int priority)
Creates and starts a new thread.
Definition: thread.c:144
VLC_H2_MAX_HEADER_TABLE
#define VLC_H2_MAX_HEADER_TABLE
Definition: h2frame.h:88
vlc_tls_SessionDelete
void vlc_tls_SessionDelete(vlc_tls_t *session)
Destroys a TLS session.
Definition: tls.c:135
vlc_h2_frame::next
struct vlc_h2_frame * next
Definition: h2frame.h:32
vlc_savecancel
int vlc_savecancel(void)
Disables thread cancellation.
Definition: thread.c:183
SetDWBE
static void SetDWBE(void *p, uint32_t dw)
Writes 32 bits in network byte order.
Definition: vlc_common.h:1064
VLC_H2_SETTING_INITIAL_WINDOW_SIZE
@ VLC_H2_SETTING_INITIAL_WINDOW_SIZE
Definition: h2frame.h:80
vlc_h2_parser_cbs::stream_reset
int(* stream_reset)(void *ctx, uint_fast32_t code)
Definition: h2frame.h:118
vlc_h2_parser_callbacks
static const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
HTTP/2 frames parser callbacks table.
Definition: h2conn.c:683
vlc_h2_stream::recv_end
bool recv_end
End-of-stream flag.
Definition: h2conn.c:80
message.h
vlc_h2_frame_length
static uint_fast32_t vlc_h2_frame_length(const struct vlc_h2_frame *f)
Definition: h2frame.c:66
vlc_h2_parse_frame_rst_stream
static int vlc_h2_parse_frame_rst_stream(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 RST_STREAM frame.
Definition: h2frame.c:698
vlc_h1_conn::opaque
void * opaque
Definition: h1conn.c:119
vlc_h2_stream_end
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition: h2conn.c:196
vlc_h2_parser::eos
bool eos
Definition: h2frame.c:459
vlc_h2_parse_frame_priority
static int vlc_h2_parse_frame_priority(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 PRIORITY frame.
Definition: h2frame.c:681
vlc_h1_conn
Definition: h1conn.c:110
vlc_h1_conn::connection_close
bool connection_close
Definition: h1conn.c:115
block_Alloc
block_t * block_Alloc(size_t size)
Allocates a block.
Definition: block.c:108
hpack.h
VLC_H2_FLOW_CONTROL_ERROR
@ VLC_H2_FLOW_CONTROL_ERROR
Definition: h2frame.h:61
vlc_h2_stream_data
static int vlc_h2_stream_data(void *ctx, struct vlc_h2_frame *f)
Reports received stream data.
Definition: h2conn.c:169
hpack_decode_destroy
void hpack_decode_destroy(struct hpack_decoder *dec)
Definition: hpack.c:85
vlc_h2_setting
vlc_h2_setting
Definition: h2frame.h:76
vlc_h2_frame_rst_stream
struct vlc_h2_frame * vlc_h2_frame_rst_stream(uint_fast32_t stream_id, uint_fast32_t error_code)
Definition: h2frame.c:241
vlc_h2_stream::conn
struct vlc_h2_conn * conn
Underlying HTTP/2 connection.
Definition: h2conn.c:74
vlc_h2_stream::stream
struct vlc_http_stream stream
Base class.
Definition: h2conn.c:73
vlc_http_msg_get_token
const char * vlc_http_msg_get_token(const struct vlc_http_msg *msg, const char *field, const char *token)
Looks up a token in a header field.
Definition: message.c:709
vlc_strerror_c
const char * vlc_strerror_c(int errnum)
Definition: error.c:34
VLC_H2_SETTING_HEADER_TABLE_SIZE
@ VLC_H2_SETTING_HEADER_TABLE_SIZE
Definition: h2frame.h:77
vlc_h2_parse_headers_end
static int vlc_h2_parse_headers_end(struct vlc_h2_parser *p)
Definition: h2frame.c:521
vlc_h2_parse_destroy
void vlc_h2_parse_destroy(struct vlc_h2_parser *p)
Definition: h2frame.c:1055
vlc_h2_conn_queue_prio
static int vlc_h2_conn_queue_prio(struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
Definition: h2conn.c:99
vlc_h2_stream_error
static int vlc_h2_stream_error(struct vlc_h2_parser *p, uint_fast32_t id, uint_fast32_t code)
Definition: h2frame.c:480
vlc_h2_stream::newer
struct vlc_h2_stream * newer
Next open stream in connection.
Definition: h2conn.c:76
pollfd::events
short events
Definition: vlc_fixups.h:420
VLC_H2_DEFAULT_MAX_FRAME
#define VLC_H2_DEFAULT_MAX_FRAME
Definition: h2frame.h:98
vlc_getaddrinfo_i11e
int vlc_getaddrinfo_i11e(const char *name, unsigned port, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:39
VLC_H2_FRAME_HEADERS
@ VLC_H2_FRAME_HEADERS
Definition: h2frame.c:94
vlc_h1_stream_wait
static struct vlc_http_msg * vlc_h1_stream_wait(struct vlc_http_stream *stream)
Definition: h1conn.c:170
vlc_http_can_read
static unsigned vlc_http_can_read(const char *buf, size_t len)
Definition: h1conn.c:39
vlc_thread_t
Thread handle.
Definition: vlc_threads.h:180
SetWBE
static void SetWBE(void *p, uint16_t w)
Writes 16 bits in network byte order.
Definition: vlc_common.h:1057
vlc_h2_parse
int vlc_h2_parse(struct vlc_h2_parser *p, struct vlc_h2_frame *f)
Definition: h2frame.c:1012
vlc_h2_frame_id
static uint_fast32_t vlc_h2_frame_id(const struct vlc_h2_frame *f)
Definition: h2frame.c:87
vlc_tls_Write
ssize_t vlc_tls_Write(vlc_tls_t *session, const void *buf, size_t len)
Sends data through a socket.
Definition: stream.c:94
vlc_h2_stream_write
static ssize_t vlc_h2_stream_write(struct vlc_http_stream *stream, const void *base, size_t length, bool eos)
Definition: h2conn.c:285
vlc_h2_conn::send_wait
vlc_cond_t send_wait
Definition: h2conn.c:62
vlc_h2_parse_error
static int vlc_h2_parse_error(struct vlc_h2_parser *p, uint_fast32_t code)
Definition: h2frame.c:474
vlc_h2_ping
static int vlc_h2_ping(void *ctx, uint_fast64_t opaque)
Reports a ping received from HTTP/2 peer.
Definition: h2conn.c:614
vlc_h2_conn::released
bool released
Connection released by owner.
Definition: h2conn.c:57
vlc_cleanup_pop
#define vlc_cleanup_pop()
Unregisters the last cancellation handler.
Definition: vlc_threads.h:1018
vlc_h2_parse_frame_goaway
static int vlc_h2_parse_frame_goaway(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 GOAWAY frame.
Definition: h2frame.c:827
CO
#define CO(c)
Definition: h2conn.c:45
POLLIN
#define POLLIN
Definition: vlc_fixups.h:414
VLC_H2_SETTING_MAX_HEADER_LIST_SIZE
@ VLC_H2_SETTING_MAX_HEADER_LIST_SIZE
Definition: h2frame.h:82
vlc_tls_Close
static void vlc_tls_Close(vlc_tls_t *session)
Closes a connection and its underlying resources.
Definition: vlc_tls.h:397
vlc_h2_parse_frame_ping
static int vlc_h2_parse_frame_ping(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 PING frame.
Definition: h2frame.c:796
vlc_http_stream
HTTP stream.
Definition: message.h:366
VLC_H2_SETTINGS_TIMEOUT
@ VLC_H2_SETTINGS_TIMEOUT
Definition: h2frame.h:62
VLC_H2_HEADERS_END_HEADERS
@ VLC_H2_HEADERS_END_HEADERS
Definition: h2frame.c:132
vlc_h2_frame_settings
struct vlc_h2_frame * vlc_h2_frame_settings(void)
Definition: h2frame.c:250
vlc_h2_stream
HTTP/2 stream.
Definition: h2conn.c:71
vlc_http_error
void *const vlc_http_error
Error pointer value.
Definition: message.c:57
vlc_h1_stream_fatal
static void * vlc_h1_stream_fatal(struct vlc_h1_conn *conn)
Definition: h1conn.c:126
hpack_decode
int hpack_decode(struct hpack_decoder *dec, const uint8_t *data, size_t length, char *headers[][2], unsigned max)
Definition: hpack.c:575
vlc_h2_setting
static void vlc_h2_setting(void *ctx, uint_fast16_t id, uint_fast32_t value)
Reports an HTTP/2 peer connection setting.
Definition: h2conn.c:585
container_of
#define container_of(ptr, type, member)
Definition: vlc_common.h:1140
VLC_H2_DATA_END_STREAM
@ VLC_H2_DATA_END_STREAM
Definition: h2frame.c:126
vlc_h2_stream::recv_wait
vlc_cond_t recv_wait
Definition: h2conn.c:87
vlc_https_chunked_write
ssize_t vlc_https_chunked_write(struct vlc_tls *tls, const void *base, size_t len, bool eos)
Definition: chunked.c:39
VLC_H2_DATA_PADDED
@ VLC_H2_DATA_PADDED
Definition: h2frame.c:127
vlc_h2_parse_failed
static int vlc_h2_parse_failed(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Definition: h2frame.c:1004
vlc_http_msg_headers
struct vlc_http_msg * vlc_http_msg_headers(const char *msg)
Parses an HTTP 1.1 message header.
Definition: message.c:366
vlc_http_conn_cbs
Definition: conn.h:33
vlc_restorecancel
void vlc_restorecancel(int state)
Restores the cancellation state.
Definition: thread.c:193
vlc_h2_stream::recv_hdr
struct vlc_http_msg * recv_hdr
Latest received headers (or NULL)
Definition: h2conn.c:82
vlc_h2_stream::send_cwnd
uint64_t send_cwnd
Send congestion window.
Definition: h2conn.c:89
vlc_h1_conn_release
static void vlc_h1_conn_release(struct vlc_http_conn *c)
Definition: h1conn.c:323
VLC_THREAD_PRIORITY_INPUT
#define VLC_THREAD_PRIORITY_INPUT
Definition: vlc_threads.h:208
VLC_H2_INIT_WINDOW
#define VLC_H2_INIT_WINDOW
Definition: h2frame.h:90
vlc_h2_stream::id
uint32_t id
Stream 31-bits identifier.
Definition: h2conn.c:77
vlc_h2_parse_preface
static int vlc_h2_parse_preface(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses the HTTP/2 connection preface.
Definition: h2frame.c:950
vlc_h2_stream_lock
static void vlc_h2_stream_lock(struct vlc_h2_stream *s)
Definition: h2conn.c:247
VLC_H2_HEADERS_PRIORITY
@ VLC_H2_HEADERS_PRIORITY
Definition: h2frame.c:134
vlc_h2_parse_frame_headers
static int vlc_h2_parse_frame_headers(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 HEADERS frame.
Definition: h2frame.c:628
vlc_h2_frame_size
size_t vlc_h2_frame_size(const struct vlc_h2_frame *f)
Definition: h2frame.c:72
vlc_http_msg_attach
void vlc_http_msg_attach(struct vlc_http_msg *m, struct vlc_http_stream *s)
Definition: message.c:259
vlc_h2_conn_callbacks
static const struct vlc_http_conn_cbs vlc_h2_conn_callbacks
Definition: h2conn.c:871
vlc_h2_parser::parser
vlc_h2_parser parser
Definition: h2frame.c:454
vlc_http_conn_release
static void vlc_http_conn_release(struct vlc_http_conn *conn)
Definition: conn.h:54
vlc_h2_parser_cbs::error
void(* error)(void *ctx, uint_fast32_t code)
Definition: h2frame.h:107
GetWBE
#define GetWBE(p)
Definition: vlc_common.h:1013
vlc_h2_parser_cbs::settings_done
int(* settings_done)(void *ctx)
Definition: h2frame.h:105
vlc_h2_parser_cbs::ping
int(* ping)(void *ctx, uint_fast64_t opaque)
Definition: h2frame.h:106
vlc_h2_setting_name
const char * vlc_h2_setting_name(uint_fast16_t id)
Definition: h2frame.c:319
vlc_h2_frame
Definition: h2frame.h:30
vlc_block.h
vlc_mutex_lock
void vlc_mutex_lock(vlc_mutex_t *mtx)
Acquires a mutex.
Definition: threads.c:158
vlc_http_conn::tls
struct vlc_tls * tls
Definition: conn.h:44
vlc_h2_frame_flags
static uint_fast8_t vlc_h2_frame_flags(const struct vlc_h2_frame *f)
Definition: h2frame.c:82
vlc_h2_stream_fatal
static int vlc_h2_stream_fatal(struct vlc_h2_stream *s, uint_fast32_t code)
Definition: h2conn.c:134
vlc_http_minor
static int vlc_http_minor(const char *msg)
Gets minor HTTP version.
Definition: h1conn.c:101
vlc_h2_frame_data
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_frame_goaway
struct vlc_h2_frame * vlc_h2_frame_goaway(uint_fast32_t last_stream_id, uint_fast32_t error_code)
Definition: h2frame.c:354
vlc_cond_t
Condition variable.
Definition: vlc_threads.h:349
vlc_h2_parser::rcwd_size
uint32_t rcwd_size
Definition: h2frame.c:465
vlc_h2_stream_unlock
static int vlc_h2_stream_unlock(struct vlc_h2_stream *s)
Definition: h2conn.c:256
VLC_H2_SETTINGS_ACK
@ VLC_H2_SETTINGS_ACK
Definition: h2frame.c:138
vlc_tls.h
vlc_h2_settings_done
static int vlc_h2_settings_done(void *ctx)
Reports end of HTTP/2 peer settings.
Definition: h2conn.c:606
vlc_h2_parser_cbs
Definition: h2frame.h:102
VLC_H2_MAX_HEADER_LIST
#define VLC_H2_MAX_HEADER_LIST
Definition: h2frame.h:92
vlc_h1_conn::conn
struct vlc_http_conn conn
Definition: h1conn.c:112
VLC_H2_FRAME_GOAWAY
@ VLC_H2_FRAME_GOAWAY
Definition: h2frame.c:100
vlc_h2_frame_headers
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
VLC_H2_MIN_MAX_FRAME
#define VLC_H2_MIN_MAX_FRAME
Definition: h2frame.h:97
vlc_h2_stream_lookup
static void * vlc_h2_stream_lookup(void *ctx, uint_fast32_t id)
Looks a stream up by ID.
Definition: h2conn.c:110
vlc_h2_stream_wake_up
static void vlc_h2_stream_wake_up(void *data)
Definition: h2conn.c:236
vlc_h2_parser_cbs::stream_window_update
void(* stream_window_update)(void *ctx, uint_fast32_t credit)
Definition: h2frame.h:119
VLC_H2_PUSH_PROMISE_END_HEADERS
@ VLC_H2_PUSH_PROMISE_END_HEADERS
Definition: h2frame.c:142
vlc_h2_conn::next_id
uint32_t next_id
Next free stream identifier.
Definition: h2conn.c:56
vlc_h2_conn::max_send_frame
uint32_t max_send_frame
Maximum sent frame size.
Definition: h2conn.c:59
vlc_h2_parse_frame_push_promise
static int vlc_h2_parse_frame_push_promise(struct vlc_h2_parser *p, struct vlc_h2_frame *f, size_t len, uint_fast32_t id)
Parses an HTTP/2 PUSH_PROMISE frame.
Definition: h2frame.c:760
vlc_h2_conn::conn
struct vlc_http_conn conn
Definition: h2conn.c:51
likely
#define likely(p)
Predicted true condition.
Definition: vlc_common.h:218
vlc_tls_operations::readv
ssize_t(* readv)(struct vlc_tls *, struct iovec *iov, unsigned len)
Callback for receiving data.
Definition: vlc_tls.h:93
vlc_interrupt_register
void vlc_interrupt_register(void(*cb)(void *), void *opaque)
Registers a custom interrupt handler.
Definition: interrupt.c:159
VLC_H2_DEFAULT_MAX_HEADER_TABLE
#define VLC_H2_DEFAULT_MAX_HEADER_TABLE
Definition: h2frame.h:95
vlc_h2_conn_destroy
static void vlc_h2_conn_destroy(struct vlc_h2_conn *conn)
Definition: h2conn.c:839
block_t::p_buffer
uint8_t * p_buffer
Payload start.
Definition: vlc_block.h:121
vlc_h2_output
Definition: h2output.c:47
vlc_http_err
void vlc_http_err(void *, const char *msg,...) VLC_FORMAT(2
vlc_h2_conn_release
static void vlc_h2_conn_release(struct vlc_http_conn *c)
Definition: h2conn.c:855
VLC_H2_SETTING_ENABLE_PUSH
@ VLC_H2_SETTING_ENABLE_PUSH
Definition: h2frame.h:78
vlc_h2_parser_cbs::stream_headers
void(* stream_headers)(void *ctx, unsigned count, const char *const headers[][2])
Definition: h2frame.h:114
vlc_h2_parse_init
struct vlc_h2_parser * vlc_h2_parse_init(void *ctx, const struct vlc_h2_parser_cbs *cbs)
Definition: h2frame.c:1032
vlc_cond_init
void vlc_cond_init(vlc_cond_t *cond)
Initializes a condition variable.
Definition: threads.c:234
VLC_H2_ENHANCE_YOUR_CALM
@ VLC_H2_ENHANCE_YOUR_CALM
Definition: h2frame.h:69
vlc_h2_parser_cbs::stream_error
int(* stream_error)(void *ctx, uint_fast32_t id, uint_fast32_t code)
Definition: h2frame.h:113
vlc_https_recv
static ssize_t vlc_https_recv(vlc_tls_t *tls, void *buf, size_t len)
Receives TLS data.
Definition: h2conn.c:708
VLC_H2_CONTINUATION_END_HEADERS
@ VLC_H2_CONTINUATION_END_HEADERS
Definition: h2frame.c:151
vlc_h2_parser::headers
struct vlc_h2_parser::@289 headers
vlc_http_msg_get_size
uintmax_t vlc_http_msg_get_size(const struct vlc_http_msg *m)
Gets HTTP payload length.
Definition: message.c:905
vlc_h2_frame::data
uint8_t data[]
Definition: h2frame.h:33
vlc_http_msg
Definition: message.c:42
block_Release
void block_Release(block_t *block)
Releases a block.
Definition: block.c:135
vlc_h1_stream_read
static block_t * vlc_h1_stream_read(struct vlc_http_stream *stream)
Definition: h1conn.c:247
vlc_h2_parser_cbs::reset
int(* reset)(void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
Definition: h2frame.h:108
vlc_join
void vlc_join(vlc_thread_t handle, void **result)
Waits for a thread to complete (if needed), then destroys it.
Definition: thread.c:151
vlc_mutex_unlock
void vlc_mutex_unlock(vlc_mutex_t *mtx)
Releases a mutex.
Definition: threads.c:209
vlc_h2_stream_open
static struct vlc_http_stream * vlc_h2_stream_open(struct vlc_http_conn *c, const struct vlc_http_msg *msg, bool has_data)
Creates a stream.
Definition: h2conn.c:514
vlc_h2_parsers
static const vlc_h2_parser vlc_h2_parsers[]
Definition: h2frame.c:936
vlc_h2_frame_window_update
struct vlc_h2_frame * vlc_h2_frame_window_update(uint_fast32_t stream_id, uint_fast32_t credit)
Definition: h2frame.c:368
h2frame.h
block_t
Definition: vlc_block.h:117
vlc_h1_stream_callbacks
static const struct vlc_http_stream_cbs vlc_h1_stream_callbacks
Definition: h1conn.c:302
vlc_tls::ops
const struct vlc_tls_operations * ops
Callbacks to operate on the stream.
Definition: vlc_tls.h:68
vlc_h2_parser::opaque
void * opaque
Definition: h2frame.c:451
VLC_H2_SETTING_MAX_FRAME_SIZE
@ VLC_H2_SETTING_MAX_FRAME_SIZE
Definition: h2frame.h:81
vlc_h2_conn::lock
vlc_mutex_t lock
State machine lock.
Definition: h2conn.c:64
vlc_h2_output_send
int vlc_h2_output_send(struct vlc_h2_output *out, struct vlc_h2_frame *f)
Definition: h2output.c:120
VLC_H2_STREAM_CLOSED
@ VLC_H2_STREAM_CLOSED
Definition: h2frame.h:63
VLC_H2_MAX_MAX_FRAME
#define VLC_H2_MAX_MAX_FRAME
Definition: h2frame.h:99
vlc_h2_reset
static int vlc_h2_reset(void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
Reports a remote HTTP/2 connection error.
Definition: h2conn.c:637
vlc_h1_conn::stream
struct vlc_http_stream stream
Definition: h1conn.c:113
vlc_h2_stream::older
struct vlc_h2_stream * older
Previous open stream in connection.
Definition: h2conn.c:75
vlc_h2_output_send_prio
int vlc_h2_output_send_prio(struct vlc_h2_output *out, struct vlc_h2_frame *f)
Definition: h2output.c:115
vlc_h2_output_destroy
void vlc_h2_output_destroy(struct vlc_h2_output *out)
Definition: h2output.c:331
VLC_H2_PUSH_PROMISE_PADDED
@ VLC_H2_PUSH_PROMISE_PADDED
Definition: h2frame.c:143
vlc_tls_Shutdown
static int vlc_tls_Shutdown(vlc_tls_t *tls, bool duplex)
Shuts a connection down.
Definition: vlc_tls.h:381
hpack_encode
size_t hpack_encode(uint8_t *restrict buf, size_t size, const char *const headers[][2], unsigned count)
Definition: hpackenc.c:154
mutex_cleanup_push
#define mutex_cleanup_push(lock)
Definition: vlc_threads.h:1053
p
#define p(t)
vlc_h2_conn::out
struct vlc_h2_output * out
Send thread.
Definition: h2conn.c:52
vlc_cancel
void vlc_cancel(vlc_thread_t thread_id)
Marks a thread as cancelled.
Definition: thread.c:167
vlc_h1_conn::proxy
bool proxy
Definition: h1conn.c:118