17 Commits

Author SHA1 Message Date
lijia
8d7b85f98c support aarch64 2024-11-15 11:32:26 +08:00
lijia
513b9b52d9 backport to master, from TSG-21660:fix support QUIC CHLO fragment 2024-10-21 17:30:48 +08:00
杨威
e770ce2c84 Resolve OMPUB-1493 "Fix " 2024-10-16 03:44:26 +00:00
liuxueli
1ab2559887 TSG-19817: Bugfix memory leak 2024-03-07 14:05:28 +08:00
yangwei
33a2bc5b39 🐎 ci(travis): remove sentry-cli 2024-01-11 16:58:54 +08:00
yangwei
aebc66e015 🎈 perf(QUIC_MAX_UDP_PAYLOAD_SIZE): from 65527 to 1460
reduce mem alloc
2024-01-11 15:46:09 +08:00
liuxueli
a7d76dda73 TSG-16626: 收到UDP Close状态,若未调用过业务层则不需要通知业务层close状态 2023-08-25 18:30:30 +08:00
yangwei
4d731800bf 🐞 fix(parse_quic_uncryption_payload): 增加长度判断,修复长度异常时造成的内存非法读
附test/pcap/quic_len-2.pcapng为解析长度异常的包
2023-07-28 23:24:57 +08:00
yangwei
1b678406e7 🔧 build(cmake version): 更新最低版本要求至3.10,修复changelog脚本生成可能报错的问题 2023-07-28 23:22:51 +08:00
yangwei
479fd1a771 🐞 fix(quic version len): 增加包长判断,避免读越界 2023-07-26 19:21:14 +08:00
liuxueli
bfeae04470 Debug版本链接ASAN,用于定位问题 2023-07-26 11:19:32 +08:00
liuxueli
513732e4f1 第一个数据包仅解析一次,节省cpu 2023-06-27 13:34:19 +08:00
liuxueli
96f9ce34ca 收到上层业务返回drop pkt状态时,不关闭对流的处理 2023-02-16 10:20:46 +08:00
liuxueli
ffb443ed7e OMPUB-527: 从解密后的client hello负载中解析user agent参数时,未对参数长度负值进行判断导致parse_quic_transport_parameter函数死循环触发sapp的watchdog timeout 2022-06-16 15:39:13 +08:00
liuxueli
98c567cf88 TSG-9724: 适配Rocky Linux8.5 2022-03-11 13:19:05 +08:00
刘学利
d76065f87e Merge branch 'feature-use-nginx-quic' into 'master'
TSG-8455 基于Nginx-QUIC和OpenSSL重构QUIC解析层

See merge request MESA_Platform/quic!3
2021-11-12 08:39:24 +00:00
刘学利
3605410615 TSG-8455 基于Nginx-QUIC和OpenSSL重构QUIC解析层 2021-11-12 08:39:24 +00:00
36 changed files with 1874 additions and 1687 deletions

4
.gitignore vendored
View File

@@ -6,7 +6,9 @@ Debug
.project
.settings/
SI
build/
build*/
src/inc
src/lib64
cmake-build-*/
.cache/
.vscode/

View File

