Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fba00d59cb | ||
|
|
82cd2ced07 | ||
|
|
1ab2559887 | ||
|
|
33a2bc5b39 | ||
|
|
aebc66e015 | ||
|
|
a7d76dda73 | ||
|
|
4d731800bf | ||
|
|
1b678406e7 | ||
|
|
479fd1a771 | ||
|
|
bfeae04470 | ||
|
|
513732e4f1 | ||
|
|
96f9ce34ca | ||
|
|
ffb443ed7e | ||
|
|
98c567cf88 | ||
|
|
d76065f87e | ||
|
|
3605410615 | ||
|
|
6e3830983c | ||
|
|
b446c3e32f |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -6,7 +6,9 @@ Debug
|
||||
.project
|
||||
.settings/
|
||||
SI
|
||||
build/
|
||||
build*/
|
||||
src/inc
|
||||
src/lib64
|
||||
cmake-build-*/
|
||||
.vscode/
|
||||
.cache/
|
||||
|
||||
129
.gitlab-ci.yml
129
.gitlab-ci.yml
@@ -1,41 +1,42 @@
|
||||
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:rockylinux"
|
||||
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
|
||||
INSTALL_DEPENDENCY_FRAMEWORK: libMESA_handle_logger-devel libcjson-devel libcjson libMESA_field_stat2-devel framework_env
|
||||
libMESA_prof_load-devel libbreakpad_mini-devel libMESA_htable-devel
|
||||
stellar-on-sapp-devel stellar-on-sapp systemd-devel libfieldstat3-devel libfieldstat3 libMESA_field_stat2
|
||||
libMESA_jump_layer libMESA_htable libMESA_handle_logger
|
||||
INSTALL_PREFIX: "/opt/tsg/"
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
- package
|
||||
|
||||
|
||||
.build_by_travis:
|
||||
.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:
|
||||
stage: test
|
||||
extends: .build_by_travis
|
||||
script:
|
||||
- yum makecache
|
||||
- ./ci/travis.sh
|
||||
- cd build
|
||||
- ctest --verbose
|
||||
|
||||
branch_build_debug:
|
||||
.build_by_travis_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis
|
||||
image: $BUILD_IMAGE_CENTOS8
|
||||
extends: .build_before_script
|
||||
script:
|
||||
- dnf --enablerepo=powertools install -y libmnl-devel
|
||||
- dnf --enablerepo=powertools install -y libnfnetlink-devel
|
||||
- ./ci/travis.sh
|
||||
tags:
|
||||
- share
|
||||
|
||||
branch_build_debug_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
except:
|
||||
@@ -43,27 +44,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 +73,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 +91,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 +108,7 @@ release_build_debug:
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release:
|
||||
release_build_release_for_centos8:
|
||||
stage: package
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
@@ -114,12 +116,57 @@ 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
|
||||
|
||||
###############################################################################
|
||||
# test
|
||||
###############################################################################
|
||||
|
||||
.install_rpm_package: &install_rpm_package
|
||||
- rpm -e sapp || true
|
||||
- rpm -e sapp-devel || true
|
||||
- rpm -e stellar-on-sapp || true
|
||||
- rpm -e stellar-on-sapp-devel || true
|
||||
- rpm -ivh /tmp/sapp.x86_64.rpm --prefix=${INSTALL_PREFIX}/sapp --force --nodeps
|
||||
- rpm -ivh /tmp/sapp-devel.x86_64.rpm --prefix=${INSTALL_PREFIX}/sapp --force --nodeps
|
||||
- rpm -ivh /tmp/stellar-on-sapp.x86_64.rpm --prefix=${INSTALL_PREFIX} --force --nodeps
|
||||
- rpm -qa | grep sapp
|
||||
- rpm -qa | grep stellar-on-sapp
|
||||
- ls -l /opt/MESA/lib && echo "/opt/MESA/lib" >> /etc/ld.so.conf
|
||||
|
||||
|
||||
history_version_test:
|
||||
stage: test
|
||||
extends: .build_by_travis_for_centos8
|
||||
script:
|
||||
- yum makecache
|
||||
- ./ci/travis.sh
|
||||
- cp -f ./support/stellar-on-sapp*.rpm /tmp/stellar-on-sapp.x86_64.rpm
|
||||
- cp -f ./support/sapp-devel*.rpm /tmp/sapp-devel.x86_64.rpm
|
||||
- cp -f ./support/sapp-4*.rpm /tmp/sapp.x86_64.rpm
|
||||
- *install_rpm_package
|
||||
- cd build
|
||||
- ctest3 --verbose
|
||||
|
||||
latest_version_test:
|
||||
stage: test
|
||||
extends: .build_by_travis_for_centos8
|
||||
script:
|
||||
- yum makecache
|
||||
- ./ci/travis.sh
|
||||
- rm -f stellar-on-sapp*.rpm sapp*.rpm
|
||||
- yumdownloader stellar-on-sapp sapp-devel sapp
|
||||
- cp -f stellar-on-sapp*.rpm /tmp/stellar-on-sapp.x86_64.rpm
|
||||
- cp -f sapp-devel*.rpm /tmp/sapp-devel.x86_64.rpm
|
||||
- cp -f sapp-4*.rpm /tmp/sapp.x86_64.rpm
|
||||
- *install_rpm_package
|
||||
- cd build
|
||||
- ctest3 --verbose
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
cmake_minimum_required (VERSION 2.8...3.10)
|
||||
|
||||
set(lib_name quic)
|
||||
|
||||
@@ -28,36 +28,23 @@ elseif(ASAN_OPTION MATCHES "THREAD")
|
||||
endif()
|
||||
# end of for ASAN
|
||||
|
||||
set(CMAKE_INSTALL_PREFIX /home/mesasoft/sapp_run)
|
||||
set(CMAKE_INSTALL_PREFIX /opt/tsg)
|
||||
|
||||
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)
|
||||
|
||||
# Shared Library Output
|
||||
add_library(quic SHARED ${SRC})
|
||||
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)
|
||||
set_target_properties(quic PROPERTIES OUTPUT_NAME ${lib_name})
|
||||
add_subdirectory(src)
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(test)
|
||||
|
||||
set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/plug/protocol/quic/quic.inf"
|
||||
"%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/quic/quic.conf")
|
||||
set(CPACK_RPM_USER_FILELIST "%config(noreplace) ${CMAKE_INSTALL_PREFIX}/sapp/conf/quic/quic.conf"
|
||||
"%config(noreplace) ${CMAKE_INSTALL_PREFIX}/conf/quic/main.conf")
|
||||
|
||||
install(TARGETS quic LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/protocol/quic COMPONENT LIBRARIES)
|
||||
install(FILES bin/quic.inf DESTINATION ${CMAKE_INSTALL_PREFIX}/plug/protocol/quic COMPONENT PROFILE)
|
||||
install(FILES bin/quic.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/conf/quic COMPONENT PROFILE)
|
||||
install(FILES include/quic.h DESTINATION /opt/MESA/include/MESA COMPONENT HEADER)
|
||||
# install(FILES bin/quic.inf DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/ COMPONENT PROFILE)
|
||||
install(FILES bin/quic.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/conf/quic COMPONENT PROFILE)
|
||||
install(FILES bin/main.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/conf/quic COMPONENT PROFILE)
|
||||
install(FILES include/quic.h DESTINATION ${CMAKE_INSTALL_PREFIX}/framework/include/quic COMPONENT HEADER)
|
||||
|
||||
include(Package)
|
||||
|
||||
6
bin/main.conf
Normal file
6
bin/main.conf
Normal file
@@ -0,0 +1,6 @@
|
||||
[QUIC]
|
||||
QUIC_PORT_LIST=443;8443;4433;
|
||||
LOG_LEVEL=30
|
||||
LOG_PATH="./log/quic/quic"
|
||||
DECRYPTED_SWITCH=2
|
||||
MAX_PARSE_PKT_NUM=3
|
||||
19
bin/quic.inf
19
bin/quic.inf
@@ -1,12 +1,9 @@
|
||||
[PLUGINFO]
|
||||
PLUGNAME=QUIC
|
||||
SO_PATH=./plug/protocol/quic/quic.so
|
||||
INIT_FUNC=QUIC_INIT
|
||||
DESTROY_FUNC=QUIC_DESTROY
|
||||
FLAGCHANGE_FUNC=QUIC_FLAG_CHANGE
|
||||
FLAGSTATE_FUNC=QUIC_PROT_FUNSTAT
|
||||
GETPLUGID_FUNC=QUIC_GETPLUGID
|
||||
[[plugin]]
|
||||
path = "./stellar_plugin/quic/quic.so"
|
||||
init = "QUIC_ONLOAD"
|
||||
exit = "QUIC_UNLOAD"
|
||||
|
||||
[UDP]
|
||||
FUNC_FLAG=ALL
|
||||
FUNC_NAME=QUIC_ENTRY
|
||||
[[plugin]]
|
||||
path = "./stellar_plugin/quic/quic_test_plug.so"
|
||||
init = "QUIC_TEST_PLUG_INIT"
|
||||
exit = "QUIC_TEST_PLUG_DESTROY"
|
||||
|
||||
16
ci/travis.sh
16
ci/travis.sh
@@ -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
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,3 +13,20 @@ fi
|
||||
if [[ -z `grep -rn 'QUIC' ${DST}/etc/entrylist.conf` ]];then
|
||||
echo "QUIC" >> ${DST}/etc/entrylist.conf
|
||||
fi
|
||||
|
||||
|
||||
DST=${RPM_INSTALL_PREFIX}/sapp/
|
||||
|
||||
mkdir -p ${DST}/stellar_plugin
|
||||
touch ${DST}/stellar_plugin/spec.toml
|
||||
|
||||
if ! grep -q '^\./plug/stellar_plugin/quic.so' "${DST}/stellar_plugin/spec.toml"; then
|
||||
echo -e "\n" >> "${DST}/stellar_plugin/spec.toml"
|
||||
echo -e "[[plugin]]" >> "${DST}/stellar_plugin/spec.toml"
|
||||
echo -e "path = \"./stellar_plugin/quic/quic.so\"" >> "${DST}/stellar_plugin/spec.toml"
|
||||
echo -e "init = \"QUIC_ONLOAD\"" >> "${DST}/stellar_plugin/spec.toml"
|
||||
echo -e "exit = \"QUIC_UNLOAD\"" >> "${DST}/stellar_plugin/spec.toml"
|
||||
echo -e "\n" >> "${DST}/stellar_plugin/spec.toml"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
#!/bin/sh
|
||||
if [ $1 == 0 ]; then
|
||||
DST=${RPM_INSTALL_PREFIX}
|
||||
mkdir -p ${DST}/plug/business/
|
||||
touch ${DST}/plug/conflist.inf
|
||||
|
||||
mkdir -p ${DST}/etc/
|
||||
touch ${DST}/etc/entrylist.conf
|
||||
|
||||
if [[ -f ${DST}/plug/conflist.inf ]];then
|
||||
sed -i '/quic.inf/d' ${DST}/plug/conflist.inf
|
||||
fi
|
||||
|
||||
if [[ -f ${DST}/etc/entrylist.conf ]];then
|
||||
sed -i '/QUIC/d' ${DST}/etc/entrylist.conf
|
||||
fi
|
||||
DST=${RPM_INSTALL_PREFIX}/sapp/stellar_plugin
|
||||
sed -i -n '$!N;/quic.so/!P;D' ${DST}/spec.toml
|
||||
sed -i '/QUIC_ONLOAD/d' ${DST}/spec.toml
|
||||
sed -i '/QUIC_UNLOAD/d' ${DST}/spec.toml
|
||||
fi
|
||||
|
||||
|
||||
70
demo/parse_quic_transport_parameter.cpp
Normal file
70
demo/parse_quic_transport_parameter.cpp
Normal 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;
|
||||
}
|
||||
@@ -1,55 +1,38 @@
|
||||
/*
|
||||
* quic.h
|
||||
*
|
||||
* Created on: 2021-11-08
|
||||
* Author: liuxueli
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef __QUIC_H__
|
||||
#define __QUIC_H__
|
||||
|
||||
#define QUIC_INTEREST_KEY (1<<QUIC_INTEREST_KEY_MASK)
|
||||
#define QUIC_CLIENT_HELLO (1<<QUIC_CLIENT_HELLO_MASK)
|
||||
#define QUIC_SERVER_HELLO (1<<QUIC_SERVER_HELLO_MASK)
|
||||
#define QUIC_CACHED_CERT (1<<QUIC_CACHED_CERT_MASK)
|
||||
#define QUIC_COMM_CERT (1<<QUIC_COMM_CERT_MASK)
|
||||
#define QUIC_CERT_CHAIN (1<<QUIC_CERT_CHAIN_MASK)
|
||||
#define QUIC_APPLICATION_DATA (1<<QUIC_APPLICATION_DATA_MASK)
|
||||
#define QUIC_USEING_VERSION (1<<QUIC_USEING_VERSION_MASK)
|
||||
#define QUIC_NEGOTIATION_VERSION (1<<QUIC_NEGOTIATION_VERSION_MASK)
|
||||
#define QUIC_REJECTION (1<<QUIC_REJECTION_MASK)
|
||||
|
||||
|
||||
enum quic_interested_region
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
QUIC_INTEREST_KEY_MASK = 0,
|
||||
QUIC_CLIENT_HELLO_MASK,
|
||||
QUIC_SERVER_HELLO_MASK,
|
||||
QUIC_CACHED_CERT_MASK,
|
||||
QUIC_COMM_CERT_MASK,
|
||||
QUIC_CERT_CHAIN_MASK,
|
||||
QUIC_APPLICATION_DATA_MASK,
|
||||
QUIC_USEING_VERSION_MASK,
|
||||
QUIC_NEGOTIATION_VERSION_MASK,
|
||||
QUIC_REJECTION_MASK
|
||||
#endif
|
||||
#include <bits/types/struct_iovec.h>
|
||||
|
||||
typedef struct iovec qstring;
|
||||
|
||||
enum quic_message_type
|
||||
{
|
||||
QUIC_NEW = 0,
|
||||
|
||||
QUIC_VERSION,
|
||||
QUIC_SNI,
|
||||
QUIC_USER_AGENT,
|
||||
QUIC_PAYLOAD,
|
||||
|
||||
QUIC_FREE,
|
||||
|
||||
QUIC_MSG_MAX,
|
||||
};
|
||||
|
||||
struct quic_client_hello
|
||||
{
|
||||
char *sni;
|
||||
char *user_agent;
|
||||
};
|
||||
#define QUIC_DECODER_TOPIC "QUIC_DECODER_MESSAGE"
|
||||
struct quic_message;
|
||||
enum quic_message_type quic_message_type_get(const struct quic_message *msg);
|
||||
|
||||
struct quic_info
|
||||
{
|
||||
unsigned int quic_version;
|
||||
struct quic_client_hello *client_hello;
|
||||
};
|
||||
void quic_message_get_version(const struct quic_message *msg, unsigned int *result);
|
||||
void quic_message_get_sni(const struct quic_message *msg, struct iovec *result);
|
||||
void quic_message_get_user_agent(const struct quic_message *msg, struct iovec *result);
|
||||
void quic_message_get_payload(const struct quic_message *msg, struct iovec *result);
|
||||
|
||||
|
||||
//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);
|
||||
|
||||
#endif /* SRC__QUIC_H__ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
15
src/CMakeLists.txt
Normal file
15
src/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required (VERSION 2.8...3.10)
|
||||
|
||||
file(GLOB SRC "*.cpp")
|
||||
set(DEPEND_DYN_LIB MESA_handle_logger)
|
||||
|
||||
include_directories(/opt/tsg/framework/include/)
|
||||
|
||||
# Shared Library Output
|
||||
add_library(${lib_name} SHARED ${SRC})
|
||||
set_target_properties(${lib_name} PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR}/src/version.map")
|
||||
set_target_properties(${lib_name} PROPERTIES PREFIX "")
|
||||
target_link_libraries(${lib_name} ${DNS_DEPEND_DYN_LIB} pthread -Wl,--no-whole-archive openssl-crypto-static -Wl,--no-whole-archive openssl-ssl-static)
|
||||
set_target_properties(${lib_name} PROPERTIES OUTPUT_NAME ${lib_name})
|
||||
|
||||
install(TARGETS ${lib_name} LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/sapp/stellar_plugin/quic COMPONENT LIBRARIES)
|
||||
55
src/Makefile
55
src/Makefile
@@ -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)
|
||||
213
src/pint.h
213
src/pint.h
@@ -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
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
@@ -6,22 +6,27 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <MESA/stream_inc/stream_base.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
#include <assert.h>
|
||||
#include <MESA/MESA_prof_load.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "quic.h"
|
||||
#include "quic_entry.h"
|
||||
#include "quic_process.h"
|
||||
#include "quic_deprotection.h"
|
||||
#include "quic_util.h"
|
||||
|
||||
struct quic_param g_quic_param;
|
||||
const char *g_quic_proto_conffile="./conf/quic/main.conf";
|
||||
const char *g_quic_regionname_conffile="./conf/quic/quic.conf";
|
||||
|
||||
static const char *g_quic_proto_conffile="./conf/quic/main.conf";
|
||||
// static const char *g_quic_regionname_conffile="./conf/quic/quic.conf";
|
||||
static const char *g_quic_log_path = "./log/quic/quic";
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include <stellar/stellar.h>
|
||||
#include <stellar/session.h>
|
||||
#include <stellar/session_mq.h>
|
||||
#include <stellar/session_exdata.h>
|
||||
|
||||
#define GIT_VERSION_CATTER(v) __attribute__((__used__)) const char * GIT_VERSION_##v = NULL
|
||||
#define GIT_VERSION_EXPEND(v) GIT_VERSION_CATTER(v)
|
||||
@@ -98,229 +103,140 @@ static int parse_quic_port(char *port_list, unsigned short *quic_port, int quic_
|
||||
|
||||
for(i=s_port; i<=e_port && port_num<quic_port_num; i++)
|
||||
{
|
||||
quic_port[port_num++]=i;
|
||||
quic_port[port_num++]= htons((unsigned short)i);
|
||||
}
|
||||
}
|
||||
|
||||
return port_num;
|
||||
}
|
||||
|
||||
|
||||
int quic_init_context(void **pme, int thread_seq)
|
||||
static void free_quicinfo(struct quic_info *quic_info)
|
||||
{
|
||||
struct quic_context *context=(struct quic_context *)dictator_malloc(thread_seq, sizeof(struct quic_context));
|
||||
memset(context, 0, sizeof(struct quic_context));
|
||||
|
||||
*pme=(void*)context;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void quic_free_client_hello(struct quic_client_hello *client_hello, int thread_seq)
|
||||
{
|
||||
if(client_hello==NULL)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
if(client_hello->sni)
|
||||
{
|
||||
dictator_free(thread_seq, client_hello->sni);
|
||||
client_hello->sni=NULL;
|
||||
}
|
||||
|
||||
if(client_hello->user_agent)
|
||||
{
|
||||
dictator_free(thread_seq, client_hello->user_agent);
|
||||
client_hello->user_agent=NULL;
|
||||
}
|
||||
|
||||
dictator_free(thread_seq, client_hello);
|
||||
client_hello=NULL;
|
||||
if(quic_info->sni.iov_base)
|
||||
FREE(quic_info->sni.iov_base);
|
||||
|
||||
if(quic_info->user_agent.iov_base)
|
||||
FREE(quic_info->user_agent.iov_base);
|
||||
return ;
|
||||
}
|
||||
|
||||
void quic_free_context(void** pme, int thread_seq)
|
||||
extern "C" void quic_on_session_msg_cb(struct session *sess, int topic_id, const void *msg, void *per_session_ctx, void *plugin_env)
|
||||
{
|
||||
if(NULL==*pme)
|
||||
struct quic_param *quic_plugin_env = (struct quic_param *)plugin_env;
|
||||
struct quic_context *context = (struct quic_context *)per_session_ctx;
|
||||
|
||||
int thread_seq = session_get_current_thread_id(sess);
|
||||
const char *payload = NULL;
|
||||
size_t payload_len = -1;
|
||||
|
||||
enum session_state sstate = session_get_current_state(sess);
|
||||
if(sstate == SESSION_STATE_CLOSING)
|
||||
{
|
||||
return ;
|
||||
struct quic_message *qmsg = quic_create_message(QUIC_FREE, context);
|
||||
quic_session_mq_publish_message_safe(sess, quic_plugin_env->quic_topic_id, qmsg);
|
||||
context->msg_state[QUIC_FREE] = 1;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)))
|
||||
payload = session_get0_current_payload(sess, &payload_len);
|
||||
if(NULL == payload || payload_len <= 0)
|
||||
{
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
|
||||
if(*pme==NULL)
|
||||
{
|
||||
quic_init_context(pme, thread_seq);
|
||||
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);
|
||||
}
|
||||
|
||||
if(state&APP_STATE_DROPME || state&APP_STATE_DROPPKT || pstream->opstate==OP_STATE_CLOSE)
|
||||
{
|
||||
quic_free_context(pme, thread_seq);
|
||||
*pme=NULL;
|
||||
return state;
|
||||
}
|
||||
|
||||
return APP_STATE_GIVEME;
|
||||
}
|
||||
|
||||
extern "C" int QUIC_INIT(void)
|
||||
{
|
||||
int ret=0;
|
||||
FILE *fp=NULL;
|
||||
char buff[2048]={0};
|
||||
int region_id=0;
|
||||
char region_name[REGION_NAME_LEN]={0};
|
||||
|
||||
memset(&g_quic_param,0,sizeof(struct quic_param));
|
||||
|
||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "LOG_LEVEL", &g_quic_param.level, RLOG_LV_FATAL);
|
||||
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "LOG_PATH", g_quic_param.log_path, sizeof(g_quic_param.log_path), "./log/quic/quic");
|
||||
|
||||
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;");
|
||||
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);
|
||||
if(g_quic_param.logger==NULL)
|
||||
{
|
||||
printf("MESA_create_runtime_log_handle failed, level: %d log_path: %s", g_quic_param.level, g_quic_param.log_path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(((fp = fopen(g_quic_regionname_conffile, "r"))!=NULL))
|
||||
{
|
||||
while(fgets(buff, sizeof(buff), fp))
|
||||
{
|
||||
ret = sscanf(buff, "%d\t%s", ®ion_id, region_name);
|
||||
if(2>ret)
|
||||
{
|
||||
fclose(fp);
|
||||
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)
|
||||
{
|
||||
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));
|
||||
g_quic_param.quic_region_cnt++;
|
||||
memset(region_name, 0, sizeof(region_name));
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_READCONF", "Open %s error, Please check %s", g_quic_regionname_conffile, g_quic_regionname_conffile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
gcry_init();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" void QUIC_GETPLUGID(unsigned short plugid)
|
||||
{
|
||||
g_quic_param.quic_plugid = plugid;
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_GETPLUGID", "quic_plugid: %d", plugid);
|
||||
}
|
||||
|
||||
extern "C" void QUIC_PROT_FUNSTAT(unsigned long long protflag)
|
||||
{
|
||||
if(0==protflag){
|
||||
return;
|
||||
}
|
||||
g_quic_param.quic_interested_region_flag=protflag;
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_PROT_FUNSTAT", "interested_region_flag: %llu", g_quic_param.quic_interested_region_flag);
|
||||
quic_analyze_entry(sess, quic_plugin_env, context, thread_seq, payload, payload_len);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
extern "C" unsigned long long quic_getRegionID(char *string, int str_len,const char g_string[MAX_REGION_NUM][REGION_NAME_LEN])
|
||||
void *quic_session_ctx_new_cb(struct session *sess, void *plugin_env)
|
||||
{
|
||||
unsigned long long i=0;
|
||||
for(i=0;i<g_quic_param.quic_region_cnt;i++)
|
||||
struct quic_param *quic_plugin_env = (struct quic_param *)plugin_env;
|
||||
if(0 == quic_protocol_identify(sess, quic_plugin_env))
|
||||
{
|
||||
if(0==strcasecmp(g_string[i], string))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
stellar_session_plugin_dettach_current_session(sess);
|
||||
return NULL;
|
||||
}
|
||||
return 0;
|
||||
int thread_seq = session_get_current_thread_id(sess);
|
||||
size_t payload_len = -1;
|
||||
const char * payload = session_get0_current_payload(sess, &payload_len);
|
||||
if(NULL == payload || payload_len <= 0)
|
||||
{
|
||||
stellar_session_plugin_dettach_current_session(sess);
|
||||
return NULL;
|
||||
}
|
||||
struct quic_info tmp_qinfo = {};
|
||||
if(PARSE_RESULT_UNKNOWN == parse_quic_all_version(quic_plugin_env, &tmp_qinfo, payload, payload_len, thread_seq))
|
||||
{
|
||||
stellar_session_plugin_dettach_current_session(sess);
|
||||
return NULL;
|
||||
}
|
||||
struct quic_context *qcontext = (struct quic_context *)CALLOC(1, sizeof(struct quic_context));
|
||||
memcpy(&qcontext->quic_info, &tmp_qinfo, sizeof(struct quic_info));
|
||||
struct quic_message *qmsg = quic_create_message(QUIC_NEW, qcontext);
|
||||
quic_session_mq_publish_message_safe(sess, quic_plugin_env->quic_topic_id, qmsg);
|
||||
return (void *)qcontext;
|
||||
}
|
||||
|
||||
extern "C" long long QUIC_FLAG_CHANGE(char* flag_str)
|
||||
void quic_session_ctx_free_cb(struct session *sess, void *session_ctx, void *plugin_env)
|
||||
{
|
||||
if(flag_str==NULL) return -1;
|
||||
long long protflag = 0;
|
||||
long long region_id = 0;
|
||||
char *start_token = flag_str;
|
||||
char *end_token = flag_str;
|
||||
char *end_pos = flag_str+strlen(flag_str);
|
||||
char region_name[REGION_NAME_LEN] = {0};
|
||||
if(session_ctx){
|
||||
struct quic_context *qcontext = (struct quic_context *)session_ctx;
|
||||
free_quicinfo(&qcontext->quic_info);
|
||||
FREE(session_ctx);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
while (end_token < end_pos)
|
||||
void quic_session_exdata_free_cb(struct session *sess, int idx, void *ex_ptr, void *arg)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void quic_msg_free_cb(struct session *sess, void *msg, void *msg_free_arg)
|
||||
{
|
||||
FREE(msg);
|
||||
}
|
||||
|
||||
extern "C" void *QUIC_ONLOAD(struct stellar *st)
|
||||
{
|
||||
char buff[2048]={0};
|
||||
|
||||
struct quic_param *quic_plugin_env = (struct quic_param *)CALLOC(1, sizeof(struct quic_param));
|
||||
quic_plugin_env->st = st;
|
||||
|
||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "LOG_LEVEL", &quic_plugin_env->level, RLOG_LV_FATAL);
|
||||
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "LOG_PATH", quic_plugin_env->log_path, sizeof(quic_plugin_env->log_path), g_quic_log_path);
|
||||
|
||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "DECRYPTED_SWITCH", &quic_plugin_env->decrypted_switch, 2);
|
||||
MESA_load_profile_int_def(g_quic_proto_conffile, "QUIC", "MAX_PARSE_PKT_NUM", &quic_plugin_env->max_parse_pkt_num, 3);
|
||||
|
||||
MESA_load_profile_string_def(g_quic_proto_conffile, "QUIC", "QUIC_PORT_LIST", buff, sizeof(buff), "443;8443;");
|
||||
quic_plugin_env->quic_port_num=parse_quic_port(buff, quic_plugin_env->quic_port_list, SUPPORT_QUIC_PORT_NUM);
|
||||
|
||||
quic_plugin_env->logger=MESA_create_runtime_log_handle(quic_plugin_env->log_path, quic_plugin_env->level);
|
||||
if(quic_plugin_env->logger==NULL)
|
||||
{
|
||||
end_token = (char*)memchr(start_token, ',', end_pos-start_token);
|
||||
if(end_token!=NULL)
|
||||
{
|
||||
memcpy(region_name, start_token, end_token-start_token);
|
||||
start_token = end_token+1;
|
||||
end_token += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(region_name, start_token, end_pos-start_token);
|
||||
end_token = end_pos;
|
||||
}
|
||||
region_id = quic_getRegionID(region_name, strlen(region_name), g_quic_param.quic_conf_regionname);
|
||||
if(-1==region_id)
|
||||
{
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_FLAG_CHANGE", "Read %s error, flag_str: %d", region_name, flag_str);
|
||||
return -1;
|
||||
}
|
||||
protflag |= ((long long)1)<<region_id;
|
||||
memset(region_name, 0, REGION_NAME_LEN);
|
||||
fprintf(stderr, "MESA_create_runtime_log_handle failed, level: %d log_path: %s", quic_plugin_env->level, quic_plugin_env->log_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
quic_plugin_env->quic_plugid = stellar_session_plugin_register(st, quic_session_ctx_new_cb, quic_session_ctx_free_cb, quic_plugin_env);
|
||||
assert(quic_plugin_env->quic_plugid >= 0);
|
||||
|
||||
MESA_handle_runtime_log(g_quic_param.logger, RLOG_LV_FATAL, "QUIC_FLAG_CHANGE", "protflag: %llu", protflag);
|
||||
return protflag;
|
||||
quic_plugin_env->exdata_id=stellar_session_exdata_new_index(st, "QUIC_EXDATA", quic_session_exdata_free_cb, quic_plugin_env);
|
||||
assert(quic_plugin_env->exdata_id >= 0);
|
||||
quic_plugin_env->udp_topic_id=stellar_session_mq_get_topic_id(st, TOPIC_UDP);
|
||||
assert(quic_plugin_env->udp_topic_id >= 0);
|
||||
stellar_session_mq_subscribe(st, quic_plugin_env->udp_topic_id, quic_on_session_msg_cb, quic_plugin_env->quic_plugid);
|
||||
|
||||
quic_plugin_env->quic_topic_id=stellar_session_mq_create_topic(st, QUIC_DECODER_TOPIC, quic_msg_free_cb, quic_plugin_env);
|
||||
assert(quic_plugin_env->quic_topic_id >= 0);
|
||||
return (void *)quic_plugin_env;
|
||||
}
|
||||
|
||||
extern "C" void QUIC_DESTROY(void)
|
||||
extern "C" void QUIC_UNLOAD(void *plugin_env)
|
||||
{
|
||||
return ;
|
||||
struct quic_param *quic_plugin_env = (struct quic_param *)plugin_env;
|
||||
MESA_destroy_runtime_log_handle(quic_plugin_env->logger);
|
||||
FREE(plugin_env);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -22,14 +26,17 @@
|
||||
|
||||
struct quic_param
|
||||
{
|
||||
unsigned long long quic_interested_region_flag;
|
||||
unsigned long long quic_region_cnt;
|
||||
unsigned short quic_plugid;
|
||||
struct stellar *st;
|
||||
int quic_plugid;
|
||||
int level;
|
||||
int quic_port_num;
|
||||
int decrypted_switch;
|
||||
int max_parse_pkt_num;
|
||||
unsigned short quic_port_list[SUPPORT_QUIC_PORT_NUM];
|
||||
// int context_bridge_id;
|
||||
int exdata_id;
|
||||
int udp_topic_id; //as subscriber
|
||||
int quic_topic_id; //as publisher
|
||||
unsigned short quic_port_list[SUPPORT_QUIC_PORT_NUM]; //network order
|
||||
char quic_conf_regionname[MAX_REGION_NUM][REGION_NAME_LEN];
|
||||
char log_path[128];
|
||||
void *logger;
|
||||
@@ -46,9 +53,5 @@ enum quic_mes_type{
|
||||
MSG_UNKNOWN = 255
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
#endif /* SRC_QUIC_ANALYSIS_H_ */
|
||||
|
||||
|
||||
@@ -11,30 +11,28 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <MESA/stream.h>
|
||||
#include <MESA/MESA_handle_logger.h>
|
||||
|
||||
#include "quic_entry.h"
|
||||
#include "quic_process.h"
|
||||
#include "quic_deprotection.h"
|
||||
|
||||
enum PARSE_RESULT
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
PARSE_RESULT_UNKNOWN,
|
||||
PARSE_RESULT_VERSION,
|
||||
PARSE_RESULT_CLIENT_HELLO,
|
||||
PARSE_RESULT_PAYLOAD,
|
||||
PARSE_RESULT_MAX
|
||||
};
|
||||
#endif
|
||||
#include "quic_util.h"
|
||||
#include <stellar/stellar.h>
|
||||
#include <stellar/session.h>
|
||||
#include <stellar/session_mq.h>
|
||||
#include <stellar/session_exdata.h>
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef PRINTADDR
|
||||
#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;
|
||||
@@ -43,49 +41,73 @@ struct quic_client_hello_msg_hdr
|
||||
uint8_t random[32];
|
||||
};
|
||||
|
||||
int check_port(unsigned short port)
|
||||
static int check_port(const struct quic_param *quic_plugin_env, unsigned short port)
|
||||
{
|
||||
int i=0;
|
||||
for(i=0; i< g_quic_param.quic_port_num; i++)
|
||||
for (int i = 0; i < quic_plugin_env->quic_port_num; i++)
|
||||
{
|
||||
if(g_quic_param.quic_port_list[i]==port)
|
||||
if (quic_plugin_env->quic_port_list[i] == port)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int is_quic_port(struct streaminfo *pstream)
|
||||
int quic_protocol_identify(struct session *sess, struct quic_param *quic_plugin_env)
|
||||
{
|
||||
unsigned short source=0, dest=0;
|
||||
|
||||
switch(pstream->addr.addrtype)
|
||||
enum session_addr_type addr_type;
|
||||
struct session_addr *saddr = session_get0_addr(sess, &addr_type);
|
||||
unsigned short sport, dport;
|
||||
if (addr_type == SESSION_ADDR_TYPE_IPV4_UDP)
|
||||
{
|
||||
case ADDR_TYPE_IPV4:
|
||||
case __ADDR_TYPE_IP_PAIR_V4:
|
||||
source=(unsigned short)ntohs(pstream->addr.ipv4->source);
|
||||
dest=(unsigned short)ntohs(pstream->addr.ipv4->dest);
|
||||
break;
|
||||
case ADDR_TYPE_IPV6:
|
||||
case __ADDR_TYPE_IP_PAIR_V6:
|
||||
source=(unsigned short)ntohs(pstream->addr.ipv6->source);
|
||||
dest=(unsigned short)ntohs(pstream->addr.ipv6->dest);
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
break;
|
||||
sport = saddr->ipv4.sport;
|
||||
dport = saddr->ipv4.dport;
|
||||
}
|
||||
|
||||
if(check_port(source) || check_port(dest))
|
||||
else if (addr_type == SESSION_ADDR_TYPE_IPV6_UDP)
|
||||
{
|
||||
return 1;
|
||||
sport = saddr->ipv6.sport;
|
||||
dport = saddr->ipv6.dport;
|
||||
}
|
||||
|
||||
return 0;
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (0 == (check_port(quic_plugin_env, sport) || check_port(quic_plugin_env, dport)))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// int is_quic_port(const struct streaminfo *pstream)
|
||||
// {
|
||||
// unsigned short source=0, dest=0;
|
||||
|
||||
// switch(pstream->addr.addrtype)
|
||||
// {
|
||||
// case ADDR_TYPE_IPV4:
|
||||
// case __ADDR_TYPE_IP_PAIR_V4:
|
||||
// source=(unsigned short)ntohs(pstream->addr.ipv4->source);
|
||||
// dest=(unsigned short)ntohs(pstream->addr.ipv4->dest);
|
||||
// break;
|
||||
// case ADDR_TYPE_IPV6:
|
||||
// case __ADDR_TYPE_IP_PAIR_V6:
|
||||
// source=(unsigned short)ntohs(pstream->addr.ipv6->source);
|
||||
// dest=(unsigned short)ntohs(pstream->addr.ipv6->dest);
|
||||
// break;
|
||||
// default:
|
||||
// return 0;
|
||||
// break;
|
||||
// }
|
||||
|
||||
// if(check_port(source) || check_port(dest))
|
||||
// {
|
||||
// return 1;
|
||||
// }
|
||||
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
static int gquic_pkn_bit2length(unsigned char bit_value)
|
||||
{
|
||||
switch(bit_value)
|
||||
@@ -100,13 +122,18 @@ static int gquic_pkn_bit2length(unsigned char bit_value)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int copy_extension_tag(const char *tag_start_pos, int tag_len, char **out, int thread_seq)
|
||||
static int copy_extension_tag(const char *tag_start_pos, int tag_len, qstring *out, int thread_seq)
|
||||
{
|
||||
if(tag_start_pos!=NULL && tag_len>0)
|
||||
{
|
||||
(*out)=(char *)dictator_malloc(thread_seq, tag_len+1);
|
||||
memcpy(*out, tag_start_pos, tag_len);
|
||||
(*out)[tag_len]='\0';
|
||||
if(out->iov_base!=NULL)
|
||||
{
|
||||
FREE(out->iov_base);
|
||||
}
|
||||
|
||||
out->iov_base=CALLOC(1, tag_len+1);
|
||||
memcpy((void *)out->iov_base, tag_start_pos, tag_len);
|
||||
out->iov_len = tag_len;
|
||||
|
||||
return tag_len;
|
||||
}
|
||||
@@ -135,57 +162,6 @@ static int msb2_varint_decode(const unsigned char *buf, long *out)
|
||||
return nfollow;
|
||||
}
|
||||
|
||||
int quic_call_business_state(struct quic_context *context)
|
||||
{
|
||||
UCHAR state = 0;
|
||||
|
||||
if(0==context->link_state)
|
||||
{
|
||||
state=SESSION_STATE_PENDING|SESSION_STATE_DATA;
|
||||
context->link_state=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
state=SESSION_STATE_DATA;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
char state=PROT_STATE_GIVEME;
|
||||
char app_state=APP_STATE_GIVEME;
|
||||
stSessionInfo session_info={0};
|
||||
|
||||
if(region_mask==QUIC_INTEREST_KEY_MASK)
|
||||
{
|
||||
session_info.plugid=g_quic_param.quic_plugid;
|
||||
session_info.prot_flag=0;
|
||||
session_info.session_state=SESSION_STATE_CLOSE;
|
||||
session_info.app_info=NULL;
|
||||
session_info.buf=NULL;
|
||||
session_info.buflen=0;
|
||||
}
|
||||
else
|
||||
{
|
||||
session_info.plugid=g_quic_param.quic_plugid;
|
||||
session_info.prot_flag=(((unsigned long long)1)<<region_mask);
|
||||
session_info.session_state=quic_call_business_state(context) ;
|
||||
session_info.app_info=(void*)(&context->quic_info);
|
||||
session_info.buf=buff;
|
||||
session_info.buflen=buff_len;
|
||||
}
|
||||
state=PROT_PROCESS(&session_info, &(context->business_pme), pstream->threadnum, pstream, a_packet);
|
||||
|
||||
if(state&PROT_STATE_DROPPKT)
|
||||
{
|
||||
app_state=APP_STATE_DROPPKT;
|
||||
}
|
||||
|
||||
return app_state;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
//https://docs.google.com/document/d/1FcpCJGTDEMblAs-Bm5TYuqhHyUqeWpqrItw2vkMFsdY/edit
|
||||
@@ -314,8 +290,11 @@ 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 *)CALLOC(1, 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)
|
||||
|
||||
@@ -336,11 +315,11 @@ int parse_special_frame_stream(struct quic_info* quic_info, const char *payload,
|
||||
switch(ext_tag_type)
|
||||
{
|
||||
case TAG_UAID:
|
||||
copy_extension_tag(payload+tag_value_start_offset, one_tag_len, &quic_info->client_hello->user_agent, thread_seq);
|
||||
copy_extension_tag(payload+tag_value_start_offset, one_tag_len, &quic_info->user_agent, thread_seq);
|
||||
parse_result=PARSE_RESULT_CLIENT_HELLO;
|
||||
break;
|
||||
case TAG_SNI:
|
||||
copy_extension_tag(payload+tag_value_start_offset, one_tag_len, &quic_info->client_hello->sni, thread_seq);
|
||||
copy_extension_tag(payload+tag_value_start_offset, one_tag_len, &quic_info->sni, thread_seq);
|
||||
parse_result=PARSE_RESULT_CLIENT_HELLO;
|
||||
break;
|
||||
default:
|
||||
@@ -356,7 +335,7 @@ int parse_special_frame_stream(struct quic_info* quic_info, const char *payload,
|
||||
return parse_result;
|
||||
}
|
||||
|
||||
int parse_quic_transport_parameter(struct quic_client_hello *client_hello, const char *quic_para, int quic_para_len, int thread_seq)
|
||||
int parse_quic_transport_parameter(struct quic_info *quic_info, const char *quic_para, int quic_para_len, int thread_seq)
|
||||
{
|
||||
int one_para_length=0;
|
||||
int para_offset=0;
|
||||
@@ -373,10 +352,14 @@ int parse_quic_transport_parameter(struct quic_client_hello *client_hello, const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
para_offset+=copy_extension_tag(quic_para+para_offset, one_para_length, &client_hello->user_agent, thread_seq);
|
||||
para_offset+=copy_extension_tag(quic_para+para_offset, one_para_length, &quic_info->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;
|
||||
}
|
||||
@@ -385,7 +368,7 @@ int parse_quic_transport_parameter(struct quic_client_hello *client_hello, const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_extension_server_name(struct quic_client_hello *client_hello, const char *ext_server_name, int ext_server_name_length, int thread_seq)
|
||||
int parse_extension_server_name(struct quic_info *quic_info, const char *ext_server_name, int ext_server_name_length, int thread_seq)
|
||||
{
|
||||
unsigned short sni_type=0;
|
||||
unsigned short sni_length=0;
|
||||
@@ -412,12 +395,12 @@ int parse_extension_server_name(struct quic_client_hello *client_hello, const ch
|
||||
}
|
||||
extension_offset+=2;
|
||||
|
||||
copy_extension_tag(ext_server_name+extension_offset, sni_length, &client_hello->sni, thread_seq);
|
||||
copy_extension_tag(ext_server_name+extension_offset, sni_length, &quic_info->sni, thread_seq);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int parse_tls_client_hello(struct quic_client_hello **client_hello, const char *payload, int payload_len, int thread_seq)
|
||||
int parse_tls_client_hello(struct quic_info *quic_info, const char *payload, int payload_len, int thread_seq)
|
||||
{
|
||||
int ret=0,skip_len=0;
|
||||
int payload_offset=0;
|
||||
@@ -426,7 +409,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;
|
||||
}
|
||||
@@ -463,11 +446,11 @@ int parse_tls_client_hello(struct quic_client_hello **client_hello, const char *
|
||||
|
||||
payload_offset+=2;
|
||||
|
||||
if(*client_hello==NULL)
|
||||
{
|
||||
*client_hello=(struct quic_client_hello *)dictator_malloc(thread_seq, sizeof(struct quic_client_hello));
|
||||
memset(*client_hello, 0, sizeof(struct quic_client_hello));
|
||||
}
|
||||
// if(*client_hello==NULL)
|
||||
// {
|
||||
// *client_hello=(struct quic_client_hello *)CALLOC(1, sizeof(struct quic_client_hello));
|
||||
// // memset(*client_hello, 0, sizeof(struct quic_client_hello));
|
||||
// }
|
||||
|
||||
extension_start_pos=payload+payload_offset;
|
||||
|
||||
@@ -487,11 +470,11 @@ int parse_tls_client_hello(struct quic_client_hello **client_hello, const char *
|
||||
switch(one_ext_type)
|
||||
{
|
||||
case EXTENSION_SERVER_NAME:
|
||||
ret=parse_extension_server_name(*client_hello, extension_start_pos+extension_offset, one_ext_len, thread_seq);
|
||||
ret=parse_extension_server_name(quic_info, extension_start_pos+extension_offset, one_ext_len, thread_seq);
|
||||
break;
|
||||
case EXTENSION_QUIC_PARAM_TLS_13:
|
||||
case EXTENSION_QUIC_PARAM_TLS_33:
|
||||
ret=parse_quic_transport_parameter(*client_hello, extension_start_pos+extension_offset, one_ext_len, thread_seq);
|
||||
ret=parse_quic_transport_parameter(quic_info, extension_start_pos+extension_offset, one_ext_len, thread_seq);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -529,7 +512,7 @@ int parse_quic_decrypted_payload(struct quic_info *quic_info, const char * paylo
|
||||
|
||||
if(join_payload[0] == QUIC_HANDSHAKE_TYPE_CLIENTHELLO)
|
||||
{
|
||||
return parse_tls_client_hello(&(quic_info->client_hello), join_payload, join_payload_len, thread_seq);
|
||||
return parse_tls_client_hello(quic_info, join_payload, join_payload_len, thread_seq);
|
||||
}
|
||||
}
|
||||
else //if(quic_version>=GQUIC_VERSION_Q047 && quic_version<=GQUIC_VERSION_Q059)
|
||||
@@ -636,11 +619,11 @@ int parse_quic_uncryption_payload(struct quic_info *quic_info, const char * payl
|
||||
+--------+--------+--------+--------+--------+--------+
|
||||
|
||||
*/
|
||||
enum QUIC_VERSION identify_gquic_version0to43(const char *payload, int payload_len, int *payload_offset)
|
||||
enum QUIC_VERSION_T identify_gquic_version0to43(const char *payload, int payload_len, int *payload_offset)
|
||||
{
|
||||
unsigned char pkn_length=0;
|
||||
unsigned char public_flags=0;
|
||||
enum QUIC_VERSION quic_version=QUIC_VERSION_UNKNOWN;
|
||||
enum QUIC_VERSION_T quic_version=QUIC_VERSION_UNKNOWN;
|
||||
|
||||
public_flags=payload[*payload_offset];
|
||||
*payload_offset+=1;
|
||||
@@ -662,7 +645,7 @@ enum QUIC_VERSION identify_gquic_version0to43(const char *payload, int payload_l
|
||||
|
||||
if(public_flags&GQUIC_PUBLIC_FLAG_VERSION && (*(unsigned char *)(payload+*payload_offset)==0x51))
|
||||
{
|
||||
quic_version=(enum QUIC_VERSION)ntohl(*(unsigned int *)(payload+*payload_offset));
|
||||
quic_version=(enum QUIC_VERSION_T)ntohl(*(unsigned int *)(payload+*payload_offset));
|
||||
*payload_offset+=sizeof(int); // skip version
|
||||
}
|
||||
|
||||
@@ -699,9 +682,9 @@ enum QUIC_VERSION identify_gquic_version0to43(const char *payload, int payload_l
|
||||
return quic_version;
|
||||
}
|
||||
|
||||
enum QUIC_VERSION identify_quic_version(const char *payload, int payload_len, int *payload_offset)
|
||||
enum QUIC_VERSION_T identify_quic_version(const char *payload, int payload_len, int *payload_offset)
|
||||
{
|
||||
enum QUIC_VERSION quic_version=(enum QUIC_VERSION)ntohl(*(unsigned int *)(payload+(*payload_offset+1)));
|
||||
enum QUIC_VERSION_T quic_version=(enum QUIC_VERSION_T)ntohl(*(unsigned int *)(payload+(*payload_offset+1)));
|
||||
if(quic_version>=GQUIC_VERSION_Q044 && quic_version<=GQUIC_VERSION_Q048)
|
||||
{
|
||||
parse_gquic_version_44to48_header(payload, payload_len, payload_offset);
|
||||
@@ -732,11 +715,16 @@ enum QUIC_VERSION identify_quic_version(const char *payload, int payload_len, in
|
||||
return QUIC_VERSION_UNKNOWN;
|
||||
}
|
||||
|
||||
enum QUIC_VERSION is_quic_protocol(const char *payload, int payload_len, int *payload_offset)
|
||||
enum QUIC_VERSION_T is_quic_protocol(const char *payload, int payload_len, int *payload_offset)
|
||||
{
|
||||
enum QUIC_VERSION quic_version=QUIC_VERSION_UNKNOWN;
|
||||
enum QUIC_VERSION_T 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,49 +741,54 @@ 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)
|
||||
enum PARSE_RESULT parse_quic_all_version(const struct quic_param *g_quic_plugin_env, struct quic_info *quic_info, const char *payload, int payload_len, int thread_seq)
|
||||
{
|
||||
int ret=0, payload_offset=0;
|
||||
unsigned char decrypt_payload[2048]={0};
|
||||
unsigned int decrypt_payload_len=sizeof(decrypt_payload);
|
||||
enum QUIC_VERSION quic_version=QUIC_VERSION_UNKNOWN;
|
||||
int ret = 0, payload_offset = 0;
|
||||
enum QUIC_VERSION_T quic_version = QUIC_VERSION_UNKNOWN;
|
||||
|
||||
if(payload==NULL || payload_len<=0)
|
||||
if (payload == NULL || payload_len <= 0)
|
||||
{
|
||||
return PARSE_RESULT_UNKNOWN;
|
||||
}
|
||||
|
||||
quic_version=is_quic_protocol(payload, payload_len, &payload_offset);
|
||||
if(quic_version==QUIC_VERSION_UNKNOWN)
|
||||
quic_version = is_quic_protocol(payload, payload_len, &payload_offset);
|
||||
if (quic_version == QUIC_VERSION_UNKNOWN)
|
||||
{
|
||||
return PARSE_RESULT_UNKNOWN;
|
||||
}
|
||||
|
||||
quic_info->quic_version=quic_version;
|
||||
quic_info->quic_version = quic_version;
|
||||
|
||||
if(quic_version>=GQUIC_VERSION_Q001 && quic_version<=GQUIC_VERSION_Q048)
|
||||
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);
|
||||
}
|
||||
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 (payload_len > payload_offset)
|
||||
{
|
||||
return (enum PARSE_RESULT)parse_quic_uncryption_payload(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_plugin_env->decrypted_switch > 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)
|
||||
if (g_quic_plugin_env->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 (enum PARSE_RESULT)ret;
|
||||
}
|
||||
quic_deprotection_free(dpt);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -805,107 +798,117 @@ unsigned char parse_quic_all_version(struct quic_info *quic_info, const char *pa
|
||||
return PARSE_RESULT_VERSION;
|
||||
}
|
||||
|
||||
|
||||
unsigned char quic_analyze_entry(struct streaminfo *pstream, struct quic_context* context, int thread_seq, void* a_packet)
|
||||
void quic_analyze_entry(struct session *sess, const struct quic_param *g_quic_plugin_env, struct quic_context *qcontext, int thread_seq, const char *payload, size_t payload_len)
|
||||
{
|
||||
unsigned char parse_result=PARSE_RESULT_UNKNOWN;
|
||||
char state=APP_STATE_GIVEME;
|
||||
struct quic_message *qmsg;
|
||||
int push_payload = 0;
|
||||
enum PARSE_RESULT parse_res = PARSE_RESULT_UNKNOWN;
|
||||
|
||||
if(pstream==NULL || pstream->pudpdetail==NULL)
|
||||
{
|
||||
return APP_STATE_DROPME;
|
||||
}
|
||||
|
||||
struct udpdetail *udp_detail=pstream->pudpdetail;
|
||||
|
||||
switch(context->pre_parse_state)
|
||||
{
|
||||
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);
|
||||
if(parse_result==PARSE_RESULT_VERSION || parse_result==PARSE_RESULT_UNKNOWN)
|
||||
{
|
||||
parse_result=PARSE_RESULT_PAYLOAD;
|
||||
if ((qcontext->parse_pkt_cnt++) >= g_quic_plugin_env->max_parse_pkt_num){
|
||||
push_payload = 1;
|
||||
}else{
|
||||
if(0 == qcontext->msg_state[QUIC_VERSION]
|
||||
|| 0 == qcontext->msg_state[QUIC_SNI]
|
||||
|| 0 == qcontext->msg_state[QUIC_USER_AGENT]){
|
||||
if(NULL == qcontext->quic_info.sni.iov_base
|
||||
|| NULL == qcontext->quic_info.user_agent.iov_base){
|
||||
parse_res = parse_quic_all_version(g_quic_plugin_env, &(qcontext->quic_info), payload, payload_len, thread_seq);
|
||||
if(PARSE_RESULT_VERSION == parse_res){
|
||||
push_payload = 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PARSE_RESULT_PAYLOAD:
|
||||
case PARSE_RESULT_UNKNOWN:
|
||||
default:
|
||||
if((context->parse_pkt_cnt++)>=g_quic_param.max_parse_pkt_num)
|
||||
{
|
||||
parse_result=PARSE_RESULT_PAYLOAD;
|
||||
break;
|
||||
|
||||
if((0 == qcontext->msg_state[QUIC_VERSION]) && (qcontext->quic_info.quic_version != 0)){
|
||||
qmsg = quic_create_message(QUIC_VERSION, qcontext);
|
||||
quic_session_mq_publish_message_safe(sess, g_quic_plugin_env->quic_topic_id, qmsg);
|
||||
qcontext->msg_state[QUIC_VERSION] = 1;
|
||||
}
|
||||
if((0 == qcontext->msg_state[QUIC_SNI]) && qcontext->quic_info.sni.iov_base){
|
||||
qmsg = quic_create_message(QUIC_SNI, qcontext);
|
||||
quic_session_mq_publish_message_safe(sess, g_quic_plugin_env->quic_topic_id, qmsg);
|
||||
qcontext->msg_state[QUIC_SNI] = 1;
|
||||
}
|
||||
if((0 == qcontext->msg_state[QUIC_USER_AGENT]) && qcontext->quic_info.user_agent.iov_base){
|
||||
qmsg = quic_create_message(QUIC_USER_AGENT, qcontext);
|
||||
quic_session_mq_publish_message_safe(sess, g_quic_plugin_env->quic_topic_id, qmsg);
|
||||
qcontext->msg_state[QUIC_USER_AGENT] =1;
|
||||
}
|
||||
parse_result=parse_quic_all_version(&(context->quic_info), (const char *)udp_detail->pdata, udp_detail->datalen, thread_seq);
|
||||
break;
|
||||
}
|
||||
|
||||
switch(parse_result)
|
||||
{
|
||||
case PARSE_RESULT_VERSION:
|
||||
context->pre_parse_state=PARSE_RESULT_VERSION;
|
||||
state=quic_call_business_plug(pstream, context, (void *)&(context->quic_info.quic_version), sizeof(unsigned int), QUIC_USEING_VERSION_MASK, a_packet);
|
||||
break;
|
||||
case PARSE_RESULT_CLIENT_HELLO:
|
||||
context->pre_parse_state=PARSE_RESULT_CLIENT_HELLO;
|
||||
state=quic_call_business_plug(pstream, context, (void *)&(context->quic_info), sizeof(void *), QUIC_CLIENT_HELLO_MASK, a_packet);
|
||||
break;
|
||||
case PARSE_RESULT_PAYLOAD:
|
||||
state=quic_call_business_plug(pstream, context, udp_detail->pdata, udp_detail->datalen, QUIC_APPLICATION_DATA_MASK, a_packet);
|
||||
break;
|
||||
default:
|
||||
return APP_STATE_DROPME;
|
||||
break;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static int copy_client_hello_extension(char *src, char *dest, int d_len)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
parse_result=parse_quic_all_version(&quic_info, (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;
|
||||
}
|
||||
|
||||
return quic_version;
|
||||
if(push_payload){
|
||||
qcontext->quic_info.payload.iov_base = (void *)payload;
|
||||
qcontext->quic_info.payload.iov_len = payload_len;
|
||||
qmsg = quic_create_message(QUIC_PAYLOAD, qcontext);
|
||||
quic_session_mq_publish_message_safe(sess, g_quic_plugin_env->quic_topic_id, qmsg);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void quic_session_mq_publish_message_safe(struct session *sess, int topic_id, void *msg)
|
||||
{
|
||||
int ret = session_mq_publish_message(sess, topic_id, msg);
|
||||
if(ret < 0){
|
||||
FREE(msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
struct quic_message *quic_create_message(enum quic_message_type mtype, struct quic_context *context)
|
||||
{
|
||||
struct quic_message *msg = (struct quic_message *)CALLOC(1, sizeof(struct quic_message));
|
||||
msg->magic = QUIC_MSG_HDR_MAGIC;
|
||||
msg->type = mtype;
|
||||
msg->qctx = context;
|
||||
return msg;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
enum quic_message_type quic_message_type_get(const struct quic_message *msg)
|
||||
{
|
||||
assert(QUIC_MSG_HDR_MAGIC == msg->magic);
|
||||
if(QUIC_MSG_HDR_MAGIC != msg->magic){
|
||||
return QUIC_MSG_MAX;
|
||||
}
|
||||
return msg->type;
|
||||
}
|
||||
|
||||
void quic_message_get_version(const struct quic_message *msg, unsigned int *result)
|
||||
{
|
||||
assert(QUIC_MSG_HDR_MAGIC == msg->magic);
|
||||
if(result){
|
||||
*result = msg->qctx->quic_info.quic_version;
|
||||
}
|
||||
}
|
||||
void quic_message_get_sni(const struct quic_message *msg, qstring *result)
|
||||
{
|
||||
assert(QUIC_MSG_HDR_MAGIC == msg->magic);
|
||||
if(result){
|
||||
result->iov_base = msg->qctx->quic_info.sni.iov_base;
|
||||
result->iov_len = msg->qctx->quic_info.sni.iov_len;
|
||||
}
|
||||
}
|
||||
void quic_message_get_user_agent(const struct quic_message *msg, qstring *result)
|
||||
{
|
||||
assert(QUIC_MSG_HDR_MAGIC == msg->magic);
|
||||
if(result){
|
||||
result->iov_base = msg->qctx->quic_info.user_agent.iov_base;
|
||||
result->iov_len = msg->qctx->quic_info.user_agent.iov_len;
|
||||
}
|
||||
|
||||
}
|
||||
void quic_message_get_payload(const struct quic_message *msg, qstring *result)
|
||||
{
|
||||
assert(QUIC_MSG_HDR_MAGIC == msg->magic);
|
||||
if(result){
|
||||
result->iov_base = msg->qctx->quic_info.payload.iov_base;
|
||||
result->iov_len = msg->qctx->quic_info.payload.iov_len;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -109,7 +109,7 @@
|
||||
#define EXT_QUIC_PARAM_QUIC_VERSION 0x4752
|
||||
|
||||
//https://github.com/quicwg/base-drafts/wiki/QUIC-Versions
|
||||
enum QUIC_VERSION
|
||||
enum QUIC_VERSION_T
|
||||
{
|
||||
QUIC_VERSION_UNKNOWN=0,
|
||||
//NetApp
|
||||
@@ -279,18 +279,53 @@ enum QUIC_VERSION
|
||||
IQUIC_VERSION_I032=0xFF000020
|
||||
};
|
||||
|
||||
// struct quic_client_hello
|
||||
// {
|
||||
// char *sni;
|
||||
// char *user_agent;
|
||||
// };
|
||||
|
||||
struct quic_info
|
||||
{
|
||||
unsigned int quic_version;
|
||||
qstring sni;
|
||||
qstring user_agent;
|
||||
qstring payload;
|
||||
// struct quic_client_hello *client_hello;
|
||||
};
|
||||
|
||||
struct quic_context
|
||||
{
|
||||
unsigned char link_state;
|
||||
unsigned char parse_pkt_cnt;
|
||||
unsigned char pre_parse_state;
|
||||
unsigned char padding[5];
|
||||
void *business_pme;
|
||||
unsigned char parse_first_pkt;
|
||||
unsigned char msg_state[QUIC_MSG_MAX];
|
||||
struct quic_info quic_info;
|
||||
};
|
||||
|
||||
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);
|
||||
#define QUIC_MSG_HDR_MAGIC 0x51554943 // ASCII: "QUIC"
|
||||
struct quic_message
|
||||
{
|
||||
unsigned int magic;
|
||||
enum quic_message_type type;
|
||||
struct quic_context *qctx;
|
||||
};
|
||||
|
||||
enum PARSE_RESULT
|
||||
{
|
||||
PARSE_RESULT_UNKNOWN,
|
||||
PARSE_RESULT_VERSION,
|
||||
PARSE_RESULT_CLIENT_HELLO,
|
||||
PARSE_RESULT_PAYLOAD,
|
||||
PARSE_RESULT_MAX
|
||||
};
|
||||
|
||||
enum PARSE_RESULT parse_quic_all_version(const struct quic_param *g_quic_plugin_env, struct quic_info *quic_info, const char *payload, int payload_len, int thread_seq);
|
||||
void quic_analyze_entry(struct session *sess, const struct quic_param *g_quic_plug_env, struct quic_context* context, int thread_seq, const char *payload, size_t payload_len);
|
||||
// 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);
|
||||
int quic_protocol_identify(struct session *sess, struct quic_param *g_quic_plug_env);
|
||||
struct quic_message *quic_create_message(enum quic_message_type mtype, struct quic_context *context);
|
||||
void quic_session_mq_publish_message_safe(struct session *sess, int topic_id, void *msg);
|
||||
#endif
|
||||
|
||||
|
||||
5
src/quic_util.h
Normal file
5
src/quic_util.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#define CALLOC(nmemb, size) calloc(nmemb, size)
|
||||
#define REALLOC(ptr, newsize) realloc(ptr, newsize)
|
||||
#define FREE(p) {free((void *)p); p = NULL;}
|
||||
@@ -3,7 +3,10 @@
|
||||
|
||||
#include "quic.h"
|
||||
#include "quic_process.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
int quic_version_int2string(unsigned int version, char *buff, int buff_len)
|
||||
{
|
||||
if(version>=GQUIC_VERSION_Q001 && version<=GQUIC_VERSION_Q099)
|
||||
@@ -82,3 +85,6 @@ int quic_version_int2string(unsigned int version, char *buff, int buff_len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
10
src/version.map
Normal file
10
src/version.map
Normal file
@@ -0,0 +1,10 @@
|
||||
VERS_3.0{
|
||||
global:
|
||||
extern "C" {
|
||||
QUIC_ONLOAD;
|
||||
QUIC_UNLOAD;
|
||||
quic_version_int2string;
|
||||
quic_message_*;
|
||||
};
|
||||
local: *;
|
||||
};
|
||||
BIN
stellar-on-sapp-2.1.1.7875675-1.el8.x86_64.rpm
Normal file
BIN
stellar-on-sapp-2.1.1.7875675-1.el8.x86_64.rpm
Normal file
Binary file not shown.
@@ -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 ./Configure linux-x86_64 --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.
BIN
support/openssl-1.1.1l.tar.gz
Normal file
BIN
support/openssl-1.1.1l.tar.gz
Normal file
Binary file not shown.
BIN
support/sapp-4.3.56.a47b3b5-1.el8.x86_64.rpm
Normal file
BIN
support/sapp-4.3.56.a47b3b5-1.el8.x86_64.rpm
Normal file
Binary file not shown.
BIN
support/sapp-devel-4.3.56.a47b3b5-1.el8.x86_64.rpm
Normal file
BIN
support/sapp-devel-4.3.56.a47b3b5-1.el8.x86_64.rpm
Normal file
Binary file not shown.
BIN
support/stellar-on-sapp-2.1.1.7875675-1.el8.x86_64.rpm
Normal file
BIN
support/stellar-on-sapp-2.1.1.7875675-1.el8.x86_64.rpm
Normal file
Binary file not shown.
@@ -1,61 +1,70 @@
|
||||
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)
|
||||
|
||||
set(proto_test_main plugin_test_main)
|
||||
set(PROTO_TEST_RUN_DIR ${CMAKE_INSTALL_PREFIX}/sapp)
|
||||
|
||||
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})
|
||||
add_test(NAME COPY_QUIC_SO COMMAND sh -c "mkdir -p ${PROTO_TEST_RUN_DIR}/stellar_plugin/${lib_name} && cp ${CMAKE_BINARY_DIR}/src/${lib_name}.so ${PROTO_TEST_RUN_DIR}/stellar_plugin/${lib_name}/${lib_name}.so")
|
||||
add_test(NAME COPY_TEST_SO COMMAND sh -c "mkdir -p ${PROTO_TEST_RUN_DIR}/stellar_plugin/${lib_name} && cp ${CMAKE_CURRENT_BINARY_DIR}/${lib_name}_test_plug.so ${PROTO_TEST_RUN_DIR}/stellar_plugin/${lib_name}/${lib_name}_test_plug.so")
|
||||
add_test(NAME COPY_TEST_SPEC COMMAND sh -c "cp ${CMAKE_SOURCE_DIR}/bin/quic.inf ${PROTO_TEST_RUN_DIR}/stellar_plugin/spec.toml")
|
||||
add_test(NAME COPY_PLUGIN_TEST_MAIN COMMAND sh -c "rpm -ql sapp | grep plugin_test_main | xargs -i cp -f {} ${PROTO_TEST_RUN_DIR}/")
|
||||
add_test(NAME COPY_MAIN_CFG COMMAND sh -c "mkdir -p ${PROTO_TEST_RUN_DIR}/conf/quic && cp ${CMAKE_SOURCE_DIR}/bin/main.conf ${PROTO_TEST_RUN_DIR}/conf/quic/")
|
||||
add_test(NAME COPY_QUIC_CFG COMMAND sh -c "mkdir -p ${PROTO_TEST_RUN_DIR}/conf/quic && cp ${CMAKE_SOURCE_DIR}/bin/quic.conf ${PROTO_TEST_RUN_DIR}/conf/quic/")
|
||||
add_test(NAME UPDATE_SAPP_LOG_LEVEL COMMAND bash -c "sed -i 's/sapp_log.fatal/sapp_log.info/' ${PROTO_TEST_RUN_DIR}/etc/sapp_log.conf")
|
||||
|
||||
set_tests_properties(COPY_QUIC_SO COPY_TEST_SO COPY_TEST_SPEC COPY_PLUGIN_TEST_MAIN COPY_MAIN_CFG COPY_QUIC_CFG UPDATE_SAPP_LOG_LEVEL
|
||||
PROPERTIES FIXTURES_SETUP TestFixture)
|
||||
|
||||
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_tests_properties(IQUIC_29_TEST
|
||||
GQUIC_23_TEST
|
||||
GQUIC_25_TEST
|
||||
GQUIC_33_TEST
|
||||
GQUIC_34_TEST
|
||||
GQUIC_35_TEST
|
||||
GQUIC_37_TEST
|
||||
GQUIC_39_TEST
|
||||
GQUIC_41_TEST
|
||||
GQUIC_43_TEST
|
||||
GQUIC_44_TEST
|
||||
GQUIC_46_TEST
|
||||
GQUIC_50_TEST
|
||||
MVFST_01_TEST
|
||||
MVFST_01_TEST
|
||||
MVFST_02_TEST
|
||||
TQUIC_TEST
|
||||
IQUIC_PORT_8443_TEST
|
||||
QUIC_RFC9000
|
||||
QUIC_RFC9000_FRAGMENT
|
||||
QUIC_RFC9000_SPECIAL
|
||||
QUIC_AIRPORT
|
||||
QUIC_SPECIAL
|
||||
PROPERTIES FIXTURES_REQUIRED TestFixture)
|
||||
|
||||
BIN
test/pcap/quic_len_-2.pcapng
Normal file
BIN
test/pcap/quic_len_-2.pcapng
Normal file
Binary file not shown.
@@ -3,101 +3,135 @@
|
||||
* create time:2021-8-21
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "cJSON.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
#include "quic.h"
|
||||
#include "MESA_prof_load.h"
|
||||
#include <MESA/stream.h>
|
||||
#include <stellar/stellar.h>
|
||||
#include <stellar/session.h>
|
||||
#include <stellar/session_mq.h>
|
||||
#include <stellar/session_exdata.h>
|
||||
|
||||
extern "C" int commit_test_result_json(cJSON *node, const char *name);
|
||||
extern "C" int quic_version_int2string(unsigned int version, char *buff, int buff_len);
|
||||
|
||||
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)
|
||||
#if 0
|
||||
#define DEBUG_PRINT(fmt, args...) fprintf(stderr, fmt, ##args)
|
||||
#else
|
||||
#define DEBUG_PRINT(fmt, args...)
|
||||
#endif
|
||||
|
||||
struct quic_gtest_context
|
||||
{
|
||||
assert(NULL != session_info || pme != NULL);
|
||||
|
||||
cJSON *ctx = (cJSON *)*pme;
|
||||
struct quic_info *quic_info=NULL;
|
||||
char version_str[128]={0};
|
||||
unsigned int version = 0;
|
||||
|
||||
if (session_info->session_state & SESSION_STATE_PENDING)
|
||||
{
|
||||
if (*pme == NULL)
|
||||
{
|
||||
ctx = cJSON_CreateObject();
|
||||
*pme = (void *)ctx;
|
||||
cJSON_AddStringToObject(ctx, "Tuple4", printaddr(&a_tcp->addr, a_tcp->threadnum));
|
||||
}
|
||||
}
|
||||
|
||||
switch (session_info->prot_flag)
|
||||
{
|
||||
case QUIC_CLIENT_HELLO:
|
||||
if (session_info == NULL || session_info->app_info == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
quic_info = (struct quic_info *)session_info->app_info;
|
||||
if(quic_info->client_hello==NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if(quic_info->client_hello->sni!=NULL)
|
||||
{
|
||||
cJSON_AddStringToObject(ctx, "SNI", (char *)(quic_info->client_hello->sni));
|
||||
}
|
||||
if(quic_info->client_hello->user_agent!=NULL)
|
||||
{
|
||||
cJSON_AddStringToObject(ctx, "UA", (char *)(quic_info->client_hello->user_agent));
|
||||
}
|
||||
|
||||
quic_version_int2string((unsigned int)(quic_info->quic_version), version_str, sizeof(version_str));
|
||||
cJSON_AddStringToObject(ctx, "VERSION", version_str);
|
||||
break;
|
||||
case QUIC_USEING_VERSION:
|
||||
version = *(unsigned int *)(session_info->buf);
|
||||
quic_version_int2string(version, version_str, sizeof(version_str));
|
||||
cJSON_AddStringToObject(ctx, "VERSION", version_str);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(session_info->session_state&SESSION_STATE_CLOSE)
|
||||
{
|
||||
if(ctx)
|
||||
{
|
||||
char result_name[16]="";
|
||||
sprintf(result_name,"QUIC_RESULT_%d", g_result_count);
|
||||
commit_test_result_json(ctx, result_name);
|
||||
g_result_count+=1;
|
||||
}
|
||||
*pme = NULL;
|
||||
return PROT_STATE_DROPME;
|
||||
|
||||
}
|
||||
|
||||
return PROT_STATE_GIVEME;
|
||||
cJSON *json_root;
|
||||
};
|
||||
|
||||
static void cJSON_Add_QStringToObject(cJSON * object, const char *name, const qstring * qstring)
|
||||
{
|
||||
char *tmp = (char *)calloc(1, qstring->iov_len + 1);
|
||||
memcpy(tmp, qstring->iov_base, qstring->iov_len);
|
||||
cJSON_AddStringToObject(object, name, tmp);
|
||||
}
|
||||
|
||||
extern "C" int QUIC_TEST_PLUG_INIT()
|
||||
extern "C" void QUIC_TEST_PLUG_ENTRY(struct session *sess, int topic_id, const void *msg, void *per_session_ctx, void *plugin_env)
|
||||
{
|
||||
return 0;
|
||||
struct quic_gtest_context *qctx = (struct quic_gtest_context *)per_session_ctx;
|
||||
struct quic_message *qmsg = (struct quic_message *)msg;
|
||||
enum quic_message_type mtype = quic_message_type_get(qmsg);
|
||||
|
||||
DEBUG_PRINT("### QUIC_TEST_PLUG_ENTRY: mtype=%d\n", (int)mtype);
|
||||
|
||||
switch(mtype){
|
||||
case QUIC_NEW:
|
||||
qctx->json_root = cJSON_CreateObject();
|
||||
cJSON_AddStringToObject(qctx->json_root, "Tuple4", session_get0_readable_addr(sess));
|
||||
break;
|
||||
|
||||
case QUIC_VERSION:
|
||||
{
|
||||
unsigned int version_int = 0;
|
||||
char version_str[128]={0};
|
||||
quic_message_get_version(qmsg, &version_int);
|
||||
assert(version_int != 0);
|
||||
quic_version_int2string(version_int, version_str, sizeof(version_str));
|
||||
cJSON_AddStringToObject(qctx->json_root, "VERSION", version_str);
|
||||
DEBUG_PRINT("### QUIC_TEST_PLUG_ENTRY: version=%x, str_version=%s\n", version_int, version_str);
|
||||
}
|
||||
break;
|
||||
|
||||
case QUIC_SNI:
|
||||
{
|
||||
qstring result = {};
|
||||
quic_message_get_sni(qmsg, &result);
|
||||
cJSON_Add_QStringToObject(qctx->json_root, "SNI", &result);
|
||||
DEBUG_PRINT("### QUIC_TEST_PLUG_ENTRY: len=%d, SNI=%p, %.*s\n", (int)result.str_len, result.str, (int)result.str_len, result.str);
|
||||
}
|
||||
break;
|
||||
|
||||
case QUIC_USER_AGENT:
|
||||
{
|
||||
qstring result = {};
|
||||
quic_message_get_user_agent(qmsg, &result);
|
||||
cJSON_Add_QStringToObject(qctx->json_root, "UA", &result);
|
||||
DEBUG_PRINT("### QUIC_TEST_PLUG_ENTRY: len=%d, UA=%p, %.*s\n", (int)result.str_len, result.str, (int)result.str_len, result.str);
|
||||
}
|
||||
break;
|
||||
|
||||
case QUIC_FREE:
|
||||
{
|
||||
char result_name[16]="";
|
||||
sprintf(result_name,"QUIC_RESULT_%d", g_result_count);
|
||||
commit_test_result_json(qctx->json_root, result_name);
|
||||
g_result_count+=1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
extern "C" void QUIC_TEST_PLUG_DESTROY(void)
|
||||
extern "C" void *quic_gtest_plug_session_ctx_new_cb(struct session *sess, void *plugin_env)
|
||||
{
|
||||
struct quic_gtest_context *ctx = (struct quic_gtest_context *)calloc(1, sizeof(struct quic_gtest_context));
|
||||
return ctx;
|
||||
}
|
||||
|
||||
extern "C" void quic_gtest_session_ctx_free_cb(struct session *sess, void *session_ctx, void *plugin_env)
|
||||
{
|
||||
free(session_ctx);
|
||||
}
|
||||
|
||||
extern "C" void *QUIC_TEST_PLUG_INIT(struct stellar *st)
|
||||
{
|
||||
void *fake_quic_gtest_plugin_env = (void *)"_fake_plugin_env_";
|
||||
int quic_gtest_plug_id = stellar_session_plugin_register(st, quic_gtest_plug_session_ctx_new_cb, quic_gtest_session_ctx_free_cb, fake_quic_gtest_plugin_env);
|
||||
int quic_topic_id = stellar_session_mq_get_topic_id(st, QUIC_DECODER_TOPIC);
|
||||
assert(quic_topic_id >= 0);
|
||||
stellar_session_mq_subscribe(st, quic_topic_id, QUIC_TEST_PLUG_ENTRY, quic_gtest_plug_id);
|
||||
|
||||
return fake_quic_gtest_plugin_env;
|
||||
}
|
||||
|
||||
extern "C" void QUIC_TEST_PLUG_DESTROY(void *plugin_env)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user