LCOV - code coverage report
Current view: top level - waltz/quic/tests - fd_quic_test_helpers.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 1 0.0 %
Date: 2025-09-17 04:38:03 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_waltz_quic_tests_fd_quic_helpers_h
       2             : #define HEADER_fd_src_waltz_quic_tests_fd_quic_helpers_h
       3             : 
       4             : #include "../fd_quic.h"
       5             : #include "../../aio/fd_aio_pcapng.h"
       6             : #include "../../udpsock/fd_udpsock.h"
       7             : #include "../../tls/test_tls_helper.h"
       8             : #include "../../../ballet/txn/fd_txn.h" /* FD_TXN_MTU */
       9             : 
      10             : #include <stdio.h>
      11             : 
      12             : /* Common helpers for QUIC tests.  The tests using these gain the
      13             :    following command-line options:
      14             : 
      15             :      --pcap <path>   Append test traffic to pcapng 1.0 at given file
      16             :                      path (encryption secrets included) */
      17             : 
      18             : /* fd_quic_virtual_pair_t is used to connect two local QUICs via
      19             :    direct fd_aio.  Optionally supports packet capture. */
      20             : 
      21             : struct fd_quic_virtual_pair {
      22             :   fd_quic_t * quic_a;
      23             :   fd_quic_t * quic_b;
      24             : 
      25             :   /* aio_{a2b,b2a} point to the first hop of each aio chain */
      26             :   fd_aio_t const * aio_a2b;
      27             :   fd_aio_t const * aio_b2a;
      28             : 
      29             :   fd_aio_pcapng_t pcapng_a2b;
      30             :   fd_aio_pcapng_t pcapng_b2a;
      31             : };
      32             : typedef struct fd_quic_virtual_pair fd_quic_virtual_pair_t;
      33             : 
      34             : FD_PROTOTYPES_BEGIN
      35             : 
      36             : extern FILE * fd_quic_test_pcap;
      37             : 
      38             : /* fd_quic_test_boot boots the QUIC test environment.
      39             :    Should be called after fd_boot().
      40             : 
      41             :    fd_quic_test_halt halts the QUIC test environment.
      42             :    Should be called before fd_halt(). */
      43             : 
      44             : void
      45             : fd_quic_test_boot( int *    pargc,
      46             :                    char *** pargv );
      47             : void
      48             : fd_quic_test_halt( void );
      49             : 
      50             : void
      51             : fd_quic_config_anonymous( fd_quic_t * quic,
      52             :                           int         role );
      53             : 
      54             : void
      55             : fd_quic_config_test_signer( fd_quic_t *              quic,
      56             :                             fd_tls_test_sign_ctx_t * sign_ctx );
      57             : 
      58             : /* fd_quic_new_anonymous creates an anonymous QUIC instance with the
      59             :    given limits.  Vacant config fields are auto-generated, except for
      60             :    role (server or client). Returns QUIC instance without local join on
      61             :    success.  Halts program on error. Caller is responsible for cleaning
      62             :    up QUIC. */
      63             : 
      64             : fd_quic_t *
      65             : fd_quic_new_anonymous( fd_wksp_t *              wksp,
      66             :                        fd_quic_limits_t const * limits,
      67             :                        int                      role,
      68             :                        fd_rng_t *               rng );
      69             : 
      70             : /* fd_quic_new_anonymous_small is like fd_quic_new_anonymous but with
      71             :    arbitrary small limits for convenience. */
      72             : 
      73             : fd_quic_t *
      74             : fd_quic_new_anonymous_small( fd_wksp_t * wksp,
      75             :                              int         role,
      76             :                              fd_rng_t *  rng );
      77             : 
      78             : /* fd_quic_virtual_pair_init sets up an aio loop between the two given QUIC
      79             :    objects.  That is, an fd_aio_send() call by quicA will trigger
      80             :    a synchronous callback to the aio receive to the quicB.  (FIXME This
      81             :    assumes no reentrancy in QUIC)  If user requested pcap, causes
      82             :    packets to get logged.  May only be called once per thread.  Any
      83             :    allocated resources get released at halt. */
      84             : 
      85             : void
      86             : fd_quic_virtual_pair_init( fd_quic_virtual_pair_t * pair,
      87             :                            fd_quic_t * quicA,
      88             :                            fd_quic_t * quicB );
      89             : 
      90             : /* fd_quic_virtual_pair_fini destroys an aio loop between the two given
      91             :    QUIC objects. */
      92             : 
      93             : void
      94             : fd_quic_virtual_pair_fini( fd_quic_virtual_pair_t * pair );
      95             : 
      96             : void
      97             : fd_quic_test_cb_tls_keylog( void *       quic_ctx,
      98             :                             char const * line );
      99             : 
     100             : FD_PROTOTYPES_END
     101             : 
     102             : /* fd_quic_udpsock is a command-line helper for creating an UDP channel
     103             :    over AF_XDP or UDP sockets. */
     104             : 
     105             : struct fd_quic_udpsock {
     106             :   int type;
     107           0 : # define FD_QUIC_UDPSOCK_TYPE_UDPSOCK 2
     108             : 
     109             :   uint   listen_ip;
     110             :   ushort listen_port;
     111             : 
     112             :   fd_wksp_t * wksp;  /* Handle to the workspace owning the objects */
     113             :   union {
     114             :     struct {
     115             :       fd_udpsock_t * sock;
     116             :       int            sock_fd;
     117             :     } udpsock;
     118             :   };
     119             : 
     120             :   fd_aio_t const * aio;
     121             : };
     122             : typedef struct fd_quic_udpsock fd_quic_udpsock_t;
     123             : 
     124             : FD_PROTOTYPES_BEGIN
     125             : 
     126             : fd_quic_udpsock_t *
     127             : fd_quic_client_create_udpsock(fd_quic_udpsock_t * udpsock,
     128             :                               fd_wksp_t *      wksp,
     129             :                               fd_aio_t const * rx_aio,
     130             :                               uint listen_ip);
     131             : 
     132             : fd_quic_udpsock_t *
     133             : fd_quic_udpsock_create( void *           _sock,
     134             :                         int *            argc,
     135             :                         char ***         argv,
     136             :                         fd_wksp_t *      wksp,
     137             :                         fd_aio_t const * rx_aio );
     138             : 
     139             : void *
     140             : fd_quic_udpsock_destroy( fd_quic_udpsock_t * udpsock );
     141             : 
     142             : void
     143             : fd_quic_udpsock_service( fd_quic_udpsock_t const * udpsock );
     144             : 
     145             : 
     146             : /* fd_quic_netem injects packet loss and reordering into an aio link. */
     147             : 
     148             : struct fd_quic_netem_reorder_buf {
     149             :   ulong sz;
     150             :   uchar buf[2048];
     151             : };
     152             : 
     153             : struct fd_quic_netem {
     154             :   fd_aio_t         local;
     155             :   fd_aio_t const * dst;
     156             :   float            thresh_drop;
     157             :   float            thresh_reorder;
     158             : 
     159             :   struct fd_quic_netem_reorder_buf reorder_buf[2];
     160             :   int                              reorder_mru; /* most recently written reorder buf */
     161             : };
     162             : 
     163             : typedef struct fd_quic_netem fd_quic_netem_t;
     164             : 
     165             : fd_quic_netem_t *
     166             : fd_quic_netem_init( fd_quic_netem_t * netem,
     167             :                     float             thres_drop,
     168             :                     float             thres_reorder );
     169             : 
     170             : /* fd_quic_netem_send implements fd_aio_send for fd_quic_netem_t. */
     171             : 
     172             : int
     173             : fd_quic_netem_send( void *                    ctx, /* fd_quic_net_em_t */
     174             :                     fd_aio_pkt_info_t const * batch,
     175             :                     ulong                     batch_cnt,
     176             :                     ulong *                   opt_batch_idx,
     177             :                     int                       flush );
     178             : 
     179             : FD_PROTOTYPES_END
     180             : 
     181             : #endif /* HEADER_fd_src_waltz_quic_tests_fd_quic_helpers_h */

Generated by: LCOV version 1.14