litespeed-quic/test/test_common.h

97 lines
2.4 KiB
C
Raw Normal View History

2017-09-22 21:00:03 +00:00
/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */
/*
* Test client's and server's common components.
*/
#ifndef TEST_COMMON_H
#define TEST_COMMON_H 1
#if __linux__
# include <linux/if.h> /* For IFNAMSIZ */
#endif
struct lsquic_engine;
struct lsquic_engine_settings;
struct lsquic_out_spec;
struct event_base;
struct event;
struct packets_in;
struct lsquic_conn;
struct prog;
enum sport_flags
{
#if LSQUIC_DONTFRAG_SUPPORTED
2017-09-22 21:00:03 +00:00
SPORT_DONT_FRAGMENT = (1 << 0),
#endif
2017-09-22 21:00:03 +00:00
SPORT_SET_SNDBUF = (1 << 1), /* SO_SNDBUF */
SPORT_SET_RCVBUF = (1 << 2), /* SO_RCVBUF */
SPORT_SERVER = (1 << 3),
};
struct service_port {
TAILQ_ENTRY(service_port) next_sport;
int fd;
#if __linux__
uint32_t n_dropped;
int drop_init;
char if_name[IFNAMSIZ];
#endif
struct event *ev;
struct lsquic_engine *engine;
void *conn_ctx;
char host[80];
struct sockaddr_storage sas;
struct packets_in *packs_in;
enum sport_flags sp_flags;
int sp_sndbuf; /* If SPORT_SET_SNDBUF is set */
int sp_rcvbuf; /* If SPORT_SET_RCVBUF is set */
struct prog *sp_prog;
};
TAILQ_HEAD(sport_head, service_port);
struct service_port *
sport_new (const char *optarg, struct prog *);
void
sport_destroy (struct service_port *);
int
sport_init_server (struct service_port *, struct lsquic_engine *,
struct event_base *);
int
sport_init_client (struct service_port *, struct lsquic_engine *,
struct event_base *);
int
sport_packets_out (void *ctx, const struct lsquic_out_spec *, unsigned count);
int
set_engine_option (struct lsquic_engine_settings *,
int *version_cleared, const char *name_value);
struct packout_buf;
struct packout_buf_allocator
{
unsigned n_out, /* Number of buffers outstanding */
max; /* Maximum outstanding. Zero mean no limit */
SLIST_HEAD(, packout_buf) free_packout_bufs;
};
void
pba_init (struct packout_buf_allocator *, unsigned max);
void *
pba_allocate (void *packout_buf_allocator, size_t);
void
pba_release (void *packout_buf_allocator, void *obj);
void
pba_cleanup (struct packout_buf_allocator *);
#endif