VLC  3.0.15
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 
30 struct vlc_h2_frame
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_DEFAULT_MAX_FRAME 16384
98 
100 struct vlc_h2_parser_cbs
101 {
102  void (*setting)(void *ctx, uint_fast16_t id, uint_fast32_t value);
103  int (*settings_done)(void *ctx);
104  int (*ping)(void *ctx, uint_fast64_t opaque);
105  void (*error)(void *ctx, uint_fast32_t code);
106  int (*reset)(void *ctx, uint_fast32_t last_seq, uint_fast32_t code);
107  void (*window_status)(void *ctx, uint32_t *rcwd);
108 
109  void *(*stream_lookup)(void *ctx, uint_fast32_t id);
110  int (*stream_error)(void *ctx, uint_fast32_t id, uint_fast32_t code);
111  void (*stream_headers)(void *ctx, unsigned count,
112  const char *const headers[][2]);
113  int (*stream_data)(void *ctx, struct vlc_h2_frame *f);
114  void (*stream_end)(void *ctx);
115  int (*stream_reset)(void *ctx, uint_fast32_t code);
116 };
117 
118 struct vlc_h2_parser *vlc_h2_parse_init(void *ctx,
119  const struct vlc_h2_parser_cbs *cbs);
120 int vlc_h2_parse(struct vlc_h2_parser *, struct vlc_h2_frame *);
121 void vlc_h2_parse_destroy(struct vlc_h2_parser *);
122 
123 #define VLC_H2_MAX_HEADERS 255
124 
125 const uint8_t *vlc_h2_frame_data_get(const struct vlc_h2_frame *f,
126  size_t *restrict len);
127 #define vlc_h2_frame_data_get(f, l) \
128  _Generic((f), \
129  const struct vlc_h2_frame *: (vlc_h2_frame_data_get)(f, l), \
130  struct vlc_h2_frame *: (uint8_t *)(vlc_h2_frame_data_get)(f, l))
131 
132 /** @} */
hpack_decode_init
struct hpack_decoder * hpack_decode_init(size_t header_table_size)
Definition: hpack.c:71
vlc_h1_stream_conn
static struct vlc_h1_conn * vlc_h1_stream_conn(struct vlc_http_stream *stream)
Definition: h1conn.c:137
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
Definition: h2frame.h:64
vlc_h2_conn_create
struct vlc_http_conn * vlc_h2_conn_create(void *ctx, struct vlc_tls *tls)
Definition: h2conn.c:719
count
size_t count
Definition: core.c:461
vlc_h2_conn::thread
vlc_thread_t thread
Receive thread.
Definition: h2conn.c:60
VLC_H2_HEADERS_PRIORITY
Definition: h2frame.c:134
vlc_h2_conn_queue
static int vlc_h2_conn_queue(struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
Definition: h2conn.c:85
VLC_H2_INTERNAL_ERROR
Definition: h2frame.h:59
GetDWBE
#define GetDWBE(p)
Definition: vlc_common.h:821
vlc_h2_parser::sid
uint32_t sid
Definition: h2frame.c:458
VLC_H2_PROTOCOL_ERROR
Definition: h2frame.h:58
VLC_H2_FRAME_PRIORITY
Definition: h2frame.c:95
vlc_h2_stream_reset
static int vlc_h2_stream_reset(void *ctx, uint_fast32_t code)
Reports remote stream error.
Definition: h2conn.c:199
vlc_restorecancel
void vlc_restorecancel(int state)
Restores the cancellation state.
Definition: thread.c:323
vlc_h2_stream_close
static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool aborted)
Terminates a stream.
Definition: h2conn.c:338
vlc_h2_stream_read
static block_t * vlc_h2_stream_read(struct vlc_http_stream *stream)
Receives stream data.
Definition: h2conn.c:270
vlc_cleanup_push
#define vlc_cleanup_push(routine, arg)
Registers a thread cancellation handler.
Definition: vlc_threads.h:975
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:952
VLC_H2_SETTINGS_ACK
Definition: h2frame.c:138
vlc_h2_parser::len
size_t len
Definition: h2frame.c:460
VLC_H2_MAX_STREAMS
#define VLC_H2_MAX_STREAMS
Definition: h2frame.h:88
VLC_H2_MAX_FRAME
#define VLC_H2_MAX_FRAME
Definition: h2frame.h:90
vlc_tls_Write
ssize_t vlc_tls_Write(vlc_tls_t *session, const void *buf, size_t len)
Sends data through a socket.
Definition: tls.c:268
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:871
hpack_decoder
Definition: hpack.c:63
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:238
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:390
vlc_http_stream::cbs
const struct vlc_http_stream_cbs * cbs
Definition: message.h:342
VLC_H2_COMPRESSION_ERROR
Definition: h2frame.h:66
VLC_H2_CANCEL
Definition: h2frame.h:65
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:153
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:900
vlc_h2_stream::recv_head
struct vlc_h2_frame * recv_head
Earliest pending received buffer.
Definition: h2conn.c:80
vlc_h2_parser_cbs::stream_data
int(* stream_data)(void *ctx, struct vlc_h2_frame *f)
Definition: h2frame.h:112
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:81
vlc_h2_type_name
static const char * vlc_h2_type_name(uint_fast8_t type)
Definition: h2frame.c:105
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:968
vlc_h2_parser_cbs::window_status
void(* window_status)(void *ctx, uint32_t *rcwd)
Definition: h2frame.h:106
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:101
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:270
vlc_h2_parser_cbs::stream_end
void(* stream_end)(void *ctx)
Definition: h2frame.h:113
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:113
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:116
vlc_interrupt.h
vlc_h2_conn::opaque
void * opaque
Definition: h2conn.c:53
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:452
vlc_http_conn::cbs
const struct vlc_http_conn_cbs * cbs
Definition: conn.h:41
pollfd::fd
int fd
Definition: vlc_fixups.h:416
vlc_h2_error
static void vlc_h2_error(void *ctx, uint_fast32_t code)
Reports a local HTTP/2 connection failure.
Definition: h2conn.c:479
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: tls.c:227
VLC_H2_NO_ERROR
Definition: h2frame.h:57
vlc_h1_conn_callbacks
static const struct vlc_http_conn_cbs vlc_h1_conn_callbacks
Definition: h1conn.c:316
vlc_http_msg_destroy
void vlc_http_msg_destroy(struct vlc_http_msg *m)
Destroys an HTTP message.
Definition: message.c:191
vlc_h1_conn::released
bool released
Definition: h1conn.c:116
vlc_h2_frame_data_get
#define vlc_h2_frame_data_get(f, l)
Definition: h2frame.h:126
vlc_h2_recv_thread
static void * vlc_h2_recv_thread(void *data)
HTTP/2 receive thread.
Definition: h2conn.c:639
vlc_h1_conn::content_length
uintmax_t content_length
Definition: h1conn.c:113
CO
#define CO(conn)
Definition: h1conn.c:121
VLC_H2_SETTING_MAX_CONCURRENT_STREAMS
Definition: h2frame.h:78
VLC_H2_HTTP_1_1_REQUIRED
Definition: h2frame.h:70
VLC_H2_DEFAULT_INIT_WINDOW
#define VLC_H2_DEFAULT_INIT_WINDOW
Definition: h2frame.h:95
pollfd
Definition: vlc_fixups.h:414
h2output.h
VLC_H2_FRAME_SIZE_ERROR
Definition: h2frame.h:63
vlc_h2_stream_callbacks
static const struct vlc_http_stream_cbs vlc_h2_stream_callbacks
Definition: h2conn.c:381
vlc_h1_conn_create
struct vlc_http_conn * vlc_h1_conn_create(void *ctx, vlc_tls_t *tls, bool proxy)
Definition: h1conn.c:322
vlc_h2_stream::interrupted
bool interrupted
Definition: h2conn.c:74
vlc_tls
Transport layer socket.
Definition: vlc_tls.h:43
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:602
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
block_heap_Alloc
block_t * block_heap_Alloc(void *addr, size_t length)
Wraps heap in a block.
Definition: block.c:253
cleanup_parser
static void cleanup_parser(void *data)
Definition: h2conn.c:633
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:76
vlc_https_headers_recv
static char * vlc_https_headers_recv(struct vlc_tls *tls, size_t *restrict lenp)
Receives HTTP headers.
Definition: h1conn.c:56
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_cond_broadcast
void vlc_cond_broadcast(vlc_cond_t *p_condvar)
Wakes up all threads waiting on a condition variable.
Definition: thread.c:262
vlc_h2_parser::cbs
const struct vlc_h2_parser_cbs * cbs
Definition: h2frame.c:452
vlc_getaddrinfo_i11e
int vlc_getaddrinfo_i11e(const char *name, unsigned port, const struct addrinfo *hints, struct addrinfo **res)
Definition: getaddrinfo.c:38
vlc_h2_stream::recv_cwnd
size_t recv_cwnd
Free space in receive congestion window.
Definition: h2conn.c:79
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:263
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_http_next_token
const char * vlc_http_next_token(const char *value)
Finds next token.
Definition: message.c:595
vlc_h2_window_status
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition: h2conn.c:516
VLC_H2_INADEQUATE_SECURITY
Definition: h2frame.h:69
vlc_h2_output_create
struct vlc_h2_output * vlc_h2_output_create(struct vlc_tls *tls, bool client)
Definition: h2output.c:300
VLC_H2_FRAME_GOAWAY
Definition: h2frame.c:100
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, struct vlc_http_conn **restrict connp)
Sends an HTTP/1.x request through a new connection.
Definition: h1conn.c:339
vlc_h2_parser::buf
uint8_t * buf
Definition: h2frame.c:461
VLC_H2_CONNECT_ERROR
Definition: h2frame.h:67
vlc_cond_signal
void vlc_cond_signal(vlc_cond_t *p_condvar)
Wakes up one thread waiting on a condition variable.
Definition: thread.c:256
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:134
vlc_cond_t
pthread_cond_t vlc_cond_t
Condition variable.
Definition: vlc_threads.h:279
vlc_h1_conn::active
bool active
Definition: h1conn.c:115
vlc_http_stream_cbs
HTTP stream callbacks.
Definition: message.h:332
vlc_http_conn
Definition: conn.h:39
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
conn.h
VLC_H2_MAX_HEADERS
#define VLC_H2_MAX_HEADERS
Definition: h2frame.h:122
VLC_H2_FRAME_RST_STREAM
Definition: h2frame.c:96
vlc_h1_conn_destroy
static void vlc_h1_conn_destroy(struct vlc_h1_conn *conn)
Definition: h1conn.c:292
vlc_h1_stream_open
static struct vlc_http_stream * vlc_h1_stream_open(struct vlc_http_conn *c, const struct vlc_http_msg *req)
Definition: h1conn.c:142
vlc_h2_error
vlc_h2_error
Definition: h2frame.h:56
vlc_h2_frame_ping
struct vlc_h2_frame * vlc_h2_frame_ping(uint64_t opaque)
Definition: h2frame.c:336
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:66
VLC_H2_FRAME_HEADERS
Definition: h2frame.c:94
VLC_H2_MAX_HEADER_TABLE
#define VLC_H2_MAX_HEADER_TABLE
Definition: h2frame.h:87
VLC_H2_FRAME_CONTINUATION
Definition: h2frame.c:102
vlc_h2_frame::next
struct vlc_h2_frame * next
Definition: h2frame.h:31
SetDWBE
static void SetDWBE(void *p, uint32_t dw)
Writes 32 bits in network byte order.
Definition: vlc_common.h:871
vlc_interrupt_register
void vlc_interrupt_register(void(*cb)(void *), void *opaque)
Registers a custom interrupt handler.
Definition: interrupt.c:160
VLC_H2_SETTING_INITIAL_WINDOW_SIZE
Definition: h2frame.h:79
vlc_h2_parser_cbs::stream_reset
int(* stream_reset)(void *ctx, uint_fast32_t code)
Definition: h2frame.h:114
vlc_h2_parser_callbacks
static const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
HTTP/2 frames parser callbacks table.
Definition: h2conn.c:529
vlc_h2_stream::recv_end
bool recv_end
End-of-stream flag.
Definition: h2conn.c:75
vlc_interrupt_unregister
int vlc_interrupt_unregister(void)
Definition: interrupt.c:167
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:118
vlc_h2_stream_end
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition: h2conn.c:188
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_tls::readv
ssize_t(* readv)(struct vlc_tls *, struct iovec *, unsigned)
Definition: vlc_tls.h:46
vlc_h1_conn
Definition: h1conn.c:109
vlc_h1_conn::connection_close
bool connection_close
Definition: h1conn.c:114
hpack.h
VLC_H2_PUSH_PROMISE_PADDED
Definition: h2frame.c:143
VLC_H2_FLOW_CONTROL_ERROR
Definition: h2frame.h:60
vlc_h2_stream_data
static int vlc_h2_stream_data(void *ctx, struct vlc_h2_frame *f)
Reports received stream data.
Definition: h2conn.c:161
hpack_decode_destroy
void hpack_decode_destroy(struct hpack_decoder *dec)
Definition: hpack.c:84
vlc_h2_setting
vlc_h2_setting
Definition: h2frame.h:75
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:69
VLC_H2_PING_ACK
Definition: h2frame.c:147
vlc_h2_stream::stream
struct vlc_http_stream stream
Base class.
Definition: h2conn.c:68
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:662
VLC_H2_SETTING_HEADER_TABLE_SIZE
Definition: h2frame.h:76
VLC_H2_FRAME_PING
Definition: h2frame.c:99
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:1036
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:91
vlc_tls_GetFD
static int vlc_tls_GetFD(vlc_tls_t *tls)
Definition: vlc_tls.h:187
block_Release
static void block_Release(block_t *block)
Releases a block.
Definition: vlc_block.h:181
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:71
pollfd::events
short events
Definition: vlc_fixups.h:417
VLC_H2_DEFAULT_MAX_FRAME
#define VLC_H2_DEFAULT_MAX_FRAME
Definition: h2frame.h:96
vlc_h1_stream_wait
static struct vlc_http_msg * vlc_h1_stream_wait(struct vlc_http_stream *stream)
Definition: h1conn.c:169
vlc_http_can_read
static unsigned vlc_http_can_read(const char *buf, size_t len)
Definition: h1conn.c:38
vlc_thread_t
Thread handle.
Definition: vlc_threads.h:252
SetWBE
static void SetWBE(void *p, uint16_t w)
Writes 16 bits in network byte order.
Definition: vlc_common.h:864
vlc_h2_parse
int vlc_h2_parse(struct vlc_h2_parser *p, struct vlc_h2_frame *f)
Definition: h2frame.c:993
vlc_h2_frame_id
static uint_fast32_t vlc_h2_frame_id(const struct vlc_h2_frame *f)
Definition: h2frame.c:87
vlc_mutex_init
void vlc_mutex_init(vlc_mutex_t *p_mutex)
Initializes a fast mutex.
Definition: thread.c:85
VLC_H2_FRAME_PUSH_PROMISE
Definition: h2frame.c:98
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:471
VLC_H2_FRAME_WINDOW_UPDATE
Definition: h2frame.c:101
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:983
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:411
VLC_H2_SETTING_MAX_HEADER_LIST_SIZE
Definition: h2frame.h:81
vlc_tls_Close
static void vlc_tls_Close(vlc_tls_t *session)
Closes a connection and its underlying resources.
Definition: vlc_tls.h:257
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_h2_stream_open
static struct vlc_http_stream * vlc_h2_stream_open(struct vlc_http_conn *c, const struct vlc_http_msg *msg)
Creates a stream.
Definition: h2conn.c:400
vlc_http_stream
HTTP stream.
Definition: message.h:340
VLC_H2_SETTINGS_TIMEOUT
Definition: h2frame.h:61
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:66
vlc_http_error
void *const vlc_http_error
Error pointer value.
Definition: message.c:55
vlc_h1_stream_fatal
static void * vlc_h1_stream_fatal(struct vlc_h1_conn *conn)
Definition: h1conn.c:125
hpack_decode
int hpack_decode(struct hpack_decoder *dec, const uint8_t *data, size_t length, char *headers[][2], unsigned max)
Definition: hpack.c:574
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:454
container_of
#define container_of(ptr, type, member)
Definition: vlc_common.h:944
vlc_h2_stream::recv_wait
vlc_cond_t recv_wait
Definition: h2conn.c:82
VLC_H2_CONTINUATION_END_HEADERS
Definition: h2frame.c:151
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:985
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:331
vlc_http_conn_cbs
Definition: conn.h:32
vlc_h2_stream::recv_hdr
struct vlc_http_msg * recv_hdr
Latest received headers (or NULL)
Definition: h2conn.c:77
likely
#define likely(p)
Definition: vlc_common.h:113
vlc_h2_parser::headers
struct vlc_h2_parser::@225 headers
vlc_savecancel
int vlc_savecancel(void)
Disables thread cancellation.
Definition: thread.c:313
vlc_h1_conn_release
static void vlc_h1_conn_release(struct vlc_http_conn *c)
Definition: h1conn.c:305
VLC_H2_HEADERS_END_HEADERS
Definition: h2frame.c:132
VLC_THREAD_PRIORITY_INPUT
#define VLC_THREAD_PRIORITY_INPUT
Definition: vlc_threads.h:322
VLC_H2_INIT_WINDOW
#define VLC_H2_INIT_WINDOW
Definition: h2frame.h:89
vlc_h2_stream::id
uint32_t id
Stream 31-bits identifier.
Definition: h2conn.c:72
VLC_H2_FRAME_SETTINGS
Definition: h2frame.c:97
vlc_mutex_t
pthread_mutex_t vlc_mutex_t
Mutex.
Definition: vlc_threads.h:267
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:931
vlc_h2_stream_lock
static void vlc_h2_stream_lock(struct vlc_h2_stream *s)
Definition: h2conn.c:223
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:257
vlc_h2_conn_callbacks
static const struct vlc_http_conn_cbs vlc_h2_conn_callbacks
Definition: h2conn.c:713
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:51
vlc_h2_parser_cbs::error
void(* error)(void *ctx, uint_fast32_t code)
Definition: h2frame.h:104
GetWBE
#define GetWBE(p)
Definition: vlc_common.h:820
vlc_h2_parser_cbs::settings_done
int(* settings_done)(void *ctx)
Definition: h2frame.h:102
vlc_h2_parser_cbs::ping
int(* ping)(void *ctx, uint_fast64_t opaque)
Definition: h2frame.h:103
vlc_h2_setting_name
const char * vlc_h2_setting_name(uint_fast16_t id)
Definition: h2frame.c:319
vlc_h2_frame
Definition: h2frame.h:29
vlc_block.h
vlc_http_conn::tls
struct vlc_tls * tls
Definition: conn.h:42
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:126
vlc_cond_destroy
void vlc_cond_destroy(vlc_cond_t *p_condvar)
Deinitializes a condition variable.
Definition: thread.c:228
vlc_http_minor
static int vlc_http_minor(const char *msg)
Gets minor HTTP version.
Definition: h1conn.c:100
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_init
void vlc_cond_init(vlc_cond_t *p_condvar)
Initializes a condition variable.
Definition: thread.c:216
vlc_cond_wait
void vlc_cond_wait(vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex)
Waits on a condition variable.
Definition: thread.c:267
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:232
VLC_H2_DATA_PADDED
Definition: h2frame.c:127
vlc_mutex_destroy
void vlc_mutex_destroy(vlc_mutex_t *p_mutex)
Deinitializes a mutex.
Definition: thread.c:110
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:463
vlc_h2_parser_cbs
Definition: h2frame.h:99
VLC_H2_MAX_HEADER_LIST
#define VLC_H2_MAX_HEADER_LIST
Definition: h2frame.h:91
VLC_H2_FRAME_DATA
Definition: h2frame.c:93
vlc_tls_SocketOpenAddrInfo
vlc_tls_t * vlc_tls_SocketOpenAddrInfo(const struct addrinfo *restrict info, bool defer_connect)
Definition: tls.c:563
vlc_h1_conn::conn
struct vlc_http_conn conn
Definition: h1conn.c:111
vlc_mutex_unlock
void vlc_mutex_unlock(vlc_mutex_t *p_mutex)
Releases a mutex.
Definition: thread.c:138
VLC_H2_DATA_END_STREAM
Definition: h2frame.c:126
unlikely
#define unlikely(p)
Definition: vlc_common.h:114
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
block_Alloc
block_t * block_Alloc(size_t size)
Allocates a block.
Definition: block.c:119
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:102
vlc_h2_stream_wake_up
static void vlc_h2_stream_wake_up(void *data)
Definition: h2conn.c:212
vlc_strerror_c
const char * vlc_strerror_c(int errnum)
Definition: error.c:34
vlc_h2_conn::next_id
uint32_t next_id
Next free stream identifier.
Definition: h2conn.c:56
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_PUSH_PROMISE_END_HEADERS
Definition: h2frame.c:142
vlc_cancel
void vlc_cancel(vlc_thread_t thread_id)
Marks a thread as cancelled.
Definition: thread.c:297
vlc_h2_conn::conn
struct vlc_http_conn conn
Definition: h2conn.c:51
VLC_H2_DEFAULT_MAX_HEADER_TABLE
#define VLC_H2_DEFAULT_MAX_HEADER_TABLE
Definition: h2frame.h:94
vlc_h2_conn_destroy
static void vlc_h2_conn_destroy(struct vlc_h2_conn *conn)
Definition: h2conn.c:680
block_t::p_buffer
uint8_t * p_buffer
Payload start.
Definition: vlc_block.h:115
vlc_h2_output
Definition: h2output.c:46
vlc_tls_SessionDelete
void vlc_tls_SessionDelete(vlc_tls_t *session)
Destroys a TLS session down.
Definition: tls.c:154
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:697
VLC_H2_SETTING_ENABLE_PUSH
Definition: h2frame.h:77
VLC_H2_HEADERS_END_STREAM
Definition: h2frame.c:131
vlc_h2_parser_cbs::stream_headers
void(* stream_headers)(void *ctx, unsigned count, const char *const headers[][2])
Definition: h2frame.h:110
vlc_h2_parse_init
struct vlc_h2_parser * vlc_h2_parse_init(void *ctx, const struct vlc_h2_parser_cbs *cbs)
Definition: h2frame.c:1013
VLC_H2_ENHANCE_YOUR_CALM
Definition: h2frame.h:68
vlc_h2_parser_cbs::stream_error
int(* stream_error)(void *ctx, uint_fast32_t id, uint_fast32_t code)
Definition: h2frame.h:109
vlc_https_recv
static ssize_t vlc_https_recv(vlc_tls_t *tls, void *buf, size_t len)
Receives TLS data.
Definition: h2conn.c:552
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:858
vlc_h2_frame::data
uint8_t data[]
Definition: h2frame.h:32
vlc_http_msg
Definition: message.c:40
vlc_h1_stream_read
static block_t * vlc_h1_stream_read(struct vlc_http_stream *stream)
Definition: h1conn.c:230
vlc_h2_parser_cbs::reset
int(* reset)(void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
Definition: h2frame.h:105
vlc_http_stream_open
static struct vlc_http_stream * vlc_http_stream_open(struct vlc_http_conn *conn, const struct vlc_http_msg *m)
Definition: conn.h:46
vlc_mutex_lock
void vlc_mutex_lock(vlc_mutex_t *p_mutex)
Acquires a mutex.
Definition: thread.c:123
vlc_h2_parsers
static const vlc_h2_parser vlc_h2_parsers[]
Definition: h2frame.c:917
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
vlc_http_msg_format
char * vlc_http_msg_format(const struct vlc_http_msg *m, size_t *restrict lenp, bool proxied)
Formats an HTTP 1.1 message header.
Definition: message.c:299
h2frame.h
block_t
Definition: vlc_block.h:111
vlc_h1_stream_callbacks
static const struct vlc_http_stream_cbs vlc_h1_stream_callbacks
Definition: h1conn.c:285
vlc_h2_parser::opaque
void * opaque
Definition: h2frame.c:451
VLC_H2_SETTING_MAX_FRAME_SIZE
Definition: h2frame.h:80
VLC_H2_HEADERS_PADDED
Definition: h2frame.c:133
vlc_h2_conn::lock
vlc_mutex_t lock
State machine lock.
Definition: h2conn.c:59
vlc_h2_output_send
int vlc_h2_output_send(struct vlc_h2_output *out, struct vlc_h2_frame *f)
Definition: h2output.c:119
VLC_H2_STREAM_CLOSED
Definition: h2frame.h:62
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:494
vlc_h1_conn::stream
struct vlc_http_stream stream
Definition: h1conn.c:112
vlc_h2_stream::older
struct vlc_h2_stream * older
Previous open stream in connection.
Definition: h2conn.c:70
vlc_h2_output_send_prio
int vlc_h2_output_send_prio(struct vlc_h2_output *out, struct vlc_h2_frame *f)
Definition: h2output.c:114
vlc_h2_output_destroy
void vlc_h2_output_destroy(struct vlc_h2_output *out)
Definition: h2output.c:331
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:270
vlc_tls_Shutdown
static int vlc_tls_Shutdown(vlc_tls_t *tls, bool duplex)
Shuts a connection down.
Definition: vlc_tls.h:241
hpack_encode
size_t hpack_encode(uint8_t *restrict buf, size_t size, const char *const headers[][2], unsigned count)
Definition: hpackenc.c:153
mutex_cleanup_push
#define mutex_cleanup_push(lock)
Definition: vlc_threads.h:1013
p
#define p(t)
vlc_h2_conn::out
struct vlc_h2_output * out
Send thread.
Definition: h2conn.c:52
vlc_h1_conn::proxy
bool proxy
Definition: h1conn.c:117