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

Generated by: LCOV version 1.14