LCOV - code coverage report
Current view: top level - waltz/quic/templ - fd_quic_templ.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 63 78 80.8 %
Date: 2025-03-20 12:08:36 Functions: 13 627 2.1 %

          Line data    Source code
       1             : /* 17.2. Long Header Packets
       2             :    Long Header Packet {
       3             :      Header Form (1) = 1,
       4             :      Fixed Bit (1) = 1,
       5             :      Long Packet Type (2),
       6             :      Type-Specific Bits (4),
       7             :      Version (32),
       8             :      Destination Connection ID Length (8),
       9             :      Destination Connection ID (0..160),
      10             :      Source Connection ID Length (8),
      11             :      Source Connection ID (0..160),
      12             :      Type-Specific Payload (..),
      13             :    }
      14             :    Figure 13: Long Header Packet Format */
      15             : 
      16             : /* long header except first byte */
      17       28242 : FD_TEMPL_DEF_STRUCT_BEGIN(long_hdr)
      18       28227 :   FD_TEMPL_MBR_ELEM    ( version,         uint                  )
      19       28227 :   FD_TEMPL_MBR_ELEM    ( dst_conn_id_len, uchar                 )
      20       56148 :   FD_TEMPL_MBR_ELEM_VAR( dst_conn_id,     0,20, dst_conn_id_len )
      21       56148 :   FD_TEMPL_MBR_ELEM    ( src_conn_id_len, uchar                 )
      22       55794 :   FD_TEMPL_MBR_ELEM_VAR( src_conn_id,     0,20, src_conn_id_len )
      23       55794 : FD_TEMPL_DEF_STRUCT_END(long_hdr)
      24             : 
      25             : 
      26             : /* 17.2.2 Version Negotiation Packet
      27             :    Version Negotiation Packet {
      28             :      Header Form (1) = 1,
      29             :      Unused (7),
      30             :      Version (32) = 0,
      31             :      Destination Connection ID Length (8),
      32             :      Destination Connection ID (0..2040),
      33             :      Source Connection ID Length (8),
      34             :      Source Connection ID (0..2040),
      35             :      Supported Version (32) ...,
      36             :    }
      37             :    Figure 14: Version Negotiation Packet */
      38             : 
      39          15 : FD_TEMPL_DEF_STRUCT_BEGIN(version_neg)
      40           0 :   FD_TEMPL_MBR_ELEM        ( h0,                 uchar                      )
      41           0 :   FD_TEMPL_MBR_ELEM        ( version,            uint                       )
      42           0 :   FD_TEMPL_MBR_ELEM        ( dst_conn_id_len,    uchar                      )
      43           0 :   FD_TEMPL_MBR_ELEM_VAR_RAW( dst_conn_id,        0,255, dst_conn_id_len     )
      44           0 :   FD_TEMPL_MBR_ELEM        ( src_conn_id_len,    uchar                      )
      45           0 :   FD_TEMPL_MBR_ELEM_VAR_RAW( src_conn_id,        0,255, src_conn_id_len     )
      46           0 : FD_TEMPL_DEF_STRUCT_END(version_neg)
      47             : 
      48             : 
      49             : /* 17.2.2 Initial Packet
      50             :    Initial Packet {
      51             :      Header Form (1) = 1,
      52             :      Fixed Bit (1) = 1,
      53             :      Long Packet Type (2) = 0,
      54             :      Reserved Bits (2),
      55             :      Packet Number Length (2),
      56             :      Version (32),
      57             :      Destination Connection ID Length (8),
      58             :      Destination Connection ID (0..160),
      59             :      Source Connection ID Length (8),
      60             :      Source Connection ID (0..160),
      61             : 
      62             :      Token Length (i),
      63             :      Token (..),
      64             :      Length (i),
      65             :      Packet Number (8..32),
      66             :      Packet Payload (8..),
      67             :    }
      68             :    Figure 15: Initial Packet
      69             : 
      70             :    The first CRYPTO frame sent always begins at an offset of 0 */
      71             : 
      72       27639 : FD_TEMPL_DEF_STRUCT_BEGIN(initial)
      73       27624 :   FD_TEMPL_MBR_ELEM          ( h0,               uchar                  )
      74       27624 :   FD_TEMPL_MBR_ELEM          ( version,          uint                   )
      75       27624 :   FD_TEMPL_MBR_ELEM          ( dst_conn_id_len,  uchar                  )
      76       55248 :   FD_TEMPL_MBR_ELEM_VAR      ( dst_conn_id,      0,20,  dst_conn_id_len )
      77       55248 :   FD_TEMPL_MBR_ELEM          ( src_conn_id_len,  uchar                  )
      78       55248 :   FD_TEMPL_MBR_ELEM_VAR      ( src_conn_id,      0,20,  src_conn_id_len )
      79             : 
      80       55248 :   FD_TEMPL_MBR_ELEM_VARINT   ( token_len,        ulong                  )
      81       68790 :   FD_TEMPL_MBR_ELEM_VAR_RAW  ( token,            0,256, token_len       )
      82             : 
      83       68790 :   FD_TEMPL_MBR_ELEM_VARINT   ( len,              ulong                  )
      84       40302 :   FD_TEMPL_MBR_ELEM_PKTNUM   ( pkt_num,          ulong                  )
      85             : 
      86             :   // CRYPTO frames, etc, may start here
      87       40302 : FD_TEMPL_DEF_STRUCT_END(initial)
      88             : 
      89             : 
      90             : /* 17.2.4 Handshake Packet
      91             :    Handshake Packet {
      92             :      Header Form (1) = 1,
      93             :      Fixed Bit (1) = 1,
      94             :      Long Packet Type (2) = 2,
      95             :      Reserved Bits (2),
      96             :      Packet Number Length (2),
      97             :      Version (32),
      98             :      Destination Connection ID Length (8),
      99             :      Destination Connection ID (0..160),
     100             :      Source Connection ID Length (8),
     101             :      Source Connection ID (0..160),
     102             :      Length (i),
     103             :      Packet Number (8..32),
     104             :      Packet Payload (8..),
     105             :    }
     106             :    Figure 17: Handshake Protected Packet */
     107             : 
     108       24075 : FD_TEMPL_DEF_STRUCT_BEGIN(handshake)
     109       24060 :   FD_TEMPL_MBR_ELEM          ( h0,               uchar                 )
     110       24060 :   FD_TEMPL_MBR_ELEM          ( version,          uint                  )
     111       24060 :   FD_TEMPL_MBR_ELEM          ( dst_conn_id_len,  uchar                 )
     112       48120 :   FD_TEMPL_MBR_ELEM_VAR      ( dst_conn_id,      0,20, dst_conn_id_len )
     113       48120 :   FD_TEMPL_MBR_ELEM          ( src_conn_id_len,  uchar                 )
     114       48120 :   FD_TEMPL_MBR_ELEM_VAR      ( src_conn_id,      0,20, src_conn_id_len )
     115             : 
     116       48120 :   FD_TEMPL_MBR_ELEM_VARINT   ( len,              ulong                 )
     117       36090 :   FD_TEMPL_MBR_ELEM_PKTNUM   ( pkt_num,          ulong                 )
     118             : 
     119             :   // payload starts here
     120       36090 : FD_TEMPL_DEF_STRUCT_END(handshake)
     121             : 
     122             : 
     123             : /* 17.2.5 Retry Packet
     124             :    Retry Packet {
     125             :      Header Form (1) = 1,
     126             :      Fixed Bit (1) = 1,
     127             :      Long Packet Type (2) = 3,
     128             :      Unused (4),
     129             :      Version (32),
     130             :      Destination Connection ID Length (8),
     131             :      Destination Connection ID (0..160),
     132             :      Source Connection ID Length (8),
     133             :      Source Connection ID (0..160),
     134             :      Retry Token (..),
     135             :      Retry Integrity Tag (128),
     136             :    }
     137             :  Figure 18: Retry Packet */
     138     6002889 : FD_TEMPL_DEF_STRUCT_BEGIN(retry_hdr)
     139     6002874 :   FD_TEMPL_MBR_ELEM    ( h0,              uchar                 )
     140     6002874 :   FD_TEMPL_MBR_ELEM    ( version,         uint                  )
     141     6002874 :   FD_TEMPL_MBR_ELEM    ( dst_conn_id_len, uchar                 )
     142    12005724 :   FD_TEMPL_MBR_ELEM_VAR( dst_conn_id,     0,20, dst_conn_id_len )
     143    12005724 :   FD_TEMPL_MBR_ELEM    ( src_conn_id_len, uchar                 )
     144    12005700 :   FD_TEMPL_MBR_ELEM_VAR( src_conn_id,     0,20, src_conn_id_len )
     145    12005700 : FD_TEMPL_DEF_STRUCT_END(retry_hdr)
     146             : 
     147             : 
     148             : 
     149             : /* 17.2. Short Header Packets
     150             :    1-RTT Packet {
     151             :      Header Form (1) = 0,
     152             :      Fixed Bit (1) = 1,
     153             :      Spin Bit (1),
     154             :      Reserved Bits (2),
     155             :      Key Phase (1),
     156             :      Packet Number Length (2),
     157             :      Destination Connection ID (0..160),
     158             :      Packet Number (8..32),
     159             :      Packet Payload (8..),
     160             :    }
     161             :    Figure 19: 1-RTT Packet */
     162    13827832 : FD_TEMPL_DEF_STRUCT_BEGIN(one_rtt)
     163    13827817 :   FD_TEMPL_MBR_ELEM       ( h0,              uchar                 )
     164    13827817 :   FD_TEMPL_MBR_ELEM_HIDDEN( dst_conn_id_len, uint                  )
     165    27655634 :   FD_TEMPL_MBR_ELEM_VAR   ( dst_conn_id,     0,20, dst_conn_id_len )
     166             : 
     167    27655634 :   FD_TEMPL_MBR_ELEM_PKTNUM( pkt_num,         ulong                  )
     168             : 
     169             :   // payload starts here
     170    13827817 : FD_TEMPL_DEF_STRUCT_END(one_rtt)
     171             : 
     172             : 
     173             : 
     174             : /* 18. Transport Parameter Encoding
     175             :    Transport Parameters {
     176             :      Transport Parameter (..) ...,
     177             :    }
     178             :    Figure 20: Sequence of Transport Parameters
     179             :    Each transport parameter is encoded as an (identifier, length, value) tuple, as shown in Figure 21:
     180             : 
     181             :    Transport Parameter {
     182             :      Transport Parameter ID (i),
     183             :      Transport Parameter Length (i),
     184             :      Transport Parameter Value (..),
     185             :    }
     186             :    Figure 21: Transport Parameter Encoding */
     187             : 
     188             : // one transport entry - repeats
     189          15 : FD_TEMPL_DEF_STRUCT_BEGIN(transport_param_entry)
     190           0 :   FD_TEMPL_MBR_ELEM_VARINT ( param_id,  ulong             )
     191           0 :   FD_TEMPL_MBR_ELEM_VARINT ( param_len, ulong             )
     192           0 :   FD_TEMPL_MBR_ELEM_VAR_RAW( param_val, 0,1024, param_len )
     193           0 : FD_TEMPL_DEF_STRUCT_END(transport_param_entry)
     194             : 
     195             : 
     196             : /* 19. Frame common header
     197             : 
     198             :    COMMON Frag {
     199             :      Type (i)
     200             :    } */
     201          21 : FD_TEMPL_DEF_STRUCT_BEGIN(common_frag)
     202           6 :   FD_TEMPL_MBR_ELEM_VARINT( type, ulong )
     203           6 : FD_TEMPL_DEF_STRUCT_END(common_frag)
     204             : 
     205             : 
     206             : /* 19.3.1. ACK Ranges (part of ACK frame)
     207             : 
     208             :    ACK Range {
     209             :      Gap (i),
     210             :      ACK Range Length (i),
     211             :    }
     212             :    Figure 26: ACK Ranges */
     213             : 
     214          63 : FD_TEMPL_DEF_STRUCT_BEGIN(ack_range_frag)
     215          48 :   FD_TEMPL_MBR_ELEM_VARINT( gap,    ulong )
     216          42 :   FD_TEMPL_MBR_ELEM_VARINT( length, ulong )
     217          42 : FD_TEMPL_DEF_STRUCT_END(ack_range_frag)
     218             : 
     219             : 
     220             : /* 19.3.2. ECN Counts (part of ACK frame)
     221             : 
     222             :    ECN Counts {
     223             :      ECT0 Count (i),
     224             :      ECT1 Count (i),
     225             :      ECN-CE Count (i),
     226             :    }
     227             :    Figure 27: ECN Count Format
     228             :    The ECN count fields are:
     229             : 
     230             :    ECT0 Count:
     231             :    A variable-length integer representing the total number of packets received with the
     232             :      ECT(0) codepoint in the packet number space of the ACK frame.
     233             : 
     234             :    ECT1 Count:
     235             :    A variable-length integer representing the total number of packets received with the
     236             :      ECT(1) codepoint in the packet number space of the ACK frame.
     237             : 
     238             :    ECN-CE Count:
     239             :    A variable-length integer representing the total number of packets received with the
     240             :      ECN-CE codepoint in the packet number space of the ACK frame. */
     241             : 
     242          15 : FD_TEMPL_DEF_STRUCT_BEGIN(ecn_counts_frag)
     243           0 :   FD_TEMPL_MBR_ELEM_VARINT( ect0_count,   ulong )
     244           0 :   FD_TEMPL_MBR_ELEM_VARINT( ect1_count,   ulong )
     245           0 :   FD_TEMPL_MBR_ELEM_VARINT( ecn_ce_count, ulong )
     246           0 : FD_TEMPL_DEF_STRUCT_END(ecn_counts_frag)
     247             : 
     248             : 
     249             : /* 18.2. Transport Parameter Definitions > Preferred Address */
     250             : 
     251          27 : FD_TEMPL_DEF_STRUCT_BEGIN(preferred_address)
     252          12 :   FD_TEMPL_MBR_ELEM_RAW  ( ipv4_address, 4                 )
     253          12 :   FD_TEMPL_MBR_ELEM      ( ipv4_port,    ushort            )
     254          12 :   FD_TEMPL_MBR_ELEM_RAW  ( ipv6_address, 16                )
     255          12 :   FD_TEMPL_MBR_ELEM      ( ipv6_port,    ushort            )
     256          12 :   FD_TEMPL_MBR_ELEM      ( conn_id_len,  uchar             )
     257          24 :   FD_TEMPL_MBR_ELEM_VAR  ( conn_id,      0,20, conn_id_len )
     258          24 :   FD_TEMPL_MBR_ELEM_RAW  ( reset_token,  16                )
     259          12 : FD_TEMPL_DEF_STRUCT_END(preferred_address)

Generated by: LCOV version 1.14