Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to build on linux #491

Open
N0N1m3 opened this issue Jan 27, 2024 · 1 comment
Open

Failed to build on linux #491

N0N1m3 opened this issue Jan 27, 2024 · 1 comment

Comments

@N0N1m3
Copy link

N0N1m3 commented Jan 27, 2024

I'm trying to build lsquic

I tried two ways

  1. As it is written in your guide
  2. As shown in this example https://github.com/dtikhonov/lsquic-tutorial/blob/master/CMakeLists.txt

My test CMakeLists.txt

CMAKE_MINIMUM_REQUIRED(VERSION 3.5)
PROJECT(lsquic-tutorial C)

ADD_SUBDIRECTORY(boringssl)

INCLUDE_DIRECTORIES(boringssl/include)
INCLUDE_DIRECTORIES(lsquic/include)
INCLUDE_DIRECTORIES(lsquic/src/liblsquic)
ADD_SUBDIRECTORY(lsquic/src/liblsquic)

wsl output:

[ 99%] Building C object lsquic/src/liblsquic/CMakeFiles/lsquic.dir/lsquic_xxhash.c.o
[ 99%] Building C object lsquic/src/liblsquic/CMakeFiles/lsquic.dir/__/lshpack/lshpack.c.o
[ 99%] Building C object lsquic/src/liblsquic/CMakeFiles/lsquic.dir/lsquic_versions_to_string.c.o
/mnt/c/Users/x/buikd/lsquic/src/liblsquic/lsquic_versions_to_string.c: In function ‘lsquic_get_alt_svc_versions’:
/mnt/c/Users/x/buikd/lsquic/src/liblsquic/lsquic_versions_to_string.c:21:18: error: expected expression before ‘)’ token
   21 |     versions &= ();
      |                  ^
/mnt/c/Users/x/buikd/lsquic/src/liblsquic/lsquic_versions_to_string.c: In function ‘lsquic_get_h3_alpns’:
/mnt/c/Users/x/buikd/lsquic/src/liblsquic/lsquic_versions_to_string.c:37:18: error: expected expression before ‘)’ token
   37 |     versions &= ();
      |                  ^
