VLC  4.0.0-dev
h2conn.c File Reference
Include dependency graph for h2conn.c:

Data Structures

struct  vlc_h2_conn
 HTTP/2 connection. More...
struct  vlc_h2_stream
 HTTP/2 stream. More...


#define CO(c)   ((c)->opaque)
#define SO(s)   CO((s)->conn)


static void vlc_h2_conn_destroy (struct vlc_h2_conn *conn)
static int vlc_h2_conn_queue (struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
static int vlc_h2_conn_queue_prio (struct vlc_h2_conn *conn, struct vlc_h2_frame *f)
static void * vlc_h2_stream_lookup (void *ctx, uint_fast32_t id)
 Looks a stream up by ID. More...
static int vlc_h2_stream_error (void *ctx, uint_fast32_t id, uint_fast32_t code)
 Reports a local stream error. More...
static int vlc_h2_stream_fatal (struct vlc_h2_stream *s, uint_fast32_t code)
static void vlc_h2_stream_headers (void *ctx, unsigned count, const char *const hdrs[][2])
 Reports received stream headers. More...
static int vlc_h2_stream_data (void *ctx, struct vlc_h2_frame *f)
 Reports received stream data. More...
static void vlc_h2_stream_end (void *ctx)
 Reports received end of stream. More...
static int vlc_h2_stream_reset (void *ctx, uint_fast32_t code)
 Reports remote stream error. More...
static void vlc_h2_stream_window_update (void *ctx, uint_fast32_t credit)
 Reports remote window size increments. More...
static void vlc_h2_stream_wake_up (void *data)
static void vlc_h2_stream_lock (struct vlc_h2_stream *s)
static int vlc_h2_stream_unlock (struct vlc_h2_stream *s)
static struct vlc_http_msgvlc_h2_stream_wait (struct vlc_http_stream *stream)
static ssize_t vlc_h2_stream_write (struct vlc_http_stream *stream, const void *base, size_t length, bool eos)
static block_tvlc_h2_stream_read (struct vlc_http_stream *stream)
 Receives stream data. More...
static void vlc_h2_stream_close (struct vlc_http_stream *stream, bool aborted)
 Terminates a stream. More...
static struct vlc_http_streamvlc_h2_stream_open (struct vlc_http_conn *c, const struct vlc_http_msg *msg, bool has_data)
 Creates a stream. More...
static void vlc_h2_initial_window_update (struct vlc_h2_conn *conn, uint_fast32_t value)
static void vlc_h2_setting (void *ctx, uint_fast16_t id, uint_fast32_t value)
 Reports an HTTP/2 peer connection setting. More...
static int vlc_h2_settings_done (void *ctx)
 Reports end of HTTP/2 peer settings. More...
static int vlc_h2_ping (void *ctx, uint_fast64_t opaque)
 Reports a ping received from HTTP/2 peer. More...
static void vlc_h2_error (void *ctx, uint_fast32_t code)
 Reports a local HTTP/2 connection failure. More...
static int vlc_h2_reset (void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
 Reports a remote HTTP/2 connection error. More...
static void vlc_h2_window_status (void *ctx, uint32_t *restrict rcwd)
static void vlc_h2_window_update (void *ctx, uint_fast32_t credit)
static ssize_t vlc_https_recv (vlc_tls_t *tls, void *buf, size_t len)
 Receives TLS data. More...
static struct vlc_h2_framevlc_h2_frame_recv (struct vlc_tls *tls)
 Receives an HTTP/2 frame through TLS. More...
static void cleanup_parser (void *data)
static void * vlc_h2_recv_thread (void *data)
 HTTP/2 receive thread. More...
static void vlc_h2_conn_release (struct vlc_http_conn *c)
struct vlc_http_connvlc_h2_conn_create (void *ctx, struct vlc_tls *tls)


static const struct vlc_http_stream_cbs vlc_h2_stream_callbacks
static const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
 HTTP/2 frames parser callbacks table. More...
static const struct vlc_http_conn_cbs vlc_h2_conn_callbacks

Macro Definition Documentation

◆ CO

#define CO (   c)    ((c)->opaque)

◆ SO

#define SO (   s)    CO((s)->conn)

Function Documentation

◆ cleanup_parser()

static void cleanup_parser ( void *  data)

◆ vlc_h2_conn_destroy()

◆ vlc_h2_conn_queue()

◆ vlc_h2_conn_queue_prio()

static int vlc_h2_conn_queue_prio ( struct vlc_h2_conn conn,
struct vlc_h2_frame f 

◆ vlc_h2_conn_release()

static void vlc_h2_conn_release ( struct vlc_http_conn c)

◆ vlc_h2_error()

static void vlc_h2_error ( void *  ctx,
uint_fast32_t  code 

◆ vlc_h2_frame_recv()

static struct vlc_h2_frame* vlc_h2_frame_recv ( struct vlc_tls tls)

Receives an HTTP/2 frame through TLS.

This function allocates memory for and receives a whole HTTP/2 frame from a TLS session.

The caller must "own" the read side of the TLS session.

This is a blocking function and may be a thread cancellation point.
a frame or NULL if the connection failed

References vlc_h2_frame::data, vlc_h2_frame::next, unlikely, vlc_cleanup_pop, vlc_cleanup_push, and vlc_https_recv().

Referenced by vlc_h2_recv_thread().

◆ vlc_h2_initial_window_update()

static void vlc_h2_initial_window_update ( struct vlc_h2_conn conn,
uint_fast32_t  value 

◆ vlc_h2_ping()

static int vlc_h2_ping ( void *  ctx,
uint_fast64_t  opaque 

Reports a ping received from HTTP/2 peer.

References vlc_h2_conn::conn, vlc_h2_conn::opaque, vlc_h2_conn_queue_prio(), and vlc_h2_frame_pong().

◆ vlc_h2_recv_thread()

◆ vlc_h2_reset()

static int vlc_h2_reset ( void *  ctx,
uint_fast32_t  last_seq,
uint_fast32_t  code 

◆ vlc_h2_setting()

static void vlc_h2_setting ( void *  ctx,
uint_fast16_t  id,
uint_fast32_t  value 

◆ vlc_h2_settings_done()

static int vlc_h2_settings_done ( void *  ctx)

Reports end of HTTP/2 peer settings.

References vlc_h2_conn::conn, vlc_h2_conn_queue(), and vlc_h2_frame_settings_ack().

◆ vlc_h2_stream_close()

static void vlc_h2_stream_close ( struct vlc_http_stream stream,
bool  aborted 

Terminates a stream.

Sends an HTTP/2 stream reset, removes the stream from the HTTP/2 connection and deletes any stream resource.

◆ vlc_h2_stream_data()

◆ vlc_h2_stream_end()

static void vlc_h2_stream_end ( void *  ctx)

◆ vlc_h2_stream_error()

static int vlc_h2_stream_error ( void *  ctx,
uint_fast32_t  id,
uint_fast32_t  code 

◆ vlc_h2_stream_fatal()

static int vlc_h2_stream_fatal ( struct vlc_h2_stream s,
uint_fast32_t  code 

◆ vlc_h2_stream_headers()

static void vlc_h2_stream_headers ( void *  ctx,
unsigned  count,
const char *const  hdrs[][2] 

◆ vlc_h2_stream_lock()

◆ vlc_h2_stream_lookup()

static void* vlc_h2_stream_lookup ( void *  ctx,
uint_fast32_t  id 

Looks a stream up by ID.

References vlc_h2_conn::conn.

◆ 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.

Allocates a locally-initiated stream identifier on an HTTP/2 connection and queue stream headers for sending.

Headers are sent asynchronously. To obtain the result and answer from the other end, use vlc_http_stream_recv_headers().

msgHTTP message headers (including response status or request)
an HTTP stream, or NULL on error

References vlc_http_stream::cbs, CO, vlc_h2_stream::conn, vlc_h2_conn::conn, container_of, vlc_h2_stream::id, vlc_h2_conn::init_send_cwnd, vlc_h2_conn::lock, vlc_h2_stream::newer, vlc_h2_conn::next_id, vlc_h2_stream::older, vlc_h2_stream::recv_cwnd, vlc_h2_stream::recv_end, vlc_h2_stream::recv_err, vlc_h2_stream::recv_hdr, vlc_h2_stream::recv_head, vlc_h2_stream::recv_tailp, vlc_h2_stream::recv_wait, vlc_h2_conn::released, vlc_h2_stream::send_cwnd, vlc_h2_stream::send_wait, vlc_h2_stream::stream, vlc_h2_conn::streams, unlikely, vlc_cond_init(), vlc_h2_conn_queue(), VLC_H2_INIT_WINDOW, vlc_h2_stream_callbacks, vlc_http_dbg(), vlc_http_msg_h2_frame(), vlc_mutex_lock(), and vlc_mutex_unlock().

◆ vlc_h2_stream_read()

◆ vlc_h2_stream_reset()

static int vlc_h2_stream_reset ( void *  ctx,
uint_fast32_t  code 

◆ vlc_h2_stream_unlock()

static int vlc_h2_stream_unlock ( struct vlc_h2_stream s)

◆ vlc_h2_stream_wait()

◆ vlc_h2_stream_wake_up()

◆ vlc_h2_stream_window_update()

static void vlc_h2_stream_window_update ( void *  ctx,
uint_fast32_t  credit 

◆ vlc_h2_stream_write()

◆ vlc_h2_window_status()

static void vlc_h2_window_status ( void *  ctx,
uint32_t *restrict  rcwd 

◆ vlc_h2_window_update()

static void vlc_h2_window_update ( void *  ctx,
uint_fast32_t  credit 

◆ vlc_https_recv()

static ssize_t vlc_https_recv ( vlc_tls_t tls,
void *  buf,
size_t  len 

Receives TLS data.

Receives bytes from the peer through a TLS session.

This may be a cancellation point. The caller is responsible for serializing reads on a given connection.

References count, pollfd::events, pollfd::fd, vlc_tls::ops, poll(), POLLIN, vlc_tls_operations::readv, vlc_restorecancel(), vlc_savecancel(), and vlc_tls_GetPollFD().

Referenced by vlc_h2_frame_recv().

Variable Documentation

◆ vlc_h2_conn_callbacks

const struct vlc_http_conn_cbs vlc_h2_conn_callbacks
Initial value:
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:505
static void vlc_h2_conn_release(struct vlc_http_conn *c)
Definition: h2conn.c:848

◆ vlc_h2_parser_callbacks

const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
Initial value:
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
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:628
static int vlc_h2_stream_data(void *ctx, struct vlc_h2_frame *f)
Reports received stream data.
Definition: h2conn.c:169
static void vlc_h2_window_update(void *ctx, uint_fast32_t credit)
Definition: h2conn.c:662
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition: h2conn.c:650
static int vlc_h2_ping(void *ctx, uint_fast64_t opaque)
Reports a ping received from HTTP/2 peer.
Definition: h2conn.c:605
static void * vlc_h2_stream_lookup(void *ctx, uint_fast32_t id)
Looks a stream up by ID.
Definition: h2conn.c:110
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:576
static void vlc_h2_error(void *ctx, uint_fast32_t code)
Reports a local HTTP/2 connection failure.
Definition: h2conn.c:613
static void vlc_h2_stream_headers(void *ctx, unsigned count, const char *const hdrs[][2])
Reports received stream headers.
Definition: h2conn.c:142
static int vlc_h2_stream_reset(void *ctx, uint_fast32_t code)
Reports remote stream error.
Definition: h2conn.c:206
static void vlc_h2_stream_window_update(void *ctx, uint_fast32_t credit)
Reports remote window size increments.
Definition: h2conn.c:220
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition: h2conn.c:195
static int vlc_h2_settings_done(void *ctx)
Reports end of HTTP/2 peer settings.
Definition: h2conn.c:597

HTTP/2 frames parser callbacks table.

Referenced by vlc_h2_recv_thread().

◆ vlc_h2_stream_callbacks

const struct vlc_http_stream_cbs vlc_h2_stream_callbacks
Initial value:
static ssize_t vlc_h2_stream_write(struct vlc_http_stream *stream, const void *base, size_t length, bool eos)
Definition: h2conn.c:280
static block_t * vlc_h2_stream_read(struct vlc_http_stream *stream)
Receives stream data.
Definition: h2conn.c:376
static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool aborted)
Terminates a stream.
Definition: h2conn.c:443
static struct vlc_http_msg * vlc_h2_stream_wait(struct vlc_http_stream *stream)
Definition: h2conn.c:261

Referenced by vlc_h2_stream_open().