@@ -1,41 +1,100 @@
image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
variables:
GIT_STRATEGY: "clone"
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rocky8-for-sapp"
BUILD_IMAGE_AARCH64_ROCKY9: "git.mesalab.cn:7443/mesa_platform/build-env:rocky9-aarch64"
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
INSTALL_PREFIX: "/opt/MESA/lib/"
INSTALL_DEPENDENCY_LIBRARY: libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel sapp-devel framework_env libMESA_prof_load-devel sapp-devel openssl-devel glib2-devel libasan libbreakpad_mini-devel libMESA_htable-devel systemd-devel
INSTALL_DEPENDENCY_PLATFORM: sapp-devel libasan systemd-devel libnsl glib2-devel libmnl-devel libnfnetlink-devel
INSTALL_DEPENDENCY_FRAMEWORK: libMESA_handle_logger-devel libcjson-devel libMESA_field_stat2-devel framework_env libMESA_prof_load-devel libbreakpad_mini-devel libMESA_htable-devel libfieldstat3 libfieldstat4
INSTALL_PREFIX: "/opt/tsg/sapp/"
stages:
- cppcheck
- build
- test
- package
###############################################################################
# cppcheck
###############################################################################
.cppcheck_script:
variables:
BUILD_TYPE: Debug
stage: cppcheck
script:
- mkdir -p build; cd build; cmake3 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
- >
cppcheck --project=compile_commands.json
--enable=all
--error-exitcode=1
--suppress=unusedFunction
--suppress=missingInclude
--suppress=uselessAssignmentPtrArg
--suppress=unmatchedSuppression
--suppress=variableScope
--suppress=unreadVariable
--suppress=cstyleCast
--suppress=memleakOnRealloc
--suppress=constParameter
--suppress=uselessAssignmentArg
--suppress=uninitvar
--suppress=unusedStructMember
--suppress=preprocessorErrorDirective
--suppress=syntaxError
--suppress=alidscanf
--suppress=knownConditionTrueFalse
--suppress=invalidscanf
--suppress=nullPointerRedundantCheck
--suppress=shiftNegativeLHS
--suppress=unsignedLessThanZero
--suppress=arithOperationsOnVoidPointer
--suppress=invalidPrintfArgType_sint
.build_by_travis:
run_cppcheck_for_x86_64_rocky8:
extends: .cppcheck_script
image: $BUILD_IMAGE_CENTOS8
tags:
- tsg-os-builder-el8
run_cppcheck_for_aarch64_rocky9:
extends: .cppcheck_script
image: $BUILD_IMAGE_AARCH64_ROCKY9
tags:
- tsg-os-builder-aarch64
###############################################################################
# build for rocky8
###############################################################################
.build_before_script:
before_script:
- mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/
- ln -s $CI_PROJECT_DIR $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
- cd $BUILD_PADDING_PREFIX/$CI_PROJECT_PATH
- chmod +x ./ci/travis.sh
script:
- yum makecache
- ./ci/travis.sh
- cd build
tags:
- share
- yum install -y elfutils-libelf-devel
run_test:
.build_by_travis_for_centos8:
stage: build
image: $BUILD_IMAGE_CENTOS8
extends: .build_before_script
script:
- ./ci/travis.sh
tags:
- share
run_test_for_centos8:
stage: test
extends: .build_by_travis
extends: .build_by_travis_for_centos8
script:
- yum makecache
- ./ci/travis.sh
- cd build
- ctest --verbose
- ctest3 --verbose
branch_build_debug:
branch_build_debug_for_centos8:
stage: build
extends: .build_by_travis
extends: .build_by_travis_for_centos8
variables:
BUILD_TYPE: Debug
except:
@@ -43,27 +102,27 @@ branch_build_debug:
- /^master.*$/i
- tags
branch_build_release:
branch_build_release_for_centos8:
stage: build
variables:
BUILD_TYPE: RelWithDebInfo
extends: .build_by_travis
extends: .build_by_travis_for_centos8
except:
- /^develop.*$/i
- /^master.*$/i
- tags
develop_build_debug:
stage: package
extends: .build_by_travis
develop_build_debug_for_centos8:
stage: build
extends: .build_by_travis_for_centos8
variables:
BUILD_TYPE: Debug
PACKAGE: 1
UPLOAD_RPM: 1
ASAN_OPTION: ADDRESS
TESTING_VERSION_BUILD: 1
PULP3_REPO_NAME: protocol-testing-x86_64.el7
PULP3_DIST_NAME: protocol-testing-x86_64.el7
PULP3_REPO_NAME: protocol-testing-x86_64.el8
PULP3_DIST_NAME: protocol-testing-x86_64.el8
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-debug"
paths:
@@ -72,16 +131,16 @@ develop_build_debug:
- /^develop.*$/i
- /^master.*$/i
develop_build_release:
stage: package
extends: .build_by_travis
develop_build_release_for_centos8:
stage: build
extends: .build_by_travis_for_centos8
variables:
BUILD_TYPE: RelWithDebInfo
PACKAGE: 1
UPLOAD_RPM: 1
TESTING_VERSION_BUILD: 1
PULP3_REPO_NAME: protocol-testing-x86_64.el7
PULP3_DIST_NAME: protocol-testing-x86_64.el7
PULP3_REPO_NAME: protocol-testing-x86_64.el8
PULP3_DIST_NAME: protocol-testing-x86_64.el8
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-release"
paths:
@@ -90,15 +149,16 @@ develop_build_release:
- /^develop.*$/i
- /^master.*$/i
release_build_debug:
release_build_debug_for_centos8:
stage: package
variables:
BUILD_TYPE: Debug
PACKAGE: 1
UPLOAD_RPM: 1
PULP3_REPO_NAME: protocol-stable-x86_64.el7
PULP3_DIST_NAME: protocol-stable-x86_64.el7
extends: .build_by_travis
ASAN_OPTION: ADDRESS
PULP3_REPO_NAME: protocol-stable-x86_64.el8
PULP3_DIST_NAME: protocol-stable-x86_64.el8
extends: .build_by_travis_for_centos8
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-debug"
paths:
@@ -106,7 +166,7 @@ release_build_debug:
only:
- tags
release_build_release:
release_build_release_for_centos8:
stage: package
variables:
BUILD_TYPE: RelWithDebInfo
@@ -114,12 +174,157 @@ release_build_release:
UPLOAD_RPM: 1
UPLOAD_SYMBOL_FILES: 1
SYMBOL_TARGET: quic
PULP3_REPO_NAME: protocol-stable-x86_64.el7
PULP3_DIST_NAME: protocol-stable-x86_64.el7
extends: .build_by_travis
PULP3_REPO_NAME: protocol-stable-x86_64.el8
PULP3_DIST_NAME: protocol-stable-x86_64.el8
extends: .build_by_travis_for_centos8
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-release"
paths:
- build/*.rpm
only:
- tags
###############################################################################
# build for rocky9
###############################################################################
.build_by_travis_for_rocky9:
stage: build
image: $BUILD_IMAGE_AARCH64_ROCKY9
extends: .build_before_script
script:
- yum install -y perl-FindBin
- ./ci/travis.sh
tags:
- tsg-os-builder-aarch64
branch_build_debug_for_rocky9:
stage: build
extends: .build_by_travis_for_rocky9
variables:
BUILD_TYPE: Debug
except:
- /^develop.*$/i
- /^master.*$/i
- tags
branch_build_release_for_rocky9:
stage: build
variables:
BUILD_TYPE: RelWithDebInfo
extends: .build_by_travis_for_rocky9
except:
- /^develop.*$/i
- /^master.*$/i
- tags
develop_build_debug_for_rocky9:
stage: build
extends: .build_by_travis_for_rocky9
variables:
BUILD_TYPE: Debug
PACKAGE: 1
UPLOAD_RPM: 1
ASAN_OPTION: ADDRESS
TESTING_VERSION_BUILD: 1
PULP3_REPO_NAME: protocol-testing-aarch64.el9
PULP3_DIST_NAME: protocol-testing-aarch64.el9
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-debug"
paths:
- build/*.rpm
only:
- /^develop.*$/i
- /^master.*$/i
develop_build_release_for_rocky9:
stage: build
extends: .build_by_travis_for_rocky9
variables:
BUILD_TYPE: RelWithDebInfo
PACKAGE: 1
UPLOAD_RPM: 1
TESTING_VERSION_BUILD: 1
PULP3_REPO_NAME: protocol-testing-aarch64.el9
PULP3_DIST_NAME: protocol-testing-aarch64.el9
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-release"
paths:
- build/*.rpm
only:
- /^develop.*$/i
- /^master.*$/i
release_build_debug_for_rocky9:
stage: package
variables:
BUILD_TYPE: Debug
PACKAGE: 1
UPLOAD_RPM: 1
ASAN_OPTION: ADDRESS
PULP3_REPO_NAME: protocol-stable-aarch64.el9
PULP3_DIST_NAME: protocol-stable-aarch64.el9
extends: .build_by_travis_for_rocky9
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-debug"
paths:
- build/*.rpm
only:
- tags
release_build_release_for_rocky9:
stage: package
variables:
BUILD_TYPE: RelWithDebInfo
PACKAGE: 1
UPLOAD_RPM: 1
UPLOAD_SYMBOL_FILES: 0
SYMBOL_TARGET: quic
PULP3_REPO_NAME: protocol-stable-aarch64.el9
PULP3_DIST_NAME: protocol-stable-aarch64.el9
extends: .build_by_travis_for_rocky9
artifacts:
name: "quic-$CI_COMMIT_REF_NAME-release"
paths:
- build/*.rpm
only:
- tags
###############################################################################
# test
###############################################################################
.download_rpm_package: &download_rpm_package
- yumdownloader sapp-4.3.69.6dd815e
- yumdownloader sapp-devel-4.3.69.6dd815e
- mv sapp-4.3.69.6dd815e*.rpm /tmp/sapp.rpm
- mv sapp-devel-4.3.69.6dd815e*.rpm /tmp/sapp-devel.rpm
.install_rpm_package: &install_rpm_package
- rpm -e sapp || true
- rpm -e sapp-devel || true
- rpm -ivh /tmp/sapp.rpm --prefix=${INSTALL_PREFIX} --force --nodeps
- rpm -ivh /tmp/sapp-devel.rpm --prefix=${INSTALL_PREFIX} --force --nodeps
- rpm -qa | grep sapp
- ls -l ${INSTALL_PREFIX}
- ldd ${INSTALL_PREFIX}/sapp
run_test_for_centos8:
stage: test
extends: .build_by_travis_for_centos8
script:
- yum makecache
- ./ci/travis.sh
- *download_rpm_package
- *install_rpm_package
- ctest3 --verbose
run_test_for_rocky9:
stage: test
extends: .build_by_travis_for_rocky9
script:
- yum makecache
- yum install -y perl-FindBin
- ./ci/travis.sh
- *download_rpm_package
- *install_rpm_package
- ctest3 --verbose

View File

@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 2.8...3.10)
set(lib_name quic)
@@ -28,25 +28,26 @@ elseif(ASAN_OPTION MATCHES "THREAD")
endif()
# end of for ASAN
set(CMAKE_INSTALL_PREFIX /home/mesasoft/sapp_run)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/opt/tsg/sapp" CACHE PATH "default install path" FORCE)
message(STATUS "CMAKE_INSTALL_PREFIX='${CMAKE_INSTALL_PREFIX}'")
endif()
include_directories(include)
include_directories(/opt/MESA/include/MESA/)
include_directories(/usr/include/glib-2.0/)
#include_directories(/usr/include/glib-2.0/include/)
include_directories(/usr/lib64/glib-2.0/include)
add_subdirectory(support)
file(GLOB SRC
"src/*.cpp"
)
set(DEPEND_DYN_LIB ssl crypto MESA_handle_logger)
set(DEPEND_DYN_LIB MESA_handle_logger)
# Shared Library Output
add_library(quic SHARED ${SRC})
set_target_properties(quic PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
set_target_properties(quic PROPERTIES PREFIX "")
target_link_libraries(quic ${DNS_DEPEND_DYN_LIB} glib-2.0 pthread -Wl,--whole-archive libgpg-error-static -Wl,--no-whole-archive libgcrypt-static)
target_link_libraries(quic ${DNS_DEPEND_DYN_LIB} pthread -Wl,--no-whole-archive openssl-crypto-static -Wl,--no-whole-archive openssl-ssl-static)
set_target_properties(quic PROPERTIES OUTPUT_NAME ${lib_name})
enable_testing()

View File

@@ -33,12 +33,16 @@ env | sort
: "${COMPILER_IS_GNUCXX:=OFF}"
# Install dependency from YUM
if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
yum install -y $INSTALL_DEPENDENCY_LIBRARY
if [ -n "${INSTALL_DEPENDENCY_FRAMEWORK}" ]; then
yum install -y $INSTALL_DEPENDENCY_FRAMEWORK
source /etc/profile.d/framework.sh
fi
if [ $ASAN_OPTION ];then
if [ -n "${INSTALL_DEPENDENCY_PLATFORM}" ]; then
yum install -y $INSTALL_DEPENDENCY_PLATFORM
fi
if [ $ASAN_OPTION ] && [ -f "/opt/rh/devtoolset-7/enable" ] ;then
source /opt/rh/devtoolset-7/enable
fi
@@ -63,9 +67,3 @@ if [ -n "${UPLOAD_RPM}" ]; then
python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm
fi
if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then
rpm -i $SYMBOL_TARGET*debuginfo*.rpm
_symbol_file=`find /usr/lib/debug/ -name "$SYMBOL_TARGET*.so*.debug"`
cp $_symbol_file ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
sentry-cli upload-dif -t elf ${_symbol_file}info.${CI_COMMIT_SHORT_SHA}
fi

View File

@@ -12,18 +12,18 @@ set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}.${VERSION_BUILD}")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_BUILD}")
execute_process(COMMAND bash -c "echo -ne \"`uname -r | awk -F'.' '{print $5\".\"$6\".\"$7}'`\"" OUTPUT_VARIABLE SYSTEM_VERSION)
execute_process(COMMAND sh changelog.sh ${CMAKE_BINARY_DIR} WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/cmake)
SET(CPACK_RPM_CHANGELOG_FILE ${CMAKE_BINARY_DIR}/changelog.txt)
# RPM Build
set(CPACK_GENERATOR "RPM")
set(CPACK_RPM_AUTO_GENERATED_FILE_NAME ON)
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_VENDOR "MESA")
set(CPACK_RPM_PACKAGE_AUTOREQPROV "yes")
set(CPACK_RPM_PACKAGE_RELEASE_LIBRARY "on")
set(CPACK_RPM_PACKAGE_RELEASE_DIST "on")
set(CPACK_RPM_DEBUGINFO_PACKAGE "on")
set(CPACK_RPM_PACKAGE_DEBUG 1)
set(CPACK_RPM_COMPONENT_INSTALL ON)
set(CPACK_COMPONENTS_IGNORE_GROUPS 1)
@@ -32,17 +32,12 @@ set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
set(CPACK_RPM_LIBRARIES_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
set(CPACK_RPM_LIBRARIES_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARIES_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
set(CPACK_COMPONENT_LIBRARIES_GROUP "libraries")
set(CPACK_COMPONENT_PROFILE_GROUP "libraries")
set(CPACK_COMPONENT_LIBRARIES_GROUP "LIBRARIES")
set(CPACK_COMPONENT_PROFILE_GROUP "LIBRARIES")
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
set(CPACK_RPM_HEADER_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
set(CPACK_RPM_HEADER_DEBUGINFO_FILE_NAME "${CPACK_RPM_HEADER_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
set(CPACK_COMPONENT_HEADER_GROUP "header")
set(CPACK_COMPONENT_HEADER_GROUP "HEADER")
set(CPACK_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})

View File

@@ -1,4 +1,4 @@
#!/bin/sh
work_path=$1
branch=`git status | grep branch | awk '{print $NF}'`
branch=`git status | grep 'On branch' | awk '{print $NF}'`
git log --branches=$branch --no-merges --date=local --show-signature --pretty="* %ad %an %ae %nhash: %H%ncommit:%n%B" | awk -F"-" '{print "- "$0}' | sed 's/- \*/\*/g' | sed 's/- $//g' | sed 's/-/ -/g' | sed 's/[0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}//g' > $work_path/changelog.txt

View File

