VLC 4.0.0-dev
Loading...
Searching...
No Matches
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.
 
static int vlc_h2_stream_error (void *ctx, uint_fast32_t id, uint_fast32_t code)
 Reports a local stream error.
 
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.
 
static int vlc_h2_stream_data (void *ctx, struct vlc_h2_frame *f)
 Reports received stream data.
 
static void vlc_h2_stream_end (void *ctx)
 Reports received end of stream.
 
static int vlc_h2_stream_reset (void *ctx, uint_fast32_t code)
 Reports remote stream error.
 
static void vlc_h2_stream_window_update (void *ctx, uint_fast32_t credit)
 Reports remote window size increments.
 
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.
 
static void vlc_h2_stream_close (struct vlc_http_stream *stream, bool aborted)
 Terminates a stream.
 
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.
 
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.
 
static int vlc_h2_settings_done (void *ctx)
 Reports end of HTTP/2 peer settings.
 
static int vlc_h2_ping (void *ctx, uint_fast64_t opaque)
 Reports a ping received from HTTP/2 peer.
 
static void vlc_h2_error (void *ctx, uint_fast32_t code)
 Reports a local HTTP/2 connection failure.
 
static int vlc_h2_reset (void *ctx, uint_fast32_t last_seq, uint_fast32_t code)
 Reports a remote HTTP/2 connection error.
 
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.
 
static struct vlc_h2_framevlc_h2_frame_recv (struct vlc_tls *tls)
 Receives an HTTP/2 frame through TLS.
 
static void cleanup_parser (void *data)
 
static void * vlc_h2_recv_thread (void *data)
 HTTP/2 receive thread.
 
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.
 
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()

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

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

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

◆ 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
cthe HTTP connection to initialize the stream from
msgHTTP message headers (including response status or request)
has_datawhether the HTTP request will have a request payload
Returns
an HTTP stream, or NULL on error

References vlc_http_stream::cbs, CO, vlc_h2_conn::conn, vlc_h2_stream::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 
)
static

◆ vlc_h2_stream_unlock()

static int vlc_h2_stream_unlock ( struct vlc_h2_stream s)
static

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

◆ vlc_h2_stream_write()

◆ 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:
=
{
}
static void vlc_h2_conn_release(struct vlc_http_conn *c)
Definition h2conn.c:852
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:509

Referenced by vlc_h2_conn_create().

◆ vlc_h2_parser_callbacks

const struct vlc_h2_parser_cbs vlc_h2_parser_callbacks
static
Initial value:
=
{
}
vlc_h2_error
Definition h2frame.h:57
vlc_h2_setting
Definition h2frame.h:76
static int vlc_h2_stream_error(void *ctx, uint_fast32_t id, uint_fast32_t code)
Reports a local stream error.
Definition h2conn.c:123
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:632
static void * vlc_h2_stream_lookup(void *ctx, uint_fast32_t id)
Looks a stream up by ID.
Definition h2conn.c:112
static int vlc_h2_stream_data(void *ctx, struct vlc_h2_frame *f)
Reports received stream data.
Definition h2conn.c:171
static void vlc_h2_window_update(void *ctx, uint_fast32_t credit)
Definition h2conn.c:666
static void vlc_h2_window_status(void *ctx, uint32_t *restrict rcwd)
Definition h2conn.c:654
static int vlc_h2_ping(void *ctx, uint_fast64_t opaque)
Reports a ping received from HTTP/2 peer.
Definition h2conn.c:609
static void vlc_h2_stream_headers(void *ctx, unsigned count, const char *const hdrs[][2])
Reports received stream headers.
Definition h2conn.c:144
static int vlc_h2_stream_reset(void *ctx, uint_fast32_t code)
Reports remote stream error.
Definition h2conn.c:208
static void vlc_h2_stream_window_update(void *ctx, uint_fast32_t credit)
Reports remote window size increments.
Definition h2conn.c:222
static void vlc_h2_stream_end(void *ctx)
Reports received end of stream.
Definition h2conn.c:197
static int vlc_h2_settings_done(void *ctx)
Reports end of HTTP/2 peer settings.
Definition h2conn.c:601

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
static
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:282
static struct vlc_http_msg * vlc_h2_stream_wait(struct vlc_http_stream *stream)
Definition h2conn.c:263
static void vlc_h2_stream_close(struct vlc_http_stream *stream, bool aborted)
Terminates a stream.
Definition h2conn.c:445
static block_t * vlc_h2_stream_read(struct vlc_http_stream *stream)
Receives stream data.
Definition h2conn.c:378

Referenced by vlc_h2_stream_open().