lsquic_enc_sess_common.c revision a0e1aeee
15392f7a3SLiteSpeed Tech/* Copyright (c) 2017 - 2019 LiteSpeed Technologies Inc.  See LICENSE. */
25392f7a3SLiteSpeed Tech#include <stddef.h>
35392f7a3SLiteSpeed Tech#include <stdint.h>
45392f7a3SLiteSpeed Tech#include <string.h>
55392f7a3SLiteSpeed Tech
65392f7a3SLiteSpeed Tech#include "lsquic.h"
75392f7a3SLiteSpeed Tech#include "lsquic_types.h"
85392f7a3SLiteSpeed Tech#include "lsquic_int_types.h"
95392f7a3SLiteSpeed Tech#include "lsquic_enc_sess.h"
105392f7a3SLiteSpeed Tech#include "lsquic_version.h"
115392f7a3SLiteSpeed Tech
125392f7a3SLiteSpeed Tech
135392f7a3SLiteSpeed Techconst char *const lsquic_enclev2str[] =
145392f7a3SLiteSpeed Tech{
155392f7a3SLiteSpeed Tech    [ENC_LEV_EARLY] = "early",
165392f7a3SLiteSpeed Tech    [ENC_LEV_CLEAR] = "clear",
175392f7a3SLiteSpeed Tech    [ENC_LEV_INIT]  = "initial",
185392f7a3SLiteSpeed Tech    [ENC_LEV_FORW]  = "forw-secure",
195392f7a3SLiteSpeed Tech};
205392f7a3SLiteSpeed Tech
215392f7a3SLiteSpeed Tech
225392f7a3SLiteSpeed Techenum lsquic_version
235392f7a3SLiteSpeed Techlsquic_zero_rtt_version (const unsigned char *buf, size_t bufsz)
245392f7a3SLiteSpeed Tech{
255392f7a3SLiteSpeed Tech    lsquic_ver_tag_t tag;
265392f7a3SLiteSpeed Tech
275392f7a3SLiteSpeed Tech    if (bufsz >= sizeof(tag))
285392f7a3SLiteSpeed Tech    {
295392f7a3SLiteSpeed Tech        memcpy(&tag, buf, sizeof(tag));
305392f7a3SLiteSpeed Tech        return lsquic_tag2ver(tag);
315392f7a3SLiteSpeed Tech    }
325392f7a3SLiteSpeed Tech    else
33a0e1aeeeSDmitri Tikhonov        return N_LSQVER;
345392f7a3SLiteSpeed Tech}
35