@@ -0,0 +1,70 @@
//https://jira.geedge.net/browse/OMPUB-527
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static int msb2_varint_decode(const unsigned char *buf, long *out)
{
unsigned long val = buf[0] & 0x3f;
unsigned int nfollow = 1<<(buf[0]>>6);
switch (nfollow-1)
{
case 7: val = (val << 8) | buf[nfollow - 7]; /*fail through*/
case 6: val = (val << 8) | buf[nfollow - 6]; /*fail through*/
case 5: val = (val << 8) | buf[nfollow - 5]; /*fail through*/
case 4: val = (val << 8) | buf[nfollow - 4]; /*fail through*/
case 3: val = (val << 8) | buf[nfollow - 3]; /*fail through*/
case 2: val = (val << 8) | buf[nfollow - 2]; /*fail through*/
case 1: val = (val << 8) | buf[nfollow-1];
case 0: break;
}
*out=val;
return nfollow;
}
int parse_quic_transport_parameter(const char *quic_para, int quic_para_len, int thread_seq)
{
int one_para_length=0;
int para_offset=0;
long one_para_type=0;
while(quic_para_len > para_offset)
{
para_offset+=msb2_varint_decode((const unsigned char *)(quic_para+para_offset), &one_para_type);
switch(one_para_type)
{
//case EXT_QUIC_PARAM_USER_AGENT: // 2021-10-20 deprecated
case 0x3129:
one_para_length=quic_para[para_offset++]; // length=1
if(one_para_length+para_offset>quic_para_len)
{
return 0;
}
//para_offset+=copy_extension_tag(quic_para+para_offset, one_para_length, &client_hello->user_agent, thread_seq);
return 1;
default:
one_para_length=(int)(quic_para[para_offset++]); // length=1
if(one_para_length<0 || one_para_length>quic_para_len)
{
break;
}
para_offset+=one_para_length;
break;
}
}
return 0;
}
int main(int argc, char *argv[])
{
char buff1[106]={0x80, 0x0, 0x47, 0x52, 0x4, 0x0, 0x0, 0x0, 0x1, 0x20, 0x4, 0x80, 0x1, 0x0, 0x0, 0xf, 0x0, 0x4, 0x4, 0x80, 0xf0, 0x0, 0x0, 0x8, 0x2, 0x40, 0x64, 0x7, 0x4, 0x80, 0x60, 0x0, 0x0, 0x9, 0x2, 0x40, 0x67, 0x6, 0x4, 0x80, 0x60, 0x0, 0x0, 0x80, 0xff, 0x73, 0xdb, 0xc, 0x0, 0x0, 0x0, 0x1, 0x3a, 0x6a, 0x9b, 0xaa, 0x4f, 0x2f, 0xbd, 0xc, 0xd5, 0xe2, 0xae, 0x32, 0x45, 0x6, 0x2e, 0xf, 0xc5, 0x82, 0x94, 0x3d, 0x5d, 0xb2, 0x69, 0x2c, 0x25, 0xbd, 0xd5, 0x85, 0x99, 0x72, 0xeb, 0x3, 0x2, 0x45, 0xc0, 0x1, 0x4, 0x80, 0x0, 0x75, 0x30, 0x71, 0x28, 0x4, 0x52, 0x56, 0x43, 0x4d, 0x5, 0x4, 0x80, 0x60, 0x0, 0x0};
char buff2[99]={0x71, 0x27, 0x4, 0x80, 0x2, 0xa5, 0xb2, 0xe4, 0xcf, 0x74, 0x5b, 0xf5, 0x6, 0x41, 0x20, 0x0, 0x8, 0x2, 0x40, 0x64, 0x4, 0x4, 0x80, 0xd4, 0x9f, 0xb7, 0x6f, 0xdf, 0xed, 0x48, 0x94, 0x18, 0xd7, 0x53, 0xf7, 0x92, 0x6, 0x94, 0xa0, 0x0, 0x0, 0x1, 0x4, 0x80, 0x0, 0x75, 0x30, 0xf, 0x0, 0x80, 0xff, 0x73, 0xdb, 0xc, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x8a, 0x7a, 0x8a, 0x3a, 0x9, 0x2, 0x40, 0x67, 0x3, 0x2, 0x45, 0xc0, 0x5, 0x4, 0x80, 0x60, 0x0, 0x0, 0x71, 0x28, 0x4, 0x52, 0x56, 0x43, 0x4d, 0x20, 0x4, 0x80, 0x1, 0x0, 0x0, 0x7, 0x4, 0x80, 0x60, 0x0, 0x0};
parse_quic_transport_parameter(buff1, 106, 0);
parse_quic_transport_parameter(buff2, 99, 0);
return 0;
}

View File

@@ -49,7 +49,7 @@ struct quic_info
//buff_len minimun 32bytes
int quic_version_int2string(unsigned int version, char *buff, int buff_len);
//ret: 0: not quic, >0: quic version
unsigned int quic_protocol_identify(struct streaminfo *a_stream, void *a_packet, char *out_sni, int *out_sni_len, char *out_ua, int *out_ua_len);
//ret: NULL: not quic, quic_info: quic version
struct quic_info *quic_protocol_identify(const struct streaminfo *a_stream);
#endif /* SRC__QUIC_H__ */

View File

