litespeed-quic/test/unittests/test_packet_out.c
Dmitri Tikhonov a5fa05f958 Release 2.13.0
- [API] Use lsxpack_header structure to process incoming headers.
- [BUGFIX] Fix assertion when zero-padding Initial packet.
- [BUGFIX] Use idle timeout before we learn of peer's value.
- Use ls-hpack 2.0.0 -- has lsxpack_header changes.
- Use ls-qpack 0.14.0 -- new, common with ls-hpack, XXH seed (not used yet).
- Code cleanup: prefix exported functions with "lsquic_".
2020-03-12 09:02:56 -04:00

100 lines
3.2 KiB
C

/* Copyright (c) 2017 - 2020 LiteSpeed Technologies Inc. See LICENSE. */
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/queue.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <fcntl.h>
#include <openssl/md5.h>
#include "lsquic.h"
#include "lsquic_int_types.h"
#include "lsquic_packet_common.h"
#include "lsquic_packet_gquic.h"
#include "lsquic_packet_out.h"
#include "lsquic_conn_flow.h"
#include "lsquic_sfcw.h"
#include "lsquic_varint.h"
#include "lsquic_hq.h"
#include "lsquic_hash.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, GQUIC_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 = lsquic_posi_first(&posi, packet_out);
assert(srec->sr_stream == &streams[0]);
assert(srec->sr_off == 7);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[1]);
assert(srec->sr_off == 8);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[2]);
assert(srec->sr_off == 9);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[1]);
assert(srec->sr_off == 10);
assert(srec->sr_frame_type == QUIC_FRAME_RST_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[3]);
assert(srec->sr_off == 11);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[4]);
assert(srec->sr_off == 12);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
srec = lsquic_posi_next(&posi);
assert(srec->sr_stream == &streams[5]);
assert(srec->sr_off == 13);
assert(srec->sr_frame_type == QUIC_FRAME_STREAM);
assert((void *) 0 == lsquic_posi_next(&posi));
lsquic_packet_out_destroy(packet_out, &enpub, NULL);
assert(!lsquic_malo_first(enpub.enp_mm.malo.stream_rec_arr));
lsquic_mm_cleanup(&enpub.enp_mm);
return 0;
}