LCOV - code coverage report
Current view: top level - waltz/quic - fd_quic_proto.c (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 18 18 100.0 %
Date: 2025-01-08 12:08:44 Functions: 2 14 14.3 %

          Line data    Source code
       1             : /* This file instantiates all the structures and functions
       2             :    of the QUIC protocol */
       3             : 
       4             : /* there are cases where we make tests in generic macros
       5             :    that fail for certain types
       6             :    TODO replace with code that passes these checks */
       7             : #pragma GCC diagnostic ignored "-Wtype-limits"
       8             : 
       9             : #include "fd_quic_types.h"
      10             : #include "fd_quic_common.h"
      11             : 
      12             : #include "fd_quic_proto.h"
      13             : 
      14             : #include "templ/fd_quic_parse_util.h"
      15             : 
      16             : #include "templ/fd_quic_parsers.h"
      17             : #include "templ/fd_quic_templ.h"
      18             : #include "templ/fd_quic_frames_templ.h"
      19             : #include "templ/fd_quic_undefs.h"
      20             : 
      21             : #include "templ/fd_quic_encoders.h"
      22             : #include "templ/fd_quic_templ.h"
      23             : #include "templ/fd_quic_frames_templ.h"
      24             : #include "templ/fd_quic_undefs.h"
      25             : 
      26             : #include "templ/fd_quic_encoders_footprint.h"
      27             : #include "templ/fd_quic_templ.h"
      28             : #include "templ/fd_quic_frames_templ.h"
      29             : #include "templ/fd_quic_undefs.h"
      30             : 
      31             : #include "templ/fd_quic_templ_dump.h"
      32             : #include "templ/fd_quic_templ.h"
      33             : #include "templ/fd_quic_frames_templ.h"
      34             : #include "templ/fd_quic_undefs.h"
      35             : 
      36             : #include "templ/fd_quic_transport_params.h"
      37             : 
      38             : /* fd_quic_encode_stream_frame is an optimized encoder for stream headers. */
      39             : 
      40             : FD_FN_UNUSED static ulong
      41             : fd_quic_encode_stream_frame( uchar * const buf,
      42             :                              uchar * const buf_end,
      43             :                              ulong   const stream_id,
      44             :                              ulong   const offset,
      45             :                              ulong   const data_sz,
      46    79319538 :                              _Bool   const fin ) {
      47    79319538 :   uchar * cur = buf;
      48             : 
      49             :   /* stream_hdr_max is the max size of a stream header:
      50             :       1 byte type
      51             :       8 bytes stream ID
      52             :       8 bytes offset
      53             :       8 bytes length */
      54    79319538 :   ulong const stream_hdr_max = 1+8+8+8;
      55             : 
      56             :   /* No space to write frame?
      57             :      (Buffer should fit max stream header size and at least 1 byte of data) */
      58    79319538 :   if( buf+stream_hdr_max+1 > buf_end ) return FD_QUIC_ENCODE_FAIL;
      59             : 
      60             :   /* Leave placeholder for frame/stream type */
      61    79319460 :   uchar * const frame_type_p = cur++;
      62    79319460 :   uint          frame_type   = 0x0a; /* stream frame with length */
      63             : 
      64             :   /* Encode stream ID */
      65    79319460 :   cur += fd_quic_varint_encode( cur, stream_id );
      66             : 
      67             :   /* Optionally encode offset */
      68    79319460 :   if( offset>0 ) {
      69           6 :     frame_type |= 0x04; /* with offset field */
      70           6 :     cur += fd_quic_varint_encode( cur, offset );
      71           6 :   }
      72             : 
      73             :   /* Encode length */
      74    79319460 :   ushort data_sz_varint = fd_ushort_bswap( (ushort)( 0x4000u | (uint)data_sz ) );
      75    79319460 :   FD_STORE( ushort, cur, data_sz_varint );
      76    79319460 :   cur += 2;
      77             : 
      78             :   /* Encode stream type */
      79    79319460 :   frame_type |= fin;
      80    79319460 :   *frame_type_p = (uchar)frame_type;
      81             :   /* Done encoding stream header */
      82             : 
      83    79319460 :   return (ulong)(cur-buf);
      84    79319538 : }

Generated by: LCOV version 1.14