VLC  3.0.15
Data Structures | Macros | Functions | Variables
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...
 

Macros

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

Functions

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_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 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)
 Creates a stream. More...
 
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 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)
 

Variables

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)
static

◆ vlc_h2_conn_destroy()

static void vlc_h2_conn_destroy ( struct vlc_h2_conn conn)
static

◆ vlc_h2_conn_queue()

static int vlc_h2_conn_queue ( struct vlc_h2_conn conn,
struct vlc_h2_frame f 
)
static

◆ vlc_h2_conn_queue_prio()

static int vlc_h2_conn_queue_prio ( struct vlc_h2_conn conn,
struct vlc_h2_frame f 
)
static

◆ vlc_h2_conn_release()

static void vlc_h2_conn_release ( struct vlc_http_conn c)
static

◆ vlc_h2_error()

static void vlc_h2_error ( void *  ctx,
uint_fast32_t  code 
)
static

◆ vlc_h2_frame_recv()

static struct vlc_h2_frame* vlc_h2_frame_recv ( struct vlc_tls tls)
static

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.

Note
This is a blocking function and may be a thread cancellation point.
Returns
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_ping()

static int vlc_h2_ping ( void *  ctx,
uint_fast64_t  opaque 
)
static

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()

static void* vlc_h2_recv_thread ( void *  data)
static

◆ vlc_h2_reset()

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

◆ vlc_h2_setting()

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

Reports an HTTP/2 peer connection setting.

References CO, vlc_h2_conn::conn, vlc_h2_setting_name(), and vlc_http_dbg().

◆ vlc_h2_settings_done()

static int vlc_h2_settings_done ( void *  ctx)
static

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 
)
static

◆ vlc_h2_stream_data()

static int vlc_h2_stream_data ( void *  ctx,
struct vlc_h2_frame f 
)
static

◆ vlc_h2_stream_end()

static void vlc_h2_stream_end ( void *  ctx)
static

◆ vlc_h2_stream_error()

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

◆ vlc_h2_stream_fatal()

static int vlc_h2_stream_fatal ( struct vlc_h2_stream s,
uint_fast32_t  code 
)
static

◆ vlc_h2_stream_headers()

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

◆ vlc_h2_stream_lock()

static void vlc_h2_stream_lock ( struct vlc_h2_stream s)
static

◆ vlc_h2_stream_lookup()

static void* vlc_h2_stream_lookup ( void *  ctx,
uint_fast32_t  id 
)
static

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 
)
static

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().

Parameters
msgHTTP message headers (including response status or request)
Returns
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::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::stream, vlc_h2_conn::streams, unlikely, vlc_cond_destroy(), 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()

static block_t* vlc_h2_stream_read ( struct vlc_http_stream stream)
static

◆ vlc_h2_stream_reset()

static int vlc_h2_stream_reset ( void *  ctx,
uint_fast32_t  code 
)
static

◆ vlc_h2_stream_unlock()

static int vlc_h2_stream_unlock ( struct vlc_h2_stream s)
static

◆ vlc_h2_stream_wait()

static struct vlc_http_msg* vlc_h2_stream_wait ( struct vlc_http_stream stream)
static

◆ vlc_h2_stream_wake_up()

static void vlc_h2_stream_wake_up ( void *  data)
static

◆ vlc_h2_window_status()

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

◆ vlc_https_recv()

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

Receives TLS data.

Receives bytes from the peer through a TLS session.

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

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

Referenced by vlc_h2_frame_recv().

Variable Documentation

◆ vlc_h2_conn_callbacks

const struct vlc_http_conn_cbs vlc_h2_conn_callbacks
static
Initial value:

Referenced by vlc_h2_conn_create().

◆ vlc_h2_parser_callbacks

const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
static

◆ vlc_h2_stream_callbacks

const struct vlc_http_stream_cbs vlc_h2_stream_callbacks
static
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_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_h2_stream_wait
static struct vlc_http_msg * vlc_h2_stream_wait(struct vlc_http_stream *stream)
Definition: h2conn.c:238
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_error
static void vlc_h2_error(void *ctx, uint_fast32_t code)
Reports a local HTTP/2 connection failure.
Definition: h2conn.c:479
vlc_h2_window_status
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition: h2conn.c:516
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_h2_stream_end
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition: h2conn.c:188
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
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_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_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
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_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_conn_release
static void vlc_h2_conn_release(struct vlc_http_conn *c)
Definition: h2conn.c:697
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