@@ -1,55 +0,0 @@
CC = gcc
CCC = g++
INCLUDES = -I/opt/MESA/include/ -I/home/sjzn/workspace/iquic_ngtcp2/openssl/build/include
LIB = -L./opt/MESA/lib/ -L/home/sjzn/workspace/iquic_ngtcp2/openssl/build/lib -lssl -lcrypto
#CFLAGS = -g3 -Wall -fPIC $(INCLUDES)
#CCCFLAGS = -std=c++11 -g3 -Wall -fPIC $(INCLUDES)
CFLAGS = -g3 -Wall -fPIC
CCCFLAGS = -std=c++11 -g3 -Wall -fPIC
TARGET = quic.so
INF = quic.inf
INSTALL_TARGET=$(TARGET)
LIB_FILE = $(wildcard ../lib/*.a)
SOURCES = $(wildcard *.c) $(wildcard gquic/*.c)
OBJECTS = $(SOURCES:.c=.o)
DEPS = $(SOURCES:.c=.d)
all:$(TARGET)
$(TARGET):$(OBJECTS) $(LIB_FILE)
$(CCC) -shared $(CFLAGS) $(OBJECTS) $(LIB) -o $@
cp $(TARGET) ../bin/
%.o:%.c
$(CC) -c -o $@ $(CFLAGS) $< $(INCLUDES)
%.o:%.cpp
$(CCC) -c -o $@ $(CCCFLAGS) $< $(INCLUDES)
-include $(DEPS)
clean :
rm -f $(OBJECTS) $(DEPS) $(TARGET)
help:
@echo "-------OBJECTS--------" $(OBJECTS)
PLUGIN_PATH=./plug/protocol
CONFLIST_NAME=conflist_protocol.inf
PLUGIN_DIR_NAME=quic
PLUGIN_INF_NAME=quic.inf
PAPP_PATH=/home/sjzn/gitFile/ceiec/sapp
TARGET_DIR=$(PAPP_PATH)/$(PLUGIN_PATH)/$(PLUGIN_DIR_NAME)/
INSERT_FILE=$(PAPP_PATH)/$(PLUGIN_PATH)/$(CONFLIST_NAME)
INSERT_CONTENT=$(PLUGIN_PATH)/$(PLUGIN_DIR_NAME)/$(PLUGIN_INF_NAME)
install:
mkdir -p $(TARGET_DIR)
cp -r ../bin/*.inf $(TARGET_DIR)
cp -r ../bin/*.so $(TARGET_DIR)
@ret=`cat $(INSERT_FILE)|grep $(INSERT_CONTENT)|wc -l`;if [ $$ret -eq 0 ];then echo $(INSERT_CONTENT) >>$(INSERT_FILE);fi
CONF_DIR=$(PAPP_PATH)/conf/
conf:
mkdir -p $(CONF_DIR)
cp -r ../bin/quic $(CONF_DIR)

View File

@@ -1,213 +0,0 @@
/* pint.h
* Definitions for extracting and translating integers safely and portably
* via pointers.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PINT_H__
#define __PINT_H__
#include <glib.h>
/* Routines that take a possibly-unaligned pointer to a 16-bit, 24-bit,
* 32-bit, 40-bit, ... 64-bit integral quantity, in a particular byte
* order, and fetch the value and return it in host byte order.
*
* The pntohN() routines fetch big-endian values; the pletohN() routines
* fetch little-endian values.
*/
static inline guint16 pntoh16(const void *p)
{
return (guint16)*((const guint8 *)(p)+0)<<8|
(guint16)*((const guint8 *)(p)+1)<<0;
}
static inline guint32 pntoh24(const void *p)
{
return (guint32)*((const guint8 *)(p)+0)<<16|
(guint32)*((const guint8 *)(p)+1)<<8|
(guint32)*((const guint8 *)(p)+2)<<0;
}
static inline guint32 pntoh32(const void *p)
{
return (guint32)*((const guint8 *)(p)+0)<<24|
(guint32)*((const guint8 *)(p)+1)<<16|
(guint32)*((const guint8 *)(p)+2)<<8|
(guint32)*((const guint8 *)(p)+3)<<0;
}
static inline guint64 pntoh40(const void *p)
{
return (guint64)*((const guint8 *)(p)+0)<<32|
(guint64)*((const guint8 *)(p)+1)<<24|
(guint64)*((const guint8 *)(p)+2)<<16|
(guint64)*((const guint8 *)(p)+3)<<8|
(guint64)*((const guint8 *)(p)+4)<<0;
}
static inline guint64 pntoh48(const void *p)
{
return (guint64)*((const guint8 *)(p)+0)<<40|
(guint64)*((const guint8 *)(p)+1)<<32|
(guint64)*((const guint8 *)(p)+2)<<24|
(guint64)*((const guint8 *)(p)+3)<<16|
(guint64)*((const guint8 *)(p)+4)<<8|
(guint64)*((const guint8 *)(p)+5)<<0;
}
static inline guint64 pntoh56(const void *p)
{
return (guint64)*((const guint8 *)(p)+0)<<48|
(guint64)*((const guint8 *)(p)+1)<<40|
(guint64)*((const guint8 *)(p)+2)<<32|
(guint64)*((const guint8 *)(p)+3)<<24|
(guint64)*((const guint8 *)(p)+4)<<16|
(guint64)*((const guint8 *)(p)+5)<<8|
(guint64)*((const guint8 *)(p)+6)<<0;
}
static inline guint64 pntoh64(const void *p)
{
return (guint64)*((const guint8 *)(p)+0)<<56|
(guint64)*((const guint8 *)(p)+1)<<48|
(guint64)*((const guint8 *)(p)+2)<<40|
(guint64)*((const guint8 *)(p)+3)<<32|
(guint64)*((const guint8 *)(p)+4)<<24|
(guint64)*((const guint8 *)(p)+5)<<16|
(guint64)*((const guint8 *)(p)+6)<<8|
(guint64)*((const guint8 *)(p)+7)<<0;
}
static inline guint16 pletoh16(const void *p)
{
return (guint16)*((const guint8 *)(p)+1)<<8|
(guint16)*((const guint8 *)(p)+0)<<0;
}
static inline guint32 pletoh24(const void *p)
{
return (guint32)*((const guint8 *)(p)+2)<<16|
(guint32)*((const guint8 *)(p)+1)<<8|
(guint32)*((const guint8 *)(p)+0)<<0;
}
static inline guint32 pletoh32(const void *p)
{
return (guint32)*((const guint8 *)(p)+3)<<24|
(guint32)*((const guint8 *)(p)+2)<<16|
(guint32)*((const guint8 *)(p)+1)<<8|
(guint32)*((const guint8 *)(p)+0)<<0;
}
static inline guint64 pletoh40(const void *p)
{
return (guint64)*((const guint8 *)(p)+4)<<32|
(guint64)*((const guint8 *)(p)+3)<<24|
(guint64)*((const guint8 *)(p)+2)<<16|
(guint64)*((const guint8 *)(p)+1)<<8|
(guint64)*((const guint8 *)(p)+0)<<0;
}
static inline guint64 pletoh48(const void *p)
{
return (guint64)*((const guint8 *)(p)+5)<<40|
(guint64)*((const guint8 *)(p)+4)<<32|
(guint64)*((const guint8 *)(p)+3)<<24|
(guint64)*((const guint8 *)(p)+2)<<16|
(guint64)*((const guint8 *)(p)+1)<<8|
(guint64)*((const guint8 *)(p)+0)<<0;
}
static inline guint64 pletoh56(const void *p)
{
return (guint64)*((const guint8 *)(p)+6)<<48|
(guint64)*((const guint8 *)(p)+5)<<40|
(guint64)*((const guint8 *)(p)+4)<<32|
(guint64)*((const guint8 *)(p)+3)<<24|
(guint64)*((const guint8 *)(p)+2)<<16|
(guint64)*((const guint8 *)(p)+1)<<8|
(guint64)*((const guint8 *)(p)+0)<<0;
}
static inline guint64 pletoh64(const void *p)
{
return (guint64)*((const guint8 *)(p)+7)<<56|
(guint64)*((const guint8 *)(p)+6)<<48|
(guint64)*((const guint8 *)(p)+5)<<40|
(guint64)*((const guint8 *)(p)+4)<<32|
(guint64)*((const guint8 *)(p)+3)<<24|
(guint64)*((const guint8 *)(p)+2)<<16|
(guint64)*((const guint8 *)(p)+1)<<8|
(guint64)*((const guint8 *)(p)+0)<<0;
}
/* Pointer routines to put items out in a particular byte order.
* These will work regardless of the byte alignment of the pointer.
*/
static inline void phton16(guint8 *p, guint16 v)
{
p[0] = (guint8)(v >> 8);
p[1] = (guint8)(v >> 0);
}
static inline void phton32(guint8 *p, guint32 v)
{
p[0] = (guint8)(v >> 24);
p[1] = (guint8)(v >> 16);
p[2] = (guint8)(v >> 8);
p[3] = (guint8)(v >> 0);
}
static inline void phton64(guint8 *p, guint64 v) {
p[0] = (guint8)(v >> 56);
p[1] = (guint8)(v >> 48);
p[2] = (guint8)(v >> 40);
p[3] = (guint8)(v >> 32);
p[4] = (guint8)(v >> 24);
p[5] = (guint8)(v >> 16);
p[6] = (guint8)(v >> 8);
p[7] = (guint8)(v >> 0);
}
static inline void phtole32(guint8 *p, guint32 v) {
p[0] = (guint8)(v >> 0);
p[1] = (guint8)(v >> 8);
p[2] = (guint8)(v >> 16);
p[3] = (guint8)(v >> 24);
}
static inline void phtole64(guint8 *p, guint64 v) {
p[0] = (guint8)(v >> 0);
p[1] = (guint8)(v >> 8);
p[2] = (guint8)(v >> 16);
p[3] = (guint8)(v >> 24);
p[4] = (guint8)(v >> 32);
p[5] = (guint8)(v >> 40);
p[6] = (guint8)(v >> 48);
p[7] = (guint8)(v >> 56);
}
/* Subtract two guint32s with respect to wraparound */
#define guint32_wraparound_diff(higher, lower) ((higher>lower)?(higher-lower):(higher+0xffffffff-lower+1))
#endif /* PINT_H */
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local Variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* ex: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/

File diff suppressed because it is too large Load Diff

View File

@@ -1,24 +1,116 @@
/**
* parser-quic.h
*
* Created on 2020-11-26
* @author: qyc
*
*
*/
#ifndef PARSER_QUIC_H
#define PARSER_QUIC_H
#ifndef _QUIC_DEPROTECTION_H
#define _QUIC_DEPROTECTION_H
#ifdef __cplusplus
extern "C" {
#ifdef __cpluscplus
extern "C"
{
#endif
/*ret: 1 sucess*/
int quic_deprotection(const char *payload, unsigned int length, unsigned char *out, unsigned int *out_length);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <sys/stat.h>
#include <arpa/inet.h>
int gcry_init();
#ifdef __cplusplus
#ifdef DEBUG_SWITCH
#define LOG_DEBUG(format, ...) \
{ \
fprintf(stdout, format "\n", ##__VA_ARGS__); \
fflush(stdout); \
}
#define LOG_WARN(format, ...) \
{ \
fprintf(stderr, format "\n", ##__VA_ARGS__); \
fflush(stderr); \
}
#define LOG_ERROR(format, ...) \
{ \
fprintf(stderr, format "\n", ##__VA_ARGS__); \
fflush(stderr); \
}
#else
#define LOG_DEBUG(format, ...)
#define LOG_WARN(format, ...)
#define LOG_ERROR(format, ...)
#endif
#define QUIC_MAX_UDP_PAYLOAD_SIZE 1460
#define quic_string(str) \
{ \
sizeof(str) - 1, (u_char *)str \
}
typedef struct
{
size_t len;
u_char *data;
} quic_str_t;
typedef struct quic_secret_s
{
quic_str_t secret;
quic_str_t key;
quic_str_t iv;
quic_str_t hp;
} quic_secret_t;
typedef enum
{
ssl_encryption_initial = 0,
ssl_encryption_early_data = 1,
ssl_encryption_handshake = 2,
ssl_encryption_application = 3,
} ssl_encryption_level_t;
typedef enum
{
LONG = 0,
SHORT = 1,
} quic_header_type;
typedef struct
{
quic_secret_t client_secret;
ssl_encryption_level_t level; // QUIC Packet Process Level
quic_header_type header_type; // QUIC Packet Header Type
uint32_t version; // QUIC Version
uint8_t flags; // QUIC Flags
u_char *data; // QUIC Packet Data
size_t len; // QUIC Packet Length
u_char *pos; // Process Ptr
uint64_t largest_pkt_num;
quic_str_t dcid; // QUIC DCID
quic_str_t scid; // QUIC SCID
quic_str_t token; // QUIC TOKEN
size_t pkt_len;
uint64_t pkt_num; // QUIC Packet Number
u_char *plaintext;
quic_str_t payload; // Decrypted data
unsigned key_phase : 1;
} quic_dpt_t;
quic_dpt_t *quic_deprotection_new(void);
void quic_deprotection_free(quic_dpt_t *dpt);
void quic_deprotection_dump(quic_dpt_t *dpt);
int quic_deprotection(quic_dpt_t *dpt, const u_char *payload, size_t payload_len);
#ifdef __cpluscplus
}
#endif
#endif //PARSER_QUIC_H
#endif

View File

@@ -1,136 +0,0 @@
/**
* utils.c
*
* Created on 2020-11-27
* @author: qyc
*
* @explain:
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "pint.h"
#include "quic_deprotection_utils.h"
#include "quic_deprotection_wsgcrypt.h"
/*
* Computes HKDF-Expand-Label(Secret, Label, Hash(context_value), Length) with a
* custom label prefix. If "context_hash" is NULL, then an empty context is
* used. Otherwise it must have the same length as the hash algorithm output.
*/
static gboolean tls13_hkdf_expand_label_context(int md, const StringInfo *secret, const char *label_prefix, const char *label, const guint8 *context_hash, guint8 context_length, guint16 out_len, guchar **out)
{
/* RFC 8446 Section 7.1:
* HKDF-Expand-Label(Secret, Label, Context, Length) =
* HKDF-Expand(Secret, HkdfLabel, Length)
* struct {
* uint16 length = Length;
* opaque label<7..255> = "tls13 " + Label; // "tls13 " is label prefix.
* opaque context<0..255> = Context;
* } HkdfLabel;
*
* RFC 5869 HMAC-based Extract-and-Expand Key Derivation Function (HKDF):
* HKDF-Expand(PRK, info, L) -> OKM
*/
gcry_error_t err;
const guint label_prefix_length = (guint)strlen(label_prefix);
const guint label_length = (guint)strlen(label);
// Some sanity checks
g_assert(label_length > 0 && label_prefix_length + label_length <= 255);
// info = HkdfLabel { length, label, context }
GByteArray *info = g_byte_array_new();
const guint16 length = g_htons(out_len);
g_byte_array_append(info, (const guint8 *)&length, sizeof(length));
const guint8 label_vector_length = label_prefix_length + label_length;
g_byte_array_append(info, &label_vector_length, 1);
g_byte_array_append(info, (const guint8 *)label_prefix, label_prefix_length);
g_byte_array_append(info, (const guint8 *)label, label_length);
g_byte_array_append(info, &context_length, 1);
if (context_length)
g_byte_array_append(info, context_hash, context_length);
*out = (guchar *)g_malloc(out_len);
err = hkdf_expand(md, secret->data, secret->data_len, info->data, info->len, *out, out_len);
g_byte_array_free(info, TRUE);
if (err) {
printf("%s failed %d: %s\n", G_STRFUNC, md, gcry_strerror(err));
g_free(*out);
*out = NULL;
return FALSE;
}
return TRUE;
}
gboolean tls13_hkdf_expand_label(int md, const StringInfo *secret, const char *label_prefix, const char *label, guint16 out_len, guchar **out)
{
return tls13_hkdf_expand_label_context(md, secret, label_prefix, label, NULL, 0, out_len, out);
}
static guint8 tvb_get_guint8(const char *tvb, const gint offset)
{
const guint8 *ptr;
ptr = (guint8 *)tvb + offset;
return *ptr;
}
static guint16 tvb_get_ntohs(const char *tvb, const gint offset)
{
const guint8 *ptr;
ptr = (guint8 *)tvb + offset;
return pntoh16(ptr);
}
static guint32 tvb_get_ntohl(const char *tvb, const gint offset)
{
const guint8 *ptr;
ptr = (guint8 *)tvb + offset;
return pntoh32(ptr);
}
static guint64 tvb_get_ntoh64(const char *tvb, const gint offset)
{
const guint8 *ptr;
ptr = (guint8 *)tvb + offset;
return pntoh64(ptr);
}
guint tvb_get_varint(const char *tvb, guint offset, guint maxlen, guint64 *value, const guint encoding)
{
*value = 0;
if (encoding & ENC_VARINT_QUIC) {
// calculate variable length
*value = tvb_get_guint8(tvb, offset);
switch((*value) >> 6) {
case 0: /* 0b00 => 1 byte length (6 bits Usable) */
(*value) &= 0x3F;
return 1;
case 1: /* 0b01 => 2 bytes length (14 bits Usable) */
*value = tvb_get_ntohs(tvb, offset) & 0x3FFF;
return 2;
case 2: /* 0b10 => 4 bytes length (30 bits Usable) */
*value = tvb_get_ntohl(tvb, offset) & 0x3FFFFFFF;
return 4;
case 3: /* 0b11 => 8 bytes length (62 bits Usable) */
*value = tvb_get_ntoh64(tvb, offset) & G_GUINT64_CONSTANT(0x3FFFFFFFFFFFFFFF);
return 8;
default: /* No Possible */
g_assert_not_reached();
break;
}
}
// 10 bytes scanned, but no bytes' msb is zero
return 0;
}

View File

@@ -1,43 +0,0 @@
/**
* utils.h
*
* Created on 2020-11-27
* @author: qyc
*
* @explain:
*/
#ifndef UTILS_H
#define UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "glib.h"
/*
* Decodes a variable-length integer used in QUIC protocol
* See https://tools.ietf.org/html/draft-ietf-quic-transport-08#section-8.1
*/
#define ENC_VARINT_QUIC 0x00000004
/* Explicit and implicit nonce length (RFC 5116 - Section 3.2.1) */
#define TLS13_AEAD_NONCE_LENGTH 12
/* XXX Should we use GByteArray instead? */
typedef struct _StringInfo {
// Backing storage which may be larger than data_len
guchar *data;
// Length of the meaningful part of data
guint data_len;
} StringInfo;
gboolean tls13_hkdf_expand_label(int md, const StringInfo *secret, const char *label_prefix, const char *label, guint16 out_len, guchar **out);
guint tvb_get_varint(const char *tvb, guint offset, guint maxlen, guint64 *value, const guint encoding);
#ifdef __cplusplus
}
#endif
#endif //UTILS_H

View File

@@ -1,69 +0,0 @@
/**
* wsgcrypt.c
*
* Created on 2020-11-26
* @author: qyc
*
* @explain:
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "quic_deprotection_wsgcrypt.h"
gcry_error_t ws_hmac_buffer(int algo, void *digest, const void *buffer, size_t length, const void *key, size_t keylen)
{
gcry_md_hd_t hmac_handle;
gcry_error_t result = gcry_md_open(&hmac_handle, algo, GCRY_MD_FLAG_HMAC);
if (result) {
return result;
}
result = gcry_md_setkey(hmac_handle, key, keylen);
if (result) {
gcry_md_close(hmac_handle);
return result;
}
gcry_md_write(hmac_handle, buffer, length);
memcpy(digest, gcry_md_read(hmac_handle, 0), gcry_md_get_algo_dlen(algo));
gcry_md_close(hmac_handle);
return GPG_ERR_NO_ERROR;
}
gcry_error_t hkdf_expand(int hashalgo, const guint8 *prk, guint prk_len, const guint8 *info, guint info_len, guint8 *out, guint out_len)
{
// Current maximum hash output size: 48 bytes for SHA-384.
guchar lastoutput[48];
gcry_md_hd_t h;
gcry_error_t err;
const guint hash_len = gcry_md_get_algo_dlen(hashalgo);
// Some sanity checks
if (!(out_len > 0 && out_len <= 255 * hash_len) || !(hash_len > 0 && hash_len <= sizeof(lastoutput)))
return GPG_ERR_INV_ARG;
err = gcry_md_open(&h, hashalgo, GCRY_MD_FLAG_HMAC);
if (err)
return err;
guint offset;
for (offset = 0; offset < out_len; offset += hash_len) {
gcry_md_reset(h);
// Set PRK
gcry_md_setkey(h, prk, prk_len);
if (offset > 0)
// T(1..N)
gcry_md_write(h, lastoutput, hash_len);
// info
gcry_md_write(h, info, info_len);
// constant 0x01..N
gcry_md_putc(h, (guint8)(offset / hash_len + 1));
memcpy(lastoutput, gcry_md_read(h, hashalgo), hash_len);
memcpy(out + offset, lastoutput, MIN(hash_len, out_len - offset));
}
gcry_md_close(h);
return 0;
}

View File

@@ -1,78 +0,0 @@
/**
* wsgcrypt.h
*
* Created on 2020-11-26
* @author: qyc
*
* @explain:
*/
#ifndef WSGCRYPT_H
#define WSGCRYPT_H
#ifdef __cplusplus
extern "C" {
#endif
#include "gcrypt.h"
#include "glib.h"
/*
* Define HAVE_LIBGCRYPT_AEAD here, because it's used in several source
* files.
*/
#if GCRYPT_VERSION_NUMBER >= 0x010600 /* 1.6.0 */
/* Whether to provide support for authentication in addition to decryption. */
#define HAVE_LIBGCRYPT_AEAD
#endif
/*
* Define some other "do we have?" items as well.
*/
#if GCRYPT_VERSION_NUMBER >= 0x010700 /* 1.7.0 */
/* Whether ChaCh20 PNE can be supported. */
#define HAVE_LIBGCRYPT_CHACHA20
/* Whether AEAD_CHACHA20_POLY1305 can be supported. */
#define HAVE_LIBGCRYPT_CHACHA20_POLY1305
#endif
#define HASH_SHA2_256_LENGTH 32
/* Convenience function to calculate the HMAC from the data in BUFFER
of size LENGTH with key KEY of size KEYLEN using the algorithm ALGO avoiding the creating of a
hash object. The hash is returned in the caller provided buffer
DIGEST which must be large enough to hold the digest of the given
algorithm. */
gcry_error_t ws_hmac_buffer(int algo, void *digest, const void *buffer, size_t length, const void *key, size_t keylen);
/**
* RFC 5869 HMAC-based Extract-and-Expand Key Derivation Function (HKDF):
* HKDF-Expand(PRK, info, L) -> OKM
*
* @param hashalgo [in] Libgcrypt hash algorithm identifier.
* @param prk [in] Pseudo-random key.
* @param prk_len [in] Length of prk.
* @param info [in] Optional context (can be NULL if info_len is zero).
* @param info_len [in] Length of info.
* @param out [out] Output keying material.
* @param out_len [in] Size of output keying material.
* @return 0 on success and an error code otherwise.
*/
gcry_error_t hkdf_expand(int hashalgo, const guint8 *prk, guint prk_len, const guint8 *info, guint info_len, guint8 *out, guint out_len);
/*
* Calculate HKDF-Extract(salt, IKM) -> PRK according to RFC 5869.
* Caller MUST ensure that 'prk' is large enough to store the digest from hash
* algorithm 'hashalgo' (e.g. 32 bytes for SHA-256).
*/
static inline gcry_error_t hkdf_extract(int hashalgo, const guint8 *salt, size_t salt_len, const guint8 *ikm, size_t ikm_len, guint8 *prk)
{
/* PRK = HMAC-Hash(salt, IKM) where salt is key, and IKM is input. */
return ws_hmac_buffer(hashalgo, prk, ikm, ikm_len, salt, salt_len);
}
#ifdef __cplusplus
}
#endif
#endif //WSGCRYPT_H

View File

@@ -6,9 +6,11 @@
*/
#include <stdio.h>
#include <MESA/stream_inc/stream_base.h>
#include <MESA/MESA_handle_logger.h>
#include <MESA/stream.h>
#include <MESA/MESA_prof_load.h>
#include <MESA/MESA_handle_logger.h>
#include "quic.h"
#include "quic_entry.h"
#include "quic_process.h"
@@ -141,47 +143,51 @@ void quic_free_client_hello(struct quic_client_hello *client_hello, int thread_s
return ;
}
void quic_free_context(void** pme, int thread_seq)
void quic_free_context(const struct streaminfo *a_stream, int bridge_id, void *data)
{
if(NULL==*pme)
if(NULL!=data)
{
return ;
struct quic_context *context = (struct quic_context *)data;
quic_free_client_hello(context->quic_info.client_hello, a_stream->threadnum);
if(context->quic_buf.buffer)
{
dictator_free(a_stream->threadnum, context->quic_buf.buffer);
}
dictator_free(a_stream->threadnum, data);
}
struct quic_context *context = (struct quic_context *)*pme;
quic_free_client_hello(context->quic_info.client_hello, thread_seq);
dictator_free(thread_seq, *pme);
*pme=NULL;
return;
}
extern "C" unsigned char QUIC_ENTRY(struct streaminfo *pstream, void**pme, int thread_seq, void *a_packet)
extern "C" unsigned char QUIC_ENTRY(const struct streaminfo *pstream, void**pme, int thread_seq, const void *a_packet)
{
unsigned char state=0;
struct quic_context *context=(struct quic_context *)*pme;
if((g_quic_param.quic_interested_region_flag<QUIC_KEY) || (!is_quic_port(pstream)))
{
return APP_STATE_DROPME;
}
if(*pme==NULL)
if(pstream->opstate==OP_STATE_PENDING)
{
quic_init_context(pme, thread_seq);
context=(struct quic_context *)*pme;
*pme=stream_bridge_async_data_get(pstream, g_quic_param.context_bridge_id);
if(*pme==NULL)
{
*pme=dictator_malloc(thread_seq, sizeof(struct quic_context));
memset(*pme, 0, sizeof(struct quic_context));
}
}
unsigned char state=0;
struct quic_context *context=(struct quic_context *)*pme;
state=quic_analyze_entry(pstream, context, thread_seq, a_packet);
if(pstream->opstate==OP_STATE_CLOSE)
{
state=quic_call_business_plug(pstream, context, NULL, 0, QUIC_INTEREST_KEY_MASK, a_packet);
}
state=quic_analyze_entry(pstream, context, thread_seq, a_packet);
if(state&APP_STATE_DROPME || state&APP_STATE_DROPPKT || pstream->opstate==OP_STATE_CLOSE)
if(state&APP_STATE_DROPME || pstream->opstate==OP_STATE_CLOSE)
{
quic_free_context(pme, thread_seq);
if(context->link_state==1)
{
quic_call_business_plug(pstream, context, NULL, 0, QUIC_INTEREST_KEY_MASK, a_packet);
}
quic_free_context(pstream, g_quic_param.context_bridge_id, *pme);
stream_bridge_async_data_put(pstream, g_quic_param.context_bridge_id, NULL);
*pme=NULL;
return state;
}
@@ -205,7 +211,7 @@ extern "C" int QUIC_INIT(void)
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "DECRYPTED_SWITCH", &g_quic_param.decrypted_switch, 2);
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "MAX_PARSE_PKT_NUM", &g_quic_param.max_parse_pkt_num, 3);
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "QUIC_PORT_LIST", buff, sizeof(buff), "443;8443;");
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "QUIC_PORT_LIST", buff, sizeof(buff), "");
g_quic_param.quic_port_num=parse_quic_port(buff, g_quic_param.quic_port_list, SUPPORT_QUIC_PORT_NUM);
g_quic_param.logger=MESA_create_runtime_log_handle(g_quic_param.log_path, g_quic_param.level);
@@ -226,14 +232,14 @@ extern "C" int QUIC_INIT(void)
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, region_line: %s", g_quic_regionname_conffile, buff);
return -1;
}
if(region_id>MAX_REGION_NUM)
if(region_id>=MAX_REGION_NUM)
{
fclose(fp);
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Read error, Please check %s, bigger than MAX_REGION_NUM, region_line: %s", g_quic_regionname_conffile, buff);
return -1;
}
strncpy(g_quic_param.quic_conf_regionname[region_id], region_name, strlen(region_name));
memcpy(g_quic_param.quic_conf_regionname[region_id], region_name, MIN(sizeof(g_quic_param.quic_conf_regionname[region_id])-1, strlen(region_name)));
g_quic_param.quic_region_cnt++;
memset(region_name, 0, sizeof(region_name));
}
@@ -246,7 +252,8 @@ extern "C" int QUIC_INIT(void)
return -1;
}
gcry_init();
g_quic_param.context_bridge_id=stream_bridge_build("QUIC_CONTEXT", "w");
stream_bridge_register_data_free_cb(g_quic_param.context_bridge_id, quic_free_context);
return 0;
}
@@ -321,6 +328,8 @@ extern "C" long long QUIC_FLAG_CHANGE(char* flag_str)
extern "C" void QUIC_DESTROY(void)
{
MESA_destroy_runtime_log_handle(g_quic_param.logger);
g_quic_param.logger = NULL;
return ;
}

