LCOV - code coverage report
Current view: top level - discof/failover - fd_failover_wire.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 6 0.0 %
Date: 2026-11-11 12:40:43 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_discof_failover_fd_failover_wire_h
       2             : #define HEADER_fd_src_discof_failover_fd_failover_wire_h
       3             : 
       4             : /* Bounded framing inside an authenticated TLS connection.  This codec
       5             :    does not handle authentication, it only decodes plaintext obtained
       6             :    from TLS. */
       7             : 
       8             : #include "fd_failover_proto.h"
       9             : 
      10             : /* Frame layout bounds */
      11           0 : #define FD_FAILOVER_FRAME_HDR_SZ (8UL)
      12             : #define FD_FAILOVER_PAYLOAD_MAX  (65536UL)
      13             : #define FD_FAILOVER_FRAME_MAX    (FD_FAILOVER_FRAME_HDR_SZ+FD_FAILOVER_PAYLOAD_MAX)
      14             : 
      15             : /* Decode results.  AGAIN means the caller has not buffered the whole frame yet, and every other error is fatal to the session. */
      16           0 : #define FD_FAILOVER_WIRE_SUCCESS     (0)
      17           0 : #define FD_FAILOVER_WIRE_ERR_AGAIN   (-1)
      18           0 : #define FD_FAILOVER_WIRE_ERR_VERSION (-2)
      19           0 : #define FD_FAILOVER_WIRE_ERR_SZ      (-3)
      20           0 : #define FD_FAILOVER_WIRE_ERR_TYPE    (-4)
      21             : 
      22             : struct __attribute__((packed)) fd_failover_frame_hdr {
      23             :   ushort version; /* FD_FAILOVER_VERSION */
      24             :   uint   len;     /* total frame length in bytes */
      25             :   ushort type;    /* FD_FAILOVER_MSG_* */
      26             : };
      27             : 
      28             : typedef struct fd_failover_frame_hdr fd_failover_frame_hdr_t;
      29             : 
      30             : FD_STATIC_ASSERT( sizeof(fd_failover_frame_hdr_t)==FD_FAILOVER_FRAME_HDR_SZ, wire_layout );
      31             : 
      32             : FD_PROTOTYPES_BEGIN
      33             : 
      34             : /* Writes one frame and payload into out, which must hold at least
      35             :    FD_FAILOVER_FRAME_MAX bytes. */
      36             : ulong
      37             : fd_failover_wire_encode( uchar *       out,
      38             :                          ushort        type,
      39             :                          uchar const * payload,
      40             :                          ulong         payload_sz );
      41             : 
      42             : /* Decodes the frame at the start of buf and, on success, points
      43             :    *out_payload and *out_payload_sz into buf. */
      44             : int
      45             : fd_failover_wire_decode( uchar const *  buf,
      46             :                          ulong          buf_sz,
      47             :                          ushort *       out_type,
      48             :                          uchar const ** out_payload,
      49             :                          ulong *        out_payload_sz,
      50             :                          ulong *        out_frame_sz );
      51             : 
      52             : FD_PROTOTYPES_END
      53             : 
      54             : #endif /* HEADER_fd_src_discof_failover_fd_failover_wire_h */

Generated by: LCOV version 1.14