/* Copyright (c) 2017 LiteSpeed Technologies Inc. See LICENSE. */ #include #include #include #include #include #include #include #include #ifndef WIN32 #include #endif #include #include #include "lsquic.h" #include "lsquic_int_types.h" #include "lsquic_packet_common.h" #include "lsquic_packet_out.h" #include "lsquic_conn_flow.h" #include "lsquic_sfcw.h" #include "lsquic_stream.h" #include "lsquic_types.h" #include "lsquic_malo.h" #include "lsquic_mm.h" #include "lsquic_engine_public.h" #include "lsquic_logger.h" int main (void) { struct lsquic_engine_public enpub; struct packet_out_srec_iter posi; lsquic_packet_out_t *packet_out; struct lsquic_stream streams[6]; struct stream_rec *srec; memset(&enpub, 0, sizeof(enpub)); memset(&streams, 0, sizeof(streams)); lsquic_mm_init(&enpub.enp_mm); packet_out = lsquic_mm_get_packet_out(&enpub.enp_mm, NULL, QUIC_MAX_PAYLOAD_SZ); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[0], QUIC_FRAME_STREAM, 7, 1); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[1], QUIC_FRAME_STREAM, 8, 1); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[2], QUIC_FRAME_STREAM, 9, 1); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[1], QUIC_FRAME_RST_STREAM, 10, 0); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[3], QUIC_FRAME_STREAM, 11, 1); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[4], QUIC_FRAME_STREAM, 12, 1); lsquic_packet_out_add_stream(packet_out, &enpub.enp_mm, &streams[5], QUIC_FRAME_STREAM, 13, 1); srec = posi_first(&posi, packet_out); assert(srec->sr_stream == &streams[0]); assert(srec->sr_off == 7); assert(srec->sr_frame_types == (1 << QUIC_FRAME_STREAM)); srec = posi_next(&posi); assert(srec->sr_stream == &streams[1]); assert(srec->sr_off == 8); assert(srec->sr_frame_types == ((1 << QUIC_FRAME_STREAM)|(1 << QUIC_FRAME_RST_STREAM))); srec = posi_next(&posi); assert(srec->sr_stream == &streams[2]); assert(srec->sr_off == 9); assert(srec->sr_frame_types == (1 << QUIC_FRAME_STREAM)); srec = posi_next(&posi); assert(srec->sr_stream == &streams[3]); assert(srec->sr_off == 11); assert(srec->sr_frame_types == (1 << QUIC_FRAME_STREAM)); srec = posi_next(&posi); assert(srec->sr_stream == &streams[4]); assert(srec->sr_off == 12); assert(srec->sr_frame_types == (1 << QUIC_FRAME_STREAM)); srec = posi_next(&posi); assert(srec->sr_stream == &streams[5]); assert(srec->sr_off == 13); assert(srec->sr_frame_types == (1 << QUIC_FRAME_STREAM)); assert((void *) 0 == posi_next(&posi)); lsquic_packet_out_destroy(packet_out, &enpub); assert(!lsquic_malo_first(enpub.enp_mm.malo.stream_rec_arr)); lsquic_mm_cleanup(&enpub.enp_mm); return 0; }