Compare commits
31 Commits
v1.0.0
...
fix-gtp-ju
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
10330f034e | ||
|
|
71a6040f8a | ||
|
|
0c02227c58 | ||
|
|
320851f683 | ||
|
|
6fb4738f19 | ||
|
|
5a89ccb0da | ||
|
|
1b30b6d6a2 | ||
|
|
e1bf15c222 | ||
|
|
e683d478a8 | ||
|
|
7a0b7d2316 | ||
|
|
004a1d3b00 | ||
|
|
86ccc7b43a | ||
|
|
3cdcf375e9 | ||
|
|
ab48f907bf | ||
|
|
7bea6fa98e | ||
|
|
d722113df2 | ||
|
|
caf7e5a32d | ||
|
|
bde81dcec6 | ||
|
|
ff7877d432 | ||
|
|
108c79ff68 | ||
|
|
0307f185fd | ||
|
|
637887fddb | ||
|
|
eee615c453 | ||
|
|
ed151c0c0e | ||
|
|
0fb6a5c61d | ||
|
|
b99651da62 | ||
|
|
5bcadbe078 | ||
|
|
daef36bc33 | ||
|
|
9c1e57d6f8 | ||
|
|
c75c00a185 | ||
|
|
810624b7a0 |
248
.gitlab-ci.yml
248
.gitlab-ci.yml
@@ -1,49 +1,125 @@
|
||||
image: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||
variables:
|
||||
GIT_STRATEGY: "clone"
|
||||
BUILD_PADDING_PREFIX: /tmp/padding_for_CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX_PREFIX/
|
||||
BUILD_IMAGE_CENTOS7: "git.mesalab.cn:7443/mesa_platform/build-env:master"
|
||||
BUILD_IMAGE_CENTOS8: "git.mesalab.cn:7443/mesa_platform/build-env:rockylinux"
|
||||
INSTALL_DEPENDENCY_LIBRARY: sapp-devel framework_env libpcap libpcap-devel
|
||||
INSTALL_PREFIX: "/opt/MESA/lib/"
|
||||
INSTALL_DEPENDENCY_LIBRARY: sapp-devel framework_env libpcap libpcap-devel
|
||||
|
||||
stages:
|
||||
- build
|
||||
- test
|
||||
|
||||
.build_by_travis:
|
||||
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
|
||||
google_test_for_centos7:
|
||||
stage: test
|
||||
image: $BUILD_IMAGE_CENTOS7
|
||||
script:
|
||||
- yum makecache
|
||||
- ./ci/travis.sh
|
||||
- cd build
|
||||
- cp -r test/sample_pcap /tmp
|
||||
- ulimit -c 0
|
||||
- cp /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer /tmp/
|
||||
- mkdir -p /opt/MESA/lib
|
||||
- cp /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so /opt/MESA/lib/
|
||||
- echo "/opt/MESA/lib" >> /etc/ld.so.conf
|
||||
- ldconfig
|
||||
- cd /tmp
|
||||
- ./gtest_jump_layer
|
||||
dependencies:
|
||||
- branch_build_debug_for_centos7
|
||||
- branch_build_release_for_centos7
|
||||
- develop_build_debug_for_centos7
|
||||
- develop_build_release_for_centos7
|
||||
- release_build_debug_for_centos7
|
||||
- release_build_release_for_centos7
|
||||
tags:
|
||||
- share
|
||||
- share
|
||||
|
||||
branch_build_debug:
|
||||
google_test_for_centos8:
|
||||
stage: test
|
||||
image: $BUILD_IMAGE_CENTOS8
|
||||
script:
|
||||
- cp -r test/sample_pcap /tmp
|
||||
- ulimit -c 0
|
||||
- cp /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer /tmp/
|
||||
- mkdir -p /opt/MESA/lib
|
||||
- cp /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so /opt/MESA/lib/
|
||||
- echo "/opt/MESA/lib" >> /etc/ld.so.conf
|
||||
- ldconfig
|
||||
- cd /tmp
|
||||
- ./gtest_jump_layer
|
||||
dependencies:
|
||||
- branch_build_debug_for_centos8
|
||||
- branch_build_release_for_centos8
|
||||
- develop_build_debug_for_centos8
|
||||
- develop_build_release_for_centos8
|
||||
- release_build_debug_for_centos8
|
||||
- release_build_release_for_centos8
|
||||
tags:
|
||||
- share
|
||||
|
||||
.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
|
||||
- sed -i 's/\/8\//\/7\//g' /etc/yum.repos.d/repo.internal.geedge.net.repo
|
||||
- yum makecache
|
||||
- chmod +x ./ci/travis.sh
|
||||
- yum install -y elfutils-libelf-devel
|
||||
|
||||
.build_by_travis_for_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis
|
||||
image: $BUILD_IMAGE_CENTOS7
|
||||
extends: .build_before_script
|
||||
script:
|
||||
- yum install -y libmnl-devel
|
||||
- yum install -y libnfnetlink-devel
|
||||
- ./ci/travis.sh
|
||||
tags:
|
||||
- share
|
||||
|
||||
.build_by_travis_for_centos8:
|
||||
stage: build
|
||||
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_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos7
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
artifacts:
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- tags
|
||||
|
||||
branch_build_release:
|
||||
branch_build_release_for_centos7:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
extends: .build_by_travis
|
||||
extends: .build_by_travis_for_centos7
|
||||
artifacts:
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- tags
|
||||
|
||||
develop_build_debug:
|
||||
develop_build_debug_for_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis
|
||||
extends: .build_by_travis_for_centos7
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
@@ -53,16 +129,18 @@ develop_build_debug:
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: MESA_jump_layer-$CI_COMMIT_REF_NAME-debug"
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
|
||||
develop_build_release:
|
||||
develop_build_release_for_centos7:
|
||||
stage: build
|
||||
extends: .build_by_travis
|
||||
extends: .build_by_travis_for_centos7
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
@@ -72,14 +150,16 @@ develop_build_release:
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el7
|
||||
artifacts:
|
||||
name: MESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
|
||||
release_build_debug:
|
||||
release_build_debug_for_centos7:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
@@ -87,15 +167,17 @@ release_build_debug:
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||
extends: .build_by_travis
|
||||
extends: .build_by_travis_for_centos7
|
||||
artifacts:
|
||||
name: MESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release:
|
||||
release_build_release_for_centos7:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
@@ -105,10 +187,120 @@ release_build_release:
|
||||
SYMBOL_TARGET: libMESA_jump_layer
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el7
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el7
|
||||
extends: .build_by_travis
|
||||
extends: .build_by_travis_for_centos7
|
||||
artifacts:
|
||||
name: MESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- tags
|
||||
|
||||
branch_build_debug_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
artifacts:
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- tags
|
||||
|
||||
branch_build_release_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
extends: .build_by_travis_for_centos8
|
||||
artifacts:
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
except:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
- tags
|
||||
|
||||
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: framework-testing-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el8
|
||||
artifacts:
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-debug"
|
||||
paths:
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
- build/*.rpm
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
|
||||
develop_build_release_for_centos8:
|
||||
stage: build
|
||||
extends: .build_by_travis_for_centos8
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
ASAN_OPTION: "OFF"
|
||||
TESTING_VERSION_BUILD: 1
|
||||
PULP3_REPO_NAME: framework-testing-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-testing-x86_64.el8
|
||||
artifacts:
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- /^develop.*$/i
|
||||
- /^master.*$/i
|
||||
|
||||
release_build_debug_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: Debug
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_centos8
|
||||
artifacts:
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- tags
|
||||
|
||||
release_build_release_for_centos8:
|
||||
stage: build
|
||||
variables:
|
||||
BUILD_TYPE: RelWithDebInfo
|
||||
PACKAGE: 1
|
||||
UPLOAD_RPM: 1
|
||||
UPLOAD_SYMBOL_FILES: 1
|
||||
SYMBOL_TARGET: libMESA_jump_layer
|
||||
PULP3_REPO_NAME: framework-stable-x86_64.el8
|
||||
PULP3_DIST_NAME: framework-stable-x86_64.el8
|
||||
extends: .build_by_travis_for_centos8
|
||||
artifacts:
|
||||
name: libMESA_jump_layer-$CI_COMMIT_REF_NAME-release"
|
||||
paths:
|
||||
- build/*.rpm
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/test/gtest_jump_layer
|
||||
- /builds/MESA_framework/mesa_jump_layer/build/src/libMESA_jump_layer.so
|
||||
only:
|
||||
- tags
|
||||
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
cmake_minimum_required (VERSION 2.8...3.10)
|
||||
|
||||
set(lib_name MESA_jump_layer)
|
||||
|
||||
@@ -34,23 +34,10 @@ elseif(ASAN_OPTION MATCHES "THREAD")
|
||||
endif()
|
||||
# end of for ASAN
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/)
|
||||
add_subdirectory(./vendor)
|
||||
add_subdirectory(./src)
|
||||
add_subdirectory(./test)
|
||||
|
||||
file(GLOB SRC
|
||||
"src/*.c"
|
||||
"src/*.cpp"
|
||||
)
|
||||
|
||||
# Shared Library Output
|
||||
add_library(${lib_name}_shared SHARED ${SRC})
|
||||
target_link_libraries(${lib_name}_shared m)
|
||||
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
||||
else()
|
||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name})
|
||||
endif()
|
||||
|
||||
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARY)
|
||||
install(FILES inc/MESA_jump_layer.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include/MESA COMPONENT HEADER)
|
||||
|
||||
include(Package)
|
||||
|
||||
@@ -37,7 +37,7 @@ if [ -n "${INSTALL_DEPENDENCY_LIBRARY}" ]; then
|
||||
yum install -y $INSTALL_DEPENDENCY_LIBRARY
|
||||
fi
|
||||
|
||||
if [ $ASAN_OPTION ];then
|
||||
if [ $ASAN_OPTION ] && [ -f "/opt/rh/devtoolset-7/enable" ] ;then
|
||||
source /opt/rh/devtoolset-7/enable
|
||||
fi
|
||||
|
||||
|
||||
@@ -12,38 +12,37 @@ 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)
|
||||
|
||||
# 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)
|
||||
set(CPACK_COMPONENTS_GROUPING ONE_PER_GROUP)
|
||||
set(CPACK_COMPONENT_HEADER_DISPLAY_NAME "develop")
|
||||
set(CPACK_COMPONENT_LIBRARY_REQUIRED TRUE)
|
||||
|
||||
set(CPACK_COMPONENT_LIBRARIES_REQUIRED TRUE)
|
||||
set(CPACK_RPM_LIBRARIES_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||
set(CPACK_COMPONENT_PROFILE_GROUP "LIBRARIES")
|
||||
set(CPACK_COMPONENT_LIBRARIES_GROUP "LIBRARIES")
|
||||
|
||||
set(CPACK_COMPONENT_HEADER_REQUIRED TRUE)
|
||||
set(CPACK_RPM_HEADER_PACKAGE_NAME "${MY_RPM_NAME_PREFIX}-devel")
|
||||
set(CPACK_RPM_LIBRARY_PACKAGE_NAME ${MY_RPM_NAME_PREFIX})
|
||||
set(CPACK_COMPONENT_HEADER_GROUP "HEADER")
|
||||
|
||||
set(CPACK_RPM_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
set(CPACK_RPM_LIBRARY_DEBUGINFO_FILE_NAME "${CPACK_RPM_LIBRARY_PACKAGE_NAME}-debuginfo-${CPACK_PACKAGE_VERSION}-${SYSTEM_VERSION}.rpm")
|
||||
set(CPACK_COMPONENT_LIBRARY_GROUP "library")
|
||||
|
||||
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_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARY_PACKAGE_NAME})
|
||||
set(CPACK_RPM_HEADER_PACKAGE_REQUIRES_PRE ${CPACK_RPM_LIBRARIES_PACKAGE_NAME})
|
||||
set(CPACK_RPM_HEADER_PACKAGE_CONFLICTS ${CPACK_RPM_HEADER_PACKAGE_NAME})
|
||||
|
||||
set(CPACK_COMPONENTS_ALL LIBRARY HEADER)
|
||||
set(CPACK_COMPONENTS_ALL HEADER PROFILE LIBRARIES)
|
||||
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQPROV "no")
|
||||
set(CPACK_RPM_PACKAGE_AUTOREQ "no")
|
||||
|
||||
set(CPACK_BUILD_SOURCE_DIRS "${CMAKE_SOURCE_DIR}")
|
||||
|
||||
|
||||
@@ -13,18 +13,45 @@ extern "C" {
|
||||
|
||||
const char *MESA_jump_layer_get_last_error(void);
|
||||
|
||||
/*
|
||||
The raw_layer_type and expect_layer_type refer to sapp_base.h->enum addr_type_t
|
||||
*/
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
/*
|
||||
CHN : <20><><EFBFBD>ݰ<EFBFBD>ͷ<EFBFBD><CDB7>ƫ<EFBFBD>ƺ<EFBFBD><C6BA><EFBFBD>.
|
||||
|
||||
<09><><EFBFBD><EFBFBD>:
|
||||
raw_data: <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ָ<EFBFBD><D6B8>;
|
||||
raw_layer_type: <20><>ǰ<EFBFBD><C7B0><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>: enum addr_type_t ;
|
||||
expect_layer_type: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD>ĵ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>: enum addr_type_t ;
|
||||
|
||||
<09><><EFBFBD><EFBFBD>ֵ:
|
||||
NULL: <20>˵<DEB4>ַ;
|
||||
NON-NULL: <20><>Ӧ<EFBFBD><D3A6><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD>ַ.
|
||||
|
||||
<09><><EFBFBD><EFBFBD>:
|
||||
<09><><EFBFBD>赱ǰ<E8B5B1><C7B0>ΪEthernet, <20><>ʼ<EFBFBD><CABC>ͷ<EFBFBD><CDB7>ַΪthis_layer_hdr, <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>IPv6<76><36>ͷ<EFBFBD><CDB7>:
|
||||
struct ip6_hdr *ip6_header;
|
||||
ip6_header = MESA_net_jump_to_layer(this_layer_hdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
|
||||
*/
|
||||
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
/*
|
||||
MESA_jump_layer_greedy<64><79>MESA_jump_layer<65><72><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƕ<EFBFBD><C7B6>Э<EFBFBD><D0AD><EFBFBD><EFBFBD>˵,
|
||||
MESA_jump_layer<65><72>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>expect_layer_type;
|
||||
MESA_jump_layer_greedy<64><79>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD>expect_layer_type;
|
||||
*/
|
||||
const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
|
||||
|
||||
/* <20><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>Ľӿ<C4BD><D3BF><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC> */
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
|
||||
|
||||
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len );
|
||||
|
||||
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len );
|
||||
const char *MESA_jump_layer_ipv6_ntop(const struct ip6_hdr *ip6_hdr, char *out_buf, int buf_len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
37
src/CMakeLists.txt
Normal file
37
src/CMakeLists.txt
Normal file
@@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 2.8...3.10)
|
||||
|
||||
set(MESA_SDK_PREFIX "/opt/MESA" CACHE STRING "MESA Framework Prefix")
|
||||
|
||||
include_directories(${MESA_SDK_PREFIX}/include)
|
||||
include_directories(${MESA_SDK_PREFIX}/include/MESA)
|
||||
include_directories(${MESA_SDK_PREFIX}/include/MESA/include)
|
||||
include_directories(${MESA_SDK_PREFIX}/include/MESA/stream_inc)
|
||||
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include/)
|
||||
|
||||
LINK_DIRECTORIES(/opt/MESA/lib)
|
||||
|
||||
#add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
|
||||
add_definitions(-D_DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
|
||||
add_definitions(-DSAPP_V4=1)
|
||||
|
||||
add_definitions(-fPIC)
|
||||
add_definitions(-std=c++11)
|
||||
|
||||
set(SRC MESA_jump_layer.cpp)
|
||||
|
||||
# Shared Library Output
|
||||
add_library(${lib_name}_shared SHARED ${SRC})
|
||||
target_link_libraries(${lib_name}_shared m)
|
||||
if(DEFINED MESA_SHARED_INSTALL_DIR)
|
||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name} LIBRARY_OUTPUT_DIRECTORY ${MESA_SHARED_INSTALL_DIR})
|
||||
else()
|
||||
set_target_properties(${lib_name}_shared PROPERTIES OUTPUT_NAME ${lib_name})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${lib_name}_shared m)
|
||||
|
||||
install(TARGETS ${lib_name}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
|
||||
#install(FILES ${CMAKE_BINARY_DIR}/src/libMESA_jump_layer.so DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES)
|
||||
|
||||
include(Package)
|
||||
@@ -211,6 +211,15 @@ static int __mjl_gtp_calc_gtp_hdr_len(const struct gtp_hdr *gtph)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(gtph->msg_type != 0xFF){
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(ntohs(gtph->len) > 1460 || ntohs(gtph->len) < 40)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(gtph->flags & (GTP_HDR_FLAG_SEQ_NUM | GTP_HDR_FLAG_N_PDU | GTP_HDR_FLAG_NEXT_EXT_HDR)){
|
||||
//todo, parse and get seq field
|
||||
p_ext_hdr += 2; //seq field length is 2 bytes
|
||||
@@ -281,15 +290,19 @@ static int gtp_jump_to_layer(const char *raw_data, int raw_layer_type, int expe
|
||||
|
||||
next_ip_layer_hdr = (unsigned char *)raw_data + gtp_hdr_len;
|
||||
|
||||
if((*next_ip_layer_hdr & 0x40) == 0x40){
|
||||
if((*next_ip_layer_hdr & 0xF0) == 0x40){
|
||||
skip_len = ipv4_jump_to_layer((char *)next_ip_layer_hdr, __ADDR_TYPE_IP_PAIR_V4, expect_layer_type);
|
||||
}else if((*next_ip_layer_hdr & 0x60) == 0x60){
|
||||
}else if((*next_ip_layer_hdr & 0xF0) == 0x60){
|
||||
skip_len = ipv6_jump_to_layer((char *)next_ip_layer_hdr, __ADDR_TYPE_IP_PAIR_V6, expect_layer_type);
|
||||
}else{
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "gtp_jump_to_layer() error, unsupport type in GTP, 0x%x!", (*next_ip_layer_hdr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(skip_len < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return gtp_hdr_len + skip_len;
|
||||
}
|
||||
|
||||
@@ -380,6 +393,10 @@ static int __mjl_parse_l2tpv2_hdr(const struct l2tp_hdr_v2 *pl2tphdrv2, struct l
|
||||
|
||||
if(pl2tphdrv2->offset_present){
|
||||
offset_size = ntohs(*((unsigned short *)ptr));
|
||||
if(offset_size > 1460)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
ptr += sizeof(short); /* 2 byte fix len offset size */
|
||||
ptr += offset_size; /* var bytes offset value length */
|
||||
}
|
||||
@@ -425,6 +442,10 @@ static int l2tp_jump_to_layer(const char *raw_data, int raw_layer_type, int exp
|
||||
skip_len = ipv6_jump_to_layer((char *)next_layer_hdr, __ADDR_TYPE_IP_PAIR_V6, expect_layer_type);
|
||||
}
|
||||
}
|
||||
|
||||
if(skip_len < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return l2tp_hdr_len + skip_len;
|
||||
}
|
||||
@@ -500,7 +521,7 @@ static int udp_jump_to_layer(const char *raw_data, int raw_layer_type, int expe
|
||||
skip_len = l2tp_jump_to_layer(raw_data+sizeof(struct mesa_udp_hdr), ADDR_TYPE_UDP, expect_layer_type);
|
||||
}else{
|
||||
/* <20><><EFBFBD><EFBFBD>UDP<44><50><EFBFBD>Ͳ<EFBFBD>֧<EFBFBD><D6A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת */
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer_greedy() not support layer type:%d", expect_layer_type);
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer_greedy() not support layer type:%d", expect_layer_type);
|
||||
return -1;
|
||||
}
|
||||
if(skip_len < 0){
|
||||
@@ -1020,6 +1041,10 @@ static int mpls_jump_to_layer(const char *raw_data, int raw_layer_type, int exp
|
||||
}
|
||||
}
|
||||
|
||||
if(skip_len < 0){
|
||||
return -1;
|
||||
}
|
||||
|
||||
return skip_len + mpls_layer_len;
|
||||
}
|
||||
|
||||
@@ -1175,6 +1200,7 @@ static int vlan8021q_jump_to_layer(const char *raw_data, int raw_layer_type, in
|
||||
/* QinQ */
|
||||
case ETH_P_8021Q:
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "vlan8021q_jump_to_layer(): multiple VLAN combine to one layer!");
|
||||
skip_len = -1;
|
||||
assert(0);
|
||||
break;
|
||||
|
||||
@@ -1244,7 +1270,7 @@ extern "C" {
|
||||
Non-NULL: the pointer to expect layer;
|
||||
NULL: not found expect layer.
|
||||
*/
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1321,7 +1347,7 @@ const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, in
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer(): unsupport raw_layer_type:%d in MESA_net_jump_to_layer()!", raw_layer_type);
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer(): unsupport raw_layer_type:%d in MESA_jump_layer()!", raw_layer_type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1332,16 +1358,21 @@ const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, in
|
||||
return ((const char *)raw_data + ret);
|
||||
}
|
||||
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
return MESA_jump_layer(raw_data, raw_layer_type, expect_layer_type);
|
||||
}
|
||||
|
||||
/*
|
||||
<09><>MESA_net_jump_to_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
MESA_net_jump_to_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿪ʼ, <20>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>˳<EFBFBD>;
|
||||
MESA_net_jump_to_layer_greedy()<29><>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Э<EFBFBD><D0AD>ͷ, <20>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>ģʽ.
|
||||
<09><>MESA_jump_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
|
||||
MESA_jump_layer()<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㿪ʼ, <20>ҵ<EFBFBD><D2B5><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD>˳<EFBFBD>;
|
||||
MESA_jump_layer_greedy()<29><>һֱ<D2BB><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ<EFBFBD>Э<EFBFBD><D0AD>ͷ, <20>ʺ<EFBFBD><CABA><EFBFBD><EFBFBD><EFBFBD>ģʽ.
|
||||
|
||||
return value:
|
||||
Non-NULL: the pointer to expect layer;
|
||||
NULL: not found expect layer.
|
||||
*/
|
||||
const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
int skip_len;
|
||||
const void *expect_layer;
|
||||
@@ -1369,7 +1400,7 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty
|
||||
expect_layer_type = __ADDR_TYPE_IP_PAIR_V6;
|
||||
}
|
||||
|
||||
expect_layer = MESA_net_jump_to_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type);
|
||||
expect_layer = MESA_jump_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type);
|
||||
while(expect_layer){
|
||||
success_layer = expect_layer;
|
||||
|
||||
@@ -1396,8 +1427,23 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty
|
||||
|
||||
case __ADDR_TYPE_IP_PAIR_V6:
|
||||
{
|
||||
//TODO2,
|
||||
goto done;
|
||||
const struct mesa_ip6_hdr *ip6hdr = (const struct mesa_ip6_hdr *)expect_layer;
|
||||
if(IPPROTO_UDP == ip6hdr->ip6_nxt_hdr){
|
||||
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
|
||||
new_raw_layer_type = ADDR_TYPE_UDP; /* IP<49><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ƫ<EFBFBD><C6AB> */
|
||||
}else if(IPPROTO_GRE == ip6hdr->ip6_nxt_hdr){
|
||||
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
|
||||
new_raw_layer_type = ADDR_TYPE_GRE; /* GRE */
|
||||
}else if(IPPROTO_IPIP == ip6hdr->ip6_nxt_hdr){
|
||||
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
|
||||
new_raw_layer_type = ADDR_TYPE_IPV4;
|
||||
}else if(IPPROTO_IPIP == ip6hdr->ip6_nxt_hdr){
|
||||
new_next_layer_data = (char *)expect_layer + sizeof(struct mesa_ip6_hdr);
|
||||
new_raw_layer_type = ADDR_TYPE_IPV6;
|
||||
}else{
|
||||
//TODO 2, IPIP, L2TPv3
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1414,17 +1460,22 @@ const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_ty
|
||||
break;
|
||||
|
||||
default:
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_net_jump_to_layer_greedy() not support layer type:%d\n", expect_layer_type);
|
||||
snprintf(_g_mesa_jump_layer_last_error, PIPE_BUF, "MESA_jump_layer_greedy() not support layer type:%d\n", expect_layer_type);
|
||||
goto done;
|
||||
}
|
||||
|
||||
expect_layer = MESA_net_jump_to_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type);
|
||||
expect_layer = MESA_jump_layer(new_next_layer_data, new_raw_layer_type, expect_layer_type);
|
||||
}
|
||||
|
||||
done:
|
||||
return success_layer;
|
||||
}
|
||||
|
||||
const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type)
|
||||
{
|
||||
return MESA_jump_layer_greedy(raw_data, raw_layer_type, expect_layer_type);
|
||||
}
|
||||
|
||||
/* ģ<><C4A3>tcpdump<6D><70>ʽ: 192.168.40.137.22 > 192.168.36.40.49429 */
|
||||
const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, int buf_len )
|
||||
{
|
||||
@@ -1440,7 +1491,7 @@ const char *MESA_jump_layer_ipv4_ntop(const struct ip *ip4_hdr, char *out_buf, i
|
||||
inner_thdr = (struct mesa_tcp_hdr *)((char *)ip4_hdr + ip4_hdr->ip_hl*4);
|
||||
sport = ntohs(inner_thdr->th_sport);
|
||||
dport = ntohs(inner_thdr->th_dport);
|
||||
}else if(IPPROTO_UDP){
|
||||
}else if(IPPROTO_UDP == inner_ip_proto){
|
||||
inner_uhdr = (struct mesa_udp_hdr *)((char *)ip4_hdr + ip4_hdr->ip_hl*4);
|
||||
sport = ntohs(inner_uhdr->uh_sport);
|
||||
dport = ntohs(inner_uhdr->uh_dport);
|
||||
@@ -1473,7 +1524,7 @@ const char *MESA_jump_layer_ipv6_ntop(const struct ip6_hdr *ip6_hdr, char *out_b
|
||||
inner_thdr = (struct tcphdr *)((char *)ip6_hdr + sizeof(struct ip6_hdr));
|
||||
sport = inner_thdr->source;
|
||||
dport = inner_thdr->dest;
|
||||
}else if(IPPROTO_UDP){
|
||||
}else if(IPPROTO_UDP== inner_ip_proto){
|
||||
inner_uhdr = (struct udphdr *)((char *)ip6_hdr + sizeof(struct ip6_hdr));
|
||||
sport = inner_uhdr->source;
|
||||
dport = inner_uhdr->dest;
|
||||
|
||||
@@ -870,8 +870,8 @@ UINT16 net_layer_to_ethernet_protocol_by_stream(const struct streaminfo *pstream
|
||||
enum addr_type_t ethernet_protocol_to_net_layer(UINT16 ether_type_host);
|
||||
int net_common_build_send_mac(unsigned char *buf, const struct mesa_ethernet_hdr *raw_eth_hdr, int addr_type, int dir_reverse, int net_topology_mode);
|
||||
int net_common_adjust_forward_mac(struct mesa_ethernet_hdr *raw_eth_hdr,int net_topology_mode);
|
||||
const void *MESA_net_jump_to_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
const void *MESA_net_jump_to_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
const void *MESA_jump_layer(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
const void *MESA_jump_layer_greedy(const void *raw_data, int raw_layer_type, int expect_layer_type);
|
||||
char MESA_ascii_to_hex(char ascii);
|
||||
const char *sapp_raw_ipv4_ntop(const struct mesa_ip4_hdr *ip4_hdr, char *out_buf, int buf_len );
|
||||
const char *sapp_raw_ipv6_ntop(const struct mesa_ip6_hdr *ip6_hdr, char *out_buf, int buf_len);
|
||||
|
||||
17
test/CMakeLists.txt
Normal file
17
test/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
cmake_minimum_required(VERSION 2.8...3.10)
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/inc)
|
||||
include_directories(${MESA_SDK_PREFIX}/include)
|
||||
include_directories(${MESA_SDK_PREFIX}/include/MESA)
|
||||
|
||||
|
||||
# add_definitions(-D_BSD_SOURCE -D_BSD_SOURCE -D__BSD_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
|
||||
add_definitions(-D_DEFAULT_SOURCE -D__FAVOR_BSD -DHAVE_NET_ETHERNET_H)
|
||||
add_definitions(-fPIC -std=c++11)
|
||||
LINK_DIRECTORIES(/opt/MESA/lib)
|
||||
LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src)
|
||||
|
||||
add_executable(gtest_jump_layer gtest_jump_layer.cpp)
|
||||
target_link_libraries(gtest_jump_layer pcap gtest-static MESA_jump_layer)
|
||||
|
||||
|
||||
@@ -1,2 +1,9 @@
|
||||
all: test_jump_layer gtest_jump_layer
|
||||
|
||||
CFLAGS = -g -Wall -fPIC -std=c++11 -DSAPP_V4=1 -D_XOPEN_SOURCE
|
||||
|
||||
test_jump_layer:test_jump_layer.c
|
||||
gcc -g -o $@ test_jump_layer.c -D_GNU_SOURCE -L/opt/MESA/lib -lMESA_jump_layer -I ../inc -I/opt/MESA/include/MESA -l pcap
|
||||
|
||||
gtest_jump_layer:gtest_jump_layer.cpp
|
||||
g++ -g -o $@ $^ $(CFLAGS) -D_GNU_SOURCE -L/opt/MESA/lib -lMESA_jump_layer -I ../inc -I/opt/MESA/include/MESA -lpcap -lgtest -lpthread
|
||||
|
||||
1404
test/gtest_jump_layer.cpp
Normal file
1404
test/gtest_jump_layer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
BIN
test/sample_pcap/eth_vlan_ip6_udp_gtpext_ip4_tcp.pcap
Normal file
BIN
test/sample_pcap/eth_vlan_ip6_udp_gtpext_ip4_tcp.pcap
Normal file
Binary file not shown.
BIN
test/sample_pcap/tcp_simple.pcap
Normal file
BIN
test/sample_pcap/tcp_simple.pcap
Normal file
Binary file not shown.
BIN
test/sample_pcap/udp_simple.pcap
Normal file
BIN
test/sample_pcap/udp_simple.pcap
Normal file
Binary file not shown.
BIN
test/sample_pcap/vxlan_inner_3_vlan_udp.pcap
Normal file
BIN
test/sample_pcap/vxlan_inner_3_vlan_udp.pcap
Normal file
Binary file not shown.
@@ -11,6 +11,9 @@ static char *g_input_pcap_name;
|
||||
static char *g_input_bpf_string;
|
||||
static struct bpf_program g_bpf_filter;
|
||||
|
||||
static int g_raw_input_layer_type = (int )ADDR_TYPE_MAC;
|
||||
static int g_expect_layer_type = (int )ADDR_TYPE_IPV4;
|
||||
|
||||
static void usage(const char *prog)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
@@ -59,39 +62,109 @@ static int pcap_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _pcap_pkt_handle(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data)
|
||||
static void _jump_from_udp(const void *uhdr)
|
||||
{
|
||||
const void *next_hdr;
|
||||
|
||||
next_hdr = MESA_jump_layer(uhdr, ADDR_TYPE_UDP, ADDR_TYPE_GPRS_TUNNEL);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to gtp from udp succ!\n");
|
||||
}
|
||||
|
||||
next_hdr = MESA_jump_layer(uhdr, ADDR_TYPE_UDP, ADDR_TYPE_L2TP);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to l2tp from udp succ!\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void _jump_from_ipv4(const void *ip4_hdr)
|
||||
{
|
||||
const void *next_hdr;
|
||||
|
||||
next_hdr = MESA_jump_layer(ip4_hdr, ADDR_TYPE_IPV4, ADDR_TYPE_TCP);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to tcp from ipv4 succ!\n");
|
||||
}
|
||||
|
||||
next_hdr = MESA_jump_layer(ip4_hdr, ADDR_TYPE_IPV4, ADDR_TYPE_UDP);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to udp from ipv4 succ!\n");
|
||||
_jump_from_udp(next_hdr);
|
||||
}
|
||||
}
|
||||
|
||||
static void _jump_from_ipv6(const void *ip4_hdr)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void _jump_from_ethernet(const void *ehdr)
|
||||
{
|
||||
const void *next_hdr;
|
||||
|
||||
next_hdr = MESA_jump_layer(ehdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV4);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to ipv4 from ethernet succ!\n");
|
||||
_jump_from_ipv4(next_hdr);
|
||||
}
|
||||
|
||||
next_hdr = MESA_jump_layer(ehdr, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
|
||||
if(next_hdr){
|
||||
printf("bingo! jump to ipv6 from ethernet succ!\n");
|
||||
_jump_from_ipv6(next_hdr);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void _jump_greedy(const struct pcap_pkthdr *hdr, const u_char *data)
|
||||
{
|
||||
const void *ip4_hdr, *ip6_h;
|
||||
|
||||
char print_buf[128];
|
||||
int offset_to_eth;
|
||||
static int pkt_index = 0;
|
||||
|
||||
ip4_hdr = MESA_net_jump_to_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV4);
|
||||
ip6_h = MESA_net_jump_to_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
|
||||
ip4_hdr = MESA_jump_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV4);
|
||||
ip6_h = MESA_jump_layer_greedy(data, ADDR_TYPE_MAC, ADDR_TYPE_IPV6);
|
||||
|
||||
|
||||
printf("-----------------------------packet index:%d------------------------------------------\n", pkt_index++);
|
||||
if(ip4_hdr){
|
||||
offset_to_eth = (u_char *)ip4_hdr-data;
|
||||
if(g_input_bpf_string
|
||||
&& (0 == bpf_filter(g_bpf_filter.bf_insns, (const unsigned char *)ip4_hdr, hdr->caplen-offset_to_eth, hdr->caplen-offset_to_eth))){
|
||||
goto done;
|
||||
printf("-----------------------------packet index:%d------------------------------------------\n", pkt_index++);
|
||||
if(ip4_hdr){
|
||||
offset_to_eth = (u_char *)ip4_hdr-data;
|
||||
if(g_input_bpf_string
|
||||
&& (0 == bpf_filter(g_bpf_filter.bf_insns, (const unsigned char *)ip4_hdr, hdr->caplen-offset_to_eth, hdr->caplen-offset_to_eth))){
|
||||
goto done;
|
||||
}
|
||||
printf("Innermost layer ipv4 offset:%d, addr: %s\n", offset_to_eth, MESA_jump_layer_ipv4_ntop((struct ip *)ip4_hdr, print_buf, sizeof(print_buf)));
|
||||
}
|
||||
printf("Innermost layer ipv4 offset:%d, addr: %s\n", offset_to_eth, MESA_jump_layer_ipv4_ntop((struct ip *)ip4_hdr, print_buf, sizeof(print_buf)));
|
||||
}
|
||||
|
||||
if(ip6_h){
|
||||
offset_to_eth = (u_char *)ip6_h-data;
|
||||
if(g_input_bpf_string
|
||||
&& (0 == bpf_filter(g_bpf_filter.bf_insns, (const unsigned char *)ip6_h, hdr->caplen-offset_to_eth, hdr->caplen-offset_to_eth))){
|
||||
goto done;
|
||||
|
||||
if(ip6_h){
|
||||
offset_to_eth = (u_char *)ip6_h-data;
|
||||
if(g_input_bpf_string
|
||||
&& (0 == bpf_filter(g_bpf_filter.bf_insns, (const unsigned char *)ip6_h, hdr->caplen-offset_to_eth, hdr->caplen-offset_to_eth))){
|
||||
goto done;
|
||||
}
|
||||
|
||||
printf("Innermost layer ipv6 offset:%d, addr: %s\n", offset_to_eth, MESA_jump_layer_ipv6_ntop((struct ip6_hdr *)ip6_h, print_buf, sizeof(print_buf)));
|
||||
}
|
||||
|
||||
done:
|
||||
|
||||
printf("--------------------------------------------------------------------------------------\n\n");
|
||||
|
||||
printf("Innermost layer ipv6 offset:%d, addr: %s\n", offset_to_eth, MESA_jump_layer_ipv6_ntop((struct ip6_hdr *)ip6_h, print_buf, sizeof(print_buf)));
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
static void _pcap_pkt_handle(u_char *user, const struct pcap_pkthdr *hdr, const u_char *data)
|
||||
{
|
||||
|
||||
_jump_from_ethernet(data);
|
||||
|
||||
_jump_greedy(hdr, data);
|
||||
|
||||
printf("--------------------------------------------------------------------------------------\n\n");
|
||||
}
|
||||
|
||||
static void pcap_run(void)
|
||||
|
||||
21
vendor/CMakeLists.txt
vendored
Normal file
21
vendor/CMakeLists.txt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# CMakeFiles for 3rd vendor library
|
||||
|
||||
include(ExternalProject)
|
||||
# libgtest
|
||||
ExternalProject_Add(libgtest PREFIX libgtest
|
||||
URL ${CMAKE_SOURCE_DIR}/vendor/googletest-release-1.10.0.tar.gz
|
||||
URL_MD5 ecd1fa65e7de707cd5c00bdac56022cd
|
||||
#CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> -DCMAKE_BUILD_TYPE=RELWITHDEBINFO)
|
||||
ExternalProject_Get_Property(libgtest INSTALL_DIR)
|
||||
file(MAKE_DIRECTORY ${INSTALL_DIR}/include)
|
||||
add_library(gtest-static STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(gtest-static libgtest)
|
||||
set_property(TARGET gtest-static PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib64/libgtest.a)
|
||||
set_property(TARGET gtest-static PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include)
|
||||
set_property(TARGET gtest-static PROPERTY INTERFACE_LINK_LIBRARIES pthread)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
vendor/googletest-release-1.10.0.tar.gz
vendored
Normal file
BIN
vendor/googletest-release-1.10.0.tar.gz
vendored
Normal file
Binary file not shown.
Reference in New Issue
Block a user