Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_http2_server.c File Reference
#include "nilorea/n_http2_server.h"
#include "nilorea/n_log.h"
#include <getopt.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for ex_http2_server.c:

Go to the source code of this file.

Data Structures

struct  PEER
struct  SEEN

Macros

#define RUNT(f)

Functions

int main (int argc, char **argv)
static int on_request (void *ud, N_H2_SERVER *srv, const N_H2_REQUEST *req)
static size_t out_count (const PEER *p, int type, size_t *total_payload)
static int out_find (const PEER *p, int type, size_t nth, N_H2_FRAME *out)
static void peer_frame (PEER *p, int type, int flags, uint32_t sid, const unsigned char *payload, size_t len)
static void peer_headers (PEER *p, uint32_t sid, const N_H2_HEADER *h, size_t n, int end_stream)
static void peer_prologue (PEER *p)
static void peer_put (PEER *p, const void *buf, size_t len)
static ssize_t peer_read (void *io, void *buf, size_t len)
static void peer_window_update (PEER *p, uint32_t sid, uint32_t inc)
static ssize_t peer_write (void *io, const void *buf, size_t len)
void process_args (int argc, char **argv)
static void test_callback_stop (void)
static void test_continuation (void)
static void test_dribbled_reads (void)
static void test_get (void)
static void test_guards (void)
static void test_handshake (void)
static void test_handshake_errors (void)
static void test_multiplex (void)
static void test_ping_goaway (void)
static void test_post_body (void)
static void test_rst_stream (void)
static void test_send_flow_control (void)
static void test_send_window_stall (void)

Variables

static int failures = 0

Data Structure Documentation

◆ PEER

struct PEER
Examples
ex_http2_server.c.

Definition at line 47 of file ex_http2_server.c.

Collaboration diagram for PEER:
Data Fields
size_t chunk
unsigned char in[65536]
size_t in_len
size_t in_off
unsigned char out[262144]
size_t out_len
int read_fail

◆ SEEN

struct SEEN
Examples
ex_http2_server.c.

Definition at line 171 of file ex_http2_server.c.

Collaboration diagram for SEEN:
Data Fields
char authority[128]
char body[4096]
size_t body_len
int calls
int expect_send_fail
char method[32]
char path[256]
unsigned char * reply
size_t reply_len
int reply_status
char scheme[16]
int stop_after

Macro Definition Documentation

◆ RUNT

