prog.h revision 65113787
1/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
2/*
3 * prog.h -- common setup and options for QUIC program
4 */
5
6#ifndef PROG_H
7#define PROG_H 1
8
9#include "test_config.h"
10
11struct event;
12struct event_base;
13struct lsquic_hash;
14struct sport_head;
15struct ssl_ctx_st;
16
17struct prog
18{
19    struct packout_buf_allocator    prog_pba;
20    struct lsquic_engine_settings   prog_settings;
21    struct lsquic_engine_api        prog_api;
22    unsigned                        prog_engine_flags;
23    struct service_port             prog_dummy_sport;   /* Use for options */
24    unsigned                        prog_packout_max;
25    unsigned short                  prog_max_packet_size;
26    int                             prog_version_cleared;
27    unsigned long                   prog_read_count;
28#if HAVE_SENDMMSG
29    int                             prog_use_sendmmsg;
30#endif
31#if HAVE_RECVMMSG
32    int                             prog_use_recvmmsg;
33#endif
34    int                             prog_use_stock_pmi;
35    struct event_base              *prog_eb;
36    struct event                   *prog_timer,
37                                   *prog_send,
38                                   *prog_usr1;
39    struct event                   *prog_usr2;
40    struct ssl_ctx_st              *prog_ssl_ctx;
41    struct lsquic_hash             *prog_certs;
42    struct event                   *prog_event_sni;
43    char                           *prog_susp_sni;
44    struct sport_head              *prog_sports;
45    struct lsquic_engine           *prog_engine;
46    const char                     *prog_hostname;
47    int                             prog_ipver;     /* 0, 4, or 6 */
48    enum {
49        PROG_FLAG_COOLDOWN  = 1 << 0,
50#if LSQUIC_PREFERRED_ADDR
51        PROG_SEARCH_ADDRS   = 1 << 1,
52#endif
53    }                               prog_flags;
54};
55
56int
57prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
58                    const struct lsquic_stream_if *, void *stream_if_ctx);
59
60#if HAVE_SENDMMSG
61#   define SENDMMSG_FLAG "g"
62#else
63#   define SENDMMSG_FLAG ""
64#endif
65#if HAVE_RECVMMSG
66#   define RECVMMSG_FLAG "j"
67#else
68#   define RECVMMSG_FLAG ""
69#endif
70
71#if LSQUIC_DONTFRAG_SUPPORTED
72#   define IP_DONTFRAG_FLAG "D"
73#else
74#   define IP_DONTFRAG_FLAG ""
75#endif
76
77#define PROG_OPTS "i:km:c:y:L:l:o:H:s:S:Y:z:G:W" RECVMMSG_FLAG SENDMMSG_FLAG \
78                                                            IP_DONTFRAG_FLAG
79
80/* Returns:
81 *  0   Applied
82 *  1   Not applicable
83 * -1   Error
84 */
85int
86prog_set_opt (struct prog *, int opt, const char *arg);
87
88struct event_base *
89prog_eb (struct prog *);
90
91int
92prog_run (struct prog *);
93
94void
95prog_cleanup (struct prog *);
96
97void
98prog_stop (struct prog *);
99
100int
101prog_prep (struct prog *);
102
103int
104prog_connect (struct prog *, unsigned char *, size_t);
105
106void
107prog_print_common_options (const struct prog *, FILE *);
108
109int
110prog_is_stopped (void);
111
112void
113prog_process_conns (struct prog *);
114
115void
116prog_sport_cant_send (struct prog *, int fd);
117
118#endif
119