Line data Source code
1 : /* QUIC encoders footprint */ 2 : 3 : /* used to define functions for determining footprint upper bound 4 : without encoding the data */ 5 : 6 : /* "returns" the number of bytes encoded */ 7 : #define FD_TEMPL_ENCODE_FP(TYPE) ( sizeof(fd_quic_##TYPE) ) 8 : 9 : /* returns bytes to be encoded */ 10 : #define FD_TEMPL_DEF_STRUCT_BEGIN(NAME) \ 11 17090699 : ulong fd_quic_encode_footprint_##NAME( fd_quic_##NAME##_t * frame ) { \ 12 17090699 : (void)frame; \ 13 17090699 : ulong buf = 0; \ 14 17090699 : ulong tmp_len = 0; (void)tmp_len; \ 15 : 16 : /* 1 byte for TYPE */ 17 : #define FD_TEMPL_MBR_FRAME_TYPE(NAME,ID_LO,ID_HI) \ 18 17090699 : buf++; 19 : 20 : 21 : /* determines footprint of element */ 22 : #define FD_TEMPL_MBR_ELEM(NAME,TYPE) \ 23 : buf += FD_TEMPL_ENCODE_FP(TYPE); \ 24 : 25 : 26 : /* worst case pktnum encoded size */ 27 : #define FD_TEMPL_MBR_ELEM_PKTNUM(NAME,TYPE) \ 28 : buf += 4; 29 : 30 : 31 : /* worst case varint encoded size */ 32 : #define FD_TEMPL_MBR_ELEM_VARINT(NAME,TYPE) \ 33 17090705 : buf += 8; \ 34 : 35 : 36 : /* VAR currently assumed to be aligned bytes */ 37 : #define FD_TEMPL_MBR_ELEM_VAR(NAME,BITS_MIN,BITS_MAX,LEN_NAME) \ 38 : tmp_len = frame->LEN_NAME; \ 39 : buf += tmp_len; 40 : 41 : 42 : /* VAR_RAW currently assumed to be aligned bytes */ 43 : #define FD_TEMPL_MBR_ELEM_VAR_RAW(NAME,BITS_MIN,BITS_MAX,LEN_NAME) \ 44 : tmp_len = frame->LEN_NAME; \ 45 : buf += tmp_len; 46 : 47 : /* determine the footprint of encoded ARRAY */ 48 : #define FD_TEMPL_MBR_ELEM_ARRAY(NAME,TYPE,BYTES_MIN,BYTES_MAX) \ 49 : tmp_len = frame->NAME##_len * sizeof(fd_quic_##TYPE); \ 50 : buf += tmp_len * FD_TEMPL_ENCODE_FP(TYPE); \ 51 : 52 : /* FIXED is an array of elements, each of the same size, 53 : with length constant */ 54 : #define FD_TEMPL_MBR_ELEM_FIXED(NAME,TYPE,ELEMS) \ 55 : buf += ELEMS * sizeof( fd_quic_##TYPE ); 56 : 57 : /* TODO remove abort() once tested */ 58 : #define FD_TEMPL_MBR_OPT(TYPE,NAME,MASK,...) \ 59 51272079 : if( frame->NAME##_opt ) { \ 60 42725549 : __VA_ARGS__ \ 61 42725549 : } 62 : 63 : 64 : /* at end, return the number of bytes consumed */ 65 : #define FD_TEMPL_DEF_STRUCT_END(NAME) \ 66 17090699 : return buf; \ 67 17090699 : } 68 : 69 : #include "fd_quic_dft.h" 70 :