#define RUNT ( f)
Value:
do { \
int before = failures; \
f(); \
if (failures != before) \
n_log(LOG_ERR, "%s: %d failure(s)", #f, failures - before); \
} while (0)
static int failures
Definition ex_atlas.c:51
#define LOG_ERR
error conditions
Definition n_log.h:100
Examples
ex_http2_server.c.

Referenced by main().

Function Documentation

◆ main()

◆ on_request()

◆ out_count()

size_t out_count ( const PEER * p,
int type,
size_t * total_payload )
static
Examples
ex_http2_server.c.

Definition at line 130 of file ex_http2_server.c.

References N_H2_FRAME::length, n_http2_frame_parse(), PEER::out, PEER::out_len, N_H2_FRAME::type, and type().

Referenced by test_callback_stop(), test_get(), test_handshake(), test_multiplex(), test_post_body(), test_send_flow_control(), and test_send_window_stall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ out_find()

int out_find ( const PEER * p,
int type,
size_t nth,
N_H2_FRAME * out )
static
Examples
ex_http2_server.c.

Definition at line 150 of file ex_http2_server.c.

References n_http2_frame_parse(), PEER::out, PEER::out_len, N_H2_FRAME::type, and type().

Referenced by test_get(), test_handshake(), test_multiplex(), and test_ping_goaway().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_frame()

void peer_frame ( PEER * p,
int type,
int flags,
uint32_t sid,
const unsigned char * payload,
size_t len )
static
Examples
ex_http2_server.c.

Definition at line 93 of file ex_http2_server.c.

References N_H2_FRAME_HEADER_LEN, n_http2_frame_build_header(), peer_put(), and type().

Referenced by peer_headers(), peer_prologue(), peer_window_update(), test_continuation(), test_handshake_errors(), test_ping_goaway(), test_post_body(), and test_rst_stream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_headers()

void peer_headers ( PEER * p,
uint32_t sid,
const N_H2_HEADER * h,
size_t n,
int end_stream )
static

< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete

< DATA/HEADERS: last frame of the stream

< HEADERS

Examples
ex_http2_server.c.

Definition at line 108 of file ex_http2_server.c.

References failures, N_H2_FLAG_END_HEADERS, N_H2_FLAG_END_STREAM, N_H2_HEADERS, n_http2_hpack_encode(), and peer_frame().

Referenced by test_callback_stop(), test_dribbled_reads(), test_get(), test_multiplex(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_prologue()

void peer_prologue ( PEER * p)
static

< SETTINGS

Examples
ex_http2_server.c.

Definition at line 102 of file ex_http2_server.c.

References N_H2_PREFACE, N_H2_SETTINGS, peer_frame(), and peer_put().

Referenced by test_callback_stop(), test_continuation(), test_dribbled_reads(), test_get(), test_handshake(), test_multiplex(), test_ping_goaway(), test_post_body(), test_rst_stream(), test_send_flow_control(), and test_send_window_stall().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_put()

void peer_put ( PEER * p,
const void * buf,
size_t len )
static
Examples
ex_http2_server.c.

Definition at line 83 of file ex_http2_server.c.

References failures, PEER::in, and PEER::in_len.

Referenced by peer_frame(), peer_prologue(), and test_handshake_errors().

Here is the caller graph for this function:

◆ peer_read()

◆ peer_window_update()

void peer_window_update ( PEER * p,
uint32_t sid,
uint32_t inc )
static

< WINDOW_UPDATE

Examples
ex_http2_server.c.

Definition at line 120 of file ex_http2_server.c.

References N_H2_WINDOW_UPDATE, and peer_frame().

Referenced by test_send_flow_control().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ peer_write()

ssize_t peer_write ( void * io,
const void * buf,
size_t len )
static

◆ process_args()

void process_args ( int argc,
char ** argv )

Definition at line 704 of file ex_http2_server.c.

References LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_NOTICE, LOG_NULL, and set_log_level().

Here is the call graph for this function:

◆ test_callback_stop()

void test_callback_stop ( void )
static

< GOAWAY

Examples
ex_http2_server.c.

Definition at line 624 of file ex_http2_server.c.

References SEEN::calls, failures, N_H2_GOAWAY, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), N_H2_HEADER::name, on_request(), out_count(), peer_headers(), peer_prologue(), peer_read(), peer_write(), SEEN::stop_after, and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_continuation()

void test_continuation ( void )
static

< HEADERS

< DATA/HEADERS: last frame of the stream

< CONTINUATION

< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete

< HEADERS

< DATA/HEADERS: last frame of the stream

< PING

< CONTINUATION

< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete

< HEADERS

< DATA/HEADERS: last frame of the stream

< CONTINUATION

< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete

Examples
ex_http2_server.c.

Definition at line 380 of file ex_http2_server.c.

References SEEN::calls, failures, N_H2_CONTINUATION, N_H2_FLAG_END_HEADERS, N_H2_FLAG_END_STREAM, N_H2_HEADERS, N_H2_PING, n_http2_hpack_encode(), n_http2_server_error(), n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), N_H2_HEADER::name, on_request(), SEEN::path, peer_frame(), peer_prologue(), peer_read(), peer_write(), and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_dribbled_reads()

void test_dribbled_reads ( void )
static
Examples
ex_http2_server.c.

Definition at line 655 of file ex_http2_server.c.

References SEEN::calls, PEER::chunk, failures, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), N_H2_HEADER::name, on_request(), SEEN::path, peer_headers(), peer_prologue(), peer_read(), peer_write(), and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_get()

void test_get ( void )
static

< HEADERS

< HEADERS/PUSH_PROMISE/CONTINUATION: header block complete

< DATA/HEADERS: last frame of the stream

< DATA

< DATA/HEADERS: last frame of the stream

