prog.h revision fb3e20e0
17d09751dSDmitri Tikhonov/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov/*
350aadb33SDmitri Tikhonov * prog.h -- common setup and options for QUIC program
450aadb33SDmitri Tikhonov */
550aadb33SDmitri Tikhonov
650aadb33SDmitri Tikhonov#ifndef PROG_H
750aadb33SDmitri Tikhonov#define PROG_H 1
850aadb33SDmitri Tikhonov
95392f7a3SLiteSpeed Tech#include "test_config.h"
105392f7a3SLiteSpeed Tech
1150aadb33SDmitri Tikhonovstruct event;
1250aadb33SDmitri Tikhonovstruct event_base;
1350aadb33SDmitri Tikhonovstruct lsquic_hash;
1450aadb33SDmitri Tikhonovstruct sport_head;
155392f7a3SLiteSpeed Techstruct ssl_ctx_st;
1650aadb33SDmitri Tikhonov
1750aadb33SDmitri Tikhonovstruct prog
1850aadb33SDmitri Tikhonov{
1950aadb33SDmitri Tikhonov    struct packout_buf_allocator    prog_pba;
2050aadb33SDmitri Tikhonov    struct lsquic_engine_settings   prog_settings;
2150aadb33SDmitri Tikhonov    struct lsquic_engine_api        prog_api;
2250aadb33SDmitri Tikhonov    unsigned                        prog_engine_flags;
2350aadb33SDmitri Tikhonov    struct service_port             prog_dummy_sport;   /* Use for options */
2450aadb33SDmitri Tikhonov    unsigned                        prog_packout_max;
2550aadb33SDmitri Tikhonov    unsigned short                  prog_max_packet_size;
2650aadb33SDmitri Tikhonov    int                             prog_version_cleared;
276aba801dSDmitri Tikhonov    unsigned long                   prog_read_count;
285392f7a3SLiteSpeed Tech#if HAVE_SENDMMSG
295392f7a3SLiteSpeed Tech    int                             prog_use_sendmmsg;
305392f7a3SLiteSpeed Tech#endif
315392f7a3SLiteSpeed Tech#if HAVE_RECVMMSG
325392f7a3SLiteSpeed Tech    int                             prog_use_recvmmsg;
335392f7a3SLiteSpeed Tech#endif
345392f7a3SLiteSpeed Tech    int                             prog_use_stock_pmi;
3550aadb33SDmitri Tikhonov    struct event_base              *prog_eb;
3650aadb33SDmitri Tikhonov    struct event                   *prog_timer,
37c44946ecSDmitri Tikhonov                                   *prog_send,
3850aadb33SDmitri Tikhonov                                   *prog_usr1;
395392f7a3SLiteSpeed Tech    struct event                   *prog_usr2;
405392f7a3SLiteSpeed Tech    struct ssl_ctx_st              *prog_ssl_ctx;
415392f7a3SLiteSpeed Tech    struct lsquic_hash             *prog_certs;
425392f7a3SLiteSpeed Tech    struct event                   *prog_event_sni;
435392f7a3SLiteSpeed Tech    char                           *prog_susp_sni;
4450aadb33SDmitri Tikhonov    struct sport_head              *prog_sports;
4550aadb33SDmitri Tikhonov    struct lsquic_engine           *prog_engine;
4650aadb33SDmitri Tikhonov    const char                     *prog_hostname;
4707354a9aSDmitri Tikhonov    int                             prog_ipver;     /* 0, 4, or 6 */
485392f7a3SLiteSpeed Tech    const char                     *prog_keylog_dir;
495392f7a3SLiteSpeed Tech    enum {
505392f7a3SLiteSpeed Tech        PROG_FLAG_COOLDOWN  = 1 << 0,
515392f7a3SLiteSpeed Tech#if LSQUIC_PREFERRED_ADDR
525392f7a3SLiteSpeed Tech        PROG_SEARCH_ADDRS   = 1 << 1,
535392f7a3SLiteSpeed Tech#endif
545392f7a3SLiteSpeed Tech    }                               prog_flags;
5550aadb33SDmitri Tikhonov};
5650aadb33SDmitri Tikhonov
57fb3e20e0SDmitri Tikhonovint
5850aadb33SDmitri Tikhonovprog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *,
5950aadb33SDmitri Tikhonov                    const struct lsquic_stream_if *, void *stream_if_ctx);
6050aadb33SDmitri Tikhonov
615392f7a3SLiteSpeed Tech#if HAVE_SENDMMSG
625392f7a3SLiteSpeed Tech#   define SENDMMSG_FLAG "g"
635392f7a3SLiteSpeed Tech#else
645392f7a3SLiteSpeed Tech#   define SENDMMSG_FLAG ""
655392f7a3SLiteSpeed Tech#endif
665392f7a3SLiteSpeed Tech#if HAVE_RECVMMSG
675392f7a3SLiteSpeed Tech#   define RECVMMSG_FLAG "j"
685392f7a3SLiteSpeed Tech#else
695392f7a3SLiteSpeed Tech#   define RECVMMSG_FLAG ""
705392f7a3SLiteSpeed Tech#endif
715392f7a3SLiteSpeed Tech
72e0197994SDmitri Tikhonov#if LSQUIC_DONTFRAG_SUPPORTED
73e0197994SDmitri Tikhonov#   define IP_DONTFRAG_FLAG "D"
74e0197994SDmitri Tikhonov#else
75e0197994SDmitri Tikhonov#   define IP_DONTFRAG_FLAG ""
76e0197994SDmitri Tikhonov#endif
77e0197994SDmitri Tikhonov
785392f7a3SLiteSpeed Tech#define PROG_OPTS "i:km:c:y:L:l:o:H:s:S:Y:z:G:W" RECVMMSG_FLAG SENDMMSG_FLAG \
795392f7a3SLiteSpeed Tech                                                            IP_DONTFRAG_FLAG
8050aadb33SDmitri Tikhonov
8150aadb33SDmitri Tikhonov/* Returns:
8250aadb33SDmitri Tikhonov *  0   Applied
8350aadb33SDmitri Tikhonov *  1   Not applicable
8450aadb33SDmitri Tikhonov * -1   Error
8550aadb33SDmitri Tikhonov */
8650aadb33SDmitri Tikhonovint
8750aadb33SDmitri Tikhonovprog_set_opt (struct prog *, int opt, const char *arg);
8850aadb33SDmitri Tikhonov
8950aadb33SDmitri Tikhonovstruct event_base *
9050aadb33SDmitri Tikhonovprog_eb (struct prog *);
9150aadb33SDmitri Tikhonov
9250aadb33SDmitri Tikhonovint
9350aadb33SDmitri Tikhonovprog_run (struct prog *);
9450aadb33SDmitri Tikhonov
9550aadb33SDmitri Tikhonovvoid
9650aadb33SDmitri Tikhonovprog_cleanup (struct prog *);
9750aadb33SDmitri Tikhonov
9850aadb33SDmitri Tikhonovvoid
9950aadb33SDmitri Tikhonovprog_stop (struct prog *);
10050aadb33SDmitri Tikhonov
10150aadb33SDmitri Tikhonovint
10250aadb33SDmitri Tikhonovprog_prep (struct prog *);
10350aadb33SDmitri Tikhonov
10450aadb33SDmitri Tikhonovint
1058ca33e0eSDmitri Tikhonovprog_connect (struct prog *, unsigned char *, size_t);
10650aadb33SDmitri Tikhonov
10750aadb33SDmitri Tikhonovvoid
10850aadb33SDmitri Tikhonovprog_print_common_options (const struct prog *, FILE *);
10950aadb33SDmitri Tikhonov
11050aadb33SDmitri Tikhonovint
11150aadb33SDmitri Tikhonovprog_is_stopped (void);
11250aadb33SDmitri Tikhonov
113e8bd737dSDmitri Tikhonovvoid
114e8bd737dSDmitri Tikhonovprog_process_conns (struct prog *);
115e8bd737dSDmitri Tikhonov
116c44946ecSDmitri Tikhonovvoid
117c44946ecSDmitri Tikhonovprog_sport_cant_send (struct prog *, int fd);
118c44946ecSDmitri Tikhonov
11950aadb33SDmitri Tikhonov#endif
120