make[2]: *** [lsquic/src/liblsquic/CMakeFiles/lsquic.dir/build.make:1257: lsquic/src/liblsquic/CMakeFiles/lsquic.dir/lsquic_versions_to_string.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:812: lsquic/src/liblsquic/CMakeFiles/lsquic.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

I have latest versions of boringssl and lsquic

My perl version: v5.34.0

perl -v

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-gnu-thread-multi
(with 60 registered patches, see perl -V for more detail)
@ChessNineeee
Copy link

ChessNineeee commented Jun 19, 2024

The perl script src/liblsquic/gen-verstr.pl will generate the wrong code under the WSL environment. The reason is the script cannot parse the header file include/libquic.h correctly due to the crlf line ending which is caused by Windows. Thus I use a tool named dos2unix to convert header file's format to unix format, and it works. Here's the correctly generated file src/liblsquic/lsquic_versions_to_string.c:

/*
 * Auto-generated by ./gen-verstrs.pl on Wed Jun 19 14:19:42 2024
 */

#include <assert.h>
#include <string.h>

#include "lsquic.h"

struct lsquic_engine;

static const char *const versions_to_string[ 1 << N_LSQVER ] = {
    [0] = "",
    [(1<<LSQVER_043)] = "43",
    [(1<<LSQVER_046)] = "46",
    [(1<<LSQVER_043)|(1<<LSQVER_046)] = "43,46",
};


const char *
lsquic_get_alt_svc_versions (unsigned versions)
{
    /* Limit to versions in versions_to_string: */
    versions &= ((1<<LSQVER_043)|(1<<LSQVER_046));
    return versions_to_string[ versions ];
}

static const struct {
    unsigned    versions;
    const char *h3_alpns[8];
} vers_2_h3_alnps[] = {
    { 0, { NULL }},
    {(1<<LSQVER_043), { "h3-Q043", NULL }},
    {(1<<LSQVER_046), { "h3-Q046", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046), { "h3-Q043", "h3-Q046", NULL }},
    {(1<<LSQVER_050), { "h3-Q050", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050), { "h3-Q043", "h3-Q050", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050), { "h3-Q046", "h3-Q050", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050), { "h3-Q043", "h3-Q046", "h3-Q050", NULL }},
    {(1<<LSQVER_ID27), { "h3-27", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27), { "h3-Q043", "h3-27", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27), { "h3-Q046", "h3-27", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27), { "h3-Q043", "h3-Q046", "h3-27", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27), { "h3-Q050", "h3-27", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27), { "h3-Q043", "h3-Q050", "h3-27", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27), { "h3-Q046", "h3-Q050", "h3-27", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", NULL }},
    {(1<<LSQVER_ID29), { "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID29), { "h3-Q043", "h3-29", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID29), { "h3-Q046", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q046", "h3-29", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID29), { "h3-Q050", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q050", "h3-29", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29), { "h3-Q046", "h3-Q050", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-29", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q043", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q046", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q046", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q050", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q050", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q046", "h3-Q050", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3-29", NULL }},
    {(1<<LSQVER_I001), { "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_I001), { "h3-Q043", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_I001), { "h3-Q046", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_I001), { "h3-Q050", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q050", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I001), { "h3-Q046", "h3-Q050", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-Q050", "h3", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-27", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q043", "h3-27", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q046", "h3-27", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-27", "h3", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q050", "h3-27", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q050", "h3-27", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q046", "h3-Q050", "h3-27", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3", NULL }},
    {(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-29", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q046", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-29", "h3", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q050", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q050", "h3-29", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q046", "h3-Q050", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-29", "h3", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q046", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q050", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q050", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q046", "h3-Q050", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3-29", "h3", NULL }},
    {(1<<LSQVER_I002), { "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_I002), { "h3-Q043", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_I002), { "h3-Q046", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_I002), { "h3-Q050", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-27", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q043", "h3-27", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q046", "h3-27", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-27", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q050", "h3-27", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-27", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-27", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "", NULL }},
    {(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-29", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q046", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-29", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q050", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-29", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-29", "", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q046", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q050", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3-29", "", NULL }},
    {(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q050", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3", "", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q050", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3", "", NULL }},
    {(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q050", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q050", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q050", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q046", "h3-Q050", "h3-27", "h3-29", "h3", "", NULL }},
    {(1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002), { "h3-Q043", "h3-Q046", "h3-Q050", "h3-27", "h3-29", "h3", "", NULL }},
};

const char *const *
lsquic_get_h3_alpns (unsigned versions)
{
    unsigned i;

    versions &= ((1<<LSQVER_043)|(1<<LSQVER_046)|(1<<LSQVER_050)|(1<<LSQVER_ID27)|(1<<LSQVER_ID29)|(1<<LSQVER_I001)|(1<<LSQVER_I002));

    for (i = 0; i < sizeof(vers_2_h3_alnps) / sizeof(vers_2_h3_alnps[0]); ++i)
        if (versions == vers_2_h3_alnps[i].versions)
            return vers_2_h3_alnps[i].h3_alpns;

    assert(0);
    return vers_2_h3_alnps[0].h3_alpns;
}

enum lsquic_version
lsquic_alpn2ver (const char *alpn, size_t len)
{
    static const struct el {
        size_t len;
        char alpn[10];
        enum lsquic_version version;
    } map[] = {
        {sizeof("h3-Q043")-1,"h3-Q043", LSQVER_043},
        {sizeof("h3-Q046")-1,"h3-Q046", LSQVER_046},
        {sizeof("h3-Q050")-1,"h3-Q050", LSQVER_050},
        {sizeof("h3-27")-1,"h3-27", LSQVER_ID27},
        {sizeof("h3-29")-1,"h3-29", LSQVER_ID29},
        {sizeof("h3")-1,"h3", LSQVER_I001},
    };
    const struct el *el;

    if (alpn)
        for (el = map; el < map + sizeof(map) / sizeof(map[0]); ++el)
            if (el->len == len && 0 == strncmp(el->alpn, alpn, len))
                return el->version;

    return -1;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants