1a74702c6SGeorge Wang/* Copyright (c) 2017 - 2022 LiteSpeed Technologies Inc.  See LICENSE. */
250aadb33SDmitri Tikhonov#ifndef __LSQUIC_TYPES_H__
350aadb33SDmitri Tikhonov#define __LSQUIC_TYPES_H__
450aadb33SDmitri Tikhonov
550aadb33SDmitri Tikhonov/**
650aadb33SDmitri Tikhonov * @file
750aadb33SDmitri Tikhonov * LSQUIC types.
850aadb33SDmitri Tikhonov */
950aadb33SDmitri Tikhonov
1050aadb33SDmitri Tikhonov#include <stdint.h>
115c957fdcSOmar Roth#include <sys/types.h>
1250aadb33SDmitri Tikhonov
135392f7a3SLiteSpeed Tech#define MAX_CID_LEN 20
145392f7a3SLiteSpeed Tech#define GQUIC_CID_LEN 8
155392f7a3SLiteSpeed Tech
1650aadb33SDmitri Tikhonov/**
1750aadb33SDmitri Tikhonov * Connection ID
1850aadb33SDmitri Tikhonov */
195392f7a3SLiteSpeed Techtypedef struct lsquic_cid
205392f7a3SLiteSpeed Tech{
215392f7a3SLiteSpeed Tech    uint_fast8_t    len;
225392f7a3SLiteSpeed Tech    union {
235392f7a3SLiteSpeed Tech        uint8_t     buf[MAX_CID_LEN];
245392f7a3SLiteSpeed Tech        uint64_t    id;
255392f7a3SLiteSpeed Tech    }               u_cid;
265392f7a3SLiteSpeed Tech#define idbuf u_cid.buf
275392f7a3SLiteSpeed Tech}
285392f7a3SLiteSpeed Techlsquic_cid_t;
295392f7a3SLiteSpeed Tech
305392f7a3SLiteSpeed Tech
315392f7a3SLiteSpeed Tech#define LSQUIC_CIDS_EQ(a, b) ((a)->len == 8 ? \
325392f7a3SLiteSpeed Tech    (b)->len == 8 && (a)->u_cid.id == (b)->u_cid.id : \
335392f7a3SLiteSpeed Tech    (a)->len == (b)->len && 0 == memcmp((a)->idbuf, (b)->idbuf, (a)->len))
345392f7a3SLiteSpeed Tech
355392f7a3SLiteSpeed Tech/** Stream ID */
365392f7a3SLiteSpeed Techtypedef uint64_t lsquic_stream_id_t;
3750aadb33SDmitri Tikhonov
3850aadb33SDmitri Tikhonov/** LSQUIC engine */
3950aadb33SDmitri Tikhonovtypedef struct lsquic_engine lsquic_engine_t;
4050aadb33SDmitri Tikhonov
4150aadb33SDmitri Tikhonov/** Connection */
4250aadb33SDmitri Tikhonovtypedef struct lsquic_conn lsquic_conn_t;
4350aadb33SDmitri Tikhonov
4450aadb33SDmitri Tikhonov/** Connection context.  This is the return value of @ref on_new_conn. */
4550aadb33SDmitri Tikhonovtypedef struct lsquic_conn_ctx lsquic_conn_ctx_t;
4650aadb33SDmitri Tikhonov
4750aadb33SDmitri Tikhonov/** Stream */
4850aadb33SDmitri Tikhonovtypedef struct lsquic_stream lsquic_stream_t;
4950aadb33SDmitri Tikhonov
5050aadb33SDmitri Tikhonov/** Stream context.  This is the return value of @ref on_new_stream. */
5150aadb33SDmitri Tikhonovtypedef struct lsquic_stream_ctx lsquic_stream_ctx_t;
5250aadb33SDmitri Tikhonov
5350aadb33SDmitri Tikhonov/** HTTP headers */
5450aadb33SDmitri Tikhonovtypedef struct lsquic_http_headers lsquic_http_headers_t;
5550aadb33SDmitri Tikhonov
5650aadb33SDmitri Tikhonov#endif
57