LCOV - code coverage report
Current view: top level - waltz/udpsock - fd_udpsock.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 2 0.0 %
Date: 2025-01-08 12:08:44 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_waltz_udpsock_fd_udpsock_h
       2             : #define HEADER_fd_src_waltz_udpsock_fd_udpsock_h
       3             : 
       4             : #include "../fd_waltz_base.h"
       5             : #include "../aio/fd_aio.h"
       6             : 
       7             : /* fd_udpsock is an unprivileged sockets-based driver for UDP apps.
       8             :    Internally uses AF_INET SOCK_DGRAM UDP sockets in O_NONBLOCK mode.
       9             : 
      10             :    Implements the fd_aio abstraction and mocks Ethernet & IP headers to
      11             :    permit operation over localhost.
      12             : 
      13             :    Very hacky, low performance, and unsuitable for production use.
      14             :    Convenient for debugging as they are compatible with the lo interface.
      15             :    Only supports single-threaded operation for now. */
      16             : 
      17             : #define FD_UDPSOCK_ALIGN (64UL)
      18             : 
      19             : struct fd_udpsock;
      20             : typedef struct fd_udpsock fd_udpsock_t;
      21             : 
      22             : FD_PROTOTYPES_BEGIN
      23             : 
      24             : FD_FN_CONST ulong
      25             : fd_udpsock_align( void );
      26             : 
      27             : FD_FN_CONST ulong
      28             : fd_udpsock_footprint( ulong mtu,
      29             :                       ulong rx_pkt_cnt,
      30             :                       ulong tx_pkt_cnt );
      31             : 
      32             : /* fd_udpsock_new prepares a new memory region with matching alignment
      33             :    and footprint for storing an fd_udpsock_t object.  Returns shmem on
      34             :    success and NULL on failure.  The caller is not joined on return. */
      35             : 
      36             : void *
      37             : fd_udpsock_new( void * shmem,
      38             :                 ulong  mtu,
      39             :                 ulong  rx_pkt_cnt,
      40             :                 ulong  tx_pkt_cnt );
      41             : 
      42             : /* fd_udpsock_join joins the caller to the given initialized memory
      43             :    region using the given UDP socket file descriptor. */
      44             : 
      45             : fd_udpsock_t *
      46             : fd_udpsock_join( void * shsock,
      47             :                  int    fd );
      48             : 
      49             : /* fd_udpsock_leave undoes a local join to the fd_udpsock_t object. */
      50             : 
      51             : void *
      52             : fd_udpsock_leave( fd_udpsock_t * sock );
      53             : 
      54             : /* fd_udpsock_delete releases ownership a memory region back to the
      55             :    caller. */
      56             : 
      57             : void *
      58             : fd_udpsock_delete( void * shsock );
      59             : 
      60             : void
      61             : fd_udpsock_set_rx( fd_udpsock_t *   sock,
      62             :                    fd_aio_t const * aio );
      63             : 
      64             : FD_FN_CONST fd_aio_t const *
      65             : fd_udpsock_get_tx( fd_udpsock_t * sock );
      66             : 
      67             : /* fd_udpsock_service services aio callbacks for incoming packets and
      68             :    handles completions for tx requests. */
      69             : 
      70             : void
      71             : fd_udpsock_service( fd_udpsock_t * sock );
      72             : 
      73             : FD_FN_PURE uint
      74             : fd_udpsock_get_ip4_address( fd_udpsock_t const * sock );
      75             : 
      76             : FD_FN_PURE uint
      77             : fd_udpsock_get_listen_port( fd_udpsock_t const * sock );
      78             : 
      79             : /* FIXME remove all usages of Ethernet layer fd_udpsock */
      80             : 
      81           0 : #define FD_UDPSOCK_LAYER_ETH (0U)
      82           0 : #define FD_UDPSOCK_LAYER_IP  (1U)
      83             : 
      84             : fd_udpsock_t *
      85             : fd_udpsock_set_layer( fd_udpsock_t * sock,
      86             :                       uint           layer );
      87             : 
      88             : FD_PROTOTYPES_END
      89             : 
      90             : #endif /* HEADER_fd_src_waltz_udpsock_fd_udpsock_h */

Generated by: LCOV version 1.14