prog.h revision 9a690580
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 const char *prog_keylog_dir; 49 enum { 50 PROG_FLAG_COOLDOWN = 1 << 0, 51#if LSQUIC_PREFERRED_ADDR 52 PROG_SEARCH_ADDRS = 1 << 1, 53#endif 54 } prog_flags; 55}; 56 57void 58prog_init (struct prog *, unsigned lsquic_engine_flags, struct sport_head *, 59 const struct lsquic_stream_if *, void *stream_if_ctx); 60 61#if HAVE_SENDMMSG 62# define SENDMMSG_FLAG "g" 63#else 64# define SENDMMSG_FLAG "" 65#endif 66#if HAVE_RECVMMSG 67# define RECVMMSG_FLAG "j" 68#else 69# define RECVMMSG_FLAG "" 70#endif 71 72#if LSQUIC_DONTFRAG_SUPPORTED 73# define IP_DONTFRAG_FLAG "D" 74#else 75# define IP_DONTFRAG_FLAG "" 76#endif 77 78#define PROG_OPTS "i:km:c:y:L:l:o:H:s:S:Y:z:G:W" RECVMMSG_FLAG SENDMMSG_FLAG \ 79 IP_DONTFRAG_FLAG 80 81/* Returns: 82 * 0 Applied 83 * 1 Not applicable 84 * -1 Error 85 */ 86int 87prog_set_opt (struct prog *, int opt, const char *arg); 88 89struct event_base * 90prog_eb (struct prog *); 91 92int 93prog_run (struct prog *); 94 95void 96prog_cleanup (struct prog *); 97 98void 99prog_stop (struct prog *); 100 101int 102prog_prep (struct prog *); 103 104int 105prog_connect (struct prog *, unsigned char *, size_t); 106 107void 108prog_print_common_options (const struct prog *, FILE *); 109 110int 111prog_is_stopped (void); 112 113void 114prog_process_conns (struct prog *); 115 116void 117prog_sport_cant_send (struct prog *, int fd); 118 119#endif 120