View File

@@ -3,6 +3,10 @@
#include "quic.h"
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#define FALSE 0x00
#define TRUE 0x01
#define MAYBE 0x02
@@ -29,6 +33,7 @@ struct quic_param
int quic_port_num;
int decrypted_switch;
int max_parse_pkt_num;
int context_bridge_id;
unsigned short quic_port_list[SUPPORT_QUIC_PORT_NUM];
char quic_conf_regionname[MAX_REGION_NUM][REGION_NAME_LEN];
char log_path[128];
@@ -47,8 +52,7 @@ enum quic_mes_type{
};
extern struct quic_param g_quic_param;
int is_quic_port(struct streaminfo *pstream);
void quic_free_client_hello(struct quic_client_hello *client_hello, int thread_seq);
int is_quic_port(const struct streaminfo *pstream);
#endif /* SRC_QUIC_ANALYSIS_H_ */

View File

@@ -31,10 +31,6 @@ enum PARSE_RESULT
#define PRINTADDR(a, b) ((b)<RLOG_LV_FATAL ? printaddr(&(a->addr), a->threadnum) : "")
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
struct quic_client_hello_msg_hdr
{
uint8_t handshake_type;
@@ -57,10 +53,10 @@ int check_port(unsigned short port)
return 0;
}
int is_quic_port(struct streaminfo *pstream)
int is_quic_port(const struct streaminfo *pstream)
{
unsigned short source=0, dest=0;
if(g_quic_param.quic_port_num==0)return 1;
switch(pstream->addr.addrtype)
{
case ADDR_TYPE_IPV4:
@@ -104,6 +100,12 @@ static int copy_extension_tag(const char *tag_start_pos, int tag_len, char **out
{
if(tag_start_pos!=NULL && tag_len>0)
{
if(*out!=NULL)
{
dictator_free(thread_seq, *out);
*out=NULL;
}
(*out)=(char *)dictator_malloc(thread_seq, tag_len+1);
memcpy(*out, tag_start_pos, tag_len);
(*out)[tag_len]='\0';
@@ -152,7 +154,7 @@ int quic_call_business_state(struct quic_context *context)
return state;
}
unsigned char quic_call_business_plug(struct streaminfo *pstream, struct quic_context *context, void *buff, int buff_len, enum quic_interested_region region_mask, void *a_packet)
unsigned char quic_call_business_plug(const struct streaminfo *pstream, struct quic_context *context, void *buff, int buff_len, enum quic_interested_region region_mask, const void *a_packet)
{
char state=PROT_STATE_GIVEME;
char app_state=APP_STATE_GIVEME;
@@ -176,7 +178,7 @@ unsigned char quic_call_business_plug(struct streaminfo *pstream, struct quic_co
session_info.buf=buff;
session_info.buflen=buff_len;
}
state=PROT_PROCESS(&session_info, &(context->business_pme), pstream->threadnum, pstream, a_packet);
state=PROT_PROCESS(&session_info, &(context->business_pme), pstream->threadnum, (struct streaminfo *)pstream, a_packet);
if(state&PROT_STATE_DROPPKT)
{
@@ -314,9 +316,12 @@ int parse_special_frame_stream(struct quic_info* quic_info, const char *payload,
return PARSE_RESULT_VERSION;
}
quic_info->client_hello=(struct quic_client_hello *)dictator_malloc(thread_seq, sizeof(struct quic_client_hello));
memset(quic_info->client_hello, 0, sizeof(struct quic_client_hello));
if(quic_info->client_hello==NULL)
{
quic_info->client_hello=(struct quic_client_hello *)dictator_malloc(thread_seq, sizeof(struct quic_client_hello));
memset(quic_info->client_hello, 0, sizeof(struct quic_client_hello));
}
tag_value_start_offset=payload_offset+tag_num*4*2; // skip length of type and offset, type(offset)=szieof(int)
while(tag_num>pass_tag_num)
@@ -376,7 +381,11 @@ int parse_quic_transport_parameter(struct quic_client_hello *client_hello, const
para_offset+=copy_extension_tag(quic_para+para_offset, one_para_length, &client_hello->user_agent, thread_seq);
return 1;
default:
one_para_length=quic_para[para_offset++]; // length=1
one_para_length=(int)(quic_para[para_offset++]); // length=1
if(one_para_length<0 || one_para_length>quic_para_len)
{
break;
}
para_offset+=one_para_length;
break;
}
@@ -426,7 +435,7 @@ int parse_tls_client_hello(struct quic_client_hello **client_hello, const char *
int parse_result=PARSE_RESULT_VERSION;
unsigned short one_ext_type=0, one_ext_len=0, extension_total_len=0;
if(payload_len-payload_offset<=sizeof(struct quic_client_hello_msg_hdr))
if(payload_len-payload_offset<=(int)sizeof(struct quic_client_hello_msg_hdr))
{
return PARSE_RESULT_VERSION;
}
@@ -511,7 +520,7 @@ int parse_tls_client_hello(struct quic_client_hello **client_hello, const char *
int parse_quic_decrypted_payload(struct quic_info *quic_info, const char * payload, int payload_len, int thread_seq)
{
char join_payload[2048]={0};
char join_payload[MAX_CLIENT_HELLO_CHUNK_SIZE]={};
int join_payload_len=sizeof(join_payload);
unsigned int quic_version=quic_info->quic_version;
@@ -737,6 +746,11 @@ enum QUIC_VERSION is_quic_protocol(const char *payload, int payload_len, int *pa
enum QUIC_VERSION quic_version=QUIC_VERSION_UNKNOWN;
unsigned char frame_type=(unsigned char)(payload[0]);
if(payload_len<=4)
{
return QUIC_VERSION_UNKNOWN;
}
if(frame_type&QUIC_LONG_HEADER_MASK)
{
quic_version=identify_quic_version(payload, payload_len, payload_offset);
@@ -753,11 +767,109 @@ enum QUIC_VERSION is_quic_protocol(const char *payload, int payload_len, int *pa
return quic_version;
}
unsigned char parse_quic_all_version(struct quic_info *quic_info, const char *payload, int payload_len, int thread_seq)
static void quic_chlo_chunk_assemble(struct quic_buffer *qbuf, unsigned char *new_payload, int new_len, int thread_seq)
{
int ret=0, payload_offset=0;
unsigned char decrypt_payload[2048]={0};
unsigned int decrypt_payload_len=sizeof(decrypt_payload);
if(NULL == new_payload || new_len <= 0){
return;
}
if(NULL == qbuf->buffer){
qbuf->buffer = (unsigned char *)dictator_malloc(thread_seq, MAX_CLIENT_HELLO_CHUNK_SIZE);
qbuf->max_size = MAX_CLIENT_HELLO_CHUNK_SIZE;
}
int max_copy_len = MIN((int)(qbuf->max_size - qbuf->datalen), new_len);
memcpy(qbuf->buffer + qbuf->datalen, new_payload, max_copy_len);
qbuf->datalen += max_copy_len;
}
static int get_chlo_total_length(const unsigned char *payload, int payload_len)
{
const struct quic_client_hello_msg_hdr *chlo_hdr=(const struct quic_client_hello_msg_hdr *)payload;
int chlo_len=0;
uint8_t *p = (uint8_t *)&chlo_len;
p[2] = chlo_hdr->client_hello_len[0];
p[1] = chlo_hdr->client_hello_len[1];
p[0] = chlo_hdr->client_hello_len[2];
return chlo_len;
}
/*
1: is chlo, and complete!
0: is chlo, but fragment;
-1: not support
*/
static int quic_chlo_is_complete(enum QUIC_VERSION quic_version, const unsigned char *payload, int payload_len)
{
if(!( (quic_version>=MVFST_VERSION_00 && quic_version<=MVFST_VERSION_0F) ||
(quic_version>=GQUIC_VERSION_T050 && quic_version<=GQUIC_VERSION_T059) ||
(quic_version>=IQUIC_VERSION_I022 && quic_version<=IQUIC_VERSION_I029) ||
(quic_version==IQUIC_VERSION_RFC9000)))
{
return -1;
}
if((payload[0] != 0x06) && (payload[0] != 0x08))
{
return -1;
}
int payload_offset = 0;
long frame_offset, frame_length;
payload_offset = 1; //skip frame type
payload_offset+=msb2_varint_decode(payload+payload_offset, &frame_offset);
payload_offset+=msb2_varint_decode(payload+payload_offset, &frame_length);
if(payload[payload_offset] != QUIC_HANDSHAKE_TYPE_CLIENTHELLO)
{
return -1;
}
int expect_len = get_chlo_total_length(payload + payload_offset, payload_len-payload_offset);
if(payload_len-payload_offset >= expect_len){
return 1;
}
return 0;
}
static enum PARSE_RESULT quic_decrypting_payload(struct quic_context *qcontext, unsigned char *udp_payload, int udp_payload_len, int thread_seq)
{
struct quic_buffer *qbuf = &qcontext->quic_buf;
unsigned char *quic_decrypted_payload;
int ret, quic_decrypted_payload_len;
quic_dpt_t *dpt = quic_deprotection_new();
enum PARSE_RESULT parse_result = PARSE_RESULT_UNKNOWN;
if(quic_deprotection(dpt, (const u_char *)udp_payload, udp_payload_len) < 0){
goto err_exit;
}
if(qbuf->datalen > 0){ //some fragment exist
quic_chlo_chunk_assemble(qbuf, dpt->payload.data, dpt->payload.len, thread_seq);
quic_decrypted_payload = qbuf->buffer;
quic_decrypted_payload_len = qbuf->datalen;
}else{
quic_decrypted_payload = dpt->payload.data;
quic_decrypted_payload_len = dpt->payload.len;
}
ret = quic_chlo_is_complete((enum QUIC_VERSION)qcontext->quic_info.quic_version, quic_decrypted_payload, quic_decrypted_payload_len);
if(0 == ret){
if(NULL == qbuf->buffer || 0 == qbuf->datalen){
quic_chlo_chunk_assemble(qbuf, dpt->payload.data, dpt->payload.len, thread_seq);
}
parse_result = PARSE_RESULT_VERSION;
goto fun_exit;
}
parse_result = (enum PARSE_RESULT)parse_quic_decrypted_payload(&qcontext->quic_info, (char *)quic_decrypted_payload, quic_decrypted_payload_len, thread_seq);
fun_exit:
quic_deprotection_free(dpt);
return parse_result;
err_exit:
quic_deprotection_free(dpt);
return PARSE_RESULT_VERSION;
}
unsigned char parse_quic_all_version(struct quic_context *qcontext, const char *payload, int payload_len, int thread_seq)
{
int payload_offset=0;
enum QUIC_VERSION quic_version=QUIC_VERSION_UNKNOWN;
if(payload==NULL || payload_len<=0)
@@ -771,31 +883,42 @@ unsigned char parse_quic_all_version(struct quic_info *quic_info, const char *pa
return PARSE_RESULT_UNKNOWN;
}
quic_info->quic_version=quic_version;
qcontext->quic_info.quic_version=quic_version;
if(quic_version>=GQUIC_VERSION_Q001 && quic_version<=GQUIC_VERSION_Q048)
{
return parse_quic_uncryption_payload(quic_info, payload+payload_offset, payload_len-payload_offset, thread_seq);
if(payload_len > payload_offset)
{
return parse_quic_uncryption_payload(&qcontext->quic_info, payload+payload_offset, payload_len-payload_offset, thread_seq);
}
return PARSE_RESULT_VERSION;
}
else if(((quic_version>=MVFST_VERSION_00 && quic_version<=MVFST_VERSION_0F) ||
(quic_version>=GQUIC_VERSION_Q049 && quic_version<=GQUIC_VERSION_Q059) ||
(quic_version>=GQUIC_VERSION_T050 && quic_version<=GQUIC_VERSION_T059) ||
(quic_version>=GQUIC_VERSION_T050 && quic_version<=GQUIC_VERSION_T059) ||
(quic_version>=IQUIC_VERSION_I022 && quic_version<=IQUIC_VERSION_I029) ||
(quic_version==IQUIC_VERSION_RFC9000))
&& g_quic_param.decrypted_switch>0
)
{
ret=quic_deprotection(payload, payload_len, decrypt_payload, &decrypt_payload_len);
if(ret!=1 || decrypt_payload_len<=0)
#if 0
quic_dpt_t *dpt = quic_deprotection_new();
if (quic_deprotection(dpt, (const u_char *)payload, payload_len) != 0)
{
quic_deprotection_free(dpt);
return PARSE_RESULT_VERSION;
}
if(g_quic_param.decrypted_switch==2)
{
return parse_quic_decrypted_payload(quic_info, (const char *)decrypt_payload, decrypt_payload_len, thread_seq);
ret = parse_quic_decrypted_payload(quic_info, (const char *)dpt->payload.data, dpt->payload.len, thread_seq);
quic_deprotection_free(dpt);
return ret;
}
quic_deprotection_free(dpt);
#else
return quic_decrypting_payload(qcontext, (unsigned char *)payload, payload_len, thread_seq);
#endif
}
else
{
@@ -806,12 +929,12 @@ unsigned char parse_quic_all_version(struct quic_info *quic_info, const char *pa
}
unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context* context, int thread_seq, void* a_packet)
unsigned char quic_analyze_entry(const struct streaminfo *pstream, struct quic_context* context, int thread_seq, const void* a_packet)
{
unsigned char parse_result=PARSE_RESULT_UNKNOWN;
char state=APP_STATE_GIVEME;
if(pstream==NULL || pstream->pudpdetail==NULL)
if(pstream==NULL || pstream->pudpdetail==NULL || context==NULL)
{
return APP_STATE_DROPME;
}
@@ -820,11 +943,11 @@ unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context
switch(context->pre_parse_state)
{
case PARSE_RESULT_CLIENT_HELLO:
case PARSE_RESULT_CLIENT_HELLO:
parse_result=PARSE_RESULT_PAYLOAD;
break;
case PARSE_RESULT_VERSION:
parse_result=parse_quic_all_version(&(context->quic_info), (const char *)udp_detail->pdata, udp_detail->datalen, thread_seq);
parse_result=parse_quic_all_version(context, (const char *)udp_detail->pdata, udp_detail->datalen, thread_seq);
if(parse_result==PARSE_RESULT_VERSION || parse_result==PARSE_RESULT_UNKNOWN)
{
parse_result=PARSE_RESULT_PAYLOAD;
@@ -833,12 +956,26 @@ unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context
case PARSE_RESULT_PAYLOAD:
case PARSE_RESULT_UNKNOWN:
default:
if(context->parse_first_pkt==1)
{
context->parse_first_pkt=0;
if(context->quic_info.client_hello==NULL)
{
parse_result=PARSE_RESULT_VERSION;
}
else
{
parse_result=PARSE_RESULT_CLIENT_HELLO;
}
break;
}
if((context->parse_pkt_cnt++)>=g_quic_param.max_parse_pkt_num)
{
parse_result=PARSE_RESULT_PAYLOAD;
break;
}
parse_result=parse_quic_all_version(&(context->quic_info), (const char *)udp_detail->pdata, udp_detail->datalen, thread_seq);
parse_result=parse_quic_all_version(context, (const char *)udp_detail->pdata, udp_detail->datalen, thread_seq);
break;
}
@@ -863,49 +1000,30 @@ unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context
return state;
}
static int copy_client_hello_extension(char *src, char *dest, int d_len)
struct quic_info *quic_protocol_identify(const struct streaminfo *a_stream)
{
if(src==NULL || dest==NULL || d_len<=0)
{
return 0;
}
int len=MIN((int)strlen(src), d_len-1);
memcpy(dest, src, len);
dest[len]='\0';
return len;
}
unsigned int quic_protocol_identify(struct streaminfo *a_stream, void *a_packet, char *out_sni, int *out_sni_len, char *out_ua, int *out_ua_len)
{
unsigned char parse_result=APP_STATE_GIVEME;
struct quic_info quic_info={0, NULL};
unsigned int quic_version=QUIC_VERSION_UNKNOWN;
if(!is_quic_port(a_stream) || a_stream==NULL || a_stream->pudpdetail==NULL)
{
return quic_version;
return NULL;
}
parse_result=parse_quic_all_version(&quic_info, (const char *)a_stream->pudpdetail->pdata, a_stream->pudpdetail->datalen, a_stream->threadnum);
struct quic_context tmp_qcontext = {};
unsigned char parse_result=APP_STATE_GIVEME;
parse_result=parse_quic_all_version(&tmp_qcontext, (const char *)a_stream->pudpdetail->pdata, a_stream->pudpdetail->datalen, a_stream->threadnum);
if(parse_result!=PARSE_RESULT_UNKNOWN)
{
if(quic_info.client_hello!=NULL)
{
*out_sni_len=copy_client_hello_extension(quic_info.client_hello->sni, out_sni, *out_sni_len);
*out_ua_len=copy_client_hello_extension(quic_info.client_hello->user_agent, out_ua, *out_ua_len);
quic_free_client_hello(quic_info.client_hello, a_stream->threadnum);
}
else
{
*out_sni_len=0;
*out_ua_len=0;
}
quic_version=quic_info.quic_version;
struct quic_context *context=(struct quic_context *)dictator_malloc(a_stream->threadnum, sizeof(struct quic_context));
memset(context, 0, sizeof(struct quic_context));
context->quic_info=tmp_qcontext.quic_info;
context->parse_first_pkt=1;
context->pre_parse_state=PARSE_RESULT_UNKNOWN;
stream_bridge_async_data_put(a_stream, g_quic_param.context_bridge_id, (void *)context);
return &(context->quic_info);
}
return quic_version;
return NULL;
}

View File

@@ -279,18 +279,28 @@ enum QUIC_VERSION
IQUIC_VERSION_I032=0xFF000020
};
#define MAX_CLIENT_HELLO_CHUNK_SIZE (4096)
struct quic_buffer
{
unsigned char *buffer;
size_t max_size;
size_t datalen;
};
struct quic_context
{
unsigned char link_state;
unsigned char parse_pkt_cnt;
unsigned char pre_parse_state;
unsigned char padding[5];
unsigned char parse_first_pkt;
unsigned char padding[4];
void *business_pme;
struct quic_info quic_info;
struct quic_buffer quic_buf; // for client hello fragment
};
unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context* context, int thread_seq, void* a_packet);
unsigned char quic_call_business_plug(struct streaminfo *pstream, struct quic_context *context, void *buff, int buff_len, enum quic_interested_region region_mask, void *a_packet);
unsigned char quic_analyze_entry(const struct streaminfo *pstream, struct quic_context* context, int thread_seq, const void* a_packet);
unsigned char quic_call_business_plug(const struct streaminfo *pstream, struct quic_context *context, void *buff, int buff_len, enum quic_interested_region region_mask, const void *a_packet);
#endif

View File

@@ -54,12 +54,6 @@ int quic_version_int2string(unsigned int version, char *buff, int buff_len)
snprintf(buff, buff_len, "quic-go QGO %02d", (version&0x000000FF));
return 1;
}
if(version>=QUIC_GO_VERSION_00 && version<=QUIC_GO_VERSION_FF)
{
snprintf(buff, buff_len, "quicly qicly0 %02d", (version&0x000000FF));
return 1;
}
if(version>=MSQUIC_VERSION_00 && version<=MSQUIC_VERSION_0F)
{

9
src/version.map Normal file
View File

@@ -0,0 +1,9 @@
VERS_2.4{
global:
extern "C++" {
QUIC_*;
*quic_version_int2string*;
*quic_protocol_identify*;
};
local: *;
};

View File

@@ -1,34 +1,28 @@
# CMakeFiles for 3rd vendor library
include(ExternalProject)
### libgpg-error
ExternalProject_Add(libgpg-error PREFIX libgpg-error
URL ${CMAKE_CURRENT_SOURCE_DIR}/libgpg-error-1.42.tar.bz2
URL_MD5 133fed221ba8f63f5842858a1ff67cb3
BUILD_COMMAND ""
CONFIGURE_COMMAND CPPFLAGS=-fPIC ./configure --enable-static --prefix=<INSTALL_DIR> CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC
### OpenSSL 1.1.1
ExternalProject_Add(OpenSSL PREFIX openssl
URL ${CMAKE_CURRENT_SOURCE_DIR}/openssl-1.1.1l.tar.gz
URL_MD5 ac0d4387f3ba0ad741b0580dd45f6ff3
CONFIGURE_COMMAND ./config --prefix=<INSTALL_DIR> --openssldir=<INSTALL_DIR>/lib/ssl enable-ec_nistp_64_gcc_128 no-shared
BUILD_COMMAND ${MAKE_COMMAND}
INSTALL_COMMAND make install_sw
BUILD_IN_SOURCE 1)
ExternalProject_Get_Property(libgpg-error INSTALL_DIR)
ExternalProject_Get_Property(OpenSSL INSTALL_DIR)
set(OPENSSL_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
set(OPENSSL_LINK_DIRECTORIES ${INSTALL_DIR}/lib)
set(OPENSSL_PKGCONFIG_PATH ${INSTALL_DIR}/lib/pkgconfig/)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
add_library(libgpg-error-static STATIC IMPORTED GLOBAL)
add_dependencies(libgpg-error-static libgpg-error)
set_property(TARGET libgpg-error-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgpg-error.a)
set_property(TARGET libgpg-error-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include/)
add_library(openssl-crypto-static STATIC IMPORTED GLOBAL)
add_dependencies(openssl-crypto-static OpenSSL)
set_property(TARGET openssl-crypto-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libcrypto.a)
set_property(TARGET openssl-crypto-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
### libgcrypt
ExternalProject_Add(libgcrypt PREFIX libgcrypt
URL ${CMAKE_CURRENT_SOURCE_DIR}/libgcrypt-1.9.4.tar.bz2
URL_MD5 edc7becfe09c75d8f95ff7623e40c52e
BUILD_COMMAND ""
DEPENDS libgpg-error-static
CONFIGURE_COMMAND CPPFLAGS=-fPIC ./configure --enable-static --disable-doc --prefix=<INSTALL_DIR> --with-libgpg-error-prefix=${CMAKE_CURRENT_BINARY_DIR}/libgpg-error/ CFLAGS=-fPIC CXXFLAGS=-fPIC LDFLAGS=-fPIC
BUILD_IN_SOURCE 1)
ExternalProject_Get_Property(libgcrypt INSTALL_DIR)
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
add_library(libgcrypt-static STATIC IMPORTED GLOBAL)
add_dependencies(libgcrypt-static libgcrypt)
set_property(TARGET libgcrypt-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgcrypt.a)
set_property(TARGET libgcrypt-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include/)
add_library(openssl-ssl-static STATIC IMPORTED GLOBAL)
add_dependencies(openssl-ssl-static OpenSSL)
set_property(TARGET openssl-ssl-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libssl.a)
set_property(TARGET openssl-ssl-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,61 +1,58 @@
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 2.8...3.10)
set(lib_name quic)
project(${lib_name}_test)
include(ExternalProject)
#### Protoco_test_run
ExternalProject_Add(ProtoTest PREFIX ProtoTest
URL ${CMAKE_CURRENT_SOURCE_DIR}/test_protocol_run.zip
URL_MD5 71d8284b59af0286b5f31f0a3160bc44
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>/conf/${lib_name}/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/bin/${lib_name}.conf <SOURCE_DIR>/conf/${lib_name}/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/conflist.inf <SOURCE_DIR>/plug/
COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>/plug/protocol/${lib_name}/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/bin/${lib_name}.inf <SOURCE_DIR>/plug/protocol/${lib_name}/
COMMAND ${CMAKE_COMMAND} -E make_directory <SOURCE_DIR>/plug/business/${lib_name}_test_plug/
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/test/${lib_name}_test_plug.inf <SOURCE_DIR>/plug/business/${lib_name}_test_plug/)
ExternalProject_Get_Property(ProtoTest INSTALL_DIR)
ExternalProject_Get_Property(ProtoTest SOURCE_DIR)
set(PROTO_TEST_RUN_DIR ${SOURCE_DIR})
add_executable(proto_test_main IMPORTED GLOBAL)
add_dependencies(proto_test_main ProtoTest)
set_property(TARGET proto_test_main PROPERTY IMPORTED_LOCATION ${SOURCE_DIR}/test_protocol_plug_main)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/opt/tsg/sapp" CACHE PATH "default install path" FORCE)
message(STATUS "CMAKE_INSTALL_PREFIX='${CMAKE_INSTALL_PREFIX}'")
endif()
add_library(${lib_name}_test_plug SHARED ${lib_name}_test_plug.cpp)
target_link_libraries(${lib_name}_test_plug MESA_prof_load cjson)
set_target_properties(${lib_name}_test_plug PROPERTIES PREFIX "")
add_test(NAME COPY_QUIC_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/${lib_name}.so ${PROTO_TEST_RUN_DIR}/plug/protocol/${lib_name}/${lib_name}.so")
add_test(NAME COPY_TEST_SO COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_test_plug.so ${PROTO_TEST_RUN_DIR}/plug/business/${lib_name}_test_plug/${lib_name}_test_plug.so")
add_test(NAME IQUIC_29_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/iquic/29//${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/iquic/29/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_23_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/23/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/23/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_25_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/25/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/25/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_33_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/33/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/33/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_34_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/34/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/34/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_35_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/35/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/35/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_37_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/37/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/37/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_39_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/39/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/39/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_41_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/41/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/41/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_43_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/43/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/43/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_44_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/44/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/44/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_46_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/46/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/46/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME GQUIC_50_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/50/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/50/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME MVFST_01_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME MVFST_02_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME TQUIC_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME IQUIC_PORT_8443_TEST COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000 COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000_FRAGMENT COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-fragment/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-fragment/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000_SPECIAL COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-special/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-special/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME QUIC_AIRPORT COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/airport/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/airport -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
add_test(NAME QUIC_SPECIAL COMMAND proto_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/special/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/special/ -name *.pcap|sort -V" WORKING_DIRECTORY ${PROTO_TEST_RUN_DIR})
set(TEST_RUN_DIR ${CMAKE_INSTALL_PREFIX})
set(PLUGIN_TEST_MAIN ${CMAKE_INSTALL_PREFIX}/plugin_test_main)
message(STATUS "TEST_RUN_DIR='${TEST_RUN_DIR}'")
# build test env
add_test(NAME MKDIR COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/protocol/${lib_name} && mkdir -p ${TEST_RUN_DIR}/plug/business/${lib_name}_test_plug && mkdir -p ${TEST_RUN_DIR}/conf/${lib_name}")
add_test(NAME COPY_PLUGIN_TEST_MAIN COMMAND sh -c "cp ${TEST_RUN_DIR}/tools/plugin_test_main ${TEST_RUN_DIR}/plugin_test_main")
add_test(NAME COPY_CONFLIST COMMAND sh -c "mkdir -p ${TEST_RUN_DIR}/plug/ && cp ${CMAKE_CURRENT_SOURCE_DIR}/conflist.inf ${TEST_RUN_DIR}/plug/conflist.inf")
add_test(NAME COPY_QUIC_DECODER_CONF COMMAND sh -c "cp ${CMAKE_SOURCE_DIR}/bin/${lib_name}.conf ${TEST_RUN_DIR}/conf/${lib_name}/")
add_test(NAME ADD_QUIC_TO_ENTRY_LIST COMMAND sh -c "echo 'QUIC' >> ${TEST_RUN_DIR}/etc/entrylist.conf")
add_test(NAME COPY_QUIC_INF COMMAND sh -c "cp ${CMAKE_SOURCE_DIR}/bin/${lib_name}.inf ${TEST_RUN_DIR}/plug/protocol/${lib_name}/${lib_name}.inf")
add_test(NAME COPY_QUIC_SO COMMAND sh -c "cp ${CMAKE_BINARY_DIR}/${lib_name}.so ${TEST_RUN_DIR}/plug/protocol/${lib_name}/${lib_name}.so")
add_test(NAME COPY_TEST_INF COMMAND sh -c "cp ${CMAKE_CURRENT_SOURCE_DIR}/${lib_name}_test_plug.inf ${TEST_RUN_DIR}/plug/business/${lib_name}_test_plug/${lib_name}_test_plug.inf")
add_test(NAME COPY_TEST_SO COMMAND sh -c "cp ${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_test_plug.so ${TEST_RUN_DIR}/plug/business/${lib_name}_test_plug/${lib_name}_test_plug.so")
# update sapp config files
add_test(NAME UPDATE_SAPP_LOG_LEVEL COMMAND bash -c "sed -i 's/sapp_log.fatal/sapp_log.info/' ${TEST_RUN_DIR}/etc/sapp_log.conf")
add_test(NAME ENABLE_SAPP_MONITOR COMMAND bash -c "sed -i 's/monitor_thread_enabled=0/monitor_thread_enabled=1/' ${TEST_RUN_DIR}/etc/sapp.toml")
add_test(NAME IQUIC_29_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/iquic/29/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/iquic/29/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_23_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/23/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/23/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_25_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/25/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/25/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_33_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/33/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/33/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_34_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/34/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/34/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_35_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/35/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/35/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_37_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/37/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/37/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_39_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/39/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/39/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_41_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/41/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/41/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_43_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/43/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/43/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_44_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/44/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/44/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_46_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/46/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/46/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME GQUIC_50_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/50/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/gquic/50/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME MVFST_01_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/01/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME MVFST_02_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/mvfst/02/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME TQUIC_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/tquic/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME IQUIC_PORT_8443_TEST COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/port-8443/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000 COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000_FRAGMENT COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-fragment/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-fragment/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_RFC9000_SPECIAL COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-special/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-special/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_AIRPORT COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/airport/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/airport -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_SPECIAL COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/special/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/special/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})
add_test(NAME QUIC_CHLO_FRAGMENT COMMAND ./plugin_test_main ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-chlo-fragment/${lib_name}_result.json -f "find ${CMAKE_CURRENT_SOURCE_DIR}/pcap/rfc9000-chlo-fragment/ -name *.pcap|sort -V" WORKING_DIRECTORY ${TEST_RUN_DIR})

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,32 @@
[
{
"Tuple4": "2607:5d00:2:2::38:2.53977>2404:6800:4005:807::2004.443",
"VERSION": "IETF QUIC RFC9000",
"SNI": "www.google.com",
"name": "QUIC_RESULT_1"
},
{
"Tuple4": "2607:5d00:2:2::38:2.50835>2404:6800:4005:80d::2003.443",
"VERSION": "IETF QUIC RFC9000",
"SNI": "www.google.com.hk",
"name": "QUIC_RESULT_2"
},
{
"Tuple4": "192.168.64.25.61166>157.240.245.35.443",
"VERSION": "IETF QUIC RFC9000",
"SNI": "www.facebook.com",
"name": "QUIC_RESULT_3"
},
{
"Tuple4": "2607:5d00:2:2::38:2.54817>2404:6800:4005:80c::200a.443",
"VERSION": "IETF QUIC RFC9000",
"SNI": "optimizationguide-pa.googleapis.com",
"name": "QUIC_RESULT_4"
},
{
"Tuple4": "192.168.54.157.60388>142.250.71.164.443",
"VERSION": "IETF QUIC RFC9000",
"SNI": "www.google.com",
"name": "QUIC_RESULT_5"
}
]

View File

@@ -19,7 +19,7 @@ extern "C" int commit_test_result_json(cJSON *node, const char *name);
static int g_result_count = 1;
extern "C" unsigned char QUIC_TEST_PLUG_ENTRY(stSessionInfo *session_info, void **pme,
int thread_seq, struct streaminfo *a_tcp, void *a_packet)
int thread_seq, struct streaminfo *a_udp, void *a_packet)
{
assert(NULL != session_info || pme != NULL);
@@ -34,7 +34,7 @@ extern "C" unsigned char QUIC_TEST_PLUG_ENTRY(stSessionInfo *session_info, void
{
ctx = cJSON_CreateObject();
*pme = (void *)ctx;
cJSON_AddStringToObject(ctx, "Tuple4", printaddr(&a_tcp->addr, a_tcp->threadnum));
cJSON_AddStringToObject(ctx, "Tuple4", printaddr(&a_udp->addr, a_udp->threadnum));
}
}

Binary file not shown.