Line data Source code
1 : #ifndef HEADER_fd_src_waltz_h2_fd_h2_tx_h 2 : #define HEADER_fd_src_waltz_h2_fd_h2_tx_h 3 : 4 : /* fd_h2_tx.h helps doing flow-controlled TX work. */ 5 : 6 : #include "fd_h2_proto.h" 7 : 8 : struct fd_h2_tx_op { 9 : void const * chunk; 10 : ulong chunk_sz; 11 : ulong fin : 1; 12 : }; 13 : 14 : typedef struct fd_h2_tx_op fd_h2_tx_op_t; 15 : 16 : FD_PROTOTYPES_BEGIN 17 : 18 : /* fd_h2_tx_op_init starts a send operation of chunk_sz bytes. chunk 19 : points to the buffer to send. flags==FD_H2_FLAG_END_STREAM closes 20 : the stream once all DATA frames have been generated. chunk_sz must 21 : be non-zero. */ 22 : 23 : static inline fd_h2_tx_op_t * 24 : fd_h2_tx_op_init( fd_h2_tx_op_t * tx_op, 25 : void const * chunk, 26 : ulong chunk_sz, 27 0 : uint flags ) { 28 0 : *tx_op = (fd_h2_tx_op_t) { 29 0 : .chunk = chunk, 30 0 : .chunk_sz = chunk_sz 31 0 : }; 32 0 : if( flags & FD_H2_FLAG_END_STREAM ) tx_op->fin = 1; 33 0 : return tx_op; 34 0 : } 35 : 36 : /* fd_h2_tx_op_copy copies as much enqueued tx data out to rbuf_tx as 37 : possible. Advances tx_op->chunk and reduces tx_op->chunk_sz. Stops 38 : copying when one of the following limits is hit: {rbuf_tx is full, 39 : out of conn TX quota, out of stream TX quota, no more tx_op bytes 40 : queued}. */ 41 : 42 : void 43 : fd_h2_tx_op_copy( fd_h2_conn_t * conn, 44 : fd_h2_stream_t * stream, 45 : fd_h2_rbuf_t * rbuf_tx, 46 : fd_h2_tx_op_t * tx_op ); 47 : 48 : /* FIXME Add sendmsg-gather API here for streamlined transmit of 49 : multiple frames via sockets? */ 50 : 51 : FD_PROTOTYPES_END 52 : 53 : #endif /* HEADER_fd_src_waltz_h2_fd_h2_tx_h */