< GOAWAY

Examples
ex_http2_server.c.

Definition at line 277 of file ex_http2_server.c.

References SEEN::authority, SEEN::body_len, SEEN::calls, failures, N_H2_FRAME::flags, N_H2_FRAME::length, SEEN::method, N_H2_DATA, N_H2_FLAG_END_HEADERS, N_H2_FLAG_END_STREAM, N_H2_GOAWAY, N_H2_HEADERS, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_request_count(), n_http2_server_run(), N_H2_HEADER::name, on_request(), out_count(), out_find(), SEEN::path, N_H2_FRAME::payload, peer_headers(), peer_prologue(), peer_read(), peer_write(), SEEN::reply, SEEN::reply_len, SEEN::scheme, N_H2_FRAME::stream_id, and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_guards()

void test_guards ( void )
static
Examples
ex_http2_server.c.

Definition at line 683 of file ex_http2_server.c.

References failures, n_http2_server_error(), n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_request_count(), n_http2_server_run(), peer_read(), peer_write(), and PEER::read_fail.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_handshake()

void test_handshake ( void )
static

< SETTINGS

< WINDOW_UPDATE

< SETTINGS

< SETTINGS

< SETTINGS/PING: acknowledgement

< SETTINGS

Examples
ex_http2_server.c.

Definition at line 216 of file ex_http2_server.c.

References failures, N_H2_FRAME::flags, N_H2_FRAME::length, N_H2_FLAG_ACK, N_H2_SETTINGS, N_H2_SETTINGS_INITIAL_WINDOW_SIZE, N_H2_WINDOW_UPDATE, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_settings_parse(), out_count(), out_find(), N_H2_FRAME::payload, peer_prologue(), peer_read(), and peer_write().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_handshake_errors()

void test_handshake_errors ( void )
static

< PING

Examples
ex_http2_server.c.

Definition at line 249 of file ex_http2_server.c.

References failures, N_H2_PING, N_H2_PREFACE, n_http2_server_error(), n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), peer_frame(), peer_put(), peer_read(), and peer_write().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_multiplex()

void test_multiplex ( void )
static

< HEADERS

< HEADERS

< HEADERS

< HEADERS

Examples
ex_http2_server.c.

Definition at line 442 of file ex_http2_server.c.

References SEEN::calls, failures, N_H2_HEADERS, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), N_H2_HEADER::name, on_request(), out_count(), out_find(), SEEN::path, peer_headers(), peer_prologue(), peer_read(), peer_write(), N_H2_FRAME::stream_id, and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_ping_goaway()

void test_ping_goaway ( void )
static

< PING

< GOAWAY

< PING

< SETTINGS/PING: acknowledgement

Examples
ex_http2_server.c.

Definition at line 480 of file ex_http2_server.c.

References SEEN::calls, failures, N_H2_FRAME::flags, N_H2_FRAME::length, N_H2_FLAG_ACK, N_H2_GOAWAY, N_H2_PING, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), on_request(), out_find(), N_H2_FRAME::payload, peer_frame(), peer_prologue(), peer_read(), and peer_write().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_post_body()

void test_post_body ( void )
static

◆ test_rst_stream()

void test_rst_stream ( void )
static

< stream cancelled

< RST_STREAM

< DATA

< DATA/HEADERS: last frame of the stream

Examples
ex_http2_server.c.

Definition at line 593 of file ex_http2_server.c.

References SEEN::calls, failures, N_H2_DATA, N_H2_ERR_CANCEL, N_H2_FLAG_END_STREAM, N_H2_RST_STREAM, n_http2_server_free(), n_http2_server_handshake(), n_http2_server_new(), n_http2_server_run(), N_H2_HEADER::name, on_request(), peer_frame(), peer_headers(), peer_prologue(), peer_read(), peer_write(), and N_H2_HEADER::value.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_send_flow_control()

void test_send_flow_control ( void )
static

◆ test_send_window_stall()

void test_send_window_stall ( void )
static

Variable Documentation

◆ failures

int failures = 0
static

Definition at line 40 of file ex_http2_server.c.