VLC  4.0.0-dev
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_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)
 

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

static void vlc_h2_initial_window_update ( struct vlc_h2_conn conn,
uint_fast32_t  value 
)
static

◆ 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

◆ 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,
bool  has_data 
)
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::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()

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

static void vlc_h2_stream_window_update ( void *  ctx,
uint_fast32_t  credit 
)
static

◆ vlc_h2_stream_write()

static ssize_t vlc_h2_stream_write ( struct vlc_http_stream stream,
const void *  base,
size_t  length,
bool  eos 
)
static

◆ vlc_h2_window_status()

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

◆ vlc_h2_window_update()

static void vlc_h2_window_update ( void *  ctx,
uint_fast32_t  credit 
)
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, 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
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: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_h2_stream_wait
static struct vlc_http_msg * vlc_h2_stream_wait(struct vlc_http_stream *stream)
Definition: h2conn.c:262
vlc_h2_window_update
static void vlc_h2_window_update(void *ctx, uint_fast32_t credit)
Definition: h2conn.c:671
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_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_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
vlc_h2_window_status
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition: h2conn.c:659
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_h2_stream_end
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition: h2conn.c:196
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
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_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_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
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_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_conn_release
static void vlc_h2_conn_release(struct vlc_http_conn *c)
Definition: h2conn.